tdon't modify argv, use a counter - geomyidae - A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log
Files
Refs
README
LICENSE
---
commit 43c38bfe30bbab0d8be207859f773e49d283053a
parent 8c3240e00e39e5a56605b97553b0a14ad0eae2dd
Author: Hiltjo Posthuma 
Date:   Wed,  9 Aug 2017 20:06:22 +0200

don't modify argv, use a counter

on some platforms (OpenBSD) this changes the exposed argv in tools
using the kvm_* interface, such as ps and pgrep.

Signed-off-by: Christoph Lohmann <20h@r-36.net>

Diffstat:
  arg.h                               |       7 ++++---

1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/arg.h b/arg.h
t@@ -16,11 +16,12 @@ extern char *argv0;
                                         argc--;\
                                         break;\
                                 }\
-                                for(argv[0]++, _argv = argv; argv[0][0];\
-                                                argv[0]++) {\
+                                int i_;\
+                                for(i_ = 1, _argv = argv; argv[0][i_];\
+                                                i_++) {\
                                         if(_argv != argv)\
                                                 break;\
-                                        _argc = argv[0][0];\
+                                        _argc = argv[0][i_];\
                                         switch(_argc)
 
 #define ARGEND                        }\