diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-04-26 20:57:20 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-04-26 20:57:20 +0300 |
commit | 563d555bc14424066973a4dbc92123d308344a49 (patch) | |
tree | e6cccc0b77953b97e075f6fed22937bdf8339035 | |
parent | 31a028f8992e6b48eb72ea8028b6248a67291bde (diff) | |
download | wydawca-563d555bc14424066973a4dbc92123d308344a49.tar.gz wydawca-563d555bc14424066973a4dbc92123d308344a49.tar.bz2 |
Support both new and legacy usage of -d
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | src/cmdline.opt | 33 |
2 files changed, 34 insertions, 3 deletions
@@ -50,11 +50,13 @@ can be running. Therefore spool locking has been discontinued. ** The --single-process option removed -** The -d (--debug) option requires argument +** The -d (--debug) option takes optional argument The argument is a decimal number specifying the desired debug level. Thus, instead of -ddd, use -d3 (or --debug=3). +The legacy usage (each -d increasing the debugging level) is still supported. + * Configuration changes ** The wakeup-interval statement removed diff --git a/src/cmdline.opt b/src/cmdline.opt index a23335d..e66564f 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt @@ -174,10 +174,39 @@ END GROUP(Debugging) -OPTION(debug,d,[<LEVEL>], +OPTION(debug,d,[<[LEVEL]>], [<set debugging level>]) BEGIN - wy_debug_level = atoi(optarg); + if (!optarg) { + wy_debug_level++; + } else { + char *p; + unsigned long n = strtoul(optarg, &p, 10); + if (*p != 0) { + /* Try to detect legacy usage */ + if (p == optarg && *p == 'd') { + n = 1; + while (*p && *p == 'd') { + n++; + p++; + } + if (*p) { + wy_log(LOG_CRIT, _("--debug: not a valid number: %s"), + optarg); + exit(EX_USAGE); + } + } else { + wy_log(LOG_CRIT, _("--debug: not a valid number: %s"), optarg); + exit(EX_USAGE); + } + } + if (n < INT_MAX) + wy_debug_level = n; + else { + wy_log(LOG_CRIT, _("--debug: number out of range: %s"), optarg); + exit(EX_USAGE); + } + } END OPTION(dump-grammar-trace,,, |