hexml 0.3 → 0.3.1
raw patch · 5 files changed
+76/−2 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.txt +2/−0
- cbits/fuzz.c +26/−0
- cbits/hexml.c +1/−1
- cbits/main.c +46/−0
- hexml.cabal +1/−1
CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for Hexml +0.3.1+ #9, don't walk off the end of the character table 0.3 #8, Mac compatibility Fix a bug when parsing closing comments
+ cbits/fuzz.c view
@@ -0,0 +1,26 @@+#include <stdio.h>+#include <stdlib.h>+#include <string.h>+#include "hexml.c"++int main(int ac, char** av)+{+#ifdef __AFL_HAVE_MANUAL_CONTROL+ __AFL_INIT();+#endif++ FILE *f = fopen(av[1], "rb");+ fseek(f, 0, SEEK_END);+ size_t fsize = ftell(f);+ rewind(f);++ char* string = malloc(fsize+1);+ memset(string, 0, fsize+1);+ (void) fread(string, fsize, 1, f);+ fclose(f);++ document *doc = hexml_document_parse(string, fsize);+ hexml_document_free(doc);+ free(string);+ return 0;+}
cbits/hexml.c view
@@ -240,7 +240,7 @@ done = 1; } -static inline bool is(char c, char tag) { return parse_table[c] & tag; }+static inline bool is(char c, char tag) { return parse_table[(unsigned char) c] & tag; } static inline bool is_name1(char c) { return is(c, tag_name1); } static inline bool is_name(char c) { return is(c, tag_name); } static inline bool is_space(char c) { return is(c, tag_space); }
+ cbits/main.c view
@@ -0,0 +1,46 @@+#include "hexml.h"+#include <stdio.h>+#include <malloc.h>+#include <time.h>+#include <string.h>+#include <assert.h>++char* readFile(char* file)+{+ FILE* f = fopen(file, "rb");+ fseek(f, 0, SEEK_END);+ int len = ftell(f);+ fseek(f, 0, SEEK_SET);+ char* res = malloc(len + 1);+ assert(res);+ res[len] = 0;+ size_t n = fread(res, 1, len, f);+ assert(n == len);+ fclose(f);+ return res;+}++char* example = "<?xml version=\"1.0\" lang=\"ja\"?><foo><bar baz=\"qux\">quux</bar><bar baz=\"bar\">hoge</bar><piyo>>piyopiyo<</piyo></foo><foo2 />";++int main(int argc, char **argv)+{+ setbuf(stdout, NULL);+ char* body = argv[1] == NULL ? example : readFile(argv[1]);+ document* doc = hexml_document_parse(body, -1);+ char* err = hexml_document_error(doc);+ if (err == NULL)+ {+ int len = hexml_node_render(doc, hexml_document_node(doc), NULL, 0);+ char* s = malloc(len + 1);+ assert(s);+ hexml_node_render(doc, hexml_document_node(doc), s, len);+ s[len] = 0;+ printf("Parse successful\n"); // , %s\n", s);+ return 0;+ }+ else+ {+ printf("Parse failed, %s\n", err);+ return 1;+ }+}
hexml.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: hexml-version: 0.3+version: 0.3.1 license: BSD3 license-file: LICENSE category: XML