sfeed

Simple RSS and Atom feed parser
git clone https://git.sinitax.com/codemadness/sfeed
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit 0091772bf234cabaa318ececdd6e261e712c654a
parent ba370db56dae47a88aed8257c7f63417aaf7d856
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 19 Apr 2014 21:08:01 +0200

cleanup

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>

Diffstat:
Msfeed.c | 35++++++++++++++++++-----------------
Msfeed_xmlenc.c | 2+-
2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/sfeed.c b/sfeed.c @@ -103,23 +103,24 @@ gettag(int feedtype, const char *name, size_t namelen) { }; int i, n; - if(namelen >= 2 && namelen <= 15) { - if(feedtype == FeedTypeRSS) { - for(i = 0; rsstag[i].name; i++) { - if(!(n = strncasecmp(rsstag[i].name, name, rsstag[i].namelen))) - return rsstag[i].id; - /* optimization: it's sorted so nothing after it matches. */ - if(n > 0) - return TagUnknown; - } - } else if(feedtype == FeedTypeAtom) { - for(i = 0; atomtag[i].name; i++) { - if(!(n = strncasecmp(atomtag[i].name, name, atomtag[i].namelen))) - return atomtag[i].id; - /* optimization: it's sorted so nothing after it matches. */ - if(n > 0) - return TagUnknown; - } + if(namelen < 2 || namelen > 15) /* optimization */ + return TagUnknown; + + if(feedtype == FeedTypeRSS) { + for(i = 0; rsstag[i].name; i++) { + if(!(n = strncasecmp(rsstag[i].name, name, rsstag[i].namelen))) + return rsstag[i].id; + /* optimization: it's sorted so nothing after it matches. */ + if(n > 0) + return TagUnknown; + } + } else if(feedtype == FeedTypeAtom) { + for(i = 0; atomtag[i].name; i++) { + if(!(n = strncasecmp(atomtag[i].name, name, atomtag[i].namelen))) + return atomtag[i].id; + /* optimization: it's sorted so nothing after it matches. */ + if(n > 0) + return TagUnknown; } } return TagUnknown; diff --git a/sfeed_xmlenc.c b/sfeed_xmlenc.c @@ -12,7 +12,7 @@ static void xmltagstart(XMLParser *p, const char *tag, size_t taglen) { if(tags > 3) /* optimization: try to find processing instruction at start */ exit(EXIT_FAILURE); - isxmlpi = (tag[0] == '?' && (!strncasecmp(tag, "?xml", taglen))) ? 1 : 0; + isxmlpi = (!strncasecmp(tag, "?xml", taglen)) ? 1 : 0; tags++; }