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

Positional specifiers in Printf don't appear to work #4204

Closed
vicuna opened this issue Feb 13, 2007 · 3 comments
Closed

Positional specifiers in Printf don't appear to work #4204

vicuna opened this issue Feb 13, 2007 · 3 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Feb 13, 2007

Original bug ID: 4204
Reporter: @dra27
Assigned to: @pierreweis
Status: closed (set by @damiendoligez on 2008-09-11T11:58:59Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.09.3
Fixed in version: 3.11+dev
Category: ~DO NOT USE (was: OCaml general)
Duplicate of: #3992
Monitored by: "Hendrik Tews"

Bug description

Positional specifiers do not work as indicated in the documentation for Printf. Specifically, the example given "For instance, %.*3$f prints a float with as many fractional digits as the value of the third argument." gives the following response in the toploop:

Printf.printf "%.*3$f";;

Characters 14-22:
Printf.printf "%.*3$f";;

rather than int -> float -> unit!

Additional information

I'm assuming that this is a code bug rather than a docs bug if Printf aims to be POSIX compliant.

@vicuna
Copy link
Author

vicuna commented Feb 13, 2007

Comment author: @dra27

Oops --- bottom two lines of the toploop transcript are missing. It should have read:

Printf.printf "%.*3$f";;

Characters 14-22:
Printf.printf "%.*3$f";;
^^^^^^^^
Bad conversion %3, at char number 0 in format string ``%.*3$f''

@vicuna
Copy link
Author

vicuna commented Apr 15, 2007

Comment author: @pierreweis

This a bug in the type-checking of format strings. This is not so easy to fix, and need a rather drastic modification of the routine that type-checks format strings. This is on the TODO list for the next version.

In the mean time, a quick fix could be to suppress positional specifiers from the documentation of format strings :)

@vicuna
Copy link
Author

vicuna commented Sep 11, 2008

Comment author: @damiendoligez

fixed by removing positional specifiers from the doc (for the time being)

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

2 participants