Revision: 65124
http://sourceforge.net/p/brlcad/code/65124
Author: starseeker
Date: 2015-05-31 17:45:05 +0000 (Sun, 31 May 2015)
Log Message:
-----------
misc fixes and tweaks
Modified Paths:
--------------
brlcad/trunk/include/bu/opt.h
brlcad/trunk/src/libbu/opt.c
Modified: brlcad/trunk/include/bu/opt.h
===================================================================
--- brlcad/trunk/include/bu/opt.h 2015-05-31 17:00:06 UTC (rev 65123)
+++ brlcad/trunk/include/bu/opt.h 2015-05-31 17:45:05 UTC (rev 65124)
@@ -43,7 +43,7 @@
* that were not associated with options */
#define BU_NON_OPTS -1
-/** Output format options for bu_opt */
+/** Output format options for bu_opt documentation generation */
typedef enum {
BU_OPT_ASCII,
BU_OPT_DOCBOOK,
@@ -67,12 +67,11 @@
*/
typedef int (*bu_opt_arg_process_t)(struct bu_vls *, struct bu_opt_data *);
+/* typedefs to avoid confusion when working with bu_opt_data
+ * and bu_opt_desc tables */
typedef struct bu_ptbl bu_opt_dtbl_t;
typedef struct bu_ptbl bu_opt_data_t;
-
-
-
/**
* "Option description" structure
*/
@@ -115,7 +114,6 @@
BU_EXPORT extern void bu_opt_desc_free(bu_opt_dtbl_t *tbl);
-
/**
* Construct a textual description of the options defined by
* the array.
@@ -128,10 +126,7 @@
*
* Opt_col specifies how wide the options column is, and desc_cols
* specifies how wide the description column is.
- *
- *
*/
-
struct bu_opt_desc_opts {
bu_opt_desc_t desc_type;
bu_opt_format_t format_type;
@@ -145,7 +140,6 @@
-
/**
* Parsed option data container
*/
@@ -158,7 +152,7 @@
};
#define BU_OPT_DATA_NULL {NULL, 0, NULL, NULL, NULL}
/**
- * Free a table of bu_opt_data results */
+ * Free a table of bu_opt_data results */
BU_EXPORT extern void bu_opt_data_free(bu_opt_data_t *data);
/**
@@ -264,7 +258,7 @@
* Option parse an argv array defined as a space separated string. This
* is a convenience function that calls bu_opt_parse_dtbl and also handles
* breaking str down into a proper argv array. */
-BU_EXPORT extern int bu_opt_parse_str_dtbl(bu_opt_data_t **results, struct
bu_vls *msgs, const char *str, bu_opt_dtbl_t *dtbl);
+BU_EXPORT extern int bu_opt_parse_dtbl_str(bu_opt_data_t **results, struct
bu_vls *msgs, const char *str, bu_opt_dtbl_t *dtbl);
/**
* In situations where multiple options are present, the general rule is that
@@ -292,7 +286,6 @@
BU_EXPORT extern int bu_opt_arg_long(struct bu_vls *msg, struct bu_opt_data
*data);
BU_EXPORT extern int bu_opt_arg_bool(struct bu_vls *msg, struct bu_opt_data
*data);
BU_EXPORT extern int bu_opt_arg_double(struct bu_vls *msg, struct bu_opt_data
*data);
-BU_EXPORT extern int bu_opt_arg_string(struct bu_vls *msg, struct bu_opt_data
*data);
/** @} */
Modified: brlcad/trunk/src/libbu/opt.c
===================================================================
--- brlcad/trunk/src/libbu/opt.c 2015-05-31 17:00:06 UTC (rev 65123)
+++ brlcad/trunk/src/libbu/opt.c 2015-05-31 17:45:05 UTC (rev 65124)
@@ -32,15 +32,15 @@
#include "bu/vls.h"
HIDDEN void
-bu_opt_data_init_entry(struct bu_opt_data *d, const char *name)
+bu_opt_data_init_entry(struct bu_opt_data **d, const char *name)
{
if (!d) return;
- BU_GET(d, struct bu_opt_data);
- d->desc = NULL;
- d->valid = 0;
- d->name = name;
- d->args = NULL;
- d->user_data = NULL;
+ BU_GET(*d, struct bu_opt_data);
+ (*d)->desc = NULL;
+ (*d)->valid = 1;
+ (*d)->name = name;
+ (*d)->args = NULL;
+ (*d)->user_data = NULL;
}
void
@@ -116,6 +116,8 @@
bu_vls_printf(&log, "%s, ", bu_opt_data_arg(d, j));
}
bu_vls_printf(&log, "%s\n", bu_opt_data_arg(d,
BU_PTBL_LEN(d->args) - 1));
+ } else {
+ bu_vls_printf(&log, "\n");
}
} else {
bu_vls_printf(&log, "\n");
@@ -631,7 +633,7 @@
* we reach an option */
if (!is_opt(argv[i])) {
if (!unknowns) {
- bu_opt_data_init_entry(unknowns, NULL);
+ bu_opt_data_init_entry(&unknowns, NULL);
BU_GET(unknowns->args, struct bu_ptbl);
bu_ptbl_init(unknowns->args, 8, "args init");
}
@@ -674,7 +676,7 @@
if (!desc_found) {
struct bu_vls rebuilt_opt = BU_VLS_INIT_ZERO;
if (!unknowns) {
- bu_opt_data_init_entry(unknowns, NULL);
+ bu_opt_data_init_entry(&unknowns, NULL);
BU_GET(unknowns->args, struct bu_ptbl);
bu_ptbl_init(unknowns->args, 8, "args init");
}
@@ -693,7 +695,7 @@
}
/* Initialize with opt */
- bu_opt_data_init_entry(data, opt);
+ bu_opt_data_init_entry(&data, opt);
data->desc = desc;
if (eq_arg) {
/* Okay, we actually need it - initialize the arg table */
@@ -809,7 +811,7 @@
}
int
-bu_opt_parse_str_dtbl(struct bu_ptbl **tbl, struct bu_vls *msgs, const char
*str, struct bu_ptbl *dtbl)
+bu_opt_parse_dtbl_str(struct bu_ptbl **tbl, struct bu_vls *msgs, const char
*str, struct bu_ptbl *dtbl)
{
int ret = 0;
char *input = NULL;
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