From 954106050f5e4550393eafda57822fb195dadb1e Mon Sep 17 00:00:00 2001 From: Connor Lane Smith Date: Fri, 10 Jun 2011 14:55:01 +0100 Subject: [PATCH] rename estrtol --- Makefile | 2 +- chmod.c | 2 +- date.c | 2 +- fold.c | 2 +- head.c | 2 +- kill.c | 4 ++-- nl.c | 2 +- sleep.c | 2 +- tail.c | 2 +- touch.c | 2 +- util.h | 2 +- util/{strnum.c => estrtol.c} | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) rename util/{strnum.c => estrtol.c} (90%) diff --git a/Makefile b/Makefile index 8969fa2..d730c49 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,9 @@ LIB = \ util/concat.o \ util/enmasse.o \ util/eprintf.o \ + util/estrtol.o \ util/putword.o \ util/recurse.o \ - util/strnum.o \ SRC = \ basename.c \ diff --git a/chmod.c b/chmod.c index a433b42..1b56b1e 100644 --- a/chmod.c +++ b/chmod.c @@ -28,7 +28,7 @@ main(int argc, char *argv[]) } if(optind == argc) 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 */ if(octal & 04000) mode |= S_ISUID; diff --git a/date.c b/date.c index ac87f1b..04b2651 100644 --- a/date.c +++ b/date.c @@ -17,7 +17,7 @@ main(int argc, char *argv[]) while((c = getopt(argc, argv, "d:")) != -1) switch(c) { case 'd': - t = strnum(optarg, 0); + t = estrtol(optarg, 0); break; default: exit(EXIT_FAILURE); diff --git a/fold.c b/fold.c index 96df4a5..2fd0ff4 100644 --- a/fold.c +++ b/fold.c @@ -29,7 +29,7 @@ main(int argc, char *argv[]) sflag = true; break; case 'w': - width = strnum(optarg, 0); + width = estrtol(optarg, 0); break; default: exit(EXIT_FAILURE); diff --git a/head.c b/head.c index 7ca8ae8..9d44360 100644 --- a/head.c +++ b/head.c @@ -17,7 +17,7 @@ main(int argc, char *argv[]) while((c = getopt(argc, argv, "n:")) != -1) switch(c) { case 'n': - n = strnum(optarg, 0); + n = estrtol(optarg, 0); break; default: exit(EXIT_FAILURE); diff --git a/kill.c b/kill.c index 9e784d4..2af222f 100644 --- a/kill.c +++ b/kill.c @@ -53,14 +53,14 @@ main(int argc, char *argv[]) eprintf("usage: %s [-s signal] [pid...]\n" " %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++) if(sigs[i].sig == sig || sig == 0) putword(sigs[i].name); putchar('\n'); } else for(; optind < argc; optind++) { - pid = strnum(argv[optind], 0); + pid = estrtol(argv[optind], 0); if(kill(pid, sig) == -1) eprintf("kill %d:", pid); } diff --git a/nl.c b/nl.c index a2281fa..aa0794e 100644 --- a/nl.c +++ b/nl.c @@ -30,7 +30,7 @@ main(int argc, char *argv[]) eprintf("usage: %s [-b mode] [-i increment] [-s separator] [file...]\n", argv[0]); break; case 'i': - incr = strnum(optarg, 0); + incr = estrtol(optarg, 0); break; case 's': sep = optarg; diff --git a/sleep.c b/sleep.c index 89c2646..1e82e25 100644 --- a/sleep.c +++ b/sleep.c @@ -13,7 +13,7 @@ main(int argc, char *argv[]) if(optind != argc-1) eprintf("usage: %s seconds\n", argv[0]); - seconds = strnum(argv[optind], 0); + seconds = estrtol(argv[optind], 0); while((seconds = sleep(seconds)) > 0) ; return EXIT_SUCCESS; diff --git a/tail.c b/tail.c index 4c3a0e7..25965dd 100644 --- a/tail.c +++ b/tail.c @@ -20,7 +20,7 @@ main(int argc, char *argv[]) while((c = getopt(argc, argv, "n:")) != -1) switch(c) { case 'n': - n = abs(strnum(optarg, 0)); + n = abs(estrtol(optarg, 0)); if(optarg[0] == '+') tail = dropinit; break; diff --git a/touch.c b/touch.c index b33bf34..5988989 100644 --- a/touch.c +++ b/touch.c @@ -26,7 +26,7 @@ main(int argc, char *argv[]) cflag = true; break; case 't': - t = strnum(optarg, 0); + t = estrtol(optarg, 0); break; default: exit(EXIT_FAILURE); diff --git a/util.h b/util.h index 515bffb..06440e3 100644 --- a/util.h +++ b/util.h @@ -5,6 +5,6 @@ char *agetcwd(void); void enmasse(int, char **, int (*)(const char *, const char *)); void eprintf(const char *, ...); +long estrtol(const char *, int); void putword(const char *); void recurse(const char *, void (*)(const char *)); -long strnum(const char *, int); diff --git a/util/strnum.c b/util/estrtol.c similarity index 90% rename from util/strnum.c rename to util/estrtol.c index 14f2f88..9af5f71 100644 --- a/util/strnum.c +++ b/util/estrtol.c @@ -4,7 +4,7 @@ #include "../util.h" long -strnum(const char *s, int base) +estrtol(const char *s, int base) { char *end; long n;