=================================================================== RCS file: /cvs/mandoc/roff.c,v retrieving revision 1.388 retrieving revision 1.392 diff -u -p -r1.388 -r1.392 --- mandoc/roff.c 2022/05/19 15:37:47 1.388 +++ mandoc/roff.c 2022/06/02 11:29:07 1.392 @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.388 2022/05/19 15:37:47 schwarze Exp $ */ +/* $Id: roff.c,v 1.392 2022/06/02 11:29:07 schwarze Exp $ */ /* * Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons @@ -1410,8 +1410,8 @@ roff_expand(struct roff *r, struct buf *buf, int ln, i * it to backslashes and translate backslashes to \e. */ - if (roff_escape(buf->buf, ln, pos, - &iesc, &iarg, &iendarg, &iend) != ESCAPE_EXPAND) { + if (roff_escape(buf->buf, ln, pos, &iesc, &inam, + &iarg, &iendarg, &iend) != ESCAPE_EXPAND) { while (pos < iend) { if (buf->buf[pos] == ec) { buf->buf[pos] = '\\'; @@ -1428,15 +1428,6 @@ roff_expand(struct roff *r, struct buf *buf, int ln, i continue; } - /* - * Treat "\E" just like "\"; - * it only makes a difference in copy mode. - */ - - inam = iesc + 1; - while (buf->buf[inam] == 'E') - inam++; - /* Handle expansion. */ res = NULL; @@ -1520,6 +1511,11 @@ roff_expand(struct roff *r, struct buf *buf, int ln, i *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 && @@ -1529,6 +1525,14 @@ roff_expand(struct roff *r, struct buf *buf, int ln, i 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 'g': + break; case 'n': if (iendarg > iarg) (void)snprintf(ubuf, sizeof(ubuf), "%d", @@ -1567,9 +1571,8 @@ roff_expand_patch(struct buf *buf, int start, const ch { 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; }