Commit Graph

20779 Commits

Author SHA1 Message Date
bors
0068bd73e0 auto merge of #8131 : Seldaek/rust/getopt_usage_newline, r=brson
It makes things ugly when the last thing you print is the usage() output, resulting in something like:

```
$ rust run foo.rs -h
Lala

Options:
    -h --help           display this help and exit
    -V --version        output version information and exit

$ prompt
```
2013-07-30 10:28:18 -07:00
Ben Blum
6b75e92afe UnsafeArc methods return unsafe pointers, so are not themselves unsafe. 2013-07-30 13:19:26 -04:00
Ben Blum
fa8102ab4a Unkillable is not unsafe. Close #7832. 2013-07-30 13:19:25 -04:00
Ben Blum
9675cd311a (cleanup) Fix unimplemented message for kill_all in newsched. 2013-07-30 13:19:25 -04:00
Ben Blum
3f6b4c24ec Add a better-for-testing optimistic_check() for pipes with cfg(test). 2013-07-30 13:19:25 -04:00
Ben Blum
cccfa8acc4 Add test cases for select 2013-07-30 13:19:25 -04:00
Ben Blum
f34fadd126 Implement select() for new runtime pipes. 2013-07-30 13:19:25 -04:00
blake2-ppc
aa89325cb0 std: Add from_bytes test for utf-8 using codepoints above 0xffff 2013-07-30 19:16:12 +02:00
blake2-ppc
b4ff95599a std: Deny overlong encodings in UTF-8
An 'overlong encoding' is a codepoint encoded non-minimally using the
utf-8 format. Denying these enforce each codepoint to have only one
valid representation in utf-8.

An example is byte sequence 0xE0 0x80 0x80 which could be interpreted as
U+0, but it's an overlong encoding since the canonical form is just
0x00.

Another example is 0xE0 0x80 0xAF which was previously accepted and is
an overlong encoding of the solidus "/". Directory traversal characters
like / and . form the most compelling argument for why this commit is
security critical.

Factor out common UTF-8 decoding expressions as macros. This commit will
partly duplicate UTF-8 decoding, so it is now present in both
fn is_utf8() and .char_range_at(); the latter using an assumption of
a valid str.
2013-07-30 19:16:12 +02:00
Jordi Boggiano
f7ebab4403 Do not enforce two newlines after the options 2013-07-30 18:40:01 +02:00
blake2-ppc
6dd185930d std: Disallow bytes 0xC0, 0xC1 (192, 193) in utf-8
Bytes 0xC0, 0xC1 can only be used to start 2-byte codepoint encodings,
that are 'overlong encodings' of codepoints below 128.

The reference given in a comment -- https://tools.ietf.org/html/rfc3629
-- does in fact already exclude these bytes, so no additional comment
should be needed in the code.
2013-07-30 17:25:29 +02:00
bors
576f395ddf auto merge of #8121 : thestinger/rust/offset, r=alexcrichton
Closes #8118, #7136

~~~rust
extern mod extra;

use std::vec;
use std::ptr;

fn bench_from_elem(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = vec::from_elem(1024, 0u8);
    }
}

fn bench_set_memory(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let mut v: ~[u8] = vec::with_capacity(1024);
        unsafe {
            let vp = vec::raw::to_mut_ptr(v);
            ptr::set_memory(vp, 0, 1024);
            vec::raw::set_len(&mut v, 1024);
        }
    }
}

fn bench_vec_repeat(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = ~[0u8, ..1024];
    }
}
~~~

Before:

    test bench_from_elem ... bench: 415 ns/iter (+/- 17)
    test bench_set_memory ... bench: 85 ns/iter (+/- 4)
    test bench_vec_repeat ... bench: 83 ns/iter (+/- 3)

After:

    test bench_from_elem ... bench: 84 ns/iter (+/- 2)
    test bench_set_memory ... bench: 84 ns/iter (+/- 5)
    test bench_vec_repeat ... bench: 84 ns/iter (+/- 3)
