~ubuntu-branches/debian/stretch/tabix/stretch

« back to all changes in this revision

Viewing changes to index.c

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2012-06-22 13:14:27 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120622131427-538ff7c4fn6xtbj4
Tags: 0.2.6-1
60eb374 Imported Upstream version 0.2.6
9de2ad5 Removed patches applied or obsoleted upstream.
2836b51 Refreshed hardening patch.
7677e45 Regression tests for autopkgtest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
 * commented out above. */
84
84
int ti_readline(BGZF *fp, kstring_t *str)
85
85
{
86
 
        int l, state = 0;
87
 
        unsigned char *buf = (unsigned char*)fp->uncompressed_block;
88
 
        str->l = 0;
89
 
        do {
90
 
                if (fp->block_offset >= fp->block_length) {
91
 
                        if (bgzf_read_block(fp) != 0) { state = -2; break; }
92
 
                        if (fp->block_length == 0) { state = -1; break; }
93
 
                }
94
 
                for (l = fp->block_offset; l < fp->block_length && buf[l] != '\n'; ++l);
95
 
                if (l < fp->block_length) state = 1;
96
 
                l -= fp->block_offset;
97
 
                if (str->l + l + 1 >= str->m) {
98
 
                        str->m = str->l + l + 2;
99
 
                        kroundup32(str->m);
100
 
                        str->s = (char*)realloc(str->s, str->m);
101
 
                }
102
 
                memcpy(str->s + str->l, buf + fp->block_offset, l);
103
 
                str->l += l;
104
 
                fp->block_offset += l + 1;
105
 
                if (fp->block_offset >= fp->block_length) {
106
 
#ifdef _USE_KNETFILE
107
 
                        fp->block_address = knet_tell(fp->x.fpr);
108
 
#else
109
 
                        fp->block_address = ftello(fp->file);
110
 
#endif
111
 
                        fp->block_offset = 0;
112
 
                        fp->block_length = 0;
113
 
                } 
114
 
        } while (state == 0);
115
 
        if (str->l == 0 && state < 0) return state;
116
 
        str->s[str->l] = 0;
117
 
        return str->l;
 
86
        return bgzf_getline(fp, '\n', str);
118
87
}
119
88
 
120
89
/*************************************