use string length from xml_entitytostr, save a few lines - grabtitle - stupid HTML title grabber
(HTM) git clone git://git.codemadness.org/grabtitle
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 20cf1608ad4cae4c89101350da8d11c9f23512b1
(DIR) parent fee48ebf0343f68a35c2b65a0f2d82e8ac803725
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
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(-)
---
(DIR) 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))