]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
uniq: prefer static init
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 15 Nov 2023 23:05:17 +0000 (15:05 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 16 Nov 2023 19:37:25 +0000 (11:37 -0800)
* 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.

src/uniq.c

index 697fc922124a2df60b3a7b0e054d331eb663a5d4..28982c103e98fb9dd0c8b58ac1fc8de8a9c984c2 100644 (file)
   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