diff options
author | Jakob Kaivo <jkk@ung.org> | 2018-10-08 10:03:12 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2018-10-08 10:03:12 -0400 |
commit | c866692bf04c8d52a9dfc97fcd019cdca4c79ea8 (patch) | |
tree | 57d6700f9364d70365f641560bbcb4813ca02094 | |
parent | b0321db03cb0482f4b75a54cba2d81325c470188 (diff) |
replace while loops with equivalent for loops
-rwxr-xr-x | color-ls | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -39,8 +39,7 @@ _colorize () { } ncolumns = columns / widest; - i = 1; - while (i <= NR) { + for (i = 1; i <= NR; i++) { # FIXME: this is all jacked up printf("%-*s", widest, all[(row * ncolumns) + (i % ncolumns)]); column += widest; @@ -65,15 +64,13 @@ _colorize () { columns = 80; } - i = 1; - while (i <= NR) { + for (i = 1; i <= NR; i++) { printf("%-*s", widest, all[i]); column += widest; if (column > columns) { printf("\n"); column = 0; } - i++; } if (column != 0) { @@ -82,18 +79,14 @@ _colorize () { } function long_output() { - i = 1; - while (i <= NR) { + for (i = 1; i <= NR; i++) { printf("%s\n", file[i]); - i++; } } function comma_output() { - i = 1; - while (i <= NR) { + for (i = 1; i <= NR; i++) { printf("%s%s", i == 1 ? "" : ", ", $0 ); - i++; } } |