]> mj.ucw.cz Git - eval.git/commitdiff
Default token buffer is 1 byte long, which makes even small limits on
authorMartin Mares <mj@ucw.cz>
Sun, 18 Nov 2007 18:50:46 +0000 (19:50 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 18 Nov 2007 18:50:46 +0000 (19:50 +0100)
maximum token size work.

judge/token.c

index 69b9398395b89fb0e3c1a6ae1fd37dfd068fec6c..3c8ce38cd71c68e642ca9a767bd4eef9b6f20388 100644 (file)
@@ -19,7 +19,7 @@ void tok_init(struct tokenizer *t, struct stream *s)
 {
   memset(t, 0, sizeof(*t));
   t->stream = s;
-  t->bufsize = 256;
+  t->bufsize = 1;
   t->token = xmalloc(t->bufsize);
   t->maxsize = DEFAULT_MAX_TOKEN;
   t->line = 1;
@@ -76,11 +76,11 @@ char *get_token(struct tokenizer *t)
       t->token[len++] = c;
       if (len >= t->bufsize)
        {
-         if (len >= t->maxsize)
+         if (len > t->maxsize)
            tok_err(t, "Token too long");
          t->bufsize *= 2;
          if (t->bufsize > t->maxsize)
-           t->bufsize = t->maxsize;
+           t->bufsize = t->maxsize+1;
          t->token = xrealloc(t->token, t->bufsize);
        }
       c = sgetc(t->stream);