repo.or.cz
/
musl.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
iconv: add euro symbol to GBK as single byte 0x80
[musl.git]
/
src
/
stdlib
/
atol.c
blob
140ea3ea3fa27ce690bd61d8a7520efa28e3aad1
1
#include <stdlib.h>
2
#include <ctype.h>
3
4
long
atol
(
const char
*
s
)
5
{
6
long
n
=
0
;
7
int
neg
=
0
;
8
while
(
isspace
(*
s
))
s
++;
9
switch
(*
s
) {
10
case
'-'
:
neg
=
1
;
11
case
'+'
:
s
++;
12
}
13
/* Compute n as a negative number to avoid overflow on LONG_MIN */
14
while
(
isdigit
(*
s
))
15
n
=
10
*
n
- (*
s
++ -
'0'
);
16
return
neg
?
n
: -
n
;
17
}