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:
Andreas Schulz 1994-12-27 00:53:14 +00:00
parent d5a22d48c4
commit 04dc4fc21c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=5239

View file

@ -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,