All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: liba2i@lists.linux.dev, Alejandro Colomar <alx@kernel.org>
Cc: sc22wg14@open-std.org, libbsd@lists.freedesktop.org,
	tech-misc@netbsd.org, christos <christos@netbsd.org>,
	"Đoàn Trần Công Danh" <congdanhqx@gmail.com>,
	"Paul Eggert" <eggert@cs.ucla.edu>,
	"Eli Schwartz" <eschwartz93@gmail.com>,
	"Guillem Jover" <guillem@hadrons.org>,
	"Iker Pedrosa" <ipedrosa@redhat.com>,
	"Michael Vetter" <jubalh@iodoru.org>,
	"Robert Elz" <kre@netbsd.org>,
	riastradh@netbsd.org, "Sam James" <sam@gentoo.org>,
	"Serge E. Hallyn" <serge@hallyn.com>
Subject: Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD
Date: Wed, 19 Mar 2025 18:35:29 +0100	[thread overview]
Message-ID: <28568979.gRfpFWEtPU@nimes> (raw)
In-Reply-To: <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




  parent reply	other threads:[~2025-03-19 17:36 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250318142555.09A86356820@www.open-std.org>
2025-03-18 13:54 ` alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Alejandro Colomar
2025-03-18 21:16   ` Alejandro Colomar
2025-03-18 21:53   ` Bruno Haible
2025-03-18 22:43     ` Alejandro Colomar
2025-03-19  0:15       ` Bruno Haible
2025-03-19 15:26         ` Alejandro Colomar
2025-03-19 18:48           ` Alejandro Colomar
2025-03-19 18:56             ` Alejandro Colomar
2025-03-19 21:59           ` Bruno Haible
2025-03-19 23:12             ` Alejandro Colomar
2025-03-19 23:30               ` strtou(3) handling of negative input Alejandro Colomar
2025-03-19 23:52               ` alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Thorsten Glaser
2025-03-20  0:19                 ` Alejandro Colomar
2025-03-20  0:31                   ` Thorsten Glaser
2025-03-20  0:36                     ` Alejandro Colomar
2025-03-19 23:52               ` nullability of status parameter in strtoi/u(3) Alejandro Colomar
2025-03-20 12:44               ` alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD Bruno Haible
2025-03-20 12:55                 ` Alejandro Colomar
2025-03-20 17:18                   ` Thorsten Glaser
2025-03-20 14:26               ` Bruno Haible
2025-03-20 14:54                 ` Alejandro Colomar
2025-03-19 19:27         ` Paul Eggert
2025-03-19 20:05           ` Alejandro Colomar
2025-03-19 20:39             ` Paul Eggert
2025-03-19 21:23               ` Alejandro Colomar
2025-03-20  0:39                 ` Paul Eggert
2025-03-20  1:15                   ` Alejandro Colomar
2025-03-20  7:03                     ` Paul Eggert
2025-03-20 10:32                       ` Alejandro Colomar
2025-03-19 15:56       ` Thorsten Glaser
2025-03-19 16:25         ` Alejandro Colomar
2025-03-19 16:36           ` Thorsten Glaser
2025-03-19 16:53             ` Alejandro Colomar
2025-03-19 17:35           ` Bruno Haible [this message]
2025-03-19 18:01             ` Alejandro Colomar
2025-03-20 16:13   ` alx-0008r2 " Alejandro Colomar
2025-03-18 17:20 ` [SC22WG14.29900] alx-0008 " Joseph Myers
2025-03-18 20:18   ` Alejandro Colomar
     [not found]   ` <20250318201854.66AB5356895@www.open-std.org>
2025-03-18 21:11     ` [SC22WG14.29912] " Joseph Myers
2025-03-18 21:35       ` Alejandro Colomar
2025-03-18 21:40         ` Alejandro Colomar
2025-03-18 22:14         ` Joseph Myers
2025-03-18 22:49           ` Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=28568979.gRfpFWEtPU@nimes \
    --to=bruno@clisp.org \
    --cc=alx@kernel.org \
    --cc=christos@netbsd.org \
    --cc=congdanhqx@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=eschwartz93@gmail.com \
    --cc=guillem@hadrons.org \
    --cc=ipedrosa@redhat.com \
    --cc=jubalh@iodoru.org \
    --cc=kre@netbsd.org \
    --cc=liba2i@lists.linux.dev \
    --cc=libbsd@lists.freedesktop.org \
    --cc=riastradh@netbsd.org \
    --cc=sam@gentoo.org \
    --cc=sc22wg14@open-std.org \
    --cc=serge@hallyn.com \
    --cc=tech-misc@netbsd.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.