more precise integer Markup.properties/XML.attributes: disallow ML-style ~ minus;
authorwenzelm
Thu, 14 Jul 2011 22:30:31 +0200
changeset 43797 fad7758421bf
parent 43796 7293403dc38b
child 43835 1162191cb57c
more precise integer Markup.properties/XML.attributes: disallow ML-style ~ minus;
src/Pure/General/markup.ML
src/Pure/General/xml.ML
--- a/src/Pure/General/markup.ML	Wed Jul 13 22:05:55 2011 +0200
+++ b/src/Pure/General/markup.ML	Thu Jul 14 22:30:31 2011 +0200
@@ -136,9 +136,11 @@
 (* integers *)
 
 fun parse_int s =
-  (case Int.fromString s of
-    SOME i => i
-  | NONE => raise Fail ("Bad integer: " ^ quote s));
+  let val i = Int.fromString s in
+    if is_none i orelse String.isPrefix "~" s
+    then raise Fail ("Bad integer: " ^ quote s)
+    else the i
+  end;
 
 val print_int = signed_string_of_int;
 
--- a/src/Pure/General/xml.ML	Wed Jul 13 22:05:55 2011 +0200
+++ b/src/Pure/General/xml.ML	Thu Jul 14 22:30:31 2011 +0200
@@ -293,9 +293,8 @@
 (* atomic values *)
 
 fun int_atom s =
-  (case Int.fromString s of
-    SOME i => i
-  | NONE => raise XML_ATOM s);
+  Markup.parse_int s
+    handle Fail _ => raise XML_ATOM s;
 
 fun bool_atom "0" = false
   | bool_atom "1" = true