parse-duration: Work around an strtoul() misfeature

2025-03-21 Thread Bruno Haible via Gnulib discussion list
The 'strtoul' man page has this note: Negative values are considered valid input and are silently converted to the equivalent unsigned long value. That is, where many callers of strtoul() only want a conversion like "231" -> 231 strtoul() also a sign before the number: "+231" ->

Re: parse-duration: Work around an strtoul() misfeature

2025-03-21 Thread Bruno Haible via Gnulib discussion list
Paul Eggert wrote: > > + while (isspace ((unsigned char) *str)) > > +str++; > > + if (isdigit ((unsigned char) *str)) > > +{ > > + unsigned long ret = strtoul (str, (char **)ppz, base); > > Perhaps "*str != '+' && *str != '-'" instead of "isdigit ((unsigned > char) *str)? It'd be a

getloadavg: Improve Linux and Android support

2025-03-21 Thread Bruno Haible via Gnulib discussion list
On Android, inside Termux, I see the test-getloadavg test fail. This patch fixes it, by using the sysinfo() system call instead of reading from /proc. Like what was done in glibc in 2021: 2025-03-21

Re: parse-duration: Work around an strtoul() misfeature

2025-03-21 Thread Paul Eggert
On 3/21/25 05:16, Bruno Haible via Gnulib discussion list wrote: + while (isspace ((unsigned char) *str)) +str++; + if (isdigit ((unsigned char) *str)) +{ + unsigned long ret = strtoul (str, (char **)ppz, base); Perhaps "*str != '+' && *str != '-'" instead of "isdigit ((unsigned

mountlist: Work around an strtoul() misfeature

2025-03-21 Thread Bruno Haible via Gnulib discussion list
Two more tweaks of the mountlist module: 2025-03-21 Bruno Haible mountlist: Add specification comment in .h file. * lib/mountlist.h (read_file_system_list): Move specification to here... * lib/mountlist.c (read_file_system_list): ...from here. 2025-03-21 Bruno Haible