aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2022-06-02 11:29:07 +0000
committerIngo Schwarze <schwarze@openbsd.org>2022-06-02 11:29:07 +0000
commit1ecd7d69278a7a53010b2bdde946bb18930ae850 (patch)
tree64717d1f374ac110b1ac89cb113a09d6808709df /roff.c
parent47c818f283c63fdbb7882e9aac6e2ab028666c9f (diff)
downloadmandoc-1ecd7d69278a7a53010b2bdde946bb18930ae850.tar.gz
mandoc-1ecd7d69278a7a53010b2bdde946bb18930ae850.tar.zst
mandoc-1ecd7d69278a7a53010b2bdde946bb18930ae850.zip
Avoid the layering violation of re-parsing for \E in roff_expand().
To that end, add another argument to roff_escape() returning the index of the escape name. This also makes the code in roff_escape() a bit more uniform in so far as it no longer needs the "char esc_name" local variable but now does everything with indices into buf[]. No functional change.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/roff.c b/roff.c
index 83701f7d..c4b944e3 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.391 2022/05/31 20:23:05 schwarze Exp $ */
+/* $Id: roff.c,v 1.392 2022/06/02 11:29:07 schwarze Exp $ */
/*
* Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -1410,8 +1410,8 @@ roff_expand(struct roff *r, struct buf *buf, int ln, int pos, char ec)
* 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, int pos, char ec)
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;