diff options
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.76 2009/11/01 07:44:32 kristaps Exp $ */ +/* $Id: html.c,v 1.77 2009/11/01 08:15:20 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -316,26 +316,26 @@ print_escape(struct html *h, const char **p) static void print_encode(struct html *h, const char *p) { + size_t sz; for (; *p; p++) { + sz = strcspn(p, "\\<>&"); + + fwrite(p, 1, sz, stdout); + p += sz; + if ('\\' == *p) { print_escape(h, &p); continue; - } - switch (*p) { - case ('<'): - printf("<"); + } else if ('\0' == *p) break; - case ('>'): + + if ('<' == *p) + printf("<"); + else if ('>' == *p) printf(">"); - break; - case ('&'): + else if ('&' == *p) printf("&"); - break; - default: - putchar(*p); - break; - } } } |