From 091d3aa837daf60bd832f189e92df8ab66586197 Mon Sep 17 00:00:00 2001 From: ache Date: Tue, 25 Dec 2001 04:10:50 +0000 Subject: Preserve errno. According to C99: "The functions atof, atoi, atol, and atoll need not affect the value of the integer expression errno on an error. If the value of the result cannot be represented, the behavior is undefined." --- lib/libc/stdlib/atoll.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/libc/stdlib/atoll.c') diff --git a/lib/libc/stdlib/atoll.c b/lib/libc/stdlib/atoll.c index 72ca59a..c0a7212 100644 --- a/lib/libc/stdlib/atoll.c +++ b/lib/libc/stdlib/atoll.c @@ -33,12 +33,18 @@ * $FreeBSD$ */ -#include +#include #include 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; } -- cgit v1.1