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

2025-04-05 Thread Paul Eggert
On 3/21/25 08:33, Bruno Haible wrote: Regarding speed, I'm not sure: the byte describing the properties of *str is in the L1 cache after the execution of isspace ((unsigned char) *str) Oh, and I just checked with gcc -O2 on x86-64, which optimizes the isdigit version into a fewer bytes' wor

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

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