* src/main.c: Replace inline array length computation with ARRAYLEN.
* src/function.c: Ditto.
* src/read.h: Ditto.
FT_ENTRY ("not", 0, 1, 1, func_not),
#endif
};
-
-#define FUNCTION_TABLE_ENTRIES (sizeof (function_table_init) / sizeof (struct function_table_entry))
\f
/* These must come after the definition of function_table. */
void
hash_init_function_table (void)
{
- hash_init (&function_table, FUNCTION_TABLE_ENTRIES * 2,
+ hash_init (&function_table, ARRAYLEN (function_table_init) * 2,
function_table_entry_hash_1, function_table_entry_hash_2,
function_table_entry_hash_cmp);
hash_load (&function_table, function_table_init,
- FUNCTION_TABLE_ENTRIES, sizeof (struct function_table_entry));
+ ARRAYLEN (function_table_init), sizeof (struct function_table_entry));
}
\f
/* Parsing of arguments, decoding of switches. */
-static char options[1 + sizeof (switches) / sizeof (switches[0]) * 3];
-static struct option long_options[(sizeof (switches) / sizeof (switches[0])) +
- (sizeof (long_option_aliases) /
- sizeof (long_option_aliases[0]))];
+static char options[1 + ARRAYLEN (switches) * 3];
+static struct option long_options[ARRAYLEN (switches) + ARRAYLEN (long_option_aliases)];
/* Fill in the string and vector for getopt. */
static void
}
}
*p = '\0';
- for (c = 0; c < (sizeof (long_option_aliases) /
- sizeof (long_option_aliases[0]));
- ++c)
+ for (c = 0; c < ARRAYLEN (long_option_aliases); ++c)
long_options[i++] = long_option_aliases[c];
long_options[i].name = 0;
}
#define NILF ((floc *)0)
+/* Number of elements in an array. */
+#define ARRAYLEN(_a) (sizeof (_a) / sizeof ((_a)[0]))
+
/* Number of characters in a string constant. Does NOT include the \0 byte. */
#define CSTRLEN(_s) (sizeof (_s)-1)
int disable = 0;
/* Compute the number of pointers we need in the table. */
- idx = sizeof (default_include_directories) / sizeof (const char *);
+ idx = ARRAYLEN (default_include_directories);
if (arg_dirs)
for (cpp = arg_dirs; *cpp != 0; ++cpp)
++idx;