Groups | Search | Server Info | Login | Register
Groups > muc.lists.netbsd.tech.misc > #98
| From | Bruno Haible <bruno@clisp.org> |
|---|---|
| Newsgroups | muc.lists.netbsd.tech.misc |
| Subject | Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD |
| Date | 2025-03-19 18:35 +0100 |
| Organization | GNU |
| Message-ID | <28568979.gRfpFWEtPU@nimes> (permalink) |
| References | <> <6alwxn5mchma25qxvmzebx5vfheulfvgev7f7xjcjshma3hfok@3qtsvbzoljb2> |
Alejandro Colomar wrote:
> > >> To address this adoption problem, how about changing these function to
> > >> generic functions (in the sense of <tgmath.h>)? In such a way that
> > >> strtoi (n, &end, base, LONG_MIN, LONG_MAX, &status)
> > >> is known to return a 'long' rather than 'intmax_t', and
> > >> strtoi (n, &end, base, INT_MIN, INT_MAX, &status)
> >
> > That, and especially…
>
> Please propose an implementation of the overload-selectinging macro, and
> clarify how this should work:
>
> n = strto*(s, NULL, 0, SHRT_MIN, UINT_MAX, &status);
Indeed, the "usual arithmetic conversions" (ISO C 23 § 6.3.1.8, § 7.27.(7))
would not work well in this case. Instead, one needs to distinguish strtoi
and strtou:
- For strtoi, the first of the types 'signed char', 'short', 'int', 'long',
'long long', 'intmax_t' that contains both the min and the max value.
- For strtou, the first of the types 'unsigned char', 'unsigned short',
'unsigned int', 'unsigned long', 'unsigned long long', 'uintmax_t' that
contains both the min and the max value.
Bruno
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Back to muc.lists.netbsd.tech.misc | Previous | Next — Previous in thread | Next in thread | Find similar
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Alejandro Colomar <alx@kernel.org> - 2025-03-18 23:43 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Bruno Haible <bruno@clisp.org> - 2025-03-19 01:15 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Alejandro Colomar <alx@kernel.org> - 2025-03-19 16:26 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Alejandro Colomar <alx@kernel.org> - 2025-03-19 19:48 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Alejandro Colomar <alx@kernel.org> - 2025-03-19 19:56 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Bruno Haible <bruno@clisp.org> - 2025-03-19 22:59 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Paul Eggert <eggert@cs.ucla.edu> - 2025-03-19 12:27 -0700
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Thorsten Glaser <tg@mirbsd.org> - 2025-03-19 16:56 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Alejandro Colomar <alx@kernel.org> - 2025-03-19 17:25 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Thorsten Glaser <tg@mirbsd.org> - 2025-03-19 17:36 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Alejandro Colomar <alx@kernel.org> - 2025-03-19 17:53 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Bruno Haible <bruno@clisp.org> - 2025-03-19 18:35 +0100
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Alejandro Colomar <alx@kernel.org> - 2025-03-19 19:01 +0100
csiph-web