On Apr 19 19:53, Corinna Vinschen via Cygwin wrote: > On Apr 19 09:17, Brian Inglis wrote: > > 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? > > Unfortunately, newlib's scanf code does not support hex floats at all yet. > Scanf collects and validates the input stream snippet which is supposed to > be given to strtod/strtold, and neither x nor p are valid chars in that > piece of code yet. > > I'll look into adding this code, which shouldn't be too complicated, > but I wouldn't be offended by patches either.
I pushed a patch which hopefully does the trick https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=9c6c2fb0f697 I also uploaded new developer snapshots to https://cygwin.com/snapshots/ Please give it a try. Thanks, Corinna -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple