From bee84153d00d1e3d59c3a0a5ba0ab4cae773cf9e Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Mon, 27 Mar 2006 11:28:06 +0000 Subject: [PATCH] More robust handling of Control-C. --- components/binaries/utilities/test_library.ml | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/components/binaries/utilities/test_library.ml b/components/binaries/utilities/test_library.ml index f0e9510db..57939da48 100644 --- a/components/binaries/utilities/test_library.ml +++ b/components/binaries/utilities/test_library.ml @@ -55,6 +55,8 @@ let urifname = let ic = open_in urifname +exception Done;; + let _ = try while true do @@ -85,13 +87,22 @@ let _ = with | End_of_file as exn -> raise exn | Sys.Break -> - Printf.printf "SKIPPED\n"; - flush stdout; - Printf.eprintf "Continue with next URI? [y/_]"; - flush stderr; - (match input_line stdin with - "y" -> () - | _ -> raise Sys.Break) + let rec skip_break prompt = + try + if prompt then + begin + Printf.printf "SKIPPED\n"; + flush stdout; + Printf.eprintf "Continue with next URI? [y/_]"; + flush stderr; + end; + (match input_line stdin with + "y" -> () + | _ -> raise Done) + with + Sys.Break -> skip_break false + in + skip_break true | exn -> Printf.printf "FAIL\n"; flush stdout; @@ -99,4 +110,4 @@ let _ = done with End_of_file - | Sys.Break -> () + | Done -> () -- 2.39.2