plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit 3a9dccd76ee6916d5586a3fba49cb8e0edb3ca5d
parent 85117729d01e8f911beef396040eb2e739e5cc65
Author: rsc <devnull@localhost>
Date:   Fri,  2 Apr 2004 22:57:49 +0000

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.

Diffstat:
Asrc/lib9/atoi.c | 9+++++++++
Asrc/lib9/atol.c | 9+++++++++
Asrc/lib9/atoll.c | 9+++++++++
Msrc/lib9/await.c | 2++
Msrc/lib9/mkfile | 3+++
5 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/lib9/atoi.c b/src/lib9/atoi.c @@ -0,0 +1,9 @@ +#include <u.h> +#include <libc.h> + +int +atoi(char *s) +{ + return strtol(s, 0, 0); +} + diff --git a/src/lib9/atol.c b/src/lib9/atol.c @@ -0,0 +1,9 @@ +#include <u.h> +#include <libc.h> + +long +atol(char *s) +{ + return strtol(s, 0, 0); +} + diff --git a/src/lib9/atoll.c b/src/lib9/atoll.c @@ -0,0 +1,9 @@ +#include <u.h> +#include <libc.h> + +vlong +atoll(char *s) +{ + return strtoll(s, 0, 0); +} + diff --git a/src/lib9/await.c b/src/lib9/await.c @@ -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; } diff --git a/src/lib9/mkfile b/src/lib9/mkfile @@ -72,6 +72,9 @@ LIB9OFILES=\ announce.$O\ argv0.$O\ atexit.$O\ + atoi.$O\ + atol.$O\ + atoll.$O\ atnotify.$O\ await.$O\ cistrcmp.$O\