[hackers] [sbase] Add ARGNUM and ARGNUMF(base) || dsp

From: <git_AT_suckless.org>
Date: Tue, 12 Nov 2013 11:18:04 +0100

commit 3f9e501f6b8bd747ac8127ca56e34db0409e03d1
Author: dsp <dsp_AT_2f30.org>
Date: Mon Nov 11 19:53:01 2013 +0000

    Add ARGNUM and ARGNUMF(base)
    
    This is useful to support the obsolete syntax -NUM for tools like
    head, tail and fold.

diff --git a/arg.h b/arg.h
index 2009b70..b8f48c0 100644
--- a/arg.h
+++ b/arg.h
_AT_@ -29,11 +29,25 @@ extern char *argv0;
                                         _argc = argv[0][0];\
                                         switch (_argc)
 
+/* Handles obsolete -NUM syntax */
+#define ARGNUM case '0':\
+ case '1':\
+ case '2':\
+ case '3':\
+ case '4':\
+ case '5':\
+ case '6':\
+ case '7':\
+ case '8':\
+ case '9'
+
 #define ARGEND }\
                         }
 
 #define ARGC() _argc
 
+#define ARGNUMF(base) (brk = 1, estrtol(argv[0], (base)))
+
 #define EARGF(x) ((argv[0][1] == '
Received on Tue Nov 12 2013 - 11:18:04 CET

This archive was generated by hypermail 2.3.0 : Tue Nov 12 2013 - 11:24:14 CET