diff options
| author | Collin Funk <collin.funk1@gmail.com> | 2025-09-23 19:17:14 -0700 |
|---|---|---|
| committer | Collin Funk <collin.funk1@gmail.com> | 2025-09-24 17:31:57 -0700 |
| commit | 1bc5ec61d8d960e1679b42f55c8f96992ced34ef (patch) | |
| tree | aa458fa9307db7b5b4a9e7704eccc515842112ba /src/ls.c | |
| parent | tail: fix tailing larger number of lines in regular files (diff) | |
| download | coreutils-1bc5ec61d8d960e1679b42f55c8f96992ced34ef.tar.gz coreutils-1bc5ec61d8d960e1679b42f55c8f96992ced34ef.zip | |
maint: prefer countof over ARRAY_CARDINALITY
* bootstrap.conf (gnulib_modules): Add stdcountof-h.
* src/system.h: Include stdcountof.h.
(ARRAY_CARDINALITY): Remove definition.
* .gitignore (/lib/stdcountof.h): Ignore Gnulib generated file.
* src/csplit.c: Use countof instead of ARRAY_CARDINALITY.
* src/df.c: Likewise.
* src/digest.c: Likewise.
* src/dircolors.c: Likewise.
* src/factor.c: Likewise.
* src/join.c: Likewise.
* src/ls.c: Likewise.
* src/od.c: Likewise.
* src/sort.c: Likewise.
* src/stdbuf.c: Likewise.
* src/tr.c: Likewise.
Diffstat (limited to 'src/ls.c')
| -rw-r--r-- | src/ls.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -180,7 +180,7 @@ enum { filetype_cardinality = arg_directory + 1 }; Keep these in sync with enum filetype. */ static char const filetype_letter[] = {'?', 'p', 'c', 'd', 'b', '-', 'l', 's', 'w', 'd'}; -static_assert (ARRAY_CARDINALITY (filetype_letter) == filetype_cardinality); +static_assert (countof (filetype_letter) == filetype_cardinality); /* Map enum filetype to <dirent.h> d_type values. */ static unsigned char const filetype_d_type[] = @@ -188,7 +188,7 @@ static unsigned char const filetype_d_type[] = DT_UNKNOWN, DT_FIFO, DT_CHR, DT_DIR, DT_BLK, DT_REG, DT_LNK, DT_SOCK, DT_WHT, DT_DIR }; -static_assert (ARRAY_CARDINALITY (filetype_d_type) == filetype_cardinality); +static_assert (countof (filetype_d_type) == filetype_cardinality); /* Map d_type values to enum filetype. */ static char const d_type_filetype[UCHAR_MAX + 1] = @@ -1621,7 +1621,7 @@ signal_setup (bool init) SIGXFSZ, #endif }; - enum { nsigs = ARRAY_CARDINALITY (sig) }; + enum { nsigs = countof (sig) }; #if ! SA_NOCLDSTOP static bool caught_sig[nsigs]; @@ -1705,8 +1705,7 @@ main (int argc, char **argv) initialize_exit_failure (LS_FAILURE); atexit (close_stdout); - static_assert (ARRAY_CARDINALITY (color_indicator) - == ARRAY_CARDINALITY (indicator_name)); + static_assert (countof (color_indicator) == countof (indicator_name)); exit_status = EXIT_SUCCESS; print_dir_name = true; @@ -2823,7 +2822,7 @@ parse_ls_color (void) state = PS_FAIL; /* Assume failure... */ if (*(p++) == '=')/* It *should* be... */ { - for (int i = 0; i < ARRAY_CARDINALITY (indicator_name); i++) + for (int i = 0; i < countof (indicator_name); i++) { if ((label0 == indicator_name[i][0]) && (label1 == indicator_name[i][1])) @@ -4036,8 +4035,7 @@ static qsortFunc const sort_functions[][2][2][2] = This line verifies at compile-time that the array of sort functions has been initialized for all possible sort keys. */ -static_assert (ARRAY_CARDINALITY (sort_functions) - == sort_numtypes - 2 + time_numtypes); +static_assert (countof (sort_functions) == sort_numtypes - 2 + time_numtypes); /* Set up SORTED_FILE to point to the in-use entries in CWD_FILE, in order. */ @@ -4986,8 +4984,7 @@ get_color_indicator (const struct fileinfo *f, bool symlink_target) C_ORPHAN, C_FIFO, C_CHR, C_DIR, C_BLK, C_FILE, C_LINK, C_SOCK, C_FILE, C_DIR }; - static_assert (ARRAY_CARDINALITY (filetype_indicator) - == filetype_cardinality); + static_assert (countof (filetype_indicator) == filetype_cardinality); type = filetype_indicator[f->filetype]; } else |
