Skip to content

Commit ae9fb3a

Browse files
committed
---
yaml --- r: 149119 b: refs/heads/try2 c: c756038 h: refs/heads/master i: 149117: 395cd0b 149115: d8464fa 149111: 3fc682e 149103: 0192e54 149087: 6602083 149055: 9e7ff93 148991: a70e21b v: v3
1 parent 184aca3 commit ae9fb3a

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 7ffa67ce924352d4ac726bec48e4e554b5bb0f8c
8+
refs/heads/try2: c7560387afc9660b4ea6a15eef1f387182c6ae51
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libgetopts/lib.rs

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -775,14 +775,13 @@ fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
775775
let mut lim = lim;
776776
777777
let mut cont = true;
778-
let slice: || = || { cont = it(ss.slice(slice_start, last_end)) };
779778
780779
// if the limit is larger than the string, lower it to save cycles
781780
if lim >= fake_i {
782781
lim = fake_i;
783782
}
784783
785-
let machine: |(uint, char)| -> bool = |(i, c)| {
784+
let machine: |&mut bool, (uint, char)| -> bool = |cont, (i, c)| {
786785
let whitespace = if ::std::char::is_whitespace(c) { Ws } else { Cr };
787786
let limit = if (i - slice_start + 1) <= lim { UnderLim } else { OverLim };
788787
@@ -794,24 +793,49 @@ fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
794793
(B, Cr, OverLim) if (i - last_start + 1) > lim
795794
=> fail!("word starting with {} longer than limit!",
796795
ss.slice(last_start, i + 1)),
797-
(B, Cr, OverLim) => { slice(); slice_start = last_start; B }
798-
(B, Ws, UnderLim) => { last_end = i; C }
799-
(B, Ws, OverLim) => { last_end = i; slice(); A }
800-
801-
(C, Cr, UnderLim) => { last_start = i; B }
802-
(C, Cr, OverLim) => { slice(); slice_start = i; last_start = i; last_end = i; B }
803-
(C, Ws, OverLim) => { slice(); A }
804-
(C, Ws, UnderLim) => { C }
796+
(B, Cr, OverLim) => {
797+
*cont = it(ss.slice(slice_start, last_end));
798+
slice_start = last_start;
799+
B
800+
}
801+
(B, Ws, UnderLim) => {
802+
last_end = i;
803+
C
804+
}
805+
(B, Ws, OverLim) => {
806+
last_end = i;
807+
*cont = it(ss.slice(slice_start, last_end));
808+
A
809+
}
810+
811+
(C, Cr, UnderLim) => {
812+
last_start = i;
813+
B
814+
}
815+
(C, Cr, OverLim) => {
816+
*cont = it(ss.slice(slice_start, last_end));
817+
slice_start = i;
818+
last_start = i;
819+
last_end = i;
820+
B
821+
}
822+
(C, Ws, OverLim) => {
823+
*cont = it(ss.slice(slice_start, last_end));
824+
A
825+
}
826+
(C, Ws, UnderLim) => {
827+
C
828+
}
805829
};
806830

807-
cont
831+
*cont
808832
};
809833

810-
ss.char_indices().advance(|x| machine(x));
834+
ss.char_indices().advance(|x| machine(&mut cont, x));
811835

812836
// Let the automaton 'run out' by supplying trailing whitespace
813837
while cont && match state { B | C => true, A => false } {
814-
machine((fake_i, ' '));
838+
machine(&mut cont, (fake_i, ' '));
815839
fake_i += 1;
816840
}
817841
return cont;

0 commit comments

Comments
 (0)