svn commit: r285552 - head/usr.bin/xargs

David Chisnall theraven at FreeBSD.org
Wed Jul 15 09:29:06 UTC 2015


On 15 Jul 2015, at 01:02, Xin Li <delphij at delphij.net> wrote:
> 
> My only concern with strtonum() is that it's English only.

Given that strtonum() wraps strtoll, it ought to support whatever the current locale is (assuming that the program calls setlocale() before calling strtonum(), otherwise it will use the C locale[1]).  Or do you mean that the error messages are not localised?

David

[1] I would strongly advise against calling strtonum() or strtoll(), rather than strtoll_l() from a library, as it is impossible to specify in a potentially multi-threaded context whether you’re currently using a human-friendly or a machine-friendly number representation.  In a single-threaded application, it’s probably fine as long as *all* of your number parsing is either from a user or from a machine-parsable file (and all of your output is similar, or you’re explicitly setting the locale before each call).  Given that strtonum() is non-standard anyway, we should probably add a strtonum_l() that takes a locale_t and a number base.


More information about the svn-src-head mailing list