diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2021-01-27 13:56:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-27 13:56:28 (GMT) |
commit | 799ec0fde45a883e3652f29a1f66dd2fdb4c56f9 (patch) | |
tree | d6e9bfbfbc6f8364a38d83d44f62dbe753d13e24 /tools/lib | |
parent | d7bce33123c9c3eea9e7399de68b2e74a55f3809 (diff) | |
download | hdf5-799ec0fde45a883e3652f29a1f66dd2fdb4c56f9.zip hdf5-799ec0fde45a883e3652f29a1f66dd2fdb4c56f9.tar.gz hdf5-799ec0fde45a883e3652f29a1f66dd2fdb4c56f9.tar.bz2 |
Small fixes (#285)
* OESS-98 convert plugin option to FetchContent, add tests
* Fixes for pkcfg files because of plugin option
* OESS-98 fix tools test for plugins
* Keep doxygen comments under 100 chars long - format hint
* Whitespace
* HDFFV-11144 - Reclassify CMake messages
* HDFFV-11099/11100 added help text
* Reworked switch statement to compare string instead
* Fix typo
* Update CDash mode
* Correct name of threadsafe
* Correct option name
* Undo accidental commit
* Small changes plus merge of tools arg parse from 1.12
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools_utils.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index aa2418d..f88cf19 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -194,44 +194,50 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') { /* long command line option */ - const char *arg = &argv[opt_ind][2]; - int i; + int i; + const char ch = '='; + char * arg = &argv[opt_ind][2]; + size_t arg_len = 0; + + opt_arg = strchr(&argv[opt_ind][2], ch); + arg_len = HDstrlen(&argv[opt_ind][2]); + if (opt_arg) { + arg_len -= HDstrlen(opt_arg); + opt_arg++; /* skip the equal sign */ + } + arg[arg_len] = 0; for (i = 0; l_opts && l_opts[i].name; i++) { size_t len = HDstrlen(l_opts[i].name); - if (HDstrncmp(arg, l_opts[i].name, len) == 0) { + if (HDstrcmp(arg, l_opts[i].name) == 0) { /* we've found a matching long command line flag */ opt_opt = l_opts[i].shortval; if (l_opts[i].has_arg != no_arg) { - if (arg[len] == '=') { - opt_arg = &arg[len + 1]; - } - else if (l_opts[i].has_arg != optional_arg) { - if (opt_ind < (argc - 1)) - if (argv[opt_ind + 1][0] != '-') - opt_arg = argv[++opt_ind]; - } - else if (l_opts[i].has_arg == require_arg) { - if (opt_err) - HDfprintf(rawerrorstream, "%s: option required for \"--%s\" flag\n", argv[0], - arg); - - opt_opt = '?'; + if (opt_arg == NULL) { + if (l_opts[i].has_arg != optional_arg) { + if (opt_ind < (argc - 1)) + if (argv[opt_ind + 1][0] != '-') + opt_arg = argv[++opt_ind]; + } + else if (l_opts[i].has_arg == require_arg) { + if (opt_err) + HDfprintf(rawerrorstream, "%s: option required for \"--%s\" flag\n", argv[0], + arg); + + opt_opt = '?'; + } } - else - opt_arg = NULL; } else { - if (arg[len] == '=') { + if (opt_arg) { if (opt_err) HDfprintf(rawerrorstream, "%s: no option required for \"%s\" flag\n", argv[0], arg); opt_opt = '?'; } - opt_arg = NULL; } break; } |