From 3e23d66c0abbb35f937f3969d2a6a54cb8827037 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Fri, 16 Jul 2010 22:33:30 +0000 Subject: Change chars.in HTML encoding to be a Unicode codepoint (int), which is later formatted in html.c. --- html.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index b6e1304d..5e19b09c 100644 --- a/html.c +++ b/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.106 2010/07/13 23:53:20 schwarze Exp $ */ +/* $Id: html.c,v 1.107 2010/07/16 22:33:30 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -217,28 +217,36 @@ print_gen_head(struct html *h) static void print_spec(struct html *h, const char *p, size_t len) { + int cp; const char *rhs; size_t sz; - rhs = chars_a2ascii(h->symtab, p, len, &sz); - - if (NULL == rhs) + if ((cp = chars_spec2cp(h->symtab, p, len)) > 0) { + printf("&#%d;", cp); + return; + } else if (-1 == cp) return; - fwrite(rhs, 1, sz, stdout); + + if (NULL != (rhs = chars_spec2str(h->symtab, p, len, &sz))) + fwrite(rhs, 1, sz, stdout); } static void print_res(struct html *h, const char *p, size_t len) { + int cp; const char *rhs; size_t sz; - rhs = chars_a2res(h->symtab, p, len, &sz); - - if (NULL == rhs) + if ((cp = chars_res2cp(h->symtab, p, len)) > 0) { + printf("&#%d;", cp); + return; + } else if (-1 == cp) return; - fwrite(rhs, 1, sz, stdout); + + if (NULL != (rhs = chars_res2str(h->symtab, p, len, &sz))) + fwrite(rhs, 1, sz, stdout); } -- cgit v1.2.3