From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 90357a38; for ; Thu, 22 Jan 2015 17:52:13 -0500 (EST) Date: Thu, 22 Jan 2015 17:52:13 -0500 (EST) Message-Id: <5242133268407992565.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Slightly improve \w width measurements: Count special characters X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- 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@. Modified Files: -------------- mdocml: roff.c Revision Data ------------- Index: roff.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/roff.c,v retrieving revision 1.252 retrieving revision 1.253 diff -Lroff.c -Lroff.c -u -p -r1.252 -r1.253 --- roff.c +++ roff.c @@ -1004,8 +1004,9 @@ roff_res(struct roff *r, struct buf *buf /* 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); @@ -1014,6 +1015,23 @@ roff_res(struct roff *r, struct buf *buf } if (maxl == 0 && *cp == term) { 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; } } -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv