diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-01-02 21:14:07 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-01-02 21:14:07 +0100 |
commit | 86993965de423bdd9f4cfb146929a1cdd9fbc0b2 (patch) | |
tree | 22657797ec44c475d3ae29e24a77764dfef390bb /sfeed.c | |
parent | 43f02f646c97ddbc4dc41fe9e119506cf95e0b28 (diff) |
trim string
Diffstat (limited to 'sfeed.c')
-rw-r--r-- | sfeed.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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); + } } } |