repo.or.cz
/
neatlibc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
regex: import changes from neatvi
[neatlibc.git]
/
atoi.c
blob
fe75f9c88931e8b2a46a4ade69d8a25a55233e30
1
#include <stdlib.h>
2
3
int
atoi
(
char
*
s
)
4
{
5
int
num
=
0
;
6
int
neg
=
0
;
7
while
(*
s
==
' '
)
8
s
++;
9
if
(*
s
==
'-'
|| *
s
==
'+'
)
10
neg
= *
s
++ ==
'-'
;
11
while
((
unsigned
) (*
s
-
'0'
) <=
9u
)
12
num
=
num
*
10
+ *
s
++ -
'0'
;
13
return
neg
? -
num
:
num
;
14
}
15
16
long
atol
(
char
*
s
)
17
{
18
return
atoi
(
s
);
19
}