Skip to content

Commit 1170565

Browse files
committed
Avoid String.split_on_char for backwards compatibility.
1 parent 8bd8ebf commit 1170565

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ppx_regexp.ml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,19 @@ let fresh_var =
4040
let c = ref 0 in
4141
fun () -> incr c; Printf.sprintf "_ppx_regexp_%d" !c
4242

43+
let rec is_zero p k =
44+
(match p.[k] with
45+
| '0' -> is_zero p (k + 1)
46+
| '1'..'9' -> false
47+
| _ -> true)
48+
4349
let rec must_match p i =
4450
let l = String.length p in
4551
if i = l then true else
4652
if p.[i] = '?' || p.[i] = '*' then false else
4753
if p.[i] = '{' then
4854
let j = String.index_from p (i + 1) '}' in
49-
(match String.split_on_char ',' (String.sub p (i + 1) (j - i - 1)) with
50-
| k :: _ when int_of_string k = 0 -> false
51-
| _ -> must_match p (j + 1))
55+
not (is_zero p (i + 1)) && must_match p (j + 1)
5256
else
5357
true
5458

0 commit comments

Comments
 (0)