Revision: 65231
          http://sourceforge.net/p/brlcad/code/65231
Author:   starseeker
Date:     2015-06-09 19:49:54 +0000 (Tue, 09 Jun 2015)
Log Message:
-----------
Go with a vls collection here...

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

Modified: brlcad/trunk/include/bu/opt.h
===================================================================
--- brlcad/trunk/include/bu/opt.h       2015-06-09 18:41:26 UTC (rev 65230)
+++ brlcad/trunk/include/bu/opt.h       2015-06-09 19:49:54 UTC (rev 65231)
@@ -161,7 +161,7 @@
  */
 BU_EXPORT extern int bu_opt_int(struct bu_vls *msg, int argc, const char 
**argv, void *set_var);
 BU_EXPORT extern int bu_opt_fastf_t(struct bu_vls *msg, int argc, const char 
**argv, void *set_var);
-BU_EXPORT extern int bu_opt_str(struct bu_vls *msg, int argc, const char 
**argv, void *set_var);
+BU_EXPORT extern int bu_opt_vls(struct bu_vls *msg, int argc, const char 
**argv, void *set_var);
 /* TODO - unimplemented */
 BU_EXPORT extern int bu_opt_bool(struct bu_vls *msg, int argc, const char 
**argv, void *set_var);
 BU_EXPORT extern int bu_opt_long(struct bu_vls *msg, int argc, const char 
**argv, void *set_var);

Modified: brlcad/trunk/src/conv/gcv/gcv.cpp
===================================================================
--- brlcad/trunk/src/conv/gcv/gcv.cpp   2015-06-09 18:41:26 UTC (rev 65230)
+++ brlcad/trunk/src/conv/gcv/gcv.cpp   2015-06-09 19:49:54 UTC (rev 65231)
@@ -337,8 +337,8 @@
     static mime_model_t out_type = MIME_MODEL_UNKNOWN;
     static char *in_path_str = NULL;
     static char *out_path_str = NULL;
-    static char *in_only_opts = NULL;
-    static char *out_only_opts = NULL;
+    static struct bu_vls in_only_opts = BU_VLS_INIT_ZERO;
+    static struct bu_vls out_only_opts = BU_VLS_INIT_ZERO;
     static struct gcv_help_state hs;
 
     struct bu_vls in_format = BU_VLS_INIT_ZERO;
@@ -361,8 +361,8 @@
        {"o", "output",           1, 1, &file_null,   (void *)&out_path_str,  
"file",       "Output file.",               },
        {"",  "input-format",     1, 1, &model_mime,  (void *)&in_type,       
"format",     "File format of input file.", },
        {"",  "output-format",    1, 1, &model_mime,  (void *)&out_type,      
"format",     "File format of output file." },
-       {"I", "input-only-opts",  1, 1, &bu_opt_str,  (void *)&in_only_opts,  
"\"[opts]\"", gcv_inopt_str,                },
-       {"O", "output-only-opts", 1, 1, &bu_opt_str,  (void *)&out_only_opts, 
"\"[opts]\"", gcv_outopt_str,               },
+       {"I", "input-only-opts",  1, 1, &bu_opt_vls,  (void *)&in_only_opts,  
"\"[opts]\"", gcv_inopt_str,                },
+       {"O", "output-only-opts", 1, 1, &bu_opt_vls,  (void *)&out_only_opts, 
"\"[opts]\"", gcv_outopt_str,               },
        BU_OPT_DESC_NULL
     };
 
@@ -469,24 +469,24 @@
     }
 
     /* If we have input and/or output specific options, append them now */
-    if (in_only_opts) {
+    if (bu_vls_strlen(&in_only_opts) > 0) {
        struct bu_vls o_tmp = BU_VLS_INIT_ZERO;
        if (bu_vls_strlen(&input_opts) > 0)
            bu_vls_printf(&input_opts, " ");
 
-       bu_vls_sprintf(&o_tmp, "%s", in_only_opts);
+       bu_vls_sprintf(&o_tmp, "%s", bu_vls_addr(&in_only_opts));
        if (bu_vls_addr(&o_tmp)[0] == '[') bu_vls_nibble(&o_tmp, 1);
        if (bu_vls_addr(&o_tmp)[strlen(bu_vls_addr(&o_tmp)) - 1] == ']') 
bu_vls_trunc(&o_tmp, -1);
        bu_vls_printf(&input_opts, "%s", bu_vls_addr(&o_tmp));
        if (bu_vls_strlen(&input_opts) > 0) bu_log("Input only opts: %s\n", 
bu_vls_addr(&o_tmp));
        bu_vls_free(&o_tmp);
     }
-    if (out_only_opts) {
+    if (bu_vls_strlen(&out_only_opts) > 0) {
        struct bu_vls o_tmp = BU_VLS_INIT_ZERO;
        if (bu_vls_strlen(&output_opts) > 0)
            bu_vls_printf(&output_opts, " ");
 
-       bu_vls_sprintf(&o_tmp, "%s", out_only_opts);
+       bu_vls_sprintf(&o_tmp, "%s", &out_only_opts);
        if (bu_vls_addr(&o_tmp)[0] == '[') bu_vls_nibble(&o_tmp, 1);
        if (bu_vls_addr(&o_tmp)[strlen(bu_vls_addr(&o_tmp)) - 1] == ']') 
bu_vls_trunc(&o_tmp, -1);
        bu_vls_printf(&output_opts, "%s", bu_vls_addr(&o_tmp));
@@ -597,7 +597,8 @@
     bu_vls_free(&log);
     bu_vls_free(&input_opts);
     bu_vls_free(&output_opts);
-
+    bu_vls_free(&in_only_opts);
+    bu_vls_free(&out_only_opts);
     return ret;
 }
 

Modified: brlcad/trunk/src/libbu/opt.c
===================================================================
--- brlcad/trunk/src/libbu/opt.c        2015-06-09 18:41:26 UTC (rev 65230)
+++ brlcad/trunk/src/libbu/opt.c        2015-06-09 19:49:54 UTC (rev 65231)
@@ -563,20 +563,20 @@
     return 1;
 }
 
-/* TODO - the bu_strdup is required because of eq_arg (i.e., breaking
- * out an argument from an atomic argv entry) - can that be reworked
- * to avoid needing the strdup by incrementing the pointer and pointing
- * to the arg portion of the original string? */
 int
-bu_opt_str(struct bu_vls *UNUSED(msg), int argc, const char **argv, void 
*set_var)
+bu_opt_vls(struct bu_vls *UNUSED(msg), int argc, const char **argv, void 
*set_var)
 {
-    char **s_set = (char **)set_var;
+    struct bu_vls *s_set = (struct bu_vls *)set_var;
 
-    if (!argv || !argv[0] || strlen(argv[0]) == 0 || argc != 1 ) {
-       return 0;
+    if (!argv || !argc ) return 0;
+
+    if (s_set) {
+       int i = 0;
+       for (i = 0; i < argc - 1; i++) {
+           bu_vls_printf(s_set, "%s ", argv[i]);
+       }
+       bu_vls_printf(s_set, "%s", argv[argc - 1]);
     }
-
-    if (s_set) (*s_set) = bu_strdup(argv[0]);
     return 1;
 }
 

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