2013-07-30 07:01:19 -07:00
bors
7fc8c14c1b auto merge of #8082 : Kimundi/rust/master, r=huonw
Also renamed bytes_iter to byte_iter to match other iterators
2013-07-30 05:13:17 -07:00
Marvin Löbel
e33fca9ffe Added str::char_offset_iter() and str::rev_char_offset_iter()
Renamed bytes_iter to byte_iter to match other iterators
Refactored str Iterators to use DoubleEnded Iterators and typedefs instead of wrapper structs
Reordered the Iterator section
Whitespace fixup
Moved clunky `each_split_within` function to the one place in the tree where it's actually needed
Replaced all block doccomments in str with line doccomments
2013-07-30 12:55:48 +02:00
bors
c124f21af5 auto merge of #8110 : brson/rust/no-rebuild, r=bblum
...oses #8101
2013-07-30 03:25:19 -07:00
bors
d75ab4a5d7 auto merge of #8107 : michaelwoerister/rust/end_of_spanned, r=cmr
Contiunation of naming cleanup in `libsyntax::ast`:
```rust
ast::node_id => ast::NodeId
ast::local_crate => ast::LOCAL_CRATE
ast::crate_node_id => ast::CRATE_NODE_ID
ast::blk_check_mode => ast::BlockCheckMode
ast::ty_field => ast::TypeField
ast::ty_method => ast::TypeMethod
```
Also moved span field directly into `TypeField` struct and cleaned up overlooked `ast::CrateConfig` renamings from last pull request.

Cheers,
Michael
2013-07-30 01:37:17 -07:00
Daniel Micay
ef870d37a5 implement pointer arithmetic with GEP
Closes #8118, #7136

~~~rust
extern mod extra;

use std::vec;
use std::ptr;

fn bench_from_elem(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = vec::from_elem(1024, 0u8);
    }
}

fn bench_set_memory(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let mut v: ~[u8] = vec::with_capacity(1024);
        unsafe {
            let vp = vec::raw::to_mut_ptr(v);
            ptr::set_memory(vp, 0, 1024);
            vec::raw::set_len(&mut v, 1024);
        }
    }
}

fn bench_vec_repeat(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = ~[0u8, ..1024];
    }
}
~~~

Before:

    test bench_from_elem ... bench: 415 ns/iter (+/- 17)
    test bench_set_memory ... bench: 85 ns/iter (+/- 4)
    test bench_vec_repeat ... bench: 83 ns/iter (+/- 3)

After:

    test bench_from_elem ... bench: 84 ns/iter (+/- 2)
    test bench_set_memory ... bench: 84 ns/iter (+/- 5)
    test bench_vec_repeat ... bench: 84 ns/iter (+/- 3)
2013-07-30 02:50:31 -04:00
bors
8695bc74a0 auto merge of #7223 : steveklabnik/rust/vec_initial_docs, r=pcwalton
Let's explain more of what this module is about, not just 'vectors.'
2013-07-29 23:49:23 -07:00
bors
e94e4d51ca auto merge of #8120 : blake2-ppc/rust/iterator-fixes, r=thestinger
Implement RandomAccessIterator (RAI) where possible, for Iterator adaptors such as Map, Enumerate, Peek, Skip, Take, Cycle, where the adapted iterator is already RAI, and for collections where it is relevant (ringbuf and bitv).

After discussion with thestinger, remove the RAI impl for VecMutIterator, we cannot soundly provide mutable access with this trait.

Implement Extendable everywhere FromIterator is already implemented.

Fixes issue #8108.
2013-07-29 19:04:22 -07:00
blake2-ppc
99490ad5ba std: Remove macro in vec that's only used once 2013-07-30 02:52:01 +02:00
blake2-ppc
ae09d95160 extra: Add .rev_iter() for bitv 2013-07-30 02:48:40 +02:00
blake2-ppc
5307d3674e std: Implement Extendable for hashmap, str and trie 2013-07-30 02:32:38 +02:00
blake2-ppc
f8ae526f70 extra: Implement iterator::Extendable 2013-07-30 02:06:49 +02:00
blake2-ppc
f68621326e extra: Implement RandomAccessIterator for RingBuf 2013-07-30 01:48:17 +02:00
blake2-ppc
2f10d1e295 extra: Implement DoubleEnded and RandomAccess iterators for bitv 2013-07-30 01:48:17 +02:00
blake2-ppc
2ff84124f0 std: Remove RandomAccessIterator impl for VecMutIterator
The RandomAccessIterator implementation is not sound for the mutable vec
iterator, and makes it easy to duplicate &mut element pointers.
2013-07-30 01:48:17 +02:00
blake2-ppc
66fccdb295 std: Tests for RandomAccessIterators 2013-07-30 01:48:17 +02:00
blake2-ppc
630627c3d4 std: Implement RandomAccessIterator for iterator adaptors
Implement RAI where possible for iterator adaptors such as Map,
Enumerate, Skip, Take, Zip, Cycle (all of the requiring that the adapted
iterator also implements RAI).
2013-07-30 01:48:17 +02:00
blake2-ppc
5d4af58c1d iterator: implement size_hint() for FlatMap 2013-07-30 01:48:17 +02:00
blake2-ppc
4b2931c90f iterator: implement DoubleEndedIterator for FlatMap 2013-07-30 01:48:17 +02:00
Brendan Zabarauskas
4f65fc7ef2 Improve std::num module description, and fix some formatting 2013-07-30 08:59:43 +10:00
Brendan Zabarauskas
b6ea0538a9 Add some missing method wrappers to std::num 2013-07-30 08:58:46 +10:00
bors
bb996bf92e auto merge of #8090 : blake2-ppc/rust/iterator-adaptor-names, r=pcwalton
Drop the "Iterator" suffix for the the structs in std::iterator.
Filter, Zip, Chain etc. are shorter type names for when iterator
pipelines need their types written out in full in return value types, so
it's easier to read and write. the iterator module already forms enough
namespace.
2013-07-29 15:49:18 -07:00
bors
d34016d109 auto merge of #8109 : blake2-ppc/rust/extern-fn-clone, r=thestinger
Implement Clone and DeepClone for functions with 0 to 8 arguments.  `extern fn()` is implicitly copyable so it's simple, except there is no way to implement it generically over #n function arguments.

