Skip to content

Commit df80a08

Browse files
committed
---
yaml --- r: 50423 b: refs/heads/auto c: fb5f020 h: refs/heads/master i: 50421: d7dabd3 50419: 8b303ac 50415: a65dee8 v: v3
1 parent 6cbafbc commit df80a08

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 4c58903454f5409c4b0cb2060ce869021dbf46c2
17+
refs/heads/auto: fb5f020cc2d1d0972d2726413d1ec053990675ad
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167

branches/auto/RELEASES.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Version 0.6 (April 2013)
3030
`@mut T`, `core::mut` or `core::cell`
3131
* `extern mod { ... }` is no longer valid syntax for foreign
3232
function modules. Use extern blocks: `extern { ... }`
33-
* Newtype enums removed. Use tuple-structs.
33+
* Newtype enums removed. Used tuple-structs.
3434
* Trait implementations no longer support visibility modifiers
3535
* Pattern matching over vectors improved and expanded
3636
* `const` renamed to `static` to correspond to lifetime name,
@@ -40,10 +40,6 @@ Version 0.6 (April 2013)
4040
`#[deriving(Clone)]`
4141
* Casts to traits must use a pointer sigil, e.g. `@foo as @Bar`
4242
instead of `foo as Bar`.
43-
* Fixed length vector types are now written as `[int, .. 3]`
44-
instead of `[int * 3]`.
45-
* Fixed length vector types can express the length as a constant
46-
expression. (ex: `[int, .. GL_BUFFER_SIZE - 2]`)
4743

4844
* Semantic changes
4945
* Types with owned pointers or custom destructors move by default,

branches/auto/src/libcore/str.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,8 +1865,10 @@ pub struct CharRange {
18651865
* Given a byte position and a str, return the previous char and its position
18661866
*
18671867
* This function can be used to iterate over a unicode string in reverse.
1868+
*
1869+
* returns 0 for next index if called on start index 0
18681870
*/
1869-
fn char_range_at_reverse(ss: &str, start: uint) -> CharRange {
1871+
pub fn char_range_at_reverse(ss: &str, start: uint) -> CharRange {
18701872
let mut prev = start;
18711873

18721874
// while there is a previous byte == 10......
@@ -1875,7 +1877,12 @@ fn char_range_at_reverse(ss: &str, start: uint) -> CharRange {
18751877
}
18761878

18771879
// now refer to the initial byte of previous char
1878-
prev -= 1u;
1880+
if prev > 0u {
1881+
prev -= 1u;
1882+
} else {
1883+
prev = 0u;
1884+
}
1885+
18791886

18801887
let ch = char_at(ss, prev);
18811888
return CharRange {ch:ch, next:prev};
@@ -3761,4 +3768,10 @@ mod tests {
37613768
"12345555".cmp(& &"123456") == Less;
37623769
"22".cmp(& &"1234") == Greater;
37633770
}
3771+
3772+
#[test]
3773+
fn test_char_range_at_reverse_underflow() {
3774+
assert!(char_range_at_reverse("abc", 0).next == 0);
3775+
}
3776+
37643777
}

0 commit comments

Comments
 (0)