summaryrefslogtreecommitdiff
path: root/xml.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2018-08-26 15:00:43 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2018-08-26 15:00:43 +0200
commit1baf6462562796680594492b7c6614c0bd5fcbb3 (patch)
tree8c670c0c795ce60fa129c0300da8b6d5c797db59 /xml.c
parent9d96397cef3d75f2af96b7a31bf2aef910346b0c (diff)
xml: use ANSI types and struct initialization
long is atleast 32-bits, codepointtoutf8() works with >= 32-bit types. Valid codepoint ranges are not larger than this. unsigned char is not needed because converted unicode bytes don't use this range. tested all valid codepoints and output on amd64, i386 and SPARC64.
Diffstat (limited to 'xml.c')
-rw-r--r--xml.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/xml.c b/xml.c
index c3a0f7c..89a7fd8 100644
--- a/xml.c
+++ b/xml.c
@@ -3,7 +3,6 @@
#include <ctype.h>
#include <errno.h>
#include <limits.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -215,7 +214,7 @@ xml_parsecdata(XMLParser *x)
}
static int
-codepointtoutf8(const uint32_t r, uint8_t *s)
+codepointtoutf8(long r, char *s)
{
if (r == 0) {
return 0; /* NUL byte */
@@ -251,16 +250,16 @@ namedentitytostr(const char *e, char *buf, size_t bufsiz)
char *entity;
int c;
} entities[] = {
- { .entity = "&amp;", .c = '&' },
- { .entity = "&lt;", .c = '<' },
- { .entity = "&gt;", .c = '>' },
- { .entity = "&apos;", .c = '\'' },
- { .entity = "&quot;", .c = '"' },
- { .entity = "&AMP;", .c = '&' },
- { .entity = "&LT;", .c = '<' },
- { .entity = "&GT;", .c = '>' },
- { .entity = "&APOS;", .c = '\'' },
- { .entity = "&QUOT;", .c = '"' }
+ { "&amp;", '&' },
+ { "&lt;", '<' },
+ { "&gt;", '>' },
+ { "&apos;", '\'' },
+ { "&quot;", '"' },
+ { "&AMP;", '&' },
+ { "&LT;", '<' },
+ { "&GT;", '>' },
+ { "&APOS;", '\'' },
+ { "&QUOT;", '"' }
};
size_t i;
@@ -285,7 +284,7 @@ namedentitytostr(const char *e, char *buf, size_t bufsiz)
static int
numericentitytostr(const char *e, char *buf, size_t bufsiz)
{
- uint32_t l;
+ long l;
int len;
char *end;