You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1413 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
I have just tried the new Scanf module in 3.06, and discovered that the format
string
%N returns one more character than I would expect. For example:
sscanf "456" "%N" (fun x -> x)
returns 1, and not 0 ("the number of characters read so far", as stated in the
docs).
And
sscanf "" "%N" (fun x -> x)
raises the exception End_of_file.
I found this error because I needed a way to check that the whole buffer is
read, and
not just a prefix. So I thought that
sscanf iso_date_string
"%4d-%2d-%2d%N"
(fun year month day n ->
if n = String.length iso_date_string then
(year,month,day)
else
Scanf.Scan_failure "Too many characters")
solved my problem, but it did not. Maybe it is a usuful extension to add a
notation
like $ in regexps that anchors at the end of strings.
Gerd
The text was updated successfully, but these errors were encountered:
%N returns one more character than I would expect. For example:
sscanf "456" "%N" (fun x -> x)
returns 1, and not 0 ("the number of characters read so far", as stated in the docs).
And
sscanf "" "%N" (fun x -> x)
raises the exception End_of_file.
This is indeed a bug that no one here have noticed, even after careful
code review! (Not mentioning intensive testing on complex formats!)
Thank you very much for pointing it out.
I found this error because I needed a way to check that the whole buffer is
read, and
not just a prefix. So I thought that
sscanf iso_date_string
"%4d-%2d-%2d%N"
(fun year month day n ->
if n = String.length iso_date_string then
(year,month,day)
else
Scanf.Scan_failure "Too many characters")
solved my problem, but it did not. Maybe it is a usuful extension to add a
notation like $ in regexps that anchors at the end of strings.
I am not completely sure that we need the $ extension.
The correction of those glitches is not completely trivial and I am
working on them. I will drop you a mail as soon as I have a
satisfactory correction.
Original bug ID: 1413
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Gerd Stolpmann
Version: 3.06
OS: Linux
Submission from: p50816707.dip0.t-ipconnect.de (80.129.103.7)
Hello,
I have just tried the new Scanf module in 3.06, and discovered that the format
string
%N returns one more character than I would expect. For example:
returns 1, and not 0 ("the number of characters read so far", as stated in the
docs).
And
raises the exception End_of_file.
I found this error because I needed a way to check that the whole buffer is
read, and
not just a prefix. So I thought that
solved my problem, but it did not. Maybe it is a usuful extension to add a
notation
like $ in regexps that anchors at the end of strings.
Gerd
The text was updated successfully, but these errors were encountered: