rename estrtol

This commit is contained in:
Connor Lane Smith 2011-06-10 14:55:01 +01:00
parent 61247e3595
commit 954106050f
12 changed files with 13 additions and 13 deletions

View File

@ -7,9 +7,9 @@ LIB = \
util/concat.o \ util/concat.o \
util/enmasse.o \ util/enmasse.o \
util/eprintf.o \ util/eprintf.o \
util/estrtol.o \
util/putword.o \ util/putword.o \
util/recurse.o \ util/recurse.o \
util/strnum.o \
SRC = \ SRC = \
basename.c \ basename.c \

View File

@ -28,7 +28,7 @@ main(int argc, char *argv[])
} }
if(optind == argc) if(optind == argc)
eprintf("usage: %s [-Rr] mode [file...]\n", argv[0]); eprintf("usage: %s [-Rr] mode [file...]\n", argv[0]);
octal = strnum(argv[optind++], 8); octal = estrtol(argv[optind++], 8);
/* posix doesn't specify modal bits */ /* posix doesn't specify modal bits */
if(octal & 04000) mode |= S_ISUID; if(octal & 04000) mode |= S_ISUID;

2
date.c
View File

@ -17,7 +17,7 @@ main(int argc, char *argv[])
while((c = getopt(argc, argv, "d:")) != -1) while((c = getopt(argc, argv, "d:")) != -1)
switch(c) { switch(c) {
case 'd': case 'd':
t = strnum(optarg, 0); t = estrtol(optarg, 0);
break; break;
default: default:
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

2
fold.c
View File

@ -29,7 +29,7 @@ main(int argc, char *argv[])
sflag = true; sflag = true;
break; break;
case 'w': case 'w':
width = strnum(optarg, 0); width = estrtol(optarg, 0);
break; break;
default: default:
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

2
head.c
View File

@ -17,7 +17,7 @@ main(int argc, char *argv[])
while((c = getopt(argc, argv, "n:")) != -1) while((c = getopt(argc, argv, "n:")) != -1)
switch(c) { switch(c) {
case 'n': case 'n':
n = strnum(optarg, 0); n = estrtol(optarg, 0);
break; break;
default: default:
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

4
kill.c
View File

@ -53,14 +53,14 @@ main(int argc, char *argv[])
eprintf("usage: %s [-s signal] [pid...]\n" eprintf("usage: %s [-s signal] [pid...]\n"
" %s -l [signum]\n", argv[0], argv[0]); " %s -l [signum]\n", argv[0], argv[0]);
sig = (optind == argc) ? 0 : strnum(argv[optind], 0); sig = (optind == argc) ? 0 : estrtol(argv[optind], 0);
for(i = 0; i < LEN(sigs); i++) for(i = 0; i < LEN(sigs); i++)
if(sigs[i].sig == sig || sig == 0) if(sigs[i].sig == sig || sig == 0)
putword(sigs[i].name); putword(sigs[i].name);
putchar('\n'); putchar('\n');
} }
else for(; optind < argc; optind++) { else for(; optind < argc; optind++) {
pid = strnum(argv[optind], 0); pid = estrtol(argv[optind], 0);
if(kill(pid, sig) == -1) if(kill(pid, sig) == -1)
eprintf("kill %d:", pid); eprintf("kill %d:", pid);
} }

2
nl.c
View File

@ -30,7 +30,7 @@ main(int argc, char *argv[])
eprintf("usage: %s [-b mode] [-i increment] [-s separator] [file...]\n", argv[0]); eprintf("usage: %s [-b mode] [-i increment] [-s separator] [file...]\n", argv[0]);
break; break;
case 'i': case 'i':
incr = strnum(optarg, 0); incr = estrtol(optarg, 0);
break; break;
case 's': case 's':
sep = optarg; sep = optarg;

View File

@ -13,7 +13,7 @@ main(int argc, char *argv[])
if(optind != argc-1) if(optind != argc-1)
eprintf("usage: %s seconds\n", argv[0]); eprintf("usage: %s seconds\n", argv[0]);
seconds = strnum(argv[optind], 0); seconds = estrtol(argv[optind], 0);
while((seconds = sleep(seconds)) > 0) while((seconds = sleep(seconds)) > 0)
; ;
return EXIT_SUCCESS; return EXIT_SUCCESS;

2
tail.c
View File

@ -20,7 +20,7 @@ main(int argc, char *argv[])
while((c = getopt(argc, argv, "n:")) != -1) while((c = getopt(argc, argv, "n:")) != -1)
switch(c) { switch(c) {
case 'n': case 'n':
n = abs(strnum(optarg, 0)); n = abs(estrtol(optarg, 0));
if(optarg[0] == '+') if(optarg[0] == '+')
tail = dropinit; tail = dropinit;
break; break;

View File

@ -26,7 +26,7 @@ main(int argc, char *argv[])
cflag = true; cflag = true;
break; break;
case 't': case 't':
t = strnum(optarg, 0); t = estrtol(optarg, 0);
break; break;
default: default:
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

2
util.h
View File

@ -5,6 +5,6 @@
char *agetcwd(void); char *agetcwd(void);
void enmasse(int, char **, int (*)(const char *, const char *)); void enmasse(int, char **, int (*)(const char *, const char *));
void eprintf(const char *, ...); void eprintf(const char *, ...);
long estrtol(const char *, int);
void putword(const char *); void putword(const char *);
void recurse(const char *, void (*)(const char *)); void recurse(const char *, void (*)(const char *));
long strnum(const char *, int);

View File

@ -4,7 +4,7 @@
#include "../util.h" #include "../util.h"
long long
strnum(const char *s, int base) estrtol(const char *s, int base)
{ {
char *end; char *end;
long n; long n;