]> matita.cs.unibo.it Git - helm.git/commitdiff
More robust handling of Control-C.
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Mon, 27 Mar 2006 11:28:06 +0000 (11:28 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Mon, 27 Mar 2006 11:28:06 +0000 (11:28 +0000)
components/binaries/utilities/test_library.ml

index f0e9510db2074b4dafddb1129f1261730e7b3355..57939da48c319bba1e506720f47f849ed08a5530 100644 (file)
@@ -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 "\e[0;31mSKIPPED\e[0m\n";
-           flush stdout;
-           Printf.eprintf "\e[0;31mContinue with next URI? [y/_]\e[0m";
-           flush stderr;
-           (match input_line stdin with
-               "y" -> ()
-             | _ -> raise Sys.Break)
+           let rec skip_break prompt =
+            try
+             if prompt then
+              begin
+               Printf.printf "\e[0;31mSKIPPED\e[0m\n";
+               flush stdout;
+               Printf.eprintf "\e[0;31mContinue with next URI? [y/_]\e[0m";
+               flush stderr;
+              end;
+             (match input_line stdin with
+                 "y" -> ()
+               | _ -> raise Done)
+            with
+             Sys.Break -> skip_break false
+           in
+            skip_break true
         | exn ->
            Printf.printf "\e[0;31mFAIL\e[0m\n";
            flush stdout;
@@ -99,4 +110,4 @@ let _ =
     done
   with
      End_of_file
-   | Sys.Break -> ()
+   | Done -> ()