NetBSD-Bugs archive

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

Re: lib/49429: Import strtonum(3)

The following reply was made to PR lib/49429; it has been noted by GNATS.

From: "Kamil Rytarowski" <>
Subject: Re: lib/49429: Import strtonum(3)
Date: Sat, 27 Dec 2014 02:44:15 +0100

 >  4) do we really want ENOSUP this way?
 strtoi(3)/strtou(3) will not work when someone might want to have code similar to this common idiom:
 /* strtod example */
 #include <stdio.h>      /* printf, NULL */
 #include <stdlib.h>     /* strtod */
 int main ()
   char szOrbits[] = "365.24 29.53";
   char* pEnd;
   double d1, d2;
   d1 = strtod (szOrbits, &pEnd);
   d2 = strtod (pEnd, NULL);
   printf ("The moon completes %.2f orbits per Earth year.\n", d1/d2);
   return 0;
 I suggest that we will promote strtol(3)-like functions usage for checking for partial conversions.
 >  5) if base is not supported then we can unexpectedly abuse errno from EINVAL  and change return value from 0 to lo/hi
 abuse errno and change it from EINVAL to ERANGE*

Home | Main Index | Thread Index | Old Index