Miscellaneous changes, mostly concerning options parsing.
authormdw <mdw>
Fri, 20 Aug 1999 07:30:33 +0000 (07:30 +0000)
committermdw <mdw>
Fri, 20 Aug 1999 07:30:33 +0000 (07:30 +0000)
xgetline.c

index 322f7aa..1e060cc 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: xgetline.c,v 1.10 1999/05/21 22:09:19 mdw Exp $
+ * $Id: xgetline.c,v 1.11 1999/08/20 07:30:33 mdw Exp $
  *
  * Fetch a line of text from the user
  *
@@ -29,6 +29,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: xgetline.c,v $
+ * Revision 1.11  1999/08/20 07:30:33  mdw
+ * Miscellaneous changes, mostly concerning options parsing.
+ *
  * Revision 1.10  1999/05/21 22:09:19  mdw
  * Take advantage of new dynamic string macros.
  *
@@ -208,19 +211,19 @@ int main(int argc, char *argv[])
     /* --- Long options structure --- */
 
     static struct option opt[] = {
-      { "help",                0,                      0,      'h' },
-      { "usage",       0,                      0,      'u' },
-      { "version",     0,                      0,      'v' },
-      { "title",       required_argument,      0,      't' },
-      { "prompt",      required_argument,      0,      'p' },
-      { "default",     required_argument,      0,      'd' },
-      { "password",    0,                      0,      'i' },
-      { "invisible",   0,                      0,      'i' },
-      { "history",     required_argument,      0,      'H' },
-      { "list",                required_argument,      0,      'l' },
-      { "histmax",     required_argument,      0,      'm' },
-      { "no-choice",   0,                      0,      'n' },
-      { 0,             0,                      0,      0 }
+      { "help",                0,              0,      'h' },
+      { "usage",       0,              0,      'u' },
+      { "version",     0,              0,      'v' },
+      { "title",       OPTF_ARGREQ,    0,      't' },
+      { "prompt",      OPTF_ARGREQ,    0,      'p' },
+      { "default",     OPTF_ARGREQ,    0,      'd' },
+      { "password",    0,              0,      'i' },
+      { "invisible",   0,              0,      'i' },
+      { "history",     OPTF_ARGREQ,    0,      'H' },
+      { "list",                OPTF_ARGREQ,    0,      'l' },
+      { "histmax",     OPTF_ARGREQ,    0,      'm' },
+      { "no-choice",   0,              0,      'n' },
+      { 0,             0,              0,      0 }
     };
     int i;
 
@@ -237,26 +240,26 @@ int main(int argc, char *argv[])
        version(stdout);
        fputs("\n", stdout);
        usage(stdout);
-       fputs(
-"\n"
-"Pops up a small window requesting input from a user, and echoes the\n"
-"response to stdout, where it can be collected by a shell script.\n"
-"\n"
-"Options available are:\n"
-"\n"
-"-h, --help            Display this help text\n"
-"-u, --usage           Display a short usage summary\n"
-"-v, --version         Display the program's version number\n"
-"\n"
-"-i, --invisible\t     Don't show the user's string as it's typed\n"
-"-t, --title=TITLE     Set the window's title string\n"
-"-p, --prompt=PROMPT   Set the window's prompt string\n"
-"-d, --default=DEFAULT Set the default string already in the window\n"
-"\n"
-"-l, --list=FILE       Read FILE into a drop-down list\n"
-"-n, --no-choice       No free text input: must choose item from list\n"
-"-H, --history=FILE    As for `--list', but update with new string\n"
-"-m, --histmax=MAX     Maximum number of items written back to file\n",
+       fputs("\
+\n\
+Pops up a small window requesting input from a user, and echoes the\n\
+response to stdout, where it can be collected by a shell script.\n\
+\n\
+Options available are:\n\
+\n\
+-h, --help             Display this help text\n\
+-u, --usage            Display a short usage summary\n\
+-v, --version          Display the program's version number\n\
+\n\
+-i, --invisible                Don't show the user's string as it's typed\n\
+-t, --title=TITLE      Set the window's title string\n\
+-p, --prompt=PROMPT    Set the window's prompt string\n\
+-d, --default=DEFAULT  Set the default string already in the window\n\
+\n\
+-l, --list=FILE                Read FILE into a drop-down list\n\
+-n, --no-choice                No free text input: must choose item from list\n\
+-H, --history=FILE     As for `--list', but update with new string\n\
+-m, --histmax=MAX      Maximum number of items written back to file\n",
           stdout);
        exit(0);
        break;
@@ -354,8 +357,9 @@ int main(int argc, char *argv[])
 
       while (dstr_putline(&d, fp) != EOF) {
        hist = g_list_append(hist, xstrdup(d.buf));
-       dstr_destroy(&d);
+       DRESET(&d);
       }
+      dstr_destroy(&d);
       fclose(fp);
     }