]> git.kaiwu.me - klib.git/commitdiff
bug with incomplete read() call
authorHeng Li <lh3@me.com>
Mon, 10 Nov 2014 21:04:13 +0000 (16:04 -0500)
committerHeng Li <lh3@me.com>
Mon, 10 Nov 2014 21:04:13 +0000 (16:04 -0500)
See also issue #43 of seqtk

kseq.h

diff --git a/kseq.h b/kseq.h
index a5cec7c289aeda5fe36edb2a828a9f669741d3a3..772cdee40aabe1863697c076bab05087c2181b8f 100644 (file)
--- a/kseq.h
+++ b/kseq.h
@@ -70,7 +70,7 @@
                if (ks->begin >= ks->end) {                                                     \
                        ks->begin = 0;                                                                  \
                        ks->end = __read(ks->f, ks->buf, __bufsize);    \
-                       if (ks->end < __bufsize) ks->is_eof = 1;                \
+                       if (ks->end == 0) ks->is_eof = 1;               \
                        if (ks->end == 0) return -1;                                    \
                }                                                                                                       \
                return (int)ks->buf[ks->begin++];                                       \
@@ -100,7 +100,7 @@ typedef struct __kstring_t {
                                if (!ks->is_eof) {                                                                              \
                                        ks->begin = 0;                                                                          \
                                        ks->end = __read(ks->f, ks->buf, __bufsize);            \
-                                       if (ks->end < __bufsize) ks->is_eof = 1;                        \
+                                       if (ks->end == 0) ks->is_eof = 1;                       \
                                        if (ks->end == 0) break;                                                        \
                                } else break;                                                                                   \
                        }                                                                                                                       \