diff options
author | Pierre Weis <Pierre.Weis@inria.fr> | 2004-10-04 20:19:44 +0000 |
---|---|---|
committer | Pierre Weis <Pierre.Weis@inria.fr> | 2004-10-04 20:19:44 +0000 |
commit | 486d45c826e1dc3d62abef7ec4cc63684372a79e (patch) | |
tree | f21ee6d8e0507b9c25bc2307ec2030923f9eea53 | |
parent | fe5f184972013b4cf1951b89e0337735dc9af86b (diff) |
Careful review of meta formats.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6626 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rwxr-xr-x | stdlib/Compflags | 1 | ||||
-rw-r--r-- | stdlib/scanf.ml | 20 |
2 files changed, 10 insertions, 11 deletions
diff --git a/stdlib/Compflags b/stdlib/Compflags index 697f38dca..197e699c0 100755 --- a/stdlib/Compflags +++ b/stdlib/Compflags @@ -18,6 +18,7 @@ case $1 in pervasives.cm[iox]|pervasives.p.cmx) echo ' -nopervasives';; camlinternalOO.cmi) echo ' -nopervasives';; camlinternalOO.cmx|camlinternalOO.p.cmx) echo ' -inline 0';; + scanf.cmx) echo ' -inline 9';; arrayLabels.cm[ox]|arrayLabels.p.cmx) echo ' -nolabels';; listLabels.cm[ox]|listLabels.p.cmx) echo ' -nolabels';; stringLabels.cm[ox]|stringLabels.p.cmx) echo ' -nolabels';; diff --git a/stdlib/scanf.ml b/stdlib/scanf.ml index f0682ca7e..5cf7bb52a 100644 --- a/stdlib/scanf.ml +++ b/stdlib/scanf.ml @@ -937,18 +937,16 @@ let kscanf ib ef fmt f = | _ -> scan_conversion skip max f i end | '(' | '{' as conv -> let i = succ i in - let sj = Printf.sub_format conv fmt i in - let sfmt = String.sub fmt i (sj - i - 1) in + let j = Printf.sub_format conv fmt i + 1 in + let mf = String.sub fmt i (j - i - 2) in let x = scan_String max ib in - let rfmt = token_string ib in - if Printf.summarize_format sfmt <> Printf.summarize_format rfmt - then format_mismatch sfmt rfmt ib else - begin match conv with - | '{' -> scan_fmt (stack f rfmt) (sj + 1) - | _ -> - let nf = scan_fmt (Obj.magic rfmt) 0 in - scan_fmt (stack f nf) (sj + 1) end - | conv -> bad_format fmt i conv + let rf = token_string ib in + if Printf.summarize_format mf <> Printf.summarize_format rf + then format_mismatch mf rf ib else + if conv = '{' then scan_fmt (stack f rf) j else + let nf = scan_fmt (Obj.magic rf) 0 in + scan_fmt (stack f nf) j + | c -> bad_format fmt i c and scan_fmt_stoppers i = if i > lim then i - 1, [] else |