I wrote: > Christos Zoulas wrote > > Committed. > > Thank you very much! > > I'm attaching a patch with errata: > - sync strtonum(3) API with OpenBSD to 1:1, in case of floating prototypes we will remain compatible (remove restricted) > - add strtonum.3, based on the original OpenBSD man-page > - move comments regarding strtonum from .c to .3 > - sync strto[iu] documentation with API > - minor cleaning. > > I left the rest actions to a NetBSD dev: > - distribution update, > - libc minor update. > > Next: estrtoi and estrtou for efuns(3). I've added additional and hopefully final set of patches for strto[iu]: - add entries to distrib/ for man-pages - add forgotten strtoi.c and strtou.c to the tools/compat machinery - add two new functions in libutil, in the efun set: estrtoi(3) and estrtou(3), their simplified API: intmax_t estrtoi(const char *, int, intmax_t, intmax_t); uintmax_t estrtou(const char *, int, uintmax_t, uintmax_t); Please review and apply. This will be hopefully everything in the libc part (well before pkgsrcizing the functions, strtonum(3) has to be detected on host). The new efun was tested with the following example: #include <util.h> #include <stdio.h> int main(int argc, char **argv) { int a = estrtoi(argv[1], 0, 10, 100); printf("a=%d\n", a); return 0; } # ./a.out 0 a.out: Cannot convert string value '0' with base 0 to a number in range [10 .. 100]: Result too large or too small # ./a.out "a" a.out: Cannot convert string value 'a' with base 0 to a number in range [10 .. 100]: Operation Canceled # ./a.out "0123a" a.out: Cannot convert string value '0123a' with base 0 to a number in range [10 .. 100]: Not supported # ./a.out "1 2 3" a.out: Cannot convert string value '1 2 3' with base 0 to a number in range [10 .. 100]: Not supported # ./a.out 13 a=13 # ./a.out 22222222222222222222222222222222222222222222 a.out: Cannot convert string value '22222222222222222222222222222222222222222222' with base 0 to a number in range [10 .. 100]: Result too large or too small Regards,
Attachment:
patch-src-distrib
Description: Binary data
Attachment:
patch-src-include
Description: Binary data
Attachment:
patch-src-lib
Description: Binary data
Attachment:
patch-src-tools
Description: Binary data