X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=pysam.git;a=blobdiff_plain;f=tabix%2Findex.c.pysam.c;fp=tabix%2Findex.c.pysam.c;h=88cdc4050ffc296e34f2f91e8a0455c5b239ac4a;hp=486e26fc1c7e6daf9ed472be9b1d3ba590963fd8;hb=920cc77ed26707a0d92f9e436121b61d84bde627;hpb=8ab946e230447a6fe686edabc5e3cfa445da1721 diff --git a/tabix/index.c.pysam.c b/tabix/index.c.pysam.c index 486e26f..88cdc40 100644 --- a/tabix/index.c.pysam.c +++ b/tabix/index.c.pysam.c @@ -85,38 +85,7 @@ int ti_readline(BGZF *fp, kstring_t *str) * commented out above. */ int ti_readline(BGZF *fp, kstring_t *str) { - int l, state = 0; - unsigned char *buf = (unsigned char*)fp->uncompressed_block; - str->l = 0; - do { - if (fp->block_offset >= fp->block_length) { - if (bgzf_read_block(fp) != 0) { state = -2; break; } - if (fp->block_length == 0) { state = -1; break; } - } - for (l = fp->block_offset; l < fp->block_length && buf[l] != '\n'; ++l); - if (l < fp->block_length) state = 1; - l -= fp->block_offset; - if (str->l + l + 1 >= str->m) { - str->m = str->l + l + 2; - kroundup32(str->m); - str->s = (char*)realloc(str->s, str->m); - } - memcpy(str->s + str->l, buf + fp->block_offset, l); - str->l += l; - fp->block_offset += l + 1; - if (fp->block_offset >= fp->block_length) { -#ifdef _USE_KNETFILE - fp->block_address = knet_tell(fp->x.fpr); -#else - fp->block_address = ftello(fp->file); -#endif - fp->block_offset = 0; - fp->block_length = 0; - } - } while (state == 0); - if (str->l == 0 && state < 0) return state; - str->s[str->l] = 0; - return str->l; + return bgzf_getline(fp, '\n', str); } /*************************************