shithub: sox

Download patch

ref: 8e9abc551e564b3ad6cf109720cdd97dea65e316
parent: bf805c3539f1d3a39d14d786e90a8b355276a23e
author: robs <robs>
date: Sat Nov 10 05:58:52 EST 2007

further Fix spurious 'Premature EOF' message

--- a/src/misc.c
+++ b/src/misc.c
@@ -205,7 +205,8 @@
         if (sox_readbuf(ft, &in, 1) != 1)
         {
             *sc = 0;
-                sox_fail_errno(ft,errno,sox_readerr);
+            if (sox_error(ft))
+              sox_fail_errno(ft, errno, sox_readerr);
             return (SOX_EOF);
         }
         if (in == 0 || in == '\n')
--- a/src/raw.c
+++ b/src/raw.c
@@ -90,7 +90,7 @@
   { \
     sox_size_t n, nread; \
     ctype *data = xmalloc(sizeof(ctype) * len); \
-    if ((nread = sox_read_ ## type ## _buf(ft, (uctype *)data, len)) != len) \
+    if ((nread = sox_read_ ## type ## _buf(ft, (uctype *)data, len)) != len && sox_error(ft)) \
       sox_fail_errno(ft, errno, sox_readerr); \
     for (n = 0; n < nread; n++) \
       *buf++ = cast(data[n], ft->clips); \
--- a/src/soxio.c
+++ b/src/soxio.c
@@ -397,7 +397,7 @@
       sox_format_t * ft, ctype *buf, sox_size_t len) \
   { \
     sox_size_t n, nread; \
-    if ((nread = sox_readbuf(ft, buf, len * size)) != len * size && ferror(ft->fp)) \
+    if ((nread = sox_readbuf(ft, buf, len * size)) != len * size && sox_error(ft)) \
       sox_fail_errno(ft, errno, sox_readerr); \
     nread /= size; \
     for (n = 0; n < nread; n++) \
@@ -416,7 +416,7 @@
   { \
     sox_size_t n, nread; \
     uint8_t *data = xmalloc(size * len); \
-    if ((nread = sox_readbuf(ft, data, len * size)) != len * size && ferror(ft->fp)) \
+    if ((nread = sox_readbuf(ft, data, len * size)) != len * size && sox_error(ft)) \
       sox_fail_errno(ft, errno, sox_readerr); \
     nread /= size; \
     for (n = 0; n < nread; n++) { \