diff options
Diffstat (limited to 'lib/libc/stdlib/atoi.c')
-rw-r--r-- | lib/libc/stdlib/atoi.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c index 48e508a..8e98a96e7 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; } |