sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit 4d6e19edcf9c031ef8195148d86bf499e3c285da
parent 2416e28bbc74959fcd5b9371c19152ec3d0c3d78
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue, 11 Nov 2014 19:11:56 +0100

move printutf8padded to util

Diffstat:
Msfeed_plain.c | 16+---------------
Mutil.c | 14++++++++++++++
Mutil.h | 1+
3 files changed, 16 insertions(+), 15 deletions(-)

diff --git 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); diff --git a/util.c b/util.c @@ -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); +} diff --git a/util.h b/util.h @@ -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);