diff options
author | Pierre Weis <Pierre.Weis@inria.fr> | 2003-03-02 23:03:15 +0000 |
---|---|---|
committer | Pierre Weis <Pierre.Weis@inria.fr> | 2003-03-02 23:03:15 +0000 |
commit | 1f955eb17e76e0a4f87bbb50d48a552866b85ebc (patch) | |
tree | 6bb4e9244490d99d22f2deed72fa845a7e790d75 /stdlib | |
parent | e132cd1f7a07a41dc7dbddea7453a86e6ebb5ea4 (diff) |
Format %S now understands continuation newlines (\\\n).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5412 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/scanf.ml | 16 | ||||
-rw-r--r-- | stdlib/scanf.mli | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/stdlib/scanf.ml b/stdlib/scanf.ml index b479e9d5b..bb37064f8 100644 --- a/stdlib/scanf.ml +++ b/stdlib/scanf.ml @@ -475,9 +475,21 @@ let scan_String max ib = | '"', false (* '"' helping Emacs *) -> Scanning.next_char ib; max - 1 | '\\', false -> - Scanning.next_char ib; loop false (scan_backslash_char (max - 1) ib) + Scanning.next_char ib; + skip_spaces true (max - 1) + | c, false -> loop false (Scanning.store_char ib c max) + | c, _ -> bad_input_char c + and skip_spaces s max = + if max = 0 || Scanning.end_of_input ib then bad_input "a string" else + let c = Scanning.checked_peek_char ib in + match c, s with + | '\n', true -> + Scanning.next_char ib; + skip_spaces false (max - 1) + | ' ', false -> skip_spaces false (max - 1) + | '\\', false -> loop true max | c, false -> loop false (Scanning.store_char ib c max) - | c, _ -> bad_input_char c in + | _ -> loop false (scan_backslash_char (max - 1) ib) in loop true max;; let scan_bool max ib = diff --git a/stdlib/scanf.mli b/stdlib/scanf.mli index dfbc93289..3a5a0ac65 100644 --- a/stdlib/scanf.mli +++ b/stdlib/scanf.mli @@ -130,7 +130,7 @@ val bscanf : - [N]: applies [f] to the number of tokens read so far. - [%]: matches one [%] character in the input. - Following the [%] character introducing a conversion there may be + Following the [%] character introducing a conversion, there may be the special flag [_]: the conversion that follows occurs as usual, but the resulting value is discarded. |