Re: checking whether a double is in the range of long

2023-04-22 Thread Paul Eggert
On 2023-04-22 16:34, Ben Pfaff wrote: determine whether converting 'd' to 'long' would yield a 'long' with the same value as 'd' LONG_MIN - 1.0 < d && d < LONG_MAX + 1.0 && d == (long) d On all practical platforms this should avoid undefined behavior and works correctly even if rounding occur

Avoid some Autoconf "was expanded before it was required" warnings

2023-04-22 Thread Bruno Haible
Building some testdir, I see this Autoconf warning: executing autoconf configure.ac:785: warning: AC_REQUIRE: `gt_LOCALE_FR_UTF8' was expanded before it was required configure.ac:785: https://www.gnu.org/software/autoconf/manual/autoconf.html#Expanded-Before-Required configure.ac:34: gl_INIT is

Re: checking whether a double is in the range of long

2023-04-22 Thread Ben Pfaff
On Sat, Apr 22, 2023 at 5:52 PM Bruno Haible wrote: > > Ben Pfaff wrote: > > determine whether converting 'd' to 'long' would > > yield a 'long' with the same value as 'd'. > > Maybe > d == (double) (long) d > ? > > Just a wild guess. I haven't tested it. I don't trust the undefined behavior in

Re: checking whether a double is in the range of long

2023-04-22 Thread Bruno Haible
Ben Pfaff wrote: > determine whether converting 'd' to 'long' would > yield a 'long' with the same value as 'd'. Maybe d == (double) (long) d ? Just a wild guess. I haven't tested it. Bruno

Re: checking whether a double is in the range of long

2023-04-22 Thread Ben Pfaff
On Sat, Apr 22, 2023 at 4:34 PM Ben Pfaff wrote: > Before this afternoon, I thought that a check like this for a double 'd': > d == floor (d) && d >= LONG_MIN && d <= LONG_MAX > was sufficient to determine whether converting 'd' to 'long' would > yield a 'long' with the same value as 'd'. > >

checking whether a double is in the range of long

2023-04-22 Thread Ben Pfaff
Before this afternoon, I thought that a check like this for a double 'd': d == floor (d) && d >= LONG_MIN && d <= LONG_MAX was sufficient to determine whether converting 'd' to 'long' would yield a 'long' with the same value as 'd'. Now I realize that this is wrong. In particular, take a look

string-desc tests: Avoid test failure on native Windows

2023-04-22 Thread Bruno Haible
On mingw 10, I see this test failure: FAIL: test-string-desc.sh = ../../gltests/test-string-desc.c:113: assertion 'string_desc_write (3, s1) == 0' failed FAIL test-string-desc.sh (exit status: 1) Apparently, in the Cygwin environment, it is not possible to pass an open f

threadlib, pthread-h, threads-h: Avoid mingw's libwinpthread by default

2023-04-22 Thread Bruno Haible
Gnulib's multithreading implementation can, on mingw, be based on mingw's libwinpthread or on native Windows primitives. But it makes a difference on the 'test-pthread-tss' test: With mingw 5.0.3 libwinpthread it fails like this: Starting test_tss ... OK Starting test_tss_dtorcheck1 ... OK

Re: a test-posixtm failure

2023-04-22 Thread Bruno Haible
Paul Eggert wrote: > I wouldn't spend much time on it, so disabling tests on those platforms > seems appropriate. OK, done: 2023-04-22 Bruno Haible posixtm tests: Avoid test failure on native Windows. * tests/test-posixtm.c (T): On native Windows, disable test cases that

Re: dfa tests: Fix test failure on mingw

2023-04-22 Thread Bruno Haible
I wrote: > > Is there some way we can instead compile or run MinGW apps so that they > > instead follow the POSIX LF convention? > > Sure. Instead of the change above, I can alternatively add a > set_binary_mode (STDOUT_FILENO, O_BINARY); > call to the C program. Done: 2023-04-22 Bruno Haib