[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] crc: New optimised slice-by-8 implementation
From: |
Bruno Haible |
Subject: |
Re: [PATCH] crc: New optimised slice-by-8 implementation |
Date: |
Thu, 31 Oct 2024 14:48:08 +0100 |
Simon Josefsson wrote:
> I added another patch (attached)
Time for me to add another tweak:
We prepend a "DO NOT EDIT" line to generated files. Some editors react to this
line by asking the user whether they really want to edit the file. At the same
time, this is less annoying than doing a "chmod a-w" of the file.
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.
diff --git a/lib/crc-generate-table.c b/lib/crc-generate-table.c
index 01f9ff77ed..314bf000ee 100644
--- a/lib/crc-generate-table.c
+++ b/lib/crc-generate-table.c
@@ -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;
}
- Re: [PATCH] crc: New optimised slice-by-8 implementation, (continued)
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Sam Russell, 2024/10/29
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Bruno Haible, 2024/10/29
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Simon Josefsson, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Sam Russell, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Simon Josefsson, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Bruno Haible, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Sam Russell, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Bruno Haible, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Simon Josefsson, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Bruno Haible, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation,
Bruno Haible <=
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Bruno Haible, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Simon Josefsson, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Bruno Haible, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Bruno Haible, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Pádraig Brady, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Sam Russell, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Sam Russell, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Pádraig Brady, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Sam Russell, 2024/10/31
- Re: [PATCH] crc: New optimised slice-by-8 implementation, Pádraig Brady, 2024/10/31