aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-05 09:32:17 +0200
committerlemon <lsof@mailbox.org>2023-06-05 09:32:17 +0200
commitefc0cf8039cbff5e0f0d52fd7414c7186129b6ac (patch)
tree27aabd39ebe1c778f052edaf7088eded379f0108 /main.c
parent6ce2ac20e1d9095281a233aeb778d0fa2c82dd74 (diff)
command line switch for debug options
Diffstat (limited to 'main.c')
-rw-r--r--main.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/main.c b/main.c
index d56cd50..d91188f 100644
--- a/main.c
+++ b/main.c
@@ -12,10 +12,11 @@ flushstd(void)
ioflush(&bstderr);
}
+/* parse an argument of the form 'opt=abcd'
+ * e.g. arg="foo=bar123"; opt="foo"; returns "bar123" */
static const char *
optval(const char *arg, const char *opt)
{
- /* arg="foo=bar123"; opt="foo"; returns "bar123" */
uint n1 = strlen(arg), n2 = strlen(opt);
if (n1 < n2+1 || memcmp(arg, opt, n2) != 0 || arg[n2] != '=')
return NULL;
@@ -41,6 +42,14 @@ optparse(const char **file, const char **targ, char **args)
else goto Bad;
} else if (!strcmp(arg, "pedantic")) {
ccopt.pedant = 1;
+ } else if (*arg == 'd' && arg[1]) {
+ /* see common.h§struct option */
+ while (*++arg) switch (*arg | 32) {
+ case 'p': ccopt.dbg.p = 1; break;
+ case 'a': ccopt.dbg.a = 1; break;
+ case 'r': ccopt.dbg.r = 1; break;
+ default: warn(NULL, "-d: invalid debug flag %'c", *arg);
+ }
} else Bad: warn(NULL, "invalid option: %'s", arg-1);
}
}