]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
split: small -n lines simplification
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 4 Mar 2023 19:41:02 +0000 (11:41 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 4 Mar 2023 22:49:45 +0000 (14:49 -0800)
* src/split.c (lines_chunk_split):
Rewrite while as if-while for clarity.

src/split.c

index d3d1dde8c2169f798199c8ca11adc4b1c9d711d0..574250d272a39643a9013fa86677df0990ba00b7 100644 (file)
@@ -980,8 +980,9 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
   /* Ensure NUMBER files are created, which truncates
      any existing files or notifies any consumers on fifos.
      FIXME: Should we do this before EXIT_FAILURE?  */
-  while (!k && chunk_no++ <= n)
-    cwrite (true, NULL, 0);
+  if (!k)
+    while (chunk_no++ <= n)
+      cwrite (true, NULL, 0);
 }
 
 /* -n K/N: Extract Kth of N chunks.  */