From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s0MKwfTg017143 for ; Wed, 22 Jan 2014 15:58:41 -0500 (EST) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s0MKwdFU026997; Wed, 22 Jan 2014 15:58:39 -0500 (EST) Date: Wed, 22 Jan 2014 15:58:39 -0500 (EST) Message-Id: <201401222058.s0MKwdFU026997@krisdoz.my.domain> 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: Implement the \: (optional line break) escape sequence, X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Implement the \: (optional line break) escape sequence, documented in the Ossanna-Kernighan-Ritter troff manual and also supported by groff. Missing feature reported by Steffen Nurpmeso . Modified Files: -------------- mdocml: chars.c chars.in html.c mandoc.h mandocdb.c mdoc_man.c term.c Revision Data ------------- Index: term.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v retrieving revision 1.215 retrieving revision 1.216 diff -Lterm.c -Lterm.c -u -p -r1.215 -r1.216 --- term.c +++ term.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze + * Copyright (c) 2010-2014 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -179,7 +179,8 @@ term_flushln(struct termp *p) /* Regular word. */ /* Break at the hyphen point if we overrun. */ if (vend > vis && vend < bp && - ASCII_HYPH == p->buf[j]) + (ASCII_HYPH == p->buf[j] || + ASCII_BREAK == p->buf[j])) jhy = j; vend += (*p->width)(p, p->buf[j]); @@ -233,6 +234,8 @@ term_flushln(struct termp *p) vbl += (*p->width)(p, ' '); continue; } + if (ASCII_BREAK == p->buf[i]) + continue; /* * Now we definitely know there will be @@ -644,7 +647,8 @@ term_strlen(const struct termp *p, const int ssz, skip, c; const char *seq, *rhs; enum mandoc_esc esc; - static const char rej[] = { '\\', ASCII_HYPH, ASCII_NBRSP, '\0' }; + static const char rej[] = { '\\', ASCII_NBRSP, ASCII_HYPH, + ASCII_BREAK, '\0' }; /* * Account for escaped sequences within string length @@ -732,6 +736,8 @@ term_strlen(const struct termp *p, const case (ASCII_HYPH): sz += cond_width(p, '-', &skip); cp++; + /* FALLTHROUGH */ + case (ASCII_BREAK): break; default: break; Index: chars.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.c,v retrieving revision 1.54 retrieving revision 1.55 diff -Lchars.c -Lchars.c -u -p -r1.54 -r1.55 --- chars.c +++ chars.c @@ -37,7 +37,7 @@ struct ln { int unicode; }; -#define LINES_MAX 329 +#define LINES_MAX 330 #define CHAR(in, ch, code) \ { NULL, (in), (ch), (code) }, Index: mdoc_man.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_man.c,v retrieving revision 1.57 retrieving revision 1.58 diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.57 -r1.58 --- mdoc_man.c +++ mdoc_man.c @@ -1,6 +1,6 @@ /* $Id$ */ /* - * Copyright (c) 2011, 2012, 2013 Ingo Schwarze + * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -364,6 +364,9 @@ print_word(const char *s) break; case (ASCII_HYPH): putchar('-'); + break; + case (ASCII_BREAK): + printf("\\:"); break; case (' '): if (MMAN_nbrword & outflags) { Index: html.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/html.c,v retrieving revision 1.153 retrieving revision 1.154 diff -Lhtml.c -Lhtml.c -u -p -r1.153 -r1.154 --- html.c +++ html.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2011, 2012, 2013 Ingo Schwarze + * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -331,7 +331,8 @@ print_encode(struct html *h, const char int c, len, nospace; const char *seq; enum mandoc_esc esc; - static const char rejs[6] = { '\\', '<', '>', '&', ASCII_HYPH, '\0' }; + static const char rejs[8] = { '\\', '<', '>', '&', + ASCII_NBRSP, ASCII_HYPH, ASCII_BREAK, '\0' }; nospace = 0; @@ -360,8 +361,13 @@ print_encode(struct html *h, const char case ('&'): printf("&"); continue; + case (ASCII_NBRSP): + putchar('-'); + continue; case (ASCII_HYPH): putchar('-'); + /* FALLTHROUGH */ + case (ASCII_BREAK): continue; default: break; Index: chars.in =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.in,v retrieving revision 1.43 retrieving revision 1.44 diff -Lchars.in -Lchars.in -u -p -r1.43 -r1.44 --- chars.in +++ chars.in @@ -1,6 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons + * Copyright (c) 2014 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -27,22 +28,25 @@ * XXX - update LINES_MAX if adding more! */ -/* Non-breaking, non-collapsing space uses unit separator. */ +/* Special break control characters. */ static const char ascii_nbrsp[2] = { ASCII_NBRSP, '\0' }; +static const char ascii_break[2] = { ASCII_BREAK, '\0' }; CHAR_TBL_START /* Spacing. */ -CHAR("c", "", 0) -CHAR("0", " ", 8194) CHAR(" ", ascii_nbrsp, 160) CHAR("~", ascii_nbrsp, 160) -CHAR("%", "", 0) -CHAR("&", "", 0) -CHAR("^", "", 0) +CHAR("0", " ", 8194) CHAR("|", "", 0) -CHAR("}", "", 0) +CHAR("^", "", 0) +CHAR("&", "", 0) +CHAR("%", "", 0) +CHAR(":", ascii_break, 0) +/* XXX The following three do not really belong into this file. */ CHAR("t", "", 0) +CHAR("c", "", 0) +CHAR("}", "", 0) /* Accents. */ CHAR("a\"", "\"", 779) Index: mandocdb.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v retrieving revision 1.113 retrieving revision 1.114 diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.113 -r1.114 --- mandocdb.c +++ mandocdb.c @@ -1664,7 +1664,7 @@ static void render_key(struct mchars *mc, struct str *key) { size_t sz, bsz, pos; - char utfbuf[7], res[5]; + char utfbuf[7], res[6]; char *buf; const char *seq, *cpp, *val; int len, u; @@ -1676,7 +1676,8 @@ render_key(struct mchars *mc, struct str res[1] = '\t'; res[2] = ASCII_NBRSP; res[3] = ASCII_HYPH; - res[4] = '\0'; + res[4] = ASCII_BREAK; + res[5] = '\0'; val = key->key; bsz = strlen(val); @@ -1707,15 +1708,23 @@ render_key(struct mchars *mc, struct str val += sz; } - if (ASCII_HYPH == *val) { + switch (*val) { + case (ASCII_HYPH): buf[pos++] = '-'; val++; continue; - } else if ('\t' == *val || ASCII_NBRSP == *val) { + case ('\t'): + /* FALLTHROUGH */ + case (ASCII_NBRSP): buf[pos++] = ' '; val++; + /* FALLTHROUGH */ + case (ASCII_BREAK): continue; - } else if ('\\' != *val) + default: + break; + } + if ('\\' != *val) break; /* Read past the slash. */ Index: mandoc.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v retrieving revision 1.114 retrieving revision 1.115 diff -Lmandoc.h -Lmandoc.h -u -p -r1.114 -r1.115 --- mandoc.h +++ mandoc.h @@ -20,6 +20,7 @@ #define ASCII_NBRSP 31 /* non-breaking space */ #define ASCII_HYPH 30 /* breakable hyphen */ +#define ASCII_BREAK 29 /* breakable zero-width space */ /* * Status level. This refers to both internal status (i.e., whilst -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv