cleanup: Correct wrong usage of feof().
authorChristoph Mallon <christoph.mallon@gmx.de>
Tue, 25 Dec 2012 15:48:12 +0000 (16:48 +0100)
committerChristoph Mallon <christoph.mallon@gmx.de>
Thu, 27 Dec 2012 11:58:44 +0000 (12:58 +0100)
main.c
wrappergen/write_jna.c

diff --git a/main.c b/main.c
index 47e8547..21d82e9 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1202,8 +1202,10 @@ static void copy_file(FILE *dest, FILE *input)
 {
        char buf[16384];
 
-       while (!feof(input) && !ferror(dest)) {
+       for (;;) {
                size_t read = fread(buf, 1, sizeof(buf), input);
+               if (read == 0)
+                       break;
                if (fwrite(buf, 1, read, dest) != read) {
                        perror("could not write output");
                }
index e48fa05..aa9ed36 100644 (file)
@@ -453,7 +453,7 @@ void write_jna_decls(FILE *output, const translation_unit_t *unit)
        /* read the avoid list */
        FILE *avoid = fopen("avoid.config", "r");
        if (avoid != NULL) {
-               while (!feof(avoid)) {
+               for (;;) {
                        char buf[1024];
                        char *res = fgets(buf, sizeof(buf), avoid);
                        if (res == NULL)