summaryrefslogtreecommitdiff
path: root/sfeed.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-01-02 21:14:07 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-01-02 21:14:07 +0100
commit86993965de423bdd9f4cfb146929a1cdd9fbc0b2 (patch)
tree22657797ec44c475d3ae29e24a77764dfef390bb /sfeed.c
parent43f02f646c97ddbc4dc41fe9e119506cf95e0b28 (diff)
trim string
Diffstat (limited to 'sfeed.c')
-rw-r--r--sfeed.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sfeed.c b/sfeed.c
index ab7a5b8..39b8a04 100644
--- a/sfeed.c
+++ b/sfeed.c
@@ -313,7 +313,7 @@ gettimetz(const char *s, char *buf, size_t bufsiz)
buf[0] = '\0';
if(bufsiz < sizeof(tzname) + STRSIZ(" -00:00"))
return 0;
- for(; *p && isspace((int)*p); p++); /* skip whitespace */
+ p = trimstart(p);
/* loop until some common timezone delimiters are found */
for(; *p && (*p != '+' && *p != '-' && *p != 'Z' && *p != 'z'); p++);
@@ -383,11 +383,13 @@ parsetime(const char *s, char *buf, size_t bufsiz)
static void
string_print(String *s)
{
- const char *p;
+ const char *p, *e;
/* skip leading whitespace */
- for(p = s->data; *p && isspace((int)*p); p++);
- for(; *p; p++) {
+ p = trimstart(s->data);
+ e = trimend(p);
+
+ for(; *p && p != e; p++) {
if(ISWSNOSPACE(*p)) {
switch(*p) {
case '\n': fputs("\\n", stdout); break;
@@ -395,8 +397,9 @@ string_print(String *s)
case '\t': fputs("\\t", stdout); break;
default: break; /* ignore other whitespace chars */
}
- } else
+ } else {
putchar(*p);
+ }
}
}