]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Map getopt to bsd_getopt if we are using the overlay
authorGuillem Jover <guillem@hadrons.org>
Wed, 25 May 2011 05:38:36 +0000 (07:38 +0200)
committerGuillem Jover <guillem@hadrons.org>
Sat, 28 May 2011 08:31:06 +0000 (10:31 +0200)
This will ensure the code can safely and correctly use optreset
transparently.

include/bsd/getopt.h
src/bsd_getopt.c

index d2963cb85b44b228d16a58b62461dd56258456c3..ba2c4ebce6f3f4b4f5b4d48c1348e6aeb341249d 100644 (file)
 __BEGIN_DECLS
 extern int optreset;
 
+#ifdef LIBBSD_OVERLAY
+#undef getopt
+#define getopt(argc, argv, optstr) bsd_getopt(argc, argv, optstr)
+#endif
+
 int bsd_getopt (int, char **, char *);
 __END_DECLS
 
index f5fb304523c1da6ef2a1be670476ac950588b9ff..3e89817af436e069a2b0850be1f13affb7f6285c 100644 (file)
@@ -36,5 +36,9 @@ bsd_getopt(int argc, char **argv, char *shortopts)
                optind = 0;
        }
 
-       return getopt(argc, argv, shortopts);
+       /*
+        * Make sure we are using the system getopt() and not a possible
+        * overlay macro.
+        */
+       return (getopt)(argc, argv, shortopts);
 }