From c866692bf04c8d52a9dfc97fcd019cdca4c79ea8 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 8 Oct 2018 10:03:12 -0400 Subject: replace while loops with equivalent for loops --- color-ls | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/color-ls b/color-ls index 5b0930f..16ba632 100755 --- a/color-ls +++ b/color-ls @@ -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++; } } -- cgit v1.2.1