Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scanf.scanf works differently around "@" char in 4.01.0+dev2 #5605

Closed
vicuna opened this issue May 3, 2012 · 3 comments
Closed

Scanf.scanf works differently around "@" char in 4.01.0+dev2 #5605

vicuna opened this issue May 3, 2012 · 3 comments

Comments

@vicuna
Copy link

vicuna commented May 3, 2012

Original bug ID: 5605
Reporter: furuse
Assigned to: @protz
Status: closed (set by @xavierleroy on 2013-08-31T10:49:13Z)
Resolution: fixed
Priority: high
Severity: major
Category: standard library
Duplicate of: #5380

Bug description

In OCaml 3.12.1,

Scanf.scanf "%S %S@\n" (fun x y -> (x,y));;

"hello" "world"

  • : string * string = ("hello", "world")

In OCaml 4.01.0+dev2_2012-04-17,

Scanf.scanf "%S %S@\n" (fun x y -> (x,y));;

"hello" "world"
Exception:
Scanf.Scan_failure
"scanf: bad input at char number 27: ``looking for '@', found '\n'''".

I do not know it is a bug or not, but this difference causes trouble at ocaml setup.ml -build in OASIS.

An interesting thing is that the following works fine:

Scanf.scanf "%S %S %s@\n" (fun x y z -> (x,y,z));;

"hello" "world" bye

  • : string * string * string = ("hello", "world", "bye")
@vicuna
Copy link
Author

vicuna commented May 3, 2012

Comment author: @ygrek

duplicate of #5380

@vicuna
Copy link
Author

vicuna commented May 3, 2012

Comment author: furuse

By reading the comment in scanf.mli, I understand the current behaviour is correct wrt it. So, I think it is a bug of OASIS caused by a buggy implementation of the old scanf.ml.

(** Scanning indications appear just after the string conversions [%s]
and [%[ range ]] to delimit the end of the token. A scanning
indication is introduced by a [@] character, followed by some
plain character [c]. It means that the string token should end
just before the next matching [c] (which is skipped). If no [c]
character is encountered, the string token spreads as much as
possible. For instance, ["%s@\t"] reads a string up to the next
tab character or to the end of input. If a [@] character appears
anywhere else in the format string, it is treated as a plain character.

@vicuna
Copy link
Author

vicuna commented May 3, 2012

Comment author: @damiendoligez

This is a known bug in oasis, and as far as I know, it was fixed a few months ago:

https://forge.ocamlcore.org/tracker/index.php?func=detail&aid=1067&group_id=54&atid=291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant