Skip to content

Commit 6bb9ab7

Browse files
committed
---
yaml --- r: 129514 b: refs/heads/snap-stage3 c: 16d538c h: refs/heads/master v: v3
1 parent caa74b3 commit 6bb9ab7

File tree

36 files changed

+161
-92
lines changed

36 files changed

+161
-92
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 566b470e138e929e8a93d613372db1ba177c494f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: b1f7d3aaa021d626b4083ddaa706b26f3521d343
4+
refs/heads/snap-stage3: 16d538cba0cc5b5830e7c17663e985d13ece8e0c
55
refs/heads/try: 80b45ddbd351f0a4a939c3a3c4e20b4defec4b35
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ To easily build on windows we can use [MSYS2](http://sourceforge.net/projects/ms
7171
3. With that now start `mingw32_shell.bat` from where you installed MSYS2 (i.e. `C:\msys`).
7272
4. From there just navigate to where you have Rust's source code, configure and build it:
7373

74-
$ ./configure --build=i686-pc-mingw32
74+
$ ./configure
7575
$ make && make install
7676

7777
[repo]: https://github.com/rust-lang/rust

branches/snap-stage3/configure

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,19 @@ case $CFG_OSTYPE in
299299
CFG_OSTYPE=apple-darwin
300300
;;
301301

302-
MINGW32*)
302+
MINGW*)
303+
# msys' `uname` does not print gcc configuration, but prints msys
304+
# configuration. so we cannot believe `uname -m`:
305+
# msys1 is always i686 and msys2 is always x86_64.
306+
# instead, msys defines $MSYSTEM which is MINGW32 on i686 and
307+
# MINGW64 on x86_64.
308+
CFG_CPUTYPE=i686
303309
CFG_OSTYPE=pc-mingw32
304-
;;
305-
306-
MINGW64*)
307-
# msys2, MSYSTEM=MINGW64
308-
CFG_OSTYPE=w64-mingw32
310+
if [ "$MSYSTEM" = MINGW64 ]
311+
then
312+
CFG_CPUTYPE=x86_64
313+
CFG_OSTYPE=w64-mingw32
314+
fi
309315
;;
310316

311317
# Thad's Cygwin identifers below

branches/snap-stage3/src/compiletest/runtest.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use header;
1717
use procsrv;
1818
use util::logv;
1919
#[cfg(target_os = "windows")]
20-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
2120
use util;
2221

2322
use std::io::File;
@@ -819,7 +818,6 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
819818
}).collect::<Vec<String> >();
820819

