diff options
-rw-r--r-- | chars.c | 2 | ||||
-rw-r--r-- | chars.in | 18 | ||||
-rw-r--r-- | html.c | 10 | ||||
-rw-r--r-- | mandoc.h | 1 | ||||
-rw-r--r-- | mandocdb.c | 19 | ||||
-rw-r--r-- | mdoc_man.c | 5 | ||||
-rw-r--r-- | term.c | 12 |
7 files changed, 48 insertions, 19 deletions
@@ -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) }, @@ -1,6 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> * * 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) @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> * * 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 *p, int norecurse) 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 *p, int norecurse) case ('&'): printf("&"); continue; + case (ASCII_NBRSP): + putchar('-'); + continue; case (ASCII_HYPH): putchar('-'); + /* FALLTHROUGH */ + case (ASCII_BREAK): continue; default: break; @@ -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 @@ -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 *key) 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 *key) 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. */ @@ -1,6 +1,6 @@ /* $Id$ */ /* - * Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -365,6 +365,9 @@ print_word(const char *s) case (ASCII_HYPH): putchar('-'); break; + case (ASCII_BREAK): + printf("\\:"); + break; case (' '): if (MMAN_nbrword & outflags) { printf("\\ "); @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> * * 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 char *cp) 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 char *cp) case (ASCII_HYPH): sz += cond_width(p, '-', &skip); cp++; + /* FALLTHROUGH */ + case (ASCII_BREAK): break; default: break; |