diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2023-03-09 13:37:26 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2023-03-11 22:56:13 +0200 |
commit | 58e6fb40f6b12ec89ff5faa0ad0d14f2835a5a25 (patch) | |
tree | af3878fa98d059d27f7de4db8a124b176de0268b /test cases | |
parent | 24ea1d3f1968bff52ccaaf33fcdd59e810459aa9 (diff) | |
download | meson-58e6fb40f6b12ec89ff5faa0ad0d14f2835a5a25.zip meson-58e6fb40f6b12ec89ff5faa0ad0d14f2835a5a25.tar.gz meson-58e6fb40f6b12ec89ff5faa0ad0d14f2835a5a25.tar.bz2 |
Make generator exe more resilient.
Diffstat (limited to 'test cases')
-rw-r--r-- | test cases/common/105 generatorcustom/gen.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test cases/common/105 generatorcustom/gen.c b/test cases/common/105 generatorcustom/gen.c index 59518c0..964ae7e 100644 --- a/test cases/common/105 generatorcustom/gen.c +++ b/test cases/common/105 generatorcustom/gen.c @@ -22,9 +22,17 @@ int main(int argc, const char ** argv) { fprintf(output, "#pragma once\n"); fprintf(output, "#define "); - char c; + int bytes_copied = 0; + int c; while((c = fgetc(input)) != EOF) { - fputc(c, output); + if(fputc(c, output) == EOF) { + fprintf(stderr, "Writing to output file failed.\n"); + return 1; + } + if(++bytes_copied > 10000) { + fprintf(stderr, "File copy stuck in an eternal loop!\n"); + return 1; + } } fputc('\n', output); |