Change _p9strsig to return nil if tmp==nil.

Add atoi, atol, atoll.
These versions call strtol/strtoll with base==0.
The Unix versions use base==10.
This commit is contained in:
rsc 2004-04-02 22:57:49 +00:00
parent 85117729d0
commit 3a9dccd76e
5 changed files with 32 additions and 0 deletions

9
src/lib9/atoi.c Normal file
View file

@ -0,0 +1,9 @@
#include <u.h>
#include <libc.h>
int
atoi(char *s)
{
return strtol(s, 0, 0);
}

9
src/lib9/atol.c Normal file
View file

@ -0,0 +1,9 @@
#include <u.h>
#include <libc.h>
long
atol(char *s)
{
return strtol(s, 0, 0);
}

9
src/lib9/atoll.c Normal file
View file

@ -0,0 +1,9 @@
#include <u.h>
#include <libc.h>
vlong
atoll(char *s)
{
return strtoll(s, 0, 0);
}

View file

@ -56,6 +56,8 @@ _p9sigstr(int sig, char *tmp)
for(i=0; i<nelem(tab); i++)
if(tab[i].sig == sig)
return tab[i].str;
if(tmp == nil)
return nil;
sprint(tmp, "sys: signal %d", sig);
return tmp;
}

View file

@ -72,6 +72,9 @@ LIB9OFILES=\
announce.$O\
argv0.$O\
atexit.$O\
atoi.$O\
atol.$O\
atoll.$O\
atnotify.$O\
await.$O\
cistrcmp.$O\