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
use weak symbols for the POSIX functions that will be used by C threads
[musl.git]
/
src
/
stdlib
/
atoi.c
blob
9baca7b895a0e2f5c3cfab1554f8dcdd280431b9
1
#include <stdlib.h>
2
#include <ctype.h>
3
4
int
atoi
(
const char
*
s
)
5
{
6
int
n
=
0
,
neg
=
0
;
7
while
(
isspace
(*
s
))
s
++;
8
switch
(*
s
) {
9
case
'-'
:
neg
=
1
;
10
case
'+'
:
s
++;
11
}
12
/* Compute n as a negative number to avoid overflow on INT_MIN */
13
while
(
isdigit
(*
s
))
14
n
=
10
*
n
- (*
s
++ -
'0'
);
15
return
neg
?
n
: -
n
;
16
}