aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-04-26 20:57:20 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-04-26 20:57:20 +0300
commit563d555bc14424066973a4dbc92123d308344a49 (patch)
treee6cccc0b77953b97e075f6fed22937bdf8339035
parent31a028f8992e6b48eb72ea8028b6248a67291bde (diff)
downloadwydawca-563d555bc14424066973a4dbc92123d308344a49.tar.gz
wydawca-563d555bc14424066973a4dbc92123d308344a49.tar.bz2
Support both new and legacy usage of -d
-rw-r--r--NEWS4
-rw-r--r--src/cmdline.opt33
2 files changed, 34 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index bd27212..01c8091 100644
--- a/NEWS
+++ b/NEWS
@@ -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,,,

Return to:

Send suggestions and report system problems to the System administrator.