summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-10-02 17:31:04 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-10-02 17:31:04 +0200
commitf9d8ddb73c6297de4702cde6382db6378786d420 (patch)
tree7d0c722f33f4b2bc79ddf7e9e103ac1cbbca4697
parentba23401be93d75733d3824d145dd6ca54fa76fa8 (diff)
sfeed: fix escape of backslash, simplify
-rw-r--r--sfeed.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/sfeed.c b/sfeed.c
index 993f2b2..76f4147 100644
--- a/sfeed.c
+++ b/sfeed.c
@@ -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;
}
}
}