catch exception in search_forward and string_match

This commit is contained in:
craff 2021-12-08 16:09:16 -10:00
parent da99ea70a9
commit 6eef2bbb01

View file

@ -191,18 +191,26 @@ let read_groups str groups cont =
let search_forward regexp_ str ?(from=0) groups cont =
let open Str in
Mutex.lock str_mutex;
try
let _ = search_forward regexp_ str from in
let cont = read_groups str groups cont in
Mutex.unlock str_mutex;
cont
with e ->
Mutex.unlock str_mutex;
raise e
let string_match regexp_ str ?(from=0) groups cont =
let open Str in
Mutex.lock str_mutex;
try
let _ = string_match regexp_ str from in
let cont = read_groups str groups cont in
Mutex.unlock str_mutex;
cont
with e ->
Mutex.unlock str_mutex;
raise e
let first_line str =
let pos = String.index str '\n' in