aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-01-22 22:51:43 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-01-22 22:51:43 +0000
commit3f21939a391eaea3a1eab39d7ae539fdd04cb52a (patch)
tree0a80244e6c6341ae858f7815c4acd0ca42b2844e /roff.c
parent5a2eef4971d2209c986589dabc0489ebf07587a9 (diff)
downloadmandoc-3f21939a391eaea3a1eab39d7ae539fdd04cb52a.tar.gz
mandoc-3f21939a391eaea3a1eab39d7ae539fdd04cb52a.tar.zst
mandoc-3f21939a391eaea3a1eab39d7ae539fdd04cb52a.zip
Slightly improve \w width measurements:
Count special characters with the same width as ASCII characters and treat all other escape sequences as if they had a width of 0. Certainly not perfect, but a bit better. For example, GNU RCS ci(1) needs this; reported by naddy@.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/roff.c b/roff.c
index f9a4166b..875c1603 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.252 2015/01/21 02:16:52 schwarze Exp $ */
+/* $Id: roff.c,v 1.253 2015/01/22 22:51:43 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -1004,8 +1004,9 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
/* Advance to the end of the name. */
+ naml = 0;
arg_complete = 1;
- for (naml = 0; maxl == 0 || naml < maxl; naml++, cp++) {
+ while (maxl == 0 || naml < maxl) {
if (*cp == '\0') {
mandoc_msg(MANDOCERR_ESC_BAD, r->parse,
ln, (int)(stesc - buf->buf), stesc);
@@ -1016,6 +1017,23 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
cp++;
break;
}
+ if (*cp++ != '\\' || stesc[1] != 'w') {
+ naml++;
+ continue;
+ }
+ switch (mandoc_escape(&cp, NULL, NULL)) {
+ case ESCAPE_SPECIAL:
+ /* FALLTHROUGH */
+ case ESCAPE_UNICODE:
+ /* FALLTHROUGH */
+ case ESCAPE_NUMBERED:
+ /* FALLTHROUGH */
+ case ESCAPE_OVERSTRIKE:
+ naml++;
+ break;
+ default:
+ break;
+ }
}
/*