From 1ccadd7c72e10854f4562115d9ce783d50163afa Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Sun, 13 Jun 2021 23:39:23 +0000 Subject: Treat `-T's optional argument as optional `-T[format]' is not possible with getopt(3) but getopt_long(3) supports "T::" exactly for that, so make the command line option go in line with configuration files and documentation. While here, check `has_arg' explicitly as getopt_long(3) only documents mnemonic values not numerical ones. --- catgirl.1 | 4 ++-- chat.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/catgirl.1 b/catgirl.1 index 5412a52..213b504 100644 --- a/catgirl.1 +++ b/catgirl.1 @@ -15,7 +15,7 @@ .Op Fl N Ar notify .Op Fl O Ar open .Op Fl S Ar bind -.Op Fl T Ar timestamp +.Op Fl T Ns Op Ar timestamp .Op Fl a Ar plain .Op Fl c Ar cert .Op Fl h Ar host @@ -188,7 +188,7 @@ Bind to source address .Ar host when connecting to the server. . -.It Fl T Ar format | Cm timestamp Op = Ar format +.It Fl T Ns Oo Ar format Oc | Cm timestamp Op = Ar format Show timestamps by default, in the specified .Xr strftime 3 diff --git a/chat.c b/chat.c index 3f6aa71..09d0ca6 100644 --- a/chat.c +++ b/chat.c @@ -190,10 +190,11 @@ int main(int argc, char *argv[]) { { .val = 'w', .name = "pass", required_argument }, {0}, }; - char opts[2 * ARRAY_LEN(options)]; + char opts[3 * ARRAY_LEN(options)]; for (size_t i = 0, j = 0; i < ARRAY_LEN(options); ++i) { opts[j++] = options[i].val; - if (options[i].has_arg) opts[j++] = ':'; + if (options[i].has_arg != no_argument) opts[j++] = ':'; + if (options[i].has_arg == optional_argument) opts[j++] = ':'; } for (int opt; 0 < (opt = getopt_config(argc, argv, opts, options, NULL));) { -- cgit 1.4.1 on value='range'>range
path: root/bin/cash/parser.h (unfollow)
Commit message (Expand)Author
2019-02-09Run hi -c after compiling hiJune McEnroe
2019-02-09Fix IRC output monospace option to emit once per lineJune McEnroe
2019-02-09Add output format options to hiJune McEnroe
2019-02-09Avoid using SGRReset and IRCResetJune McEnroe
2019-02-08Use X macros for hi classesJune McEnroe
2019-02-08Don't open folds when using {}June McEnroe
2019-02-08Add sh syntax to hiJune McEnroe
2019-02-08Use [] to quote special characters in regexJune McEnroe
2019-02-08Improve ANSI output and base IRC on itJune McEnroe
2019-02-08Add hi -nJune McEnroe
2019-02-08Elaborate hi man pageJune McEnroe
2019-02-08Use set for parent in hiJune McEnroe
2019-02-08Switch back to semantic keyword grouping in hiJune McEnroe
2019-02-08Match only the basename in hiJune McEnroe
2019-02-07Add mdoc syntax to hiJune McEnroe
2019-02-07Support multi-line C macros in hiJune McEnroe
2019-02-07Detect .mk files as makeJune McEnroe
2019-02-07Add make syntax to hiJune McEnroe
2019-02-07Add IRC output to hiJune McEnroe
2019-02-07Improve C syntax accuracy and add Format classJune McEnroe
2019-02-07Factor out hi checkJune McEnroe
2019-02-07Add Escape class to hiJune McEnroe
2019-02-07Add Todo class and parent syntax constraintJune McEnroe