My prevoius commit missed some things. The out_line didn't need
to be padded to 8 chars. Simply make sure that never more than 8 chars are printed ( %-.8s ). The former commit otherwise hosed the width calculation and landed on different positions for the time output. Also the strlen(xx_out_line) hoses the wide calculation, so that it sometimes make it much larger than necessary. Simply use always 8 chars for the out_line calculation now. Looks good this way.
This commit is contained in:
parent
bc52f83749
commit
32fbcd2a75
@ -136,7 +136,8 @@ main(argc, argv)
|
||||
mp = myutmp;
|
||||
width = 0;
|
||||
for (i = 0; i < nusers; i++) {
|
||||
int j = strlen(mp->myhost) + 1 + strlen(mp->myutmp.out_line);
|
||||
/* append one for the blank and use 8 for the out_line */
|
||||
int j = strlen(mp->myhost) + 1 + 8;
|
||||
if (j > width)
|
||||
width = j;
|
||||
mp++;
|
||||
@ -144,7 +145,7 @@ main(argc, argv)
|
||||
mp = myutmp;
|
||||
for (i = 0; i < nusers; i++) {
|
||||
char buf[BUFSIZ];
|
||||
(void)sprintf(buf, "%s:%-8.8s", mp->myhost, mp->myutmp.out_line);
|
||||
(void)sprintf(buf, "%s:%-.8s", mp->myhost, mp->myutmp.out_line);
|
||||
printf("%-8.8s %-*s %.12s",
|
||||
mp->myutmp.out_name,
|
||||
width,
|
||||
|
Loading…
x
Reference in New Issue
Block a user