From 79eb0f67b83fca3d8917845fe0c913cd0e10e2f2 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Thu, 8 May 2014 14:59:03 +0000 Subject: style: linewrap, etc Signed-off-by: Hiltjo Posthuma --- sfeed.c | 3 ++- xml.c | 18 ++++++++++++------ xml.h | 28 +++++++++++++++++++--------- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/sfeed.c b/sfeed.c index cc1e966..0cfcdb3 100644 --- a/sfeed.c +++ b/sfeed.c @@ -688,7 +688,8 @@ xml_handler_end_element(XMLParser *p, const char *name, size_t namelen, int issh /* not sure if needed */ ctx.iscontenttag = 0; ctx.iscontent = 0; - } else if(!strcmp(ctx.tag, name)) { /* clear */ /* XXX: optimize ? */ + } else if(!strcmp(ctx.tag, name)) { /* clear */ + /* XXX: optimize ? */ ctx.field = NULL; ctx.tag[0] = '\0'; /* unset tag */ ctx.taglen = 0; diff --git a/xml.c b/xml.c index 88b2e95..fdb6209 100644 --- a/xml.c +++ b/xml.c @@ -28,12 +28,13 @@ xmlparser_parseattrs(XMLParser *x) { while((c = xmlparser_getnext(x)) != EOF) { if(isspace(c)) { /* TODO: simplify endname ? */ - if(namelen) /* do nothing */ + if(namelen) endname = 1; else continue; } - if(c == '?'); /* ignore */ + if(c == '?') + ; /* ignore */ else if(c == '=') { x->name[namelen] = '\0'; } else if(namelen && ((endname && isalpha(c)) || (c == '>' || c == '/'))) { @@ -66,7 +67,8 @@ xmlparser_parseattrs(XMLParser *x) { break; if(valuelen < sizeof(x->data) - 1) x->data[valuelen++] = c; - else { /* TODO: entity too long? this should be very strange. */ + else { + /* TODO: entity too long? this should be very strange. */ x->data[valuelen] = '\0'; if(x->xmlattr) x->xmlattr(x, x->tag, x->taglen, x->name, namelen, x->data, valuelen); @@ -138,7 +140,9 @@ xmlparser_parsecomment(XMLParser *x) { } i = 0; } - if(datalen < sizeof(x->data) - 1) /* || (c == '-' && d >= sizeof(x->data) - 4)) { */ /* TODO: what if the end has --, and its cut on the boundary, test this. */ + /* || (c == '-' && d >= sizeof(x->data) - 4)) { */ + /* TODO: what if the end has --, and its cut on the boundary, test this. */ + if(datalen < sizeof(x->data) - 1) x->data[datalen++] = c; else { x->data[datalen] = '\0'; @@ -181,7 +185,8 @@ xmlparser_parsecdata(XMLParser *x) { } i = 0; } - if(datalen < sizeof(x->data) - 1) { /* TODO: what if the end has ]>, and its cut on the boundary */ + /* TODO: what if the end has ]>, and its cut on the boundary */ + if(datalen < sizeof(x->data) - 1) { x->data[datalen++] = c; } else { x->data[datalen] = '\0'; @@ -266,7 +271,8 @@ xmlparser_parse(XMLParser *x) { x->tag[taglen++] = c; } } - } else { /* parse data */ + } else { + /* parse data */ datalen = 0; if(x->xmldatastart) x->xmldatastart(x); diff --git a/xml.h b/xml.h index 5a01078..46634eb 100644 --- a/xml.h +++ b/xml.h @@ -5,21 +5,31 @@ typedef struct xmlparser { /* handlers */ void (*xmltagstart)(struct xmlparser *p, const char *tag, size_t taglen); - void (*xmltagstartparsed)(struct xmlparser *p, const char *tag, size_t taglen, int isshort); - void (*xmltagend)(struct xmlparser *p, const char *tag, size_t taglen, int isshort); + void (*xmltagstartparsed)(struct xmlparser *p, const char *tag, + size_t taglen, int isshort); + void (*xmltagend)(struct xmlparser *p, const char *tag, size_t taglen, + int isshort); void (*xmldatastart)(struct xmlparser *p); void (*xmldata)(struct xmlparser *p, const char *data, size_t datalen); void (*xmldataend)(struct xmlparser *p); - void (*xmldataentity)(struct xmlparser *p, const char *data, size_t datalen); - void (*xmlattrstart)(struct xmlparser *p, const char *tag, size_t taglen, const char *name, size_t namelen); - void (*xmlattr)(struct xmlparser *p, const char *tag, size_t taglen, const char *name, size_t namelen, const char *value, size_t valuelen); - void (*xmlattrend)(struct xmlparser *p, const char *tag, size_t taglen, const char *name, size_t namelen); - void (*xmlattrentity)(struct xmlparser *p, const char *tag, size_t taglen, const char *name, size_t namelen, const char *value, size_t valuelen); + void (*xmldataentity)(struct xmlparser *p, const char *data, + size_t datalen); + void (*xmlattrstart)(struct xmlparser *p, const char *tag, size_t taglen, + const char *name, size_t namelen); + void (*xmlattr)(struct xmlparser *p, const char *tag, size_t taglen, + const char *name, size_t namelen, const char *value, + size_t valuelen); + void (*xmlattrend)(struct xmlparser *p, const char *tag, size_t taglen, + const char *name, size_t namelen); + void (*xmlattrentity)(struct xmlparser *p, const char *tag, size_t taglen, + const char *name, size_t namelen, const char *value, + size_t valuelen); void (*xmlcdatastart)(struct xmlparser *p); void (*xmlcdata)(struct xmlparser *p, const char *data, size_t datalen); void (*xmlcdataend)(struct xmlparser *p); void (*xmlcommentstart)(struct xmlparser *p); - void (*xmlcomment)(struct xmlparser *p, const char *comment, size_t commentlen); + void (*xmlcomment)(struct xmlparser *p, const char *comment, + size_t commentlen); void (*xmlcommentend)(struct xmlparser *p); FILE *fp; /* file stream to read from */ @@ -32,7 +42,7 @@ typedef struct xmlparser { char data[BUFSIZ]; /* data buffer used for tag and attribute data */ size_t readoffset; size_t readlastbytes; - unsigned char readbuf[BUFSIZ]; /* read buffer used by xmlparser_getnext() */ + unsigned char readbuf[BUFSIZ]; /* read buffer used by xmlparser_getnext */ } XMLParser; void xmlparser_init(XMLParser *x, FILE *fp); -- cgit v1.2.3