aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2022-05-31 20:23:05 +0000
committerIngo Schwarze <schwarze@openbsd.org>2022-05-31 20:23:05 +0000
commitbfab7104d861ff6e91e84c914c0f977343449298 (patch)
tree6d4648f1138aeb04731afc789a621012a21cab6c /roff.c
parentea452a23a02a06e590a1b863b12b3fa42b728535 (diff)
downloadmandoc-bfab7104d861ff6e91e84c914c0f977343449298.tar.gz
mandoc-bfab7104d861ff6e91e84c914c0f977343449298.tar.zst
mandoc-bfab7104d861ff6e91e84c914c0f977343449298.zip
Rudimentary implementation of the \A escape sequence, following groff
semantics (test identifier for syntactical validity), not at all following the completely unrelated Heirloom semantics (define hyperlink target position). The main motivation for providing this implementation is to get \A into the parsing class ESCAPE_EXPAND that corresponds to groff parsing behaviour, which is quite similar to the \B escape sequence (test numerical expression for syntactical validity). This is likely to improve parsing of nested escape sequences in the future. Validation isn't perfect yet. In particular, this implementation rejects \A arguments containing some escape sequences that groff allows to slip through. But that is unlikely to cause trouble even in documents using \A for non-trivial purposes. Rejecting the nested escapes in question might even improve robustnest because the rejected names are unlikely to really be usable for practical purposes - no matter that groff dubiously considers them syntactically valid.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/roff.c b/roff.c
index 0c36e08e..83701f7d 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.390 2022/05/31 18:09:57 schwarze Exp $ */
+/* $Id: roff.c,v 1.391 2022/05/31 20:23:05 schwarze Exp $ */
/*
* Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -1520,6 +1520,11 @@ roff_expand(struct roff *r, struct buf *buf, int ln, int pos, char ec)
*dst++ = '"';
}
continue;
+ case 'A':
+ ubuf[0] = iendarg > iarg ? '1' : '0';
+ ubuf[1] = '\0';
+ res = ubuf;
+ break;
case 'B':
npos = 0;
ubuf[0] = iendarg > iarg && iend > iendarg &&