We may want to unget more than one character.
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
size_t size;
size_t len;
int c;
+ int un[5];
+ int n_un;
struct isl_token *tokens[5];
int n_token;
s->col = 0;
s->eof = 0;
s->c = -1;
+ s->n_un = 0;
for (i = 0; i < 5; ++i)
s->tokens[i] = NULL;
s->n_token = 0;
int c;
if (s->eof)
return -1;
+ if (s->n_un)
+ return s->c = s->un[--s->n_un];
if (s->file)
c = fgetc(s->file);
else {
static void isl_stream_ungetc(struct isl_stream *s, int c)
{
- if (s->file)
- ungetc(c, s->file);
- else
- --s->str;
+ isl_assert(s->ctx, s->n_un < 5, return);
+ s->un[s->n_un++] = c;
s->c = -1;
}