]> mj.ucw.cz Git - libucw.git/commitdiff
Opt: OPT_NO_HELP is gone
authorMartin Mares <mj@ucw.cz>
Mon, 17 Feb 2014 17:12:58 +0000 (18:12 +0100)
committerMartin Mares <mj@ucw.cz>
Mon, 17 Feb 2014 17:12:58 +0000 (18:12 +0100)
ucw/opt-help.c
ucw/opt.h

index 199427d08d4ef77538d7829bcab9481da3b7ea15..74ea18b2185373c055a91c07b61f1e47bbc44e66 100644 (file)
@@ -30,12 +30,12 @@ static void opt_help_scan_item(struct help *h, struct opt_precomputed *opt)
 {
   struct opt_item *item = opt->item;
 
-  if (opt->flags & OPT_NO_HELP)
+  if (!item->help)
     return;
 
   if (item->cls == OPT_CL_HELP) {
     struct help_line *l = GARY_PUSH(h->lines);
-    l->extra = item->help ? : "";
+    l->extra = item->help;
     return;
   }
 
@@ -43,29 +43,27 @@ static void opt_help_scan_item(struct help *h, struct opt_precomputed *opt)
     return;
 
   struct help_line *first = GARY_PUSH(h->lines);
-  if (item->help) {
-    char *text = mp_strdup(h->pool, item->help);
-    struct help_line *l = first;
-    while (text) {
-      char *eol = strchr(text, '\n');
-      if (eol)
-       *eol++ = 0;
-
-      int field = (l == first ? 1 : 0);
-      char *f = text;
-      while (f) {
-       char *tab = strchr(f, '\t');
-       if (tab)
-         *tab++ = 0;
-       if (field < 3)
-         l->fields[field++] = f;
-       f = tab;
-      }
-
-      text = eol;
-      if (text)
-       l = GARY_PUSH(h->lines);
+  char *text = mp_strdup(h->pool, item->help);
+  struct help_line *l = first;
+  while (text) {
+    char *eol = strchr(text, '\n');
+    if (eol)
+      *eol++ = 0;
+
+    int field = (l == first ? 1 : 0);
+    char *f = text;
+    while (f) {
+      char *tab = strchr(f, '\t');
+      if (tab)
+        *tab++ = 0;
+      if (field < 3)
+        l->fields[field++] = f;
+      f = tab;
     }
+
+    text = eol;
+    if (text)
+      l = GARY_PUSH(h->lines);
   }
 
   if (item->name) {
index 5eae050eb68938f624a484fdec60ad7b7e6bb1f4..cdc6a0aa9b2779b6417bf1b3048b6e5a4f2bf1fb 100644 (file)
--- a/ucw/opt.h
+++ b/ucw/opt.h
@@ -100,7 +100,7 @@ struct opt_item {
   const char * name;                   // long name (NULL if none)
   int letter;                          // short name (0 if none)
   void * ptr;                          // variable to store the value to
-  const char * help;                   // description in --help
+  const char * help;                   // description in --help (NULL to omit the option from the help)
   union opt_union {
     struct opt_section * section;      // subsection for OPT_CL_SECTION
     int value;                         // value for OPT_CL_SWITCH
@@ -126,7 +126,6 @@ struct opt_item {
 #define OPT_NO_VALUE       0x4         /** The option must have no value. **/
 #define OPT_MAYBE_VALUE            0x8         /** The option may have a value. **/
 #define OPT_NEGATIVE       0x10        /** Reversing the effect of OPT_INC or saving @false into OPT_BOOL. **/
-#define OPT_NO_HELP        0x20        /** Exclude this option from the help. **/
 #define OPT_LAST_ARG       0x40        /** Stop processing arguments after this line. **/
 #define OPT_SINGLE         0x100       /** The option must appear at most once. **/
 #define OPT_MULTIPLE       0x200       /** The option may appear multiple times; will save all the values into a simple list. **/