projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
now same as atoi
[unix-history]
/
usr
/
src
/
lib
/
libc
/
stdlib
/
atoi.c
diff --git
a/usr/src/lib/libc/stdlib/atoi.c
b/usr/src/lib/libc/stdlib/atoi.c
index
7382fc2
..
6553fab
100644
(file)
--- a/
usr/src/lib/libc/stdlib/atoi.c
+++ b/
usr/src/lib/libc/stdlib/atoi.c
@@
-1,25
+1,25
@@
-/* @(#)atoi.c 4.
1 (Berkeley) %G%
*/
-atoi(
a
p)
-
char *a
p;
+/* @(#)atoi.c 4.
2 (Berkeley) 1/11/81
*/
+atoi(p)
+
register char *
p;
{
{
- register int n, c;
- register char *p;
- int f;
+ register int n;
+ register int f;
- p = ap;
n = 0;
f = 0;
n = 0;
f = 0;
-loop:
- while(*p == ' ' || *p == ' ')
- p++;
- if(*p == '-') {
- f++;
- p++;
- goto loop;
+ for(;;p++) {
+ switch(*p) {
+ case ' ':
+ case '\t':
+ continue;
+ case '-':
+ f++;
+ case '+':
+ p++;
+ }
+ break;
}
while(*p >= '0' && *p <= '9')
n = n*10 + *p++ - '0';
}
while(*p >= '0' && *p <= '9')
n = n*10 + *p++ - '0';
- if(f)
- n = -n;
- return(n);
+ return(f? -n: n);
}
}