summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2014-11-17 00:04:58 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2014-11-17 00:04:58 +0100
commit93f397c19641e0c1da7ab41cbd91c57b0a750f9a (patch)
tree2ec148480ad8830e76f0f587aa1ac7f3bcf49fb2
parent242559a6cdfe5ad7d021a50995bda916ee41dfc8 (diff)
code-style, ugly test-code (remove later)
-rw-r--r--TODO9
-rw-r--r--xml.c30
2 files changed, 30 insertions, 9 deletions
diff --git a/TODO b/TODO
index 7c04881..8011deb 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,12 @@
+[ ] check read errors:
+ ferror, return code of fread, fwrite, fclose...
+
+[x] handle invalid value in strtoul.
+[x] compile with -Wextra and use (void) to ignore unused parameters?
+[x] use uint32_t for codepointtoutf8?
+
+[ ] separate codepointtoutf8 and entity handling from sfeed.c into xml.c?
+
[ ] test again on:
- Linux (glibc+gcc, musl-gcc, clang, tcc).
- OpenBSD
diff --git a/xml.c b/xml.c
index 70b1c5e..0e91cad 100644
--- a/xml.c
+++ b/xml.c
@@ -1,13 +1,20 @@
+#include <ctype.h>
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
-#include <ctype.h>
+#include <string.h>
#include "xml.h"
static __inline__ int /* like getc(), but do some smart buffering */
-xmlparser_getnext(XMLParser *x) {
- return fgetc(x->fp);
+xmlparser_getnext(XMLParser *x)
+{
+ int c;
+ if(ferror(x->fp))
+ return EOF;
+ if(feof(x->fp))
+ return EOF;
+ c = fgetc(x->fp);
+ return c;
#if 0
if(x->readoffset >= x->readlastbytes) {
x->readoffset = 0;
@@ -19,7 +26,8 @@ xmlparser_getnext(XMLParser *x) {
}
static __inline__ void
-xmlparser_parseattrs(XMLParser *x) {
+xmlparser_parseattrs(XMLParser *x)
+{
size_t namelen = 0, valuelen;
int c, endsep, endname = 0;
@@ -113,7 +121,8 @@ xmlparser_parseattrs(XMLParser *x) {
}
static __inline__ void
-xmlparser_parsecomment(XMLParser *x) {
+xmlparser_parsecomment(XMLParser *x)
+{
size_t datalen = 0, i = 0;
int c;
@@ -158,7 +167,8 @@ xmlparser_parsecomment(XMLParser *x) {
*
*/
static __inline__ void
-xmlparser_parsecdata(XMLParser *x) {
+xmlparser_parsecdata(XMLParser *x)
+{
size_t datalen = 0, i = 0;
int c;
@@ -195,13 +205,15 @@ xmlparser_parsecdata(XMLParser *x) {
}
void
-xmlparser_init(XMLParser *x, FILE *fp) {
+xmlparser_init(XMLParser *x, FILE *fp)
+{
memset(x, 0, sizeof(XMLParser));
x->fp = fp;
}
void
-xmlparser_parse(XMLParser *x) {
+xmlparser_parse(XMLParser *x)
+{
int c, ispi;
size_t datalen, tagdatalen, taglen;