[hackers] [sbase] rename estrtol || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Fri, 10 Jun 2011 15:55:07 +0200 (CEST)

changeset: 75:b68c4b2047f7
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Fri Jun 10 14:55:01 2011 +0100
files: Makefile chmod.c date.c fold.c head.c kill.c nl.c sleep.c tail.c touch.c util.h util/estrtol.c util/strnum.c
description:
rename estrtol

diff -r 361b9b5df1d2 -r b68c4b2047f7 Makefile
--- a/Makefile Fri Jun 10 14:51:53 2011 +0100
+++ b/Makefile Fri Jun 10 14:55:01 2011 +0100
@@ -7,9 +7,9 @@
         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 -r 361b9b5df1d2 -r b68c4b2047f7 chmod.c
--- a/chmod.c Fri Jun 10 14:51:53 2011 +0100
+++ b/chmod.c Fri Jun 10 14:55:01 2011 +0100
@@ -28,7 +28,7 @@
                 }
         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 -r 361b9b5df1d2 -r b68c4b2047f7 date.c
--- a/date.c Fri Jun 10 14:51:53 2011 +0100
+++ b/date.c Fri Jun 10 14:55:01 2011 +0100
@@ -17,7 +17,7 @@
         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 -r 361b9b5df1d2 -r b68c4b2047f7 fold.c
--- a/fold.c Fri Jun 10 14:51:53 2011 +0100
+++ b/fold.c Fri Jun 10 14:55:01 2011 +0100
@@ -29,7 +29,7 @@
                         sflag = true;
                         break;
                 case 'w':
- width = strnum(optarg, 0);
+ width = estrtol(optarg, 0);
                         break;
                 default:
                         exit(EXIT_FAILURE);
diff -r 361b9b5df1d2 -r b68c4b2047f7 head.c
--- a/head.c Fri Jun 10 14:51:53 2011 +0100
+++ b/head.c Fri Jun 10 14:55:01 2011 +0100
@@ -17,7 +17,7 @@
         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 -r 361b9b5df1d2 -r b68c4b2047f7 kill.c
--- a/kill.c Fri Jun 10 14:51:53 2011 +0100
+++ b/kill.c Fri Jun 10 14:55:01 2011 +0100
@@ -53,14 +53,14 @@
                         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 -r 361b9b5df1d2 -r b68c4b2047f7 nl.c
--- a/nl.c Fri Jun 10 14:51:53 2011 +0100
+++ b/nl.c Fri Jun 10 14:55:01 2011 +0100
@@ -30,7 +30,7 @@
                                 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 -r 361b9b5df1d2 -r b68c4b2047f7 sleep.c
--- a/sleep.c Fri Jun 10 14:51:53 2011 +0100
+++ b/sleep.c Fri Jun 10 14:55:01 2011 +0100
@@ -13,7 +13,7 @@
         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 -r 361b9b5df1d2 -r b68c4b2047f7 tail.c
--- a/tail.c Fri Jun 10 14:51:53 2011 +0100
+++ b/tail.c Fri Jun 10 14:55:01 2011 +0100
@@ -20,7 +20,7 @@
         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 -r 361b9b5df1d2 -r b68c4b2047f7 touch.c
--- a/touch.c Fri Jun 10 14:51:53 2011 +0100
+++ b/touch.c Fri Jun 10 14:55:01 2011 +0100
@@ -26,7 +26,7 @@
                         cflag = true;
                         break;
                 case 't':
- t = strnum(optarg, 0);
+ t = estrtol(optarg, 0);
                         break;
                 default:
                         exit(EXIT_FAILURE);
diff -r 361b9b5df1d2 -r b68c4b2047f7 util.h
--- a/util.h Fri Jun 10 14:51:53 2011 +0100
+++ b/util.h Fri Jun 10 14:55:01 2011 +0100
@@ -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 -r 361b9b5df1d2 -r b68c4b2047f7 util/estrtol.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/util/estrtol.c Fri Jun 10 14:55:01 2011 +0100
@@ -0,0 +1,20 @@
+/* See LICENSE file for copyright and license details. */
+#include <stdio.h>
+#include <stdlib.h>
+#include "../util.h"
+
+long
+estrtol(const char *s, int base)
+{
+ char *end;
+ long n;
+
+ n = strtol(s, &end, base);
+ if(*end != '\0') {
+ if(base == 0)
+ eprintf("%s: not a number\n", s);
+ else
+ eprintf("%s: not a base %d number\n", s, base);
+ }
+ return n;
+}
diff -r 361b9b5df1d2 -r b68c4b2047f7 util/strnum.c
--- a/util/strnum.c Fri Jun 10 14:51:53 2011 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#include <stdio.h>
-#include <stdlib.h>
-#include "../util.h"
-
-long
-strnum(const char *s, int base)
-{
- char *end;
- long n;
-
- n = strtol(s, &end, base);
- if(*end != '\0') {
- if(base == 0)
- eprintf("%s: not a number\n", s);
- else
- eprintf("%s: not a base %d number\n", s, base);
- }
- return n;
-}
Received on Fri Jun 10 2011 - 15:55:07 CEST

This archive was generated by hypermail 2.2.0 : Fri Jun 10 2011 - 16:00:11 CEST