source: trunk/minix/lib/ansi/atol.c@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 673 bytes
Line 
1/*
2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
4 */
5/* $Header: /cvsup/minix/src/lib/ansi/atol.c,v 1.1.1.1 2005/04/21 14:56:04 beng Exp $ */
6
7#include <ctype.h>
8#include <stdlib.h>
9
10/* We do not use strtol here for backwards compatibility in behaviour on
11 overflow.
12*/
13long
14atol(register const char *nptr)
15{
16 long total = 0;
17 int minus = 0;
18
19 while (isspace(*nptr)) nptr++;
20 if (*nptr == '+') nptr++;
21 else if (*nptr == '-') {
22 minus = 1;
23 nptr++;
24 }
25 while (isdigit(*nptr)) {
26 total *= 10;
27 total += (*nptr++ - '0');
28 }
29 return minus ? -total : total;
30}
Note: See TracBrowser for help on using the repository browser.