summaryrefslogtreecommitdiffstats
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
commit8a2f1706fd6632a3035d5145d1d04c67148824c6 (patch)
tree036ac644b953d589ee4612e6ff0de4254ecfde10
parent9dab699617f9fb0f3b8739588ad633acef45dcdf (diff)
downloadmandoc-8a2f1706fd6632a3035d5145d1d04c67148824c6.tar.gz
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@.
-rw-r--r--roff.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/roff.c b/roff.c
index 3948711e..435b0bfc 100644
--- a/roff.c
+++ b/roff.c
@@ -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;
+ }
}
/*