diff options
| author | Tyge Løvset <[email protected]> | 2023-02-12 22:47:55 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-02-12 23:20:18 +0100 |
| commit | 7dc6fddc079f4f572c8fb7c0ffd5a27e03291a2d (patch) | |
| tree | 681d1894d917bc2fe244375298ea40f736c18e18 /include/stc/coption.h | |
| parent | 9904a7ea36f9e4f45d7e41e409ed23ad22821e8a (diff) | |
| download | STC-modified-7dc6fddc079f4f572c8fb7c0ffd5a27e03291a2d.tar.gz STC-modified-7dc6fddc079f4f572c8fb7c0ffd5a27e03291a2d.zip | |
Fairly large update before release 4.1, cleaning up docs and some minor additions.
Diffstat (limited to 'include/stc/coption.h')
| -rw-r--r-- | include/stc/coption.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/stc/coption.h b/include/stc/coption.h index 69d0796f..65dae444 100644 --- a/include/stc/coption.h +++ b/include/stc/coption.h @@ -107,7 +107,7 @@ static void coption_permute_(char *argv[], int j, int n) { */ static int coption_get(coption *opt, int argc, char *argv[], const char *shortopts, const coption_long *longopts) { - int optc = -1, i0, j, posixly_correct = (shortopts[0] == '+'); + int optc = -1, i0, j, posixly_correct = (shortopts && shortopts[0] == '+'); if (!posixly_correct) { while (opt->_i < argc && (argv[opt->_i][0] != '-' || argv[opt->_i][1] == '\0')) ++opt->_i, ++opt->_nargs; @@ -149,12 +149,12 @@ static int coption_get(coption *opt, int argc, char *argv[], } } } - } else { /* a short option */ + } else if (shortopts) { /* a short option */ const char *p; if (opt->_pos == 0) opt->_pos = 1; optc = opt->opt = argv[opt->_i][opt->_pos++]; opt->_optstr[1] = optc, opt->optstr = opt->_optstr; - p = strchr((char *) shortopts, optc); + p = strchr(shortopts, optc); if (p == 0) { optc = '?'; /* unknown option */ } else if (p[1] == ':') { |
