diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-10-02 17:31:04 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-10-02 17:31:04 +0200 |
commit | f9d8ddb73c6297de4702cde6382db6378786d420 (patch) | |
tree | 7d0c722f33f4b2bc79ddf7e9e103ac1cbbca4697 | |
parent | ba23401be93d75733d3824d145dd6ca54fa76fa8 (diff) |
sfeed: fix escape of backslash, simplify
-rw-r--r-- | sfeed.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -378,22 +378,22 @@ string_print_encoded(String *s) return; /* skip leading whitespace */ - for (p = s->data; *p && isspace((int)*p); p++) + for (p = s->data; *p && ISSPACE((int)*p); p++) ; /* seek offset of trailing whitespace */ - for (e = p + strlen(p); e > p && isspace((int)*(e - 1)); e--) + for (e = p + strlen(p); e > p && ISSPACE((int)*(e - 1)); e--) ; for (; *p && p != e; p++) { - if (isspace((int)*p) && *p != ' ') { - switch (*p) { - case '\n': fputs("\\n", stdout); break; - case '\\': fputs("\\\\", stdout); break; - case '\t': fputs("\\t", stdout); break; - default: break; /* ignore other whitespace chars */ - } - } else if (!iscntrl((int)*p)) { /* ignore control chars */ - putchar(*p); + switch (*p) { + case '\n': fputs("\\n", stdout); break; + case '\\': fputs("\\\\", stdout); break; + case '\t': fputs("\\t", stdout); break; + default: + /* ignore control chars */ + if (!ISCONTROL((int)*p)) + putchar(*p); + break; } } } |