821820
#[cfg(target_os = "windows")]
822-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
823821
fn to_lower( s : &str ) -> String {
824822
let i = s.chars();
825823
let c : Vec<char> = i.map( |c| {
@@ -833,7 +831,6 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
833831
}
834832

835833
#[cfg(target_os = "windows")]
836-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
837834
fn prefix_matches( line : &str, prefix : &str ) -> bool {
838835
to_lower(line).as_slice().starts_with(to_lower(prefix).as_slice())
839836
}
@@ -1251,15 +1248,13 @@ fn make_cmdline(_libpath: &str, prog: &str, args: &[String]) -> String {
12511248
}
12521249

12531250
#[cfg(target_os = "windows")]
1254-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
12551251
fn make_cmdline(libpath: &str, prog: &str, args: &[String]) -> String {
12561252
format!("{} {} {}", lib_path_cmd_prefix(libpath), prog, args.connect(" "))
12571253
}
12581254

12591255
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
12601256
// for diagnostic purposes
12611257
#[cfg(target_os = "windows")]
1262-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
12631258
fn lib_path_cmd_prefix(path: &str) -> String {
12641259
format!("{}=\"{}\"", util::lib_path_env_var(), util::make_new_path(path))
12651260
}

branches/snap-stage3/src/compiletest/util.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use common::Config;
1212

1313
#[cfg(target_os = "windows")]
14-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
1514
use std::os::getenv;
1615

1716
/// Conversion table from triple OS name to Rust SYSNAME
@@ -36,7 +35,6 @@ pub fn get_os(triple: &str) -> &'static str {
3635
}
3736

3837
#[cfg(target_os = "windows")]
39-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
4038
pub fn make_new_path(path: &str) -> String {
4139

4240
// Windows just uses PATH as the library search path, so we have to
@@ -50,11 +48,9 @@ pub fn make_new_path(path: &str) -> String {
5048
}
5149

5250
#[cfg(target_os = "windows")]
53-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
5451
pub fn lib_path_env_var() -> &'static str { "PATH" }
5552

5653
#[cfg(target_os = "windows")]
57-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
5854
pub fn path_div() -> &'static str { ";" }
5955

6056
pub fn logv(config: &Config, s: String) {

branches/snap-stage3/src/doc/guide.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,8 @@ To do that, we'll need to make a new module. Make a new file, `src/lib.rs`,
33253325
and put this in it:
33263326

33273327
```{rust}
3328-
fn add_three_times_four(x: int) -> int {
3328+
# fn main() {}
3329+
pub fn add_three_times_four(x: int) -> int {
33293330
(x + 3) * 4
33303331
}
33313332
```

branches/snap-stage3/src/etc/maketest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
# msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
1616
# `c:\real\abs\path1;c:\real\abs\path2` (semicolons) if shell thinks
1717
# the value is list of paths.
18+
# (if there is only one path, it becomes `c:/real/abs/path`.)
1819
# this causes great confusion and error: shell and Makefile doesn't like
1920
# windows paths so it is really error-prone. revert it for peace.
2021
def normalize_path(v):
21-
# c:\path -> /c/path
22-
if ':\\' in v:
23-
v = '/' + v.replace(':\\', '/')
2422
v = v.replace('\\', '/')
23+
# c:/path -> /c/path
24+
if ':/' in v:
25+
v = '/' + v.replace(':/', '/')
2526
return v
2627

2728

branches/snap-stage3/src/etc/mklldeps.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ def run(args):
6868
]
6969

7070
f.write("#[cfg(" + ', '.join(cfg) + ")]\n")
71-
if os == "windows": # NOTE: Remove after snapshot
72-
f.write("#[cfg(stage0, target_arch = \"%s\", target_os = \"win32\")]\n" % (arch,))
7371

7472
version = run([llconfig, '--version']).strip()
7573

branches/snap-stage3/src/libcore/str.rs

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ struct TwoWaySearcher {
419419
memory: uint
420420
}
421421

422+
// This is the Two-Way search algorithm, which was introduced in the paper:
423+
// Crochemore, M., Perrin, D., 1991, Two-way string-matching, Journal of the ACM 38(3):651-675.
422424
impl TwoWaySearcher {
423425
fn new(needle: &[u8]) -> TwoWaySearcher {
424426
let (critPos1, period1) = TwoWaySearcher::maximal_suffix(needle, false);
@@ -437,7 +439,14 @@ impl TwoWaySearcher {
437439
let byteset = needle.iter()
438440
.fold(0, |a, &b| (1 << ((b & 0x3f) as uint)) | a);
439441

440-
if needle.slice_to(critPos) == needle.slice_from(needle.len() - critPos) {
442+
443+
// The logic here (calculating critPos and period, the final if statement to see which
444+
// period to use for the TwoWaySearcher) is essentially an implementation of the
445+
// "small-period" function from the paper (p. 670)
446+
//
447+
// In the paper they check whether `needle.slice_to(critPos)` is a suffix of
448+
// `needle.slice(critPos, critPos + period)`, which is precisely what this does
449+
if needle.slice_to(critPos) == needle.slice(period, period + critPos) {
441450
TwoWaySearcher {
442451
critPos: critPos,
443452
period: period,
@@ -508,6 +517,9 @@ impl TwoWaySearcher {
508517
}
509518
}
510519

520+
// returns (i, p) where i is the "critical position", the starting index of
521+
// of maximal suffix, and p is the period of the suffix
522+
// see p. 668 of the paper
511523
#[inline]
512524
fn maximal_suffix(arr: &[u8], reversed: bool) -> (uint, uint) {
513525
let mut left = -1; // Corresponds to i in the paper
@@ -1705,6 +1717,13 @@ pub trait StrSlice<'a> {
17051717
fn utf16_units(&self) -> Utf16CodeUnits<'a>;
17061718
}
17071719

1720+
#[inline(never)]
1721+
fn slice_error_fail(s: &str, begin: uint, end: uint) -> ! {
1722+
assert!(begin <= end);
1723+
fail!("index {} and/or {} in `{}` do not lie on character boundary",
1724+
begin, end, s);
1725+
}
1726+
17081727
impl<'a> StrSlice<'a> for &'a str {
17091728
#[inline]
17101729
fn contains<'a>(&self, needle: &'a str) -> bool {
@@ -1808,22 +1827,34 @@ impl<'a> StrSlice<'a> for &'a str {
18081827

18091828
#[inline]
18101829
fn slice(&self, begin: uint, end: uint) -> &'a str {
1811-
assert!(self.is_char_boundary(begin) && self.is_char_boundary(end),
1812-
"index {} and/or {} in `{}` do not lie on character boundary", begin,
1813-
end, *self);
1814-
unsafe { raw::slice_bytes(*self, begin, end) }
1830+
// is_char_boundary checks that the index is in [0, .len()]
1831+
if begin <= end &&
1832+
self.is_char_boundary(begin) &&
1833+
self.is_char_boundary(end) {
1834+
unsafe { raw::slice_unchecked(*self, begin, end) }
1835+
} else {
1836+
slice_error_fail(*self, begin, end)
1837+
}
18151838
}
18161839

18171840
#[inline]
18181841
fn slice_from(&self, begin: uint) -> &'a str {
1819-
self.slice(begin, self.len())
1842+
// is_char_boundary checks that the index is in [0, .len()]
1843+
if self.is_char_boundary(begin) {
1844+
unsafe { raw::slice_unchecked(*self, begin, self.len()) }
1845+
} else {
1846+
slice_error_fail(*self, begin, self.len())
1847+
}
18201848
}
18211849

18221850
#[inline]
18231851
fn slice_to(&self, end: uint) -> &'a str {
1824-
assert!(self.is_char_boundary(end), "index {} in `{}` does not lie on \
1825-
a character boundary", end, *self);
1826-
unsafe { raw::slice_bytes(*self, 0, end) }
1852+
// is_char_boundary checks that the index is in [0, .len()]
1853+
if self.is_char_boundary(end) {
1854+
unsafe { raw::slice_unchecked(*self, 0, end) }
1855+
} else {
1856+
slice_error_fail(*self, 0, end)
1857+
}
18271858
}
18281859

18291860
fn slice_chars(&self, begin: uint, end: uint) -> &'a str {
@@ -1898,9 +1929,10 @@ impl<'a> StrSlice<'a> for &'a str {
18981929
#[inline]
18991930
fn is_char_boundary(&self, index: uint) -> bool {
19001931
if index == self.len() { return true; }
1901-
if index > self.len() { return false; }
1902-
let b = self.as_bytes()[index];
1903-
return b < 128u8 || b >= 192u8;
1932+
match self.as_bytes().get(index) {
1933+
None => false,
1934+
Some(&b) => b < 128u8 || b >= 192u8,
1935+
}
19041936
}
19051937

19061938
#[inline]

branches/snap-stage3/src/libcoretest/str.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,27 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
fn check_contains_all_substrings(s: &str) {
12+
assert!(s.contains(""));
13+
for i in range(0, s.len()) {
14+
for j in range(i+1, s.len() + 1) {
15+
assert!(s.contains(s.slice(i, j)));
16+
}
17+
}
18+
}
19+
1120
#[test]
1221
fn strslice_issue_16589() {
1322
assert!("bananas".contains("nana"));
23+
24+
// prior to the fix for #16589, x.contains("abcdabcd") returned false
25+
// test all substrings for good measure
26+
check_contains_all_substrings("012345678901234567890123456789bcdabcdabcd");
27+
}
28+
29+
30+
#[test]
31+
fn test_strslice_contains() {
32+
let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'";
33+
check_contains_all_substrings(x);
1434
}

branches/snap-stage3/src/liblibc/lib.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
* sanity while editing, filling-in-details and eliminating duplication) into
6565
* definitions common-to-all (held in modules named c95, c99, posix88, posix01
6666
* and posix08) and definitions that appear only on *some* platforms (named
67-
* 'extra'). This would be things like significant OSX foundation kit, or win32
67+
* 'extra'). This would be things like significant OSX foundation kit, or Windows
6868
* library kernel32.dll, or various fancy glibc, linux or BSD extensions.
6969
*
7070
* In addition to the per-platform 'extra' modules, we define a module of
@@ -1195,15 +1195,14 @@ pub mod types {
11951195
}
11961196

11971197
#[cfg(target_os = "windows")]
1198-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
11991198
pub mod os {
12001199
pub mod common {
12011200
pub mod posix01 {
12021201
use types::os::arch::c95::{c_short, time_t, c_long};
12031202
use types::os::arch::extra::{int64, time64_t};
12041203
use types::os::arch::posix88::{dev_t, ino_t};
12051204

1206-
// pub Note: this is the struct called stat64 in win32. Not stat,
1205+
// pub Note: this is the struct called stat64 in Windows. Not stat,
12071206
// nor stati64.
12081207
#[repr(C)]
12091208
pub struct stat {
@@ -1220,7 +1219,7 @@ pub mod types {
12201219
pub st_ctime: time64_t,
12211220
}
12221221

1223-
// note that this is called utimbuf64 in win32
1222+
// note that this is called utimbuf64 in Windows
12241223
#[repr(C)]
12251224
pub struct utimbuf {
12261225
pub actime: time64_t,
@@ -1915,7 +1914,6 @@ pub mod consts {
19151914
// into this module.
19161915

19171916
#[cfg(target_os = "windows")]
1918-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
19191917
pub mod os {
19201918
pub mod c95 {
19211919
use types::os::arch::c95::{c_int, c_uint};
@@ -4000,7 +3998,6 @@ pub mod funcs {
40003998
// with the same POSIX functions and types as other platforms.
40013999

40024000
#[cfg(target_os = "windows")]
4003-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
40044001
pub mod posix88 {
40054002
pub mod stat_ {
40064003
use types::os::common::posix01::{stat, utimbuf};
@@ -4430,7 +4427,6 @@ pub mod funcs {
44304427
}
44314428

44324429
#[cfg(target_os = "windows")]
4433-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
44344430
pub mod posix01 {
44354431
pub mod stat_ {
44364432
}
@@ -4447,7 +4443,6 @@ pub mod funcs {
44474443

44484444

44494445
#[cfg(target_os = "windows")]
4450-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
44514446
#[cfg(target_os = "linux")]
44524447
#[cfg(target_os = "android")]
44534448
#[cfg(target_os = "macos")]
@@ -4586,7 +4581,6 @@ pub mod funcs {
45864581

45874582

45884583
#[cfg(target_os = "windows")]
4589-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
45904584
pub mod bsd44 {
45914585
}
45924586

@@ -4613,7 +4607,6 @@ pub mod funcs {
46134607

46144608

46154609
#[cfg(target_os = "windows")]
4616-
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
46174610
pub mod extra {
46184611

46194612
pub mod kernel32 {

branches/snap-stage3/src/libnative/io/file_win32.rs renamed to branches/snap-stage3/src/libnative/io/file_windows.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Blocking win32-based file I/O
11+
//! Blocking Windows-based file I/O
1212
1313
use alloc::arc::Arc;
1414
use libc::{c_int, c_void};
1515
use libc;
1616
use std::c_str::CString;
1717
use std::mem;
18-
use std::os::win32::fill_utf16_buf_and_decode;
18+
use std::os::windows::fill_utf16_buf_and_decode;
1919
use std::ptr;
2020
use std::rt::rtio;
2121
use std::rt::rtio::{IoResult, IoError};

0 commit comments

Comments
 (0)