diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-03-29 22:46:03 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-03-29 22:46:03 -0700 |
commit | f3614cce61ab22526ff34b311e4ef4e8c63b90f7 (patch) | |
tree | 1df0a3df9780be5246a0f1bd0026243a45d87bc4 /cppawk-case.1 | |
parent | 0e0f84f24a0e2abd3e01008fb6f411cdfaee205d (diff) | |
download | cppawk-f3614cce61ab22526ff34b311e4ef4e8c63b90f7.tar.gz cppawk-f3614cce61ab22526ff34b311e4ef4e8c63b90f7.tar.bz2 cppawk-f3614cce61ab22526ff34b311e4ef4e8c63b90f7.zip |
man cppawk-case: use fonts in synopsis and examples.
Diffstat (limited to 'cppawk-case.1')
-rw-r--r-- | cppawk-case.1 | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/cppawk-case.1 b/cppawk-case.1 index f3496b0..db924b8 100644 --- a/cppawk-case.1 +++ b/cppawk-case.1 @@ -4,26 +4,29 @@ case \- macro for portable switch statement .SH SYNOPSIS + +.ft B #include <case.h> - case (expr) { - of ("abc") + case (\fIexpr\fP) { + of (\fI"abc"\fP) print "single key abc case" cbreak - of (1, 2, 3) - print "multi-key 1, 2, 3 case" + of (\fI1\fP, \fI2\fP, \fI3\fP) + print \fI"multi-key 1, 2, 3 case"\fP cfall # fall through - matching (/regex1/, /regex2/, /regex3/) - print "regex case" + matching (\fI/regex1/\fP, \fI/regex2/\fP, \fI/regex3/\fP) + print \fI"regex case"\fP cbreak - mixed (("def", "ghi"), (/regex4/, /regex5/)) + mixed ((\fI"def"\fP, \fI"ghi"\fP), (\fI/regex4/\fP, \fI/regex5/\fP)) otherwise - print "default case" + print \fI"default case"\fP } +.ft R .SH DESCRIPTION The @@ -70,9 +73,11 @@ macros take variable arguments. Multiple matching keys or regular expressions are specified as multiple arguments, rather than by repetition of the construct: - of (3) of (4) print "3 or 4"; cbreak // incorrect +.ft B + of (\fI3\fP) of (\fI4\fP) print \fI"3 or 4"\fP; cbreak // incorrect - of (3, 4) print "3 or 4"; cbreak // correct + of (\fI3\fP, \fI4\fP) print \fI"3 or 4"\fP; cbreak // correct +.ft R The .B mixed @@ -80,7 +85,9 @@ macro takes exactly two arguments, which are parenthesized lists of keys. The left list must be a list of ordinary value keys, and the second of regular expression literals: - mixed ((1, 2, "a"), (/xyz$/, /^\et/)) +.ft B + mixed ((\fI1\fP, \fI2\fP, \fI"a"\fP), (\fI/xyz$/\fP, \fI/^\et/\fP)) +.ft R Each clause must specify how it terminates: whether it breaks out of the .B case @@ -95,21 +102,23 @@ must be used for this purpose. The macro takes exactly one argument, the expression whose value is to be returned from the surrounding function: - function f(input, - case_temps) +.ft B + function f(\fIinput\fP, + \fIcase_temps\fP) { - case (input) { - match (/abc/) - print "match on regex /abc/" - cret(1) + case (\fIinput\fP) { + match (\fI/abc/\fP) + print \fI"match on regex /abc/"\fP + cret(\fI1\fP) otherwise cbreak } // other logic - return 0 + return \fI0\fP } +.ft R When .B case @@ -130,19 +139,21 @@ Defining the temporary variables as local is done using the provided .B case_temps macro: +.ft B #include <case.h> - function fun(x, y, z, # arguments - a, b, # locals - case_temps) # locals for case + function fun(\fIx\fP, \fIy\fP, \fIz\fP, # arguments + \fIa\fP, \fIb\fP, # locals + \fIcase_temps\fP) # locals for case { - case (x) { - of (42) { + case (\fIx\fP) { + of (\fI42\fP) { ... } ... } } +.ft R .B case_temps does not have to be in the last argument position. It is guaranteed to expand to one or |