Added POPT_KEEP_FIRST to cause popt to *not* ignore first arg. r2-4-10 r2-4-100 r2-4-101 r2-4-102 r2-4-11 r2-4-12 r2-4-99 r5-0-4
authorMarc Ewing <marc@src.gnome.org>
Sun, 2 Nov 1997 22:49:50 +0000 (22:49 +0000)
committerMarc Ewing <marc@src.gnome.org>
Sun, 2 Nov 1997 22:49:50 +0000 (22:49 +0000)
svn path=/trunk/; revision=39

support/popt-gnome.h
support/popt.c
support/popt.h

index 0072e25..c341a83 100644 (file)
@@ -16,7 +16,9 @@
 #define POPT_ERROR_BADNUMBER   -17
 #define POPT_ERROR_OVERFLOW    -18
 
+/* context creation flags */
 #define POPT_BADOPTION_NOALIAS  (1 << 0)  /* don't go into an alias */
+#define POPT_KEEP_FIRST                (1 << 1)  /* pay attention to argv[0] */
 
 struct poptOption {
     const char * longName;     /* may be NULL */
index ead28da..d75a5e1 100644 (file)
@@ -29,6 +29,7 @@ struct poptContext_s {
     char * appName;
     struct poptAlias * aliases;
     int numAliases;
+    int flags;
 };
 
 poptContext poptGetContext(char * name ,int argc, char ** argv, 
@@ -41,7 +42,11 @@ poptContext poptGetContext(char * name ,int argc, char ** argv,
     con->os->currAlias = NULL;
     con->os->nextCharArg = NULL;
     con->os->nextArg = NULL;
-    con->os->next = 1;                 /* skip argv[0] */
+
+    if (flags & POPT_KEEP_FIRST)
+       con->os->next = 0;                      /* include argv[0] */
+    else
+       con->os->next = 1;                      /* skip argv[0] */
 
     con->leftovers = malloc(sizeof(char *) * (argc + 1));
     con->numLeftovers = 0;
@@ -50,6 +55,7 @@ poptContext poptGetContext(char * name ,int argc, char ** argv,
     con->options = options;
     con->aliases = NULL;
     con->numAliases = 0;
+    con->flags = 0;
     
     if (!name)
        con->appName = NULL;
index 0072e25..c341a83 100644 (file)
@@ -16,7 +16,9 @@
 #define POPT_ERROR_BADNUMBER   -17
 #define POPT_ERROR_OVERFLOW    -18
 
+/* context creation flags */
 #define POPT_BADOPTION_NOALIAS  (1 << 0)  /* don't go into an alias */
+#define POPT_KEEP_FIRST                (1 << 1)  /* pay attention to argv[0] */
 
 struct poptOption {
     const char * longName;     /* may be NULL */