Revision: 65117
          http://sourceforge.net/p/brlcad/code/65117
Author:   starseeker
Date:     2015-05-30 19:06:38 +0000 (Sat, 30 May 2015)
Log Message:
-----------
Handle multiple entries with simultaneous keys in description generation.

Modified Paths:
--------------
    brlcad/trunk/src/conv/gcv/gcv.cpp
    brlcad/trunk/src/libbu/opt.c

Modified: brlcad/trunk/src/conv/gcv/gcv.cpp
===================================================================
--- brlcad/trunk/src/conv/gcv/gcv.cpp   2015-05-30 18:52:31 UTC (rev 65116)
+++ brlcad/trunk/src/conv/gcv/gcv.cpp   2015-05-30 19:06:38 UTC (rev 65117)
@@ -267,8 +267,9 @@
 
 #define gcv_help_str "Print help and exit.  If a format is specified to 
--help, print help specific to that format"
 enum gcv_opt_enums { GCV_HELP, IN_FILE, OUT_FILE, IN_FORMAT, OUT_FORMAT, 
IN_OPTS, OUT_OPTS };
-struct bu_opt_desc gcv_opt_desc[8] = {
+struct bu_opt_desc gcv_opt_desc[9] = {
     {GCV_HELP,    0, 1, "h", "help",             NULL,          "-h [format]", 
"--help [format]",             gcv_help_str},
+    {GCV_HELP,    0, 1, "?", "",                 NULL,          "-? [format]", 
"",                            gcv_help_str},
     {IN_FILE ,    1, 1, "i", "input",            &(file_stat),  "-i file",     
"--input file",                "Input file." },
     {OUT_FILE,    1, 1, "o", "output",           &(file_null),  "-o file",     
"--output file",               "Output file." },
     {IN_FORMAT ,  1, 1, "",  "input-format",     &(model_mime), "",            
"--input-format format",       "File format of input file." },

Modified: brlcad/trunk/src/libbu/opt.c
===================================================================
--- brlcad/trunk/src/libbu/opt.c        2015-05-30 18:52:31 UTC (rev 65116)
+++ brlcad/trunk/src/libbu/opt.c        2015-05-30 19:06:38 UTC (rev 65117)
@@ -605,6 +605,18 @@
        if (!status[i]) {
            struct bu_vls opts = BU_VLS_INIT_ZERO;
            struct bu_vls help_str = BU_VLS_INIT_ZERO;
+
+           /* We handle all entries with the same key in the same
+            * pass, so set the status flags accordingly */
+           j = i;
+           while (j < opt_cnt) {
+               struct bu_opt_desc *d = &(ds[j]);
+               if (d->index == curr->index) {
+                   status[j] = 1;
+               }
+               j++;
+           }
+
            /* Collect the short options first - may be multiple instances with
             * the same index defining aliases, so accumulate all of them. */
            j = i;
@@ -620,10 +632,14 @@
                            bu_vls_printf(&opts, "%s, ", d->shortopt_doc);
                        }
                    }
+                   /* While we're at it, pick up the string.  The last string 
with
+                    * a matching key wins, as long as its not empty */
                    if (strlen(d->help_string) > 0) bu_vls_sprintf(&help_str, 
"%s", d->help_string);
                }
                j++;
            }
+
+           /* Now do the long opts */
            j = i;
            while (j < opt_cnt) {
                struct bu_opt_desc *d = &(ds[j]);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to