Skip to content

Commit 37647c3

Browse files
committed
add optional arguments
1 parent 77881a7 commit 37647c3

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

jscomp/bsb/bsb_arg.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,10 @@
100100
raise (Bad (Ext_buffer.contents b))
101101

102102

103-
let parse_exn ~usage ~argv ~start (speclist : t) anonfun =
104-
let l = Array.length argv in
103+
let parse_exn ~usage ~argv ~start ?(finish=Array.length argv) (speclist : t) anonfun =
105104
let current = ref start in
106105
let rev_list = ref [] in
107-
while !current < l do
106+
while !current < finish do
108107
let s = argv.(!current) in
109108
incr current;
110109
if s <> "" && s.[0] = '-' then begin
@@ -117,7 +116,7 @@
117116
| Unit_call f -> f ()
118117
end
119118
| String f ->
120-
if !current >= l then stop_raise ~usage ~error:(Missing s) speclist
119+
if !current >= finish then stop_raise ~usage ~error:(Missing s) speclist
121120
else begin
122121
let arg = argv.(!current) in
123122
incr current;

jscomp/bsb/bsb_arg.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ val parse_exn :
4545
usage:string ->
4646
argv:string array ->
4747
start:int ->
48+
?finish:int ->
4849
(key * spec * doc) list ->
4950
anon_fun -> unit

lib/4.06.1/bsb.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,7 @@ val parse_exn :
17181718
usage:string ->
17191719
argv:string array ->
17201720
start:int ->
1721+
?finish:int ->
17211722
(key * spec * doc) list ->
17221723
anon_fun -> unit
17231724
end = struct
@@ -1824,11 +1825,10 @@ end = struct
18241825
raise (Bad (Ext_buffer.contents b))
18251826

18261827

1827-
let parse_exn ~usage ~argv ~start (speclist : t) anonfun =
1828-
let l = Array.length argv in
1828+
let parse_exn ~usage ~argv ~start ?(finish=Array.length argv) (speclist : t) anonfun =
18291829
let current = ref start in
18301830
let rev_list = ref [] in
1831-
while !current < l do
1831+
while !current < finish do
18321832
let s = argv.(!current) in
18331833
incr current;
18341834
if s <> "" && s.[0] = '-' then begin
@@ -1841,7 +1841,7 @@ end = struct
18411841
| Unit_call f -> f ()
18421842
end
18431843
| String f ->
1844-
if !current >= l then stop_raise ~usage ~error:(Missing s) speclist
1844+
if !current >= finish then stop_raise ~usage ~error:(Missing s) speclist
18451845
else begin
18461846
let arg = argv.(!current) in
18471847
incr current;

lib/4.06.1/unstable/bsb_native.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,7 @@ val parse_exn :
17181718
usage:string ->
17191719
argv:string array ->
17201720
start:int ->
1721+
?finish:int ->
17211722
(key * spec * doc) list ->
17221723
anon_fun -> unit
17231724
end = struct
@@ -1824,11 +1825,10 @@ end = struct
18241825
raise (Bad (Ext_buffer.contents b))
18251826

18261827

1827-
let parse_exn ~usage ~argv ~start (speclist : t) anonfun =
1828-
let l = Array.length argv in
1828+
let parse_exn ~usage ~argv ~start ?(finish=Array.length argv) (speclist : t) anonfun =
18291829
let current = ref start in
18301830
let rev_list = ref [] in
1831-
while !current < l do
1831+
while !current < finish do
18321832
let s = argv.(!current) in
18331833
incr current;
18341834
if s <> "" && s.[0] = '-' then begin
@@ -1841,7 +1841,7 @@ end = struct
18411841
| Unit_call f -> f ()
18421842
end
18431843
| String f ->
1844-
if !current >= l then stop_raise ~usage ~error:(Missing s) speclist
1844+
if !current >= finish then stop_raise ~usage ~error:(Missing s) speclist
18451845
else begin
18461846
let arg = argv.(!current) in
18471847
incr current;

0 commit comments

Comments
 (0)