commit 7a31e4fcdca0f2f82e9fea143dc157607a811ccf
parent 07692ff2b49ab52c4ae4635891b248ff5cde6ae2
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 8 Apr 2014 15:09:52 +0200
sfeed: simplify, comment old code
this might be alot slower, but also more clear (test this later).
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
Diffstat:
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/sfeed.c b/sfeed.c
@@ -151,7 +151,7 @@ namedentitytostr(const char *e, char *buffer, size_t bufsiz) {
{ NULL, NULL }
};
size_t i;
- if(*e != '&' || bufsiz < 2) /* doesnt start with & */
+ if(*e != '&' || bufsiz < 2) /* doesn't start with & */
return 0;
for(i = 0; entities[i][0]; i++) {
/* NOTE: compares max 7 chars */
@@ -356,13 +356,22 @@ parsetime(const char *s, char *buf, size_t bufsiz) {
static void
string_print(String *s) {
const char *p;
- char buffer[BUFSIZ + 4];
- size_t i;
+/* char buffer[BUFSIZ + 4];
+ size_t i;*/
if(!s->len)
return;
/* skip leading whitespace */
for(p = s->data; *p && isspace((int)*p); p++);
+ for(; *p; p++) {
+ switch(*p) {
+ case '\n': fputs("\\n", stdout); break;
+ case '\\': fputs("\\\\", stdout); break;
+ case '\t': fputs("\\t", stdout); break;
+ default: putchar(*p); break;
+ }
+ }
+#if 0
for(i = 0; *p; p++) {
if(ISWSNOSPACE(*p)) { /* isspace(c) && c != ' ' */
if(*p == '\n') { /* escape newline */
@@ -386,6 +395,7 @@ string_print(String *s) {
}
if(i) /* write remaining */
fwrite(buffer, 1, i, stdout);
+#endif
}
static int