fix option handling when running gqa command in mged.

this replaces the custom handling with getopt consistency, so now -pprefix should work
This commit is contained in:
Christopher Sean Morrison committed 2026-08-08 01:51:54 -04:00
1 parent d3412fb56a
commit da430b14d8
2 files changed
+31 -14

No files matched your search

+11
View File
@@ -91,6 +91,16 @@ if(BRLCAD_ENABLE_TCL)
# MGED needs the tclIndex and pkgIndex files set up correctly
add_dependencies(mged TclIndexBld)
brlcad_add_test(
NAME mged_gqa_separate_prefix
COMMAND
"${CMAKE_COMMAND}"
"-DMGED=$<TARGET_FILE:mged>"
"-DDB=${CMAKE_SOURCE_DIR}/src/libged/tests/draw/moss.g"
"-DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/test_gqa_prefix.cmake"
)
# MGED is one of the programs that gets a start menu entry
set_property(
INSTALL "${BIN_DIR}/$<TARGET_FILE_NAME:mged>"
@@ -119,6 +129,7 @@ set(
mged_impl.h
mged_wdb.h
sedit.h
test_gqa_prefix.cmake
)
cmakefiles(${mged_ignore_files})
+20 -14
View File
@@ -945,6 +945,7 @@ cmd_ged_erase_wrapper(ClientData clientData, Tcl_Interp *interpreter, int argc,
int
cmd_ged_gqa(ClientData clientData, Tcl_Interp *interpreter, int argc, const char *argv[])
{
static const char *gqa_options = "A:a:de:f:g:Gn:N:p:P:qrS:t:U:u:vV:W:h?";
char **vp;
int i;
int ret;
@@ -963,21 +964,26 @@ cmd_ged_gqa(ClientData clientData, Tcl_Interp *interpreter, int argc, const char
vp = &gd_rt_cmd[0];
/* Grab command name and any options */
/* Locate the first object without mistaking separate option values for
* geometry names. ged_gqa_core() will perform the authoritative parse. */
char *saved_optarg = bu_optarg;
int saved_opterr = bu_opterr;
int saved_optopt = bu_optopt;
int saved_optind = bu_optind;
bu_opterr = 0;
bu_optind = 1;
while (bu_getopt(argc, (char * const *)argv, gqa_options) != -1)
;
i = bu_optind;
bu_optarg = saved_optarg;
bu_opterr = saved_opterr;
bu_optopt = saved_optopt;
bu_optind = saved_optind;
/* Grab command name and all options, including separate values. */
*vp++ = (char *)argv[0];
for (i=1; i < argc; i++) {
if (argv[i][0] != '-')
break;
if (argv[i][0] == '-' &&
argv[i][1] == '-' &&
argv[i][2] == '\0') {
++i;
break;
}
*vp++ = (char *)argv[i];
}
for (int option_index = 1; option_index < i; option_index++)
*vp++ = (char *)argv[option_index];
/*
* Append remaining args, if any. Otherwise, append currently