~pythonregexp2.7/python/issue2636-01+09-01-01

« back to all changes in this revision

Viewing changes to Modules/cStringIO.c

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 00:02:12 UTC
  • mfrom: (39022.1.34 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922000212-7r0q4f4ugiq57jph
Merged in changes from the Atomic Grouping / Possessive Qualifiers branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
static PyObject *
120
120
IO_cgetval(PyObject *self) {
121
121
        if (!IO__opencheck(IOOOBJECT(self))) return NULL;
 
122
        assert(IOOOBJECT(self)->pos >= 0);
122
123
        return PyString_FromStringAndSize(((IOobject*)self)->buf,
123
124
                                          ((IOobject*)self)->pos);
124
125
}
137
138
        }
138
139
        else
139
140
                  s=self->string_size;
 
141
        assert(self->pos >= 0);
140
142
        return PyString_FromStringAndSize(self->buf, s);
141
143
}
142
144
 
157
159
        Py_ssize_t l;
158
160
 
159
161
        if (!IO__opencheck(IOOOBJECT(self))) return -1;
 
162
        assert(IOOOBJECT(self)->pos >= 0);
 
163
        assert(IOOOBJECT(self)->string_size >= 0);
160
164
        l = ((IOobject*)self)->string_size - ((IOobject*)self)->pos;  
161
165
        if (n < 0 || n > l) {
162
166
                n = l;
192
196
        for (n = ((IOobject*)self)->buf + ((IOobject*)self)->pos,
193
197
               s = ((IOobject*)self)->buf + ((IOobject*)self)->string_size; 
194
198
             n < s && *n != '\n'; n++);
 
199
 
195
200
        if (n < s) n++;
196
201
 
197
202
        *output=((IOobject*)self)->buf + ((IOobject*)self)->pos;
198
203
        l = n - ((IOobject*)self)->buf - ((IOobject*)self)->pos;
199
 
        assert(((IOobject*)self)->pos + l < INT_MAX);
200
 
        ((IOobject*)self)->pos += (int)l;
 
204
 
 
205
        assert(IOOOBJECT(self)->pos <= PY_SSIZE_T_MAX - l);
 
206
        assert(IOOOBJECT(self)->pos >= 0);
 
207
        assert(IOOOBJECT(self)->string_size >= 0);
 
208
 
 
209
        ((IOobject*)self)->pos += l;
201
210
        return (int)l;
202
211
}
203
212
 
215
224
                n -= m;
216
225
                self->pos -= m;
217
226
        }
 
227
        assert(IOOOBJECT(self)->pos >= 0);
218
228
        return PyString_FromStringAndSize(output, n);
219
229
}
220
230
 
277
287
 
278
288
        if (!IO__opencheck(self)) return NULL;
279
289
 
 
290
        assert(self->pos >= 0);
280
291
        return PyInt_FromSsize_t(self->pos);
281
292
}
282
293