diff options
-rw-r--r-- | sfeed_plain.c | 16 | ||||
-rw-r--r-- | util.c | 14 | ||||
-rw-r--r-- | util.h | 1 |
3 files changed, 16 insertions, 15 deletions
diff --git a/sfeed_plain.c b/sfeed_plain.c index f57a8c8..1c86441 100644 --- a/sfeed_plain.c +++ b/sfeed_plain.c @@ -6,20 +6,6 @@ #include "util.h" -static void -printutf8padded(FILE *fp, const char *s, size_t len, int pad) { - size_t n = 0, i; - - for(i = 0; s[i] && n < len; i++) { - /* start of character */ - if((s[i] & 0xc0) != 0x80) - n++; - putc(s[i], fp); - } - for(; n < len; n++) - putc(pad, fp); -} - int main(void) { char *line = NULL, *fields[FieldLast]; @@ -39,7 +25,7 @@ main(void) { if(fields[FieldFeedName][0] != '\0') printf("%-15.15s ", fields[FieldFeedName]); printf("%-30.30s ", fields[FieldTimeFormatted]); - printutf8padded(stdout, fields[FieldTitle], 70, ' '); + printutf8pad(stdout, fields[FieldTitle], 70, ' '); fputs(" ", stdout); if(fields[FieldBaseSiteUrl][0] != '\0') printlink(fields[FieldLink], fields[FieldBaseSiteUrl], stdout); @@ -135,3 +135,17 @@ feedsfree(struct feed *f) { free(f); } } + +void +printutf8pad(FILE *fp, const char *s, size_t len, int pad) { + size_t n = 0, i; + + for(i = 0; s[i] && n < len; i++) { + /* start of character */ + if((s[i] & 0xc0) != 0x80) + n++; + putc(s[i], fp); + } + for(; n < len; n++) + putc(pad, fp); +} @@ -23,3 +23,4 @@ unsigned int parseline(char **line, size_t *size, char **fields, void printfeednameid(const char *s, FILE *fp); void printhtmlencoded(const char *s, FILE *fp); void printlink(const char *link, const char *baseurl, FILE *fp); +void printutf8pad(FILE *fp, const char *s, size_t len, int pad); |