diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2022-05-30 23:03:47 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2022-05-30 23:03:47 +0000 |
commit | da6633e8c5db9f71ef2499ad46bc43e3854c2ac9 (patch) | |
tree | dc16ff25d96062244163d68f4ecdbe27a4f1f465 /roff.c | |
parent | 47b136859c01b58c485871ddf294a613d823ece4 (diff) | |
download | mandoc-da6633e8c5db9f71ef2499ad46bc43e3854c2ac9.tar.gz mandoc-da6633e8c5db9f71ef2499ad46bc43e3854c2ac9.tar.zst mandoc-da6633e8c5db9f71ef2499ad46bc43e3854c2ac9.zip |
Dummy implementation of the roff(7) \V (interpolate environment variable)
escape sequence. This is needed to get \V into the correct parsing
class, ESCAPE_EXPAND.
It is intentional that mandoc(1) output is *not* influenced by environment
variables, so interpolate the name of the variable with some decorating
punctuation rather than interpolating its value.
Diffstat (limited to 'roff.c')
-rw-r--r-- | roff.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.388 2022/05/19 15:37:47 schwarze Exp $ */ +/* $Id: roff.c,v 1.389 2022/05/30 23:03:47 schwarze Exp $ */ /* * Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> @@ -1529,6 +1529,12 @@ roff_expand(struct roff *r, struct buf *buf, int ln, int pos, char ec) ubuf[1] = '\0'; res = ubuf; break; + case 'V': + mandoc_msg(MANDOCERR_UNSUPP, ln, iesc, + "%.*s", iend - iesc, buf->buf + iesc); + roff_expand_patch(buf, iendarg, "}", iend); + roff_expand_patch(buf, iesc, "${", iarg); + continue; case 'n': if (iendarg > iarg) (void)snprintf(ubuf, sizeof(ubuf), "%d", @@ -1567,9 +1573,8 @@ roff_expand_patch(struct buf *buf, int start, const char *repl, int end) { char *nbuf; - buf->buf[start] = '\0'; - buf->sz = mandoc_asprintf(&nbuf, "%s%s%s", buf->buf, repl, - buf->buf + end) + 1; + buf->sz = mandoc_asprintf(&nbuf, "%.*s%s%s", start, buf->buf, + repl, buf->buf + end) + 1; free(buf->buf); buf->buf = nbuf; } |