From: Paul Eggert Date: Wed, 15 Nov 2023 23:05:17 +0000 (-0800) Subject: uniq: prefer static init X-Git-Tag: v9.5~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bee7c9754b8be39e81c7260d4eac13ce5702dcd;p=thirdparty%2Fcoreutils.git uniq: prefer static init * src/uniq.c (skip_fields, skip_chars, check_chars, count_occurrences) (output_unique, output_first_repeated, output_later_repeated) (delimit_groups): Initialize statically, rather than in ‘main’. This shrinks the executable a bit. --- diff --git a/src/uniq.c b/src/uniq.c index 697fc92212..28982c103e 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -51,24 +51,24 @@ while (0) /* Number of fields to skip on each line when doing comparisons. */ -static idx_t skip_fields; +static idx_t skip_fields = false; /* Number of chars to skip after skipping any fields. */ -static idx_t skip_chars; +static idx_t skip_chars = false; /* Number of chars to compare. */ -static idx_t check_chars; +static idx_t check_chars = IDX_MAX; /* Whether to precede the output lines with a count of the number of times they occurred in the input. */ -static bool count_occurrences; +static bool count_occurrences = false; /* Which lines to output: unique lines, the first of a group of repeated lines, and the second and subsequent of a group of repeated lines. */ -static bool output_unique; -static bool output_first_repeated; -static bool output_later_repeated; +static bool output_unique = true; +static bool output_first_repeated = true; +static bool output_later_repeated = false; /* If true, ignore case when comparing. */ static bool ignore_case; @@ -96,7 +96,7 @@ static enum delimit_method const delimit_method_map[] = }; /* Select whether/how to delimit groups of duplicate lines. */ -static enum delimit_method delimit_groups; +static enum delimit_method delimit_groups = DM_NONE; enum grouping_method { @@ -481,14 +481,6 @@ main (int argc, char **argv) atexit (close_stdout); - skip_chars = 0; - skip_fields = 0; - check_chars = IDX_MAX; - output_unique = output_first_repeated = true; - output_later_repeated = false; - count_occurrences = false; - delimit_groups = DM_NONE; - while (true) { /* Parse an operand with leading "+" as a file after "--" was