summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2014-11-11 19:11:56 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2014-11-11 19:11:56 +0100
commit4d6e19edcf9c031ef8195148d86bf499e3c285da (patch)
treed0c6cbcc69683e58d86c4ecdbe1cc76d139af1e7
parent2416e28bbc74959fcd5b9371c19152ec3d0c3d78 (diff)
move printutf8padded to util
-rw-r--r--sfeed_plain.c16
-rw-r--r--util.c14
-rw-r--r--util.h1
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);
diff --git a/util.c b/util.c
index 776a579..618080e 100644
--- 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
index c3b5f1e..db9ef4c 100644
--- 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);