tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Reuse strtonum(3) and reallocarray(3) from OpenBSD



"Kamil Rytarowski" <n54%gmx.com@localhost> wrote:
 |Steffen Nurpmeso wrote:
 |> "Kamil Rytarowski" <n54%gmx.com@localhost> wrote:
 |>|I've prepared a small patch adding strtonum(3)
 |> 
 |> This is a ridiculous interface.
 |> You just cannot object to what Jörg Sonnenberger said and at the
 |> same time propose a function that requires multiple steps in order
 |> to decide wether the return value is a valid one or indicates an
 |> error condition instead.
 |> If you want at all costs a good number converting facility, use
 |> e.g. that:
 |> 
 |> [...]
 |
 |Hello Steffen,
 |
 |Thank you for your feedback.
 |
 |Please don't mind, but this is not my argument, its superiority.

No no.

 |The API is clear and it's doing well for what it's meant.
 |It's also preventing from simple bugs, like the one of mine, \
 |when I was porting timeout for NetBSD:
 |http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/timeout/ti\
 |meout.c?annotate=1.4
 |
 |Please see:
 |find /usr/src -name '*.[ch]' -exec grep strtonum {} \;|nl 
 |It gives me 136 results (NetBSD-current)

Your count includes for example quite a lot of GNU awk(1) matches,
which also has a different semantic than the C version has [1].

  [1] https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html

PF may leave NetBSD in a not too distant future.
libbind uses its own special version for tests..
ftp-proxy is too lazy to do (x < Y || x > Z) or something, three
times.  I personally don't use tmux(1), as GNU screen(1) is so
much better (in my opinion), also historically:

  ?0[steffen@sherwood screen.tar_bomb_git]$ git grep -i strtonum master:
  ?1[steffen@sherwood screen.tar_bomb_git]$ 

So then there is ZFS which i will never use; and i wonder
why something that requires Python to run defines its own
zfs_nicestrtonum(libzfs_handle_t *hdl, const char *value, uint64_t
*num); to do it better.

Then there is the LUA internal special lua_strtonum().

So NetBSD ends up with m4(1) (GNU), sdiff(1) (GNU think)
and finally gpioctl(1).

 |We already DO implement strtonum(3) MANY times in our sources, \

No really, that is propaganda much too loud.

 |doing it system-wide and in a central place is major improvement. \
 |Not just for reusing the same code, but exporting it for custom \
 |user-space software.
 |
 |As long as it's not system-wide new code using strtonum(3) \
 |in our sources will need compat layer and implementation / \
 |reimplementation of this function with the ridiculous interface.

Whereas i feel overwhelmed by the pressure of the superiority
i will not take the second part.
This interface _is_ ridiculous.

 |BTW. Interesting language, what's it?

It is C++ (with some empty defines to make things more explicit).
You want a really good interface?  Design it and implement
strtonum() as a macro or inline wrapper.
Ciao,

--steffen


Home | Main Index | Thread Index | Old Index