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=68c074fc81858150ca7447a88e731eec96be6378;hpb=768881ffd9d33e3c5fa00dd9ea6f488f4f0700b3 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); } /*************************************