summaryrefslogtreecommitdiffstats
path: root/html.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-11-01 08:15:20 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-11-01 08:15:20 +0000
commitca6a9925d3ba6ddf9b4c245a4a1a271964774519 (patch)
tree2688a485dce573b6efceb7b45992b4c185d06d12 /html.c
parent13099e0c4c23befef2f762613590494d89487710 (diff)
downloadmandoc-ca6a9925d3ba6ddf9b4c245a4a1a271964774519.tar.gz
print_encode() using strcspn instead of looping/putchar() (noted by Joerg Sonnenberger).
Diffstat (limited to 'html.c')
-rw-r--r--html.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/html.c b/html.c
index 2bd90110..6eae9461 100644
--- a/html.c
+++ b/html.c
@@ -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("&lt;");
+ } else if ('\0' == *p)
break;
- case ('>'):
+
+ if ('<' == *p)
+ printf("&lt;");
+ else if ('>' == *p)
printf("&gt;");
- break;
- case ('&'):
+ else if ('&' == *p)
printf("&amp;");
- break;
- default:
- putchar(*p);
- break;
- }
}
}