DRYer
This commit is contained in:
parent
808c68dd0b
commit
40bc1d4f38
1 changed files with 4 additions and 5 deletions
|
|
@ -92,11 +92,10 @@ write_control_ch(Shlex *self) {
|
|||
|
||||
static void
|
||||
read_valid_digits(Shlex *self, int max, char *output, bool(*is_valid)(Py_UCS4 ch)) {
|
||||
for (int i = 0; i < max && self->src_pos < self->src_sz; i++) {
|
||||
Py_UCS4 ch = PyUnicode_READ(self->kind, self->src_data, self->src_pos);
|
||||
if (!is_valid(ch)) break;
|
||||
output[0] = ch;
|
||||
self->src_pos++; output++;
|
||||
for (int i = 0; i < max && self->src_pos < self->src_sz; i++, output++) {
|
||||
Py_UCS4 ch = read_ch(self);
|
||||
if (!is_valid(ch)) { self->src_pos--; break; }
|
||||
*output = ch;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue