summaryrefslogtreecommitdiff
path: root/bk_man.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2006-05-06 22:58:26 +0000
committerBen Harris <bjh21@bjh21.me.uk>2006-05-06 22:58:26 +0000
commitf260ea6f412ef4b7e9a39b62a1764f366fefddd2 (patch)
tree7e531d4a122c6774e8a9b956e43de01b807486ee /bk_man.c
parent72fee02708b2c5f644cf50ca34fe3f7857a3fefb (diff)
downloadhalibut-f260ea6f412ef4b7e9a39b62a1764f366fefddd2.zip
halibut-f260ea6f412ef4b7e9a39b62a1764f366fefddd2.tar.gz
halibut-f260ea6f412ef4b7e9a39b62a1764f366fefddd2.tar.bz2
halibut-f260ea6f412ef4b7e9a39b62a1764f366fefddd2.tar.xz
Add support for nonbreaking hyphens to the "man" backend. man_rdaddwc() is beginning
to get ugly. [originally from svn r6654]
Diffstat (limited to 'bk_man.c')
-rw-r--r--bk_man.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/bk_man.c b/bk_man.c
index 8daf2a8..7bd19ea 100644
--- a/bk_man.c
+++ b/bk_man.c
@@ -481,6 +481,12 @@ static int man_convert(wchar_t const *s, int maxlen,
* spaces always.
*/
rdaddc(&out, '\\');
+ } else if (*q == '-') {
+ /*
+ * Turn nonbreakable hyphens into \(hy.
+ */
+ rdaddsc(&out, "\\(hy");
+ continue;
} else if (*q == '"' && (quote_props & QUOTE_QUOTES)) {
/*
* Double quote within double quotes. Quote it by
@@ -573,18 +579,32 @@ static int man_rdaddwc(rdstringc *rs, word *text, word *end,
if (removeattr(text->type) == word_Normal) {
charset_state s2 = *state;
+ int len = ustrlen(text->text), hyphen = FALSE;
- if (man_convert(text->text, 0, &c, quote_props, conf->charset, &s2) ||
+ if (text->breaks && text->text[len - 1] == '-') {
+ len--;
+ hyphen = TRUE;
+ }
+ if (len == 0 ||
+ man_convert(text->text, len, &c, quote_props, conf->charset,
+ &s2) ||
!text->alt) {
- rdaddsc(rs, c);
- if (*c)
+ if (len != 0) {
+ rdaddsc(rs, c);
+ if (*c)
+ quote_props &= ~QUOTE_INITCTRL; /* not at start any more */
+ *state = s2;
+ }
+ if (hyphen) {
+ rdaddc(rs, '-');
quote_props &= ~QUOTE_INITCTRL; /* not at start any more */
- *state = s2;
+ }
} else {
quote_props = man_rdaddwc(rs, text->alt, NULL,
quote_props, conf, state);
}
- sfree(c);
+ if (len != 0)
+ sfree(c);
} else if (removeattr(text->type) == word_WhiteSpace) {
rdaddc(rs, ' ');
quote_props &= ~QUOTE_INITCTRL; /* not at start any more */