diff --git a/src/stdune/scanf.ml b/src/stdune/scanf.ml index df8dc40362b6..edca00fcb10c 100644 --- a/src/stdune/scanf.ml +++ b/src/stdune/scanf.ml @@ -1,12 +1,12 @@ module Scanf = Dune_caml.Scanf -let try_ f = - match f () with - | exception End_of_file -> Error () +let unescaped x = + match Scanf.unescaped x with | exception Scanf.Scan_failure _ -> Error () - | exception (Failure _) -> Error () | x -> Ok x -let unescaped x = try_ (fun () -> Scanf.unescaped x) - -let sscanf x fmt f = try_ (fun () -> Scanf.sscanf x fmt f) +exception E +let sscanf x fmt f = + match Scanf.ksscanf x (fun _ _ -> raise_notrace E) fmt f with + | exception E -> Error () + | x -> Ok x