From 1b939f3fc9a59c4dd5ac04a9c995a8457d4ee32a Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Wed, 21 Jul 2010 20:35:03 +0000 Subject: Accomodate for groff's crappy behaviour wherein an unrecognised single-character escape (and ONLY this type of escape) will map back into itself: "If a backslash is followed by a character that does not constitute a defined escape sequence the backslash is silently ignored and the character maps to itself." (From groff.7.) Found by Jason McIntyre. --- html.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index 5e19b09c..070562fb 100644 --- a/html.c +++ b/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.107 2010/07/16 22:33:30 kristaps Exp $ */ +/* $Id: html.c,v 1.108 2010/07/21 20:35:03 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -88,7 +88,8 @@ static const char *const htmlattrs[ATTR_MAX] = { "summary", }; -static void print_spec(struct html *, const char *, size_t); +static void print_spec(struct html *, enum roffdeco, + const char *, size_t); static void print_res(struct html *, const char *, size_t); static void print_ctag(struct html *, enum htmltag); static void print_doctype(struct html *); @@ -215,7 +216,7 @@ print_gen_head(struct html *h) static void -print_spec(struct html *h, const char *p, size_t len) +print_spec(struct html *h, enum roffdeco d, const char *p, size_t len) { int cp; const char *rhs; @@ -224,6 +225,9 @@ print_spec(struct html *h, const char *p, size_t len) if ((cp = chars_spec2cp(h->symtab, p, len)) > 0) { printf("&#%d;", cp); return; + } else if (-1 == cp && DECO_SSPECIAL == d) { + fwrite(p, 1, len, stdout); + return; } else if (-1 == cp) return; @@ -342,8 +346,10 @@ print_encode(struct html *h, const char *p, int norecurse) case (DECO_RESERVED): print_res(h, seq, sz); break; + case (DECO_SSPECIAL): + /* FALLTHROUGH */ case (DECO_SPECIAL): - print_spec(h, seq, sz); + print_spec(h, deco, seq, sz); break; case (DECO_PREVIOUS): /* FALLTHROUGH */ -- cgit v1.2.3-56-ge451