Allows deriving of Clone on structs containing `extern "Rust" fn`.
2013-07-29 14:01:24 -07:00
Steve Klabnik
538fbc38c9 Adding an initial description to vec.rs.
Let's explain more of what this module is about, not just 'vectors.'
2013-07-29 16:18:41 -04:00
Ben Blum
7326bc879e Optimize try_recv to not require the two context switches when data is available. 2013-07-29 16:04:16 -04:00
Ben Blum
1137fbd9ab Remove ChanOneHack/PortOneHack extra allocation 2013-07-29 16:04:16 -04:00
Brian Anderson
ceba95ced2 mk: Add NO_BENCH variable for turning off the --bench flag 2013-07-29 12:43:45 -07:00
Brian Anderson
ac2cd14867 mk: Rename CTEST_BENCH to TEST_BENCH
The CTEST prefix is specifically related to the compiletest driver
2013-07-29 12:38:12 -07:00
Brian Anderson
8ae900f51d mk: Fix NO_REBUILD so stdtest can be tested without re-bootstrapping. Closes #8101 2013-07-29 11:22:50 -07:00
bors
2830d7d013 auto merge of #8032 : catamorphism/rust/rustpkg-tags, r=graydon
r? @graydon    Package IDs can now be of the form a/b/c#FOO, where (if a/b/c is
    a git repository) FOO is any tag in the repository. Non-numeric
    tags only match against package IDs with the same tag, and aren't
    compared linearly like numeric versions.
    
 While I was at it, refactored the code that calls `git clone`,  and segregated build output properly for different packages.
2013-07-29 11:04:25 -07:00
blake2-ppc
11aad20cf8 std: Implement Clone and DeepClone for extern "Rust" fn
Implement Clone and DeepClone for functions with 0 to 8 arguments.
2013-07-29 19:43:21 +02:00
bors
fddb35e988 auto merge of #7984 : gifnksm/rust/tutorial-links, r=bstrie 2013-07-29 09:16:22 -07:00
bors
63c9b112b5 auto merge of #8003 : crnobog/rust/case-insensitive-error-prefix, r=cmr
Paths are case insensitive on windows and rustc and compiletest may disagree on casing.
Fixes test compile-fail/circular_modules_main on win32
2013-07-29 07:31:24 -07:00
Michael Woerister
8a329770b6 New naming convention for ast::{node_id, local_crate, crate_node_id, blk_check_mode, ty_field, ty_method} 2013-07-29 16:16:48 +02:00
bors
8413d4769f auto merge of #8085 : mrordinaire/rust/percent-p, r=huonw
pull request for #8011
2013-07-29 05:40:26 -07:00
Do Nhat Minh
79f1052b19 Added %p directive to fmt!, which expects *T as argument 2013-07-29 20:34:01 +08:00
bors
27812ea5e0 auto merge of #8091 : kevinmehall/rust/const-struct-base, r=alexcrichton
With an expression like

    static w : foo = foo { a:5, ..x };

Rust currently gives the error "constant contains unimplemented expression type". This branch implements support for constant structs with `..base`.
2013-07-28 20:34:29 -07:00
blake2-ppc
4b45f47881 std: Rename Iterator adaptor types to drop the -Iterator suffix
Drop the "Iterator" suffix for the the structs in std::iterator.
Filter, Zip, Chain etc. are shorter type names for when iterator
pipelines need their types written out in full in return value types, so
it's easier to read and write. the iterator module already forms enough
namespace.
2013-07-29 04:20:56 +02:00
Kevin Mehall
1493141bfd Add support for ..base on static struct initializers. 2013-07-28 22:07:27 -04:00