base64: don't rely on feof returning 0/1
authorJim Meyering <meyering@redhat.com>
Fri, 27 Jun 2008 14:26:05 +0000 (16:26 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 27 Jun 2008 14:26:05 +0000 (16:26 +0200)
* src/base64.c (do_decode): feof is specified to return nonzero,
not 0/1, so use "k < 1 + !!feof(in)" as the loop termination test.

src/base64.c

index 5067b28..416e573 100644 (file)
@@ -214,7 +214,7 @@ do_decode (FILE *in, FILE *out, bool ignore_garbage)
         However, when it processes the final input buffer, we want
         to iterate it one additional time, but with an indicator
         telling it to flush what is in CTX.  */
-      for (k = 0; k < 1 + feof (in); k++)
+      for (k = 0; k < 1 + !!feof (in); k++)
        {
          if (k == 1 && ctx.i == 0)
            break;