diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 2001-12-25 04:10:50 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 2001-12-25 04:10:50 +0000 |
commit | b12990ca585044c567abc2cfbea6c019b0b21dac (patch) | |
tree | f459d8eef7a900e7333840ef9c570e9ce81b1125 | |
parent | 9dd4281db826fdae02215c9d4237d18e80d38489 (diff) |
Notes
-rw-r--r-- | lib/libc/stdlib/atof.c | 12 | ||||
-rw-r--r-- | lib/libc/stdlib/atoi.c | 11 | ||||
-rw-r--r-- | lib/libc/stdlib/atol.3 | 8 | ||||
-rw-r--r-- | lib/libc/stdlib/atol.c | 12 | ||||
-rw-r--r-- | lib/libc/stdlib/atoll.c | 10 |
5 files changed, 44 insertions, 9 deletions
diff --git a/lib/libc/stdlib/atof.c b/lib/libc/stdlib/atof.c index 130e2858f926..e6dffa9184d4 100644 --- a/lib/libc/stdlib/atof.c +++ b/lib/libc/stdlib/atof.c @@ -29,18 +29,26 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)atof.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#include <errno.h> #include <stdlib.h> -#include <stddef.h> double atof(ascii) const char *ascii; { - return (strtod(ascii, NULL)); + double r; + int saverr; + + saverr = errno; + r = strtod(ascii, (char **)NULL); + errno = saverr; + return r; } diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c index 48e508aef8fd..8e98a96e7111 100644 --- a/lib/libc/stdlib/atoi.c +++ b/lib/libc/stdlib/atoi.c @@ -29,18 +29,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)atoi.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#include <errno.h> #include <stdlib.h> -#include <stddef.h> int atoi(str) const char *str; { - return((int)strtol(str, (char **)NULL, 10)); + int r, saverr; + + saverr = errno; + r = (int)strtol(str, (char **)NULL, 10); + errno = saverr; + return r; } diff --git a/lib/libc/stdlib/atol.3 b/lib/libc/stdlib/atol.3 index d23f42d330da..9ba67cdaf9f4 100644 --- a/lib/libc/stdlib/atol.3 +++ b/lib/libc/stdlib/atol.3 @@ -82,6 +82,13 @@ representation. It is equivalent to: .Pp .Dl "strtoll(nptr, (char **)NULL, 10);" +.Sh ERRORS +The +.Fn atol +function does not detect errors. +The +.Fn atoll +function does not detect errors. .Sh SEE ALSO .Xr atof 3 , .Xr atoi 3 , @@ -94,7 +101,6 @@ The function conforms to .St -isoC . -.Pp The .Fn atoll function diff --git a/lib/libc/stdlib/atol.c b/lib/libc/stdlib/atol.c index 31bcaa67c410..b85b8b2648da 100644 --- a/lib/libc/stdlib/atol.c +++ b/lib/libc/stdlib/atol.c @@ -29,18 +29,26 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)atol.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ -#include <stddef.h> +#include <errno.h> #include <stdlib.h> long atol(str) const char *str; { - return(strtol(str, (char **)NULL, 10)); + long r; + int saverr; + + saverr = errno; + r = strtol(str, (char **)NULL, 10); + errno = saverr; + return r; } diff --git a/lib/libc/stdlib/atoll.c b/lib/libc/stdlib/atoll.c index 72ca59ae270b..c0a7212f5106 100644 --- a/lib/libc/stdlib/atoll.c +++ b/lib/libc/stdlib/atoll.c @@ -33,12 +33,18 @@ * $FreeBSD$ */ -#include <stddef.h> +#include <errno.h> #include <stdlib.h> long long atoll(str) const char *str; { - return(strtoll(str, (char **)NULL, 10)); + long long r; + int saverr; + + saverr = errno; + r = strtoll(str, (char **)NULL, 10); + errno = saverr; + return r; } |