]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
uniq: change macro to function
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 15 Nov 2023 23:08:34 +0000 (15:08 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 16 Nov 2023 19:37:25 +0000 (11:37 -0800)
* src/uniq.c (swap_lines): New static function, replacing
the old SWAP_LINES macro.  These days this is just as fast.
All uses changed.

src/uniq.c

index 28982c103e98fb9dd0c8b58ac1fc8de8a9c984c2..16cf9a08287d008d7af07f154fa7c090fdd5adbd 100644 (file)
   proper_name ("Richard M. Stallman"), \
   proper_name ("David MacKenzie")
 
-#define SWAP_LINES(A, B)                       \
-  do                                           \
-    {                                          \
-      struct linebuffer *_tmp;                 \
-      _tmp = (A);                              \
-      (A) = (B);                               \
-      (B) = _tmp;                              \
-    }                                          \
-  while (0)
+static void
+swap_lines (struct linebuffer **a, struct linebuffer **b)
+{
+  struct linebuffer *tmp = *a;
+  *a = *b;
+  *b = tmp;
+}
 
 /* Number of fields to skip on each line when doing comparisons. */
 static idx_t skip_fields = false;
@@ -370,7 +368,7 @@ check_file (char const *infile, char const *outfile, char delimiter)
                   stdout) != thisline->length)
                 write_error ();
 
-              SWAP_LINES (prevline, thisline);
+              swap_lines (&prevline, &thisline);
               prevfield = thisfield;
               prevlen = thislen;
               first_group_printed = true;
@@ -433,7 +431,7 @@ check_file (char const *infile, char const *outfile, char delimiter)
           if (!match || output_later_repeated)
             {
               writeline (prevline, match, match_count);
-              SWAP_LINES (prevline, thisline);
+              swap_lines (&prevline, &thisline);
               prevfield = thisfield;
               prevlen = thislen;
               if (!match)