util: printescape(): it's enough to set a flag, no counter needed - tscrape - t… | |
git clone git://git.codemadness.org/tscrape | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 8e11f80c105f02b55641d9068d03448a6ffc1ea3 | |
parent 9a0c90f26b3eef023910a699c7385b709a01ce90 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Fri, 20 Mar 2020 19:09:49 +0100 | |
util: printescape(): it's enough to set a flag, no counter needed | |
Diffstat: | |
M util.c | 10 +++++----- | |
1 file changed, 5 insertions(+), 5 deletions(-) | |
--- | |
diff --git a/util.c b/util.c | |
@@ -110,7 +110,7 @@ printutf8pad(FILE *fp, const char *s, size_t len, int pad) | |
void | |
printescape(const char *s) | |
{ | |
- size_t i; | |
+ int r; | |
const char *e; | |
/* strip leading and trailing white-space */ | |
@@ -119,13 +119,13 @@ printescape(const char *s) | |
for (e = s + strlen(s); e > s && isspace((unsigned char)*(e - 1)); e--) | |
; | |
- for (i = 0; *s && s < e; s++) { | |
+ for (r = 0; *s && s < e; s++) { | |
if (iscntrl((unsigned char)*s) || isspace((unsigned char)*s)) { | |
- i++; | |
+ r = 1; | |
continue; | |
} | |
- if (i) { | |
- i = 0; | |
+ if (r) { | |
+ r = 0; | |
putchar(' '); | |
} | |
putchar(*s); |