pcre-ocaml
pcre-ocaml copied to clipboard
A possible bug in full_split ?
Over at the OCaml discussion forum, someone found what looks like a bug with full_split
: https://discuss.ocaml.org/t/full-split-in-pcre/12948/1
TL;DR it looks like full_split isn't getting unmatched groups right for delimiters after the first delimiter. I dug into the code, and it seems like the problem might be with the way that full_split invokes unsafe_pcre_exec
. To wit, everywhere else except in the split
functions (full_split, internal_psplit) the value of subj_start
is always 0
. But in these two functions, it is the same as pos
.
When I changed this to 0
, the bug evinced in the post above disappeared.
I'm going to dig further, but I thought I'd report this, and ask for your feedback. If you're still actively maintaining this code, I'll send a PR; otherwise, I'll just fix it in the pcre2
codebase.