]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: tac: prefer static initialization
authorCollin Funk <collin.funk1@gmail.com>
Fri, 20 Feb 2026 05:08:43 +0000 (21:08 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Fri, 20 Feb 2026 05:08:43 +0000 (21:08 -0800)
* src/tac.c (separator, separator_ends_record, sentinel_length):
Initialize variables.
(main): Remove unnecessary initializations.

src/tac.c

index 161a5ea4ee6aca56cc4d34e7792a73d3c03e9c04..4cab99d0b318490bf38181a89efa20a095b0702b 100644 (file)
--- a/src/tac.c
+++ b/src/tac.c
@@ -63,19 +63,19 @@ tac -r -s '.\|
 #define WRITESIZE 8192
 
 /* The string that separates the records of the file. */
-static char const *separator;
+static char const *separator = "\n";
 
 /* True if we have ever read standard input.  */
 static bool have_read_stdin = false;
 
 /* If true, print 'separator' along with the record preceding it
    in the file; otherwise with the record following it. */
-static bool separator_ends_record;
+static bool separator_ends_record = true;
 
 /* 0 if 'separator' is to be matched as a regular expression;
    otherwise, the length of 'separator', used as a sentinel to
    stop the search. */
-static size_t sentinel_length;
+static size_t sentinel_length = 1;
 
 /* The length of a match with 'separator'.  If 'sentinel_length' is 0,
    'match_length' is computed every time a match succeeds;
@@ -504,10 +504,6 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  separator = "\n";
-  sentinel_length = 1;
-  separator_ends_record = true;
-
   while ((optc = getopt_long (argc, argv, "brs:", longopts, NULL)) != -1)
     {
       switch (optc)