use string length from xml_entitytostr, save a few lines - grabtitle - stupid H… | |
git clone git://git.codemadness.org/grabtitle | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 20cf1608ad4cae4c89101350da8d11c9f23512b1 | |
parent fee48ebf0343f68a35c2b65a0f2d82e8ac803725 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Sat, 31 Mar 2018 13:43:34 +0200 | |
use string length from xml_entitytostr, save a few lines | |
Diffstat: | |
M title.c | 9 ++++----- | |
1 file changed, 4 insertions(+), 5 deletions(-) | |
--- | |
diff --git a/title.c b/title.c | |
@@ -39,9 +39,7 @@ xmltagend(XMLParser *p, const char *t, size_t tl, int isshort) | |
static void | |
xmldata(XMLParser *p, const char *d, size_t dl) | |
{ | |
- if (!istitle) | |
- return; | |
- if (titlelen + dl + 1 >= sizeof(title)) | |
+ if (!istitle || titlelen + dl + 1 >= sizeof(title)) | |
return; | |
memcpy(title + titlelen, d, dl); | |
titlelen += dl; | |
@@ -52,13 +50,14 @@ static void | |
xmldataentity(XMLParser *p, const char *d, size_t dl) | |
{ | |
char buf[16]; | |
+ ssize_t len; | |
if (!istitle) | |
return; | |
- if (xml_entitytostr(d, buf, sizeof(buf))) { | |
+ if ((len = xml_entitytostr(d, buf, sizeof(buf)))) { | |
d = buf; | |
- dl = strlen(buf); | |
+ dl = len; | |
} | |
if (titlelen + dl + 1 >= sizeof(title)) |