diff options
author | Jim Meyering <meyering@redhat.com> | 2009-05-17 13:02:25 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-05-17 13:59:12 +0200 |
commit | 9593a3d8e78ece58deab5a30632021322bbc16d0 (patch) | |
tree | a2f3e289371a2d3e78eb2ca3a35c99c0b54c8d4c /src | |
parent | 65ed4ca07bd18c2038b5863ed1e18d3bfc8e696d (diff) | |
download | coreutils-9593a3d8e78ece58deab5a30632021322bbc16d0.tar.xz |
maint: use ARRAY_CARDINALITY more
* src/sort.c (main): Use ARRAY_CARDINALITY, rather than open-coding it.
* src/factor.c (WHEEL_END): Likewise.
* src/csplit.c (main): Likewise.
* src/od.c: Likewise,
* src/ls.c (main): Likewise.
(N_ENTRIES): Remove definition. Use ARRAY_CARDINALITY instead.
* src/dircolors.c: Likewise.
(array_len): Remove definition.
Diffstat (limited to 'src')
-rw-r--r-- | src/csplit.c | 2 | ||||
-rw-r--r-- | src/dircolors.c | 5 | ||||
-rw-r--r-- | src/factor.c | 2 | ||||
-rw-r--r-- | src/ls.c | 6 | ||||
-rw-r--r-- | src/od.c | 7 | ||||
-rw-r--r-- | src/sort.c | 2 |
6 files changed, 11 insertions, 13 deletions
diff --git a/src/csplit.c b/src/csplit.c index 4f0beb6c4..b2892c917 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -1403,7 +1403,7 @@ main (int argc, char **argv) SIGXFSZ, #endif }; - enum { nsigs = sizeof sig / sizeof sig[0] }; + enum { nsigs = ARRAY_CARDINALITY (sig) }; struct sigaction act; diff --git a/src/dircolors.c b/src/dircolors.c index 7dad7fd9b..f01d5575f 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -1,5 +1,5 @@ /* dircolors - output commands to set the LS_COLOR environment variable - Copyright (C) 1996-2008 Free Software Foundation, Inc. + Copyright (C) 1996-2009 Free Software Foundation, Inc. Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000 H. Peter Anvin This program is free software: you can redistribute it and/or modify @@ -73,8 +73,7 @@ static const char *const ls_codes[] = "so", "bd", "bd", "cd", "cd", "do", "ex", "lc", "lc", "rc", "rc", "ec", "ec", "su", "su", "sg", "sg", "st", "ow", "ow", "tw", "tw", "ca", "hl", "cl", NULL }; -#define array_len(Array) (sizeof (Array) / sizeof *(Array)) -verify (array_len (slack_codes) == array_len (ls_codes)); +verify (ARRAY_CARDINALITY (slack_codes) == ARRAY_CARDINALITY (ls_codes)); static struct option const long_options[] = { diff --git a/src/factor.c b/src/factor.c index 47273a2bc..9ac703ce8 100644 --- a/src/factor.c +++ b/src/factor.c @@ -282,7 +282,7 @@ static const unsigned char wheel_tab[] = }; #define WHEEL_START (wheel_tab + WHEEL_SIZE) -#define WHEEL_END (wheel_tab + (sizeof wheel_tab / sizeof wheel_tab[0])) +#define WHEEL_END (wheel_tab + ARRAY_CARDINALITY (wheel_tab)) /* FIXME: comment */ @@ -1223,7 +1223,7 @@ main (int argc, char **argv) SIGXFSZ, #endif }; - enum { nsigs = sizeof sig / sizeof sig[0] }; + enum { nsigs = ARRAY_CARDINALITY (sig) }; #if ! SA_NOCLDSTOP bool caught_sig[nsigs]; @@ -1238,8 +1238,8 @@ main (int argc, char **argv) initialize_exit_failure (LS_FAILURE); atexit (close_stdout); -#define N_ENTRIES(Array) (sizeof Array / sizeof *(Array)) - assert (N_ENTRIES (color_indicator) + 1 == N_ENTRIES (indicator_name)); + assert (ARRAY_CARDINALITY (color_indicator) + 1 + == ARRAY_CARDINALITY (indicator_name)); exit_status = EXIT_SUCCESS; print_dir_name = true; @@ -1,5 +1,5 @@ /* od -- dump files in octal and other formats - Copyright (C) 92, 1995-2008 Free Software Foundation, Inc. + Copyright (C) 92, 1995-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -148,8 +148,7 @@ static unsigned int const bytes_to_hex_digits[] = /* It'll be a while before we see integral types wider than 16 bytes, but if/when it happens, this check will catch it. Without this check, a wider type would provoke a buffer overrun. */ -verify (MAX_INTEGRAL_TYPE_SIZE - < sizeof bytes_to_hex_digits / sizeof *bytes_to_hex_digits); +verify (MAX_INTEGRAL_TYPE_SIZE < ARRAY_CARDINALITY (bytes_to_hex_digits)); /* Make sure the other arrays have the same length. */ verify (sizeof bytes_to_oct_digits == sizeof bytes_to_signed_dec_digits); @@ -172,7 +171,7 @@ static const int width_bytes[] = /* Ensure that for each member of `enum size_spec' there is an initializer in the width_bytes array. */ -verify (sizeof width_bytes / sizeof width_bytes[0] == N_SIZE_SPECS); +verify (ARRAY_CARDINALITY (width_bytes) == N_SIZE_SPECS); /* Names for some non-printing characters. */ static char const charname[33][4] = diff --git a/src/sort.c b/src/sort.c index f48d727df..6dea2ff08 100644 --- a/src/sort.c +++ b/src/sort.c @@ -3104,7 +3104,7 @@ main (int argc, char **argv) SIGXFSZ, #endif }; - enum { nsigs = sizeof sig / sizeof sig[0] }; + enum { nsigs = ARRAY_CARDINALITY (sig) }; #if SA_NOCLDSTOP struct sigaction act; |