`ls`: move width checking to before filename printing.

this matches gnu/posix `ls` more (maybe?).
also it looks better imo
master
Drake 3 years ago
parent e8412ff491
commit 19d0be3cf0

@ -168,6 +168,11 @@ int main(int argc, char **argv) {
strcpy(oldwd, wd);
int currLen = 0;
for (i = 0; i < n; i++) {
currLen += strlen(words[i]);
if (currLen >= maxLen) {
printf("\n");
currLen = 0;
}
if (colour == false) {
printf("%s ", words[i]);
} else {
@ -187,11 +192,6 @@ int main(int argc, char **argv) {
printf("%s ", words[i]);
}
}
currLen += strlen(words[i]);
if (currLen >= maxLen) {
printf("\n");
currLen = 0;
}
}
free(out);
printf("\n");

Loading…
Cancel
Save