mscan: fix formatting of %f without width, and for %s with width

pull/2/head
Christian Neukirchen 8 years ago
parent d779211dc7
commit a5c5e22204

@ -32,9 +32,11 @@ static int curyday;
static char default_fflag[] = "%c%u%r %-3n %10d %17f %t %2i%s"; static char default_fflag[] = "%c%u%r %-3n %10d %17f %t %2i%s";
static char *fflag = default_fflag; static char *fflag = default_fflag;
void int
u8putstr(FILE *out, char *s, ssize_t l, int pad) u8putstr(FILE *out, char *s, ssize_t l, int pad)
{ {
ssize_t ol = l;
while (*s && l > 0) { while (*s && l > 0) {
if (*s == '\t') if (*s == '\t')
*s = ' '; *s = ' ';
@ -58,6 +60,10 @@ u8putstr(FILE *out, char *s, ssize_t l, int pad)
if (pad) if (pad)
while (l-- > 0) while (l-- > 0)
putc(' ', out); putc(' ', out);
if (l < 0)
l = 0;
return ol - l;
} }
int int
@ -350,8 +356,12 @@ oneline(char *file)
fmt_date(msg, w, Iflag || *f == 'D')); fmt_date(msg, w, Iflag || *f == 'D'));
break; break;
case 'f': case 'f':
u8putstr(stdout, fmt_from(msg), w ? w : 16, 1); if (w)
wleft -= w > 0 ? w : -w; wleft -= u8putstr(stdout,
fmt_from(msg), w, 1);
else
wleft -= u8putstr(stdout,
fmt_from(msg), wleft, 0);
break; break;
case 'i': case 'i':
{ {
@ -370,9 +380,12 @@ oneline(char *file)
} }
break; break;
case 's': case 's':
if (!w) w = wleft; if (w)
u8putstr(stdout, fmt_subject(msg, file), wleft, 0); wleft -= u8putstr(stdout,
wleft -= w; fmt_subject(msg, file), w, 1);
else
wleft -= u8putstr(stdout,
fmt_subject(msg, file), wleft, 0);
break; break;
case 'b': case 'b':
{ {

Loading…
Cancel
Save