]> Savannah Git Hosting - gnulib.git/commitdiff
crc: Tweak generator.
authorBruno Haible <bruno@clisp.org>
Thu, 31 Oct 2024 13:23:09 +0000 (14:23 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 31 Oct 2024 13:23:09 +0000 (14:23 +0100)
* lib/crc-generate-table.c (print_header): Don't emit a blank line at
the end.
(print_copyright_notice): Prepend a "DO NOT EDIT" line.
(main): Fail if disk is full after we wrote part of the file.

ChangeLog
lib/crc-generate-table.c

index b0719c23bf2512f2267d5a195003bf1369f95748..cce8ccf7d06588ef0ff2fffb79e8ae735c1c8a0d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,17 @@
+2024-10-31  Bruno Haible  <bruno@clisp.org>
+
+       crc: Tweak generator.
+       * lib/crc-generate-table.c (print_header): Don't emit a blank line at
+       the end.
+       (print_copyright_notice): Prepend a "DO NOT EDIT" line.
+       (main): Fail if disk is full after we wrote part of the file.
+
 2024-10-31  Simon Josefsson  <simon@josefsson.org>
 
        crc: make it a maintainer setting rather than a user setting.
        * m4/crc.m4 (gl_CRC_SLICE_BY_8): Drop AC_ARG_ENABLE.
 
-2024-10-27  Sam Russell  <sam.h.russell@gmail.com>
+2024-10-31  Sam Russell  <sam.h.russell@gmail.com>
 
        crc: New optimised slice-by-8 implementation
        * lib/crc.c: Implementation of slice-by-8 algorithm
index 01f9ff77ed44e5fa4f460245df91626745061e4f..314bf000ee8a322bc36a1634a38f9ae2f15bd761 100644 (file)
@@ -94,12 +94,13 @@ print_header (FILE * stream)
         fprintf (stream, ",");
       fprintf (stream, "\n");
     }
-  fprintf (stream, "};\n\n");
+  fprintf (stream, "};\n");
 }
 
 void
 print_copyright_notice (FILE * stream)
 {
+  fprintf (stream, "/* DO NOT EDIT! GENERATED AUTOMATICALLY! */\n");
   fprintf (stream, "/* crc.c -- cyclic redundancy checks\n");
   fprintf (stream,
            "Copyright (C) 2005-2006, 2009-2024 Free Software Foundation, Inc.\n");
@@ -134,17 +135,23 @@ main (int argc, char *argv[])
       fprintf (stderr, " Usage: %s crc-sliceby8.h\n", argv[0]);
       exit (1);
     }
-  FILE *stream;
 
-  stream = fopen (argv[1], "w");
+  const char *filename = argv[1];
+  FILE *stream = fopen (filename, "w");
   if (stream == NULL)
     {
-      fprintf (stderr, "cannot open '%s' for writing\n", argv[1]);
+      fprintf (stderr, "cannot open '%s' for writing\n", filename);
       exit (1);
     }
 
   print_copyright_notice (stream);
   print_header (stream);
 
+  if (ferror (stream) || fclose (stream))
+    {
+      fprintf (stderr, "error writing to '%s'\n", filename);
+      exit (1);
+    }
+
   return 0;
 }