public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
To: cygwin@cygwin.com
Subject: Re: should scanf be getting built supporting hexadecimal float
Date: Mon, 19 Apr 2021 09:17:48 -0600	[thread overview]
Message-ID: <91cf4bdd-9a97-6d6b-73af-01e891c22182@SystematicSw.ab.ca> (raw)
In-Reply-To: <189e0004-0cee-0e1d-2c2f-0acd7d8ca2fb@SystematicSw.ab.ca>

On 2021-04-19 09:07, Brian Inglis wrote:
> On 2021-04-18 22:09, Keith Thompson via Cygwin wrote:
>> The *scanf() functions don't handle hexadecimal floating-point input
>> (for example "0x1p+0" representing 1.0).
>> On Cygwin, the output (compiled with gcc or clang) is:
>> sscanf returned 1, x = 0 (expected 1), FAILED
>> On Ubuntu, the output is:
>> sscanf returned 1, x = 1, PASSED
>> Looking through the newlib sources (git://sourceware.org/git/newlib-cygwin.git),
>> this might be related to the _WANT_IO_C99_FORMATS macro, but I haven't
>> looked into
>> the details.
>> The test case passes on Cygwin when compiled with i686-w64-mingw32-gcc
>> or x86_64-w64-mingw32-gcc.

> This seems like an oversight as gdtoa-gethex.c was added about 2006 and scanf 
> and strtod support it.
> See augmented STC with strtod added attached:
> 
> $ gcc -o hexfloat-scanf-test{,.c}
> $ ./hexfloat-scanf-test
> sscanf returned 2, unscanned 'x1p+0', x = 0 (expected 1), FAILED
> strtod unscanned '', x = 1, PASSED

Should the Cygwin newlib build be enabling hex float support?

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

  reply	other threads:[~2021-04-19 15:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19  4:09 sscanf doesn't handle hexadecimal floating-point input Keith Thompson
2021-04-19 15:07 ` sscanf doesn't handle hexadecimal float but strtod does Brian Inglis
2021-04-19 15:17   ` Brian Inglis [this message]
2021-04-19 17:53     ` should scanf be getting built supporting hexadecimal float Corinna Vinschen
2021-04-19 20:12       ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91cf4bdd-9a97-6d6b-73af-01e891c22182@SystematicSw.ab.ca \
    --to=brian.inglis@systematicsw.ab.ca \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).