summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/man/2/atof7
-rw-r--r--sys/src/libc/port/atol.c43
-rw-r--r--sys/src/libc/port/atoll.c2
3 files changed, 3 insertions, 49 deletions
diff --git a/sys/man/2/atof b/sys/man/2/atof
index cf7a88fde..885aade28 100644
--- a/sys/man/2/atof
+++ b/sys/man/2/atof
@@ -135,10 +135,3 @@ Zero is returned if the beginning of the input string is not
interpretable as a number; even in this case,
.I rptr
will be updated.
-.SH BUGS
-.I Atoi,
-.I atol,
-and
-.I atoll
-accept octal and hexadecimal numbers in the style of C,
-contrary to the ANSI specification.
diff --git a/sys/src/libc/port/atol.c b/sys/src/libc/port/atol.c
index 6928da7bd..cf7270c6f 100644
--- a/sys/src/libc/port/atol.c
+++ b/sys/src/libc/port/atol.c
@@ -4,50 +4,11 @@
long
atol(char *s)
{
- long n;
- int f, c;
-
- n = 0;
- f = 0;
- while(*s == ' ' || *s == '\t')
- s++;
- if(*s == '-' || *s == '+') {
- if(*s++ == '-')
- f = 1;
- while(*s == ' ' || *s == '\t')
- s++;
- }
- if(s[0]=='0' && s[1]) {
- if(s[1]=='x' || s[1]=='X'){
- s += 2;
- for(;;) {
- c = *s;
- if(c >= '0' && c <= '9')
- n = n*16 + c - '0';
- else
- if(c >= 'a' && c <= 'f')
- n = n*16 + c - 'a' + 10;
- else
- if(c >= 'A' && c <= 'F')
- n = n*16 + c - 'A' + 10;
- else
- break;
- s++;
- }
- } else
- while(*s >= '0' && *s <= '7')
- n = n*8 + *s++ - '0';
- } else
- while(*s >= '0' && *s <= '9')
- n = n*10 + *s++ - '0';
- if(f)
- n = -n;
- return n;
+ return strtol(s, nil, 10);
}
int
atoi(char *s)
{
-
- return atol(s);
+ return strtol(s, nil, 10);
}
diff --git a/sys/src/libc/port/atoll.c b/sys/src/libc/port/atoll.c
index b4497de59..d4d794248 100644
--- a/sys/src/libc/port/atoll.c
+++ b/sys/src/libc/port/atoll.c
@@ -4,5 +4,5 @@
vlong
atoll(char *s)
{
- return strtoll(s, nil, 0);
+ return strtoll(s, nil, 10);
}