Re: [PATCH v1] xstrtol: Remove dead code

2024-07-19 Thread Alejandro Colomar
Hi Bruno, On Fri, Jul 19, 2024 at 06:54:40PM GMT, Bruno Haible wrote: > Alejandro Colomar wrote: > > strtod(3) defers to strtol(3) for the example program. > > Is this adequate? strtod() can produce underflow (e.g. for "1e-500"). > In this case all implementations except MSVC set errno to ERANGE.

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-19 Thread Bruno Haible
Alejandro Colomar wrote: > We'd need to know the precise specification of that system that can set > errno = ENOMEM. > > Is *endp guaranteed to be set? Or may it be unset (as happens with > EINVAL)? One system that calls malloc() during strtod() is NetBSD. See $ grep -ri malloc src/lib/libc/gdt

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-19 Thread Bruno Haible
Alejandro Colomar wrote: > strtod(3) defers to strtol(3) for the example program. Is this adequate? strtod() can produce underflow (e.g. for "1e-500"). In this case all implementations except MSVC set errno to ERANGE. This is a case that cannot happen in strtol(). Bruno

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Andrew J. Hesford
Stop tagging me in your submissions. I have no involvement in any of this activity. -- Andrew J. Hesford a...@sideband.org [Mobile communication] > On Jul 18, 2024, at 5:25 PM, Alejandro Colomar wrote: > > On Thu, Jul 18, 2024 at 11:09:40PM GMT, Bruno Haible wrote: >> Hi Alejandro, > > Hi Br

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Alejandro Colomar
On Fri, Jul 19, 2024 at 12:14:19AM GMT, Alejandro Colomar wrote: > [CC -= Andrew, per explicit request] > > On Thu, Jul 18, 2024 at 11:25:11PM GMT, Alejandro Colomar wrote: > > On Thu, Jul 18, 2024 at 11:09:40PM GMT, Bruno Haible wrote: > > > Hi Alejandro, > > Hi Bruno, > > > > > strtol(3) has a

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Alejandro Colomar
Hi Bruno, On Fri, Jul 19, 2024 at 12:34:39AM GMT, Bruno Haible wrote: > Alejandro Colomar wrote: > > > - Some systems return "wrong" errno values. Example: [1] > > > - Some systems fail with ENOMEM when memory is tight. Who says that > > > an implementation of strtol() cannot use malloc()

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Bruno Haible
Alejandro Colomar wrote: > > - Some systems return "wrong" errno values. Example: [1] > > - Some systems fail with ENOMEM when memory is tight. Who says that > > an implementation of strtol() cannot use malloc() ? Some implementations > > of strtod() do use malloc(). > > > > So, what y

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Alejandro Colomar
[CC -= Andrew, per explicit request] On Thu, Jul 18, 2024 at 11:25:11PM GMT, Alejandro Colomar wrote: > On Thu, Jul 18, 2024 at 11:09:40PM GMT, Bruno Haible wrote: > > Hi Alejandro, Hi Bruno, > > > strtol(3) has a limited set of possible states: > > > ... > > > The condition '*endp != s && errno

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Alejandro Colomar
On Thu, Jul 18, 2024 at 11:09:40PM GMT, Bruno Haible wrote: > Hi Alejandro, Hi Bruno, > > strtol(3) has a limited set of possible states: > > ... > > The condition '*endp != s && errno != 0 && errno != ERANGE' is > > unreachable. The only errno possible if '*endp != s' is ERANGE. > > Such a sta

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Bruno Haible
Hi Alejandro, > strtol(3) has a limited set of possible states: > ... > The condition '*endp != s && errno != 0 && errno != ERANGE' is > unreachable. The only errno possible if '*endp != s' is ERANGE. Such a statement can be true if you look at the standards (ISO C, POSIX). However, there's a d