diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-11-01 08:15:20 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-11-01 08:15:20 +0000 |
commit | ca6a9925d3ba6ddf9b4c245a4a1a271964774519 (patch) | |
tree | 2688a485dce573b6efceb7b45992b4c185d06d12 /html.c | |
parent | 13099e0c4c23befef2f762613590494d89487710 (diff) | |
download | mandoc-ca6a9925d3ba6ddf9b4c245a4a1a271964774519.tar.gz |
print_encode() using strcspn instead of looping/putchar() (noted by Joerg Sonnenberger).
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -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; - } } } |