Groups | Search | Server Info | Login | Register


Groups > muc.lists.netbsd.tech.misc > #115

Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD

From Paul Eggert <eggert@cs.ucla.edu>
Newsgroups muc.lists.netbsd.tech.misc
Subject Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD
Date 2025-03-19 12:27 -0700
Organization UCLA Computer Science Department
Message-ID <e42cfaa9-0756-45ea-a54e-31297200e3c0@cs.ucla.edu> (permalink)
References <> <3237498.fEcJ0Lxnt5@nimes>

Show all headers | View raw


On 2025-03-18 17:15, Bruno Haible wrote:
> If you don't want to do that, I can only repeat what I said in the previous
> mail: The proposal*does not achieve the goal* of avoiding the most common
> programmer mistakes. For a robust API, the success test should*only* involve
> testing the returned 'status', nothing else.

This was my initial reaction as well. Although strtol has real problems, 
the proposed interface is even more complicated and confusing and I 
suspect that in practice it'd be misused even more often than strtol is.

I suggest starting from scratch. In particular, use a functional style, 
with no side effects (no pointers-to-results). Just return the result 
you want, as a struct, and keep the struct simple. Two struct components 
should suffice: the scanned numeric value and a success/error indicator.


--
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 | NextPrevious in thread | Next in thread | Find similar


Thread

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