commit 7fd65102614838dcd44d250892a6cc6a934871aa
parent de425062f40d95fbd30d0ab030969cb6a1251c12
Author: hhvn <dev@hhvn.uk>
Date: Sat, 19 Mar 2022 17:02:31 +0000
Smarter author padding.
Previously, if one author length exceeded maxauthwidth, then the padding
would be set to maxauthwidth. Now it is only the max length that does
not exceed maxauthwidth.
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/sfeed_curses.c b/sfeed_curses.c
@@ -1098,7 +1098,7 @@ feed_items_get(struct feed *f, FILE *fp, struct items *itemsret)
struct item *item, *items = NULL;
char *line = NULL;
size_t cap, i, linesize = 0, nitems;
- ssize_t linelen;
+ ssize_t linelen, authlen;
off_t offset;
int ret = -1;
size_t mauthw = 0;
@@ -1133,8 +1133,9 @@ feed_items_get(struct feed *f, FILE *fp, struct items *itemsret)
#else
linetoitem(estrdup(line), item);
#endif
- if (maxauthwidth && strlen(item->fields[FieldAuthor]) > mauthw)
- mauthw = strlen(item->fields[FieldAuthor]);
+ authlen = strlen(item->fields[FieldAuthor]);
+ if (authlen > mauthw && authlen <= maxauthwidth)
+ mauthw = authlen;
nitems++;
}
if (ferror(fp))
@@ -1148,7 +1149,7 @@ err:
itemsret->cap = cap;
itemsret->items = items;
itemsret->len = nitems;
- itemsret->mauthw = mauthw < maxauthwidth ? mauthw : maxauthwidth;
+ itemsret->mauthw = mauthw;
free(line);
if (ret)