diff options
Diffstat (limited to 'src/lj_cparse.c')
-rw-r--r-- | src/lj_cparse.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/lj_cparse.c b/src/lj_cparse.c index 107c0381..b88ce5d3 100644 --- a/src/lj_cparse.c +++ b/src/lj_cparse.c | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include "lj_gc.h" | 10 | #include "lj_gc.h" |
11 | #include "lj_err.h" | 11 | #include "lj_err.h" |
12 | #include "lj_buf.h" | ||
12 | #include "lj_str.h" | 13 | #include "lj_str.h" |
13 | #include "lj_ctype.h" | 14 | #include "lj_ctype.h" |
14 | #include "lj_cparse.h" | 15 | #include "lj_cparse.h" |
@@ -88,11 +89,9 @@ static LJ_AINLINE CPChar cp_get(CPState *cp) | |||
88 | /* Grow save buffer. */ | 89 | /* Grow save buffer. */ |
89 | static LJ_NOINLINE void cp_save_grow(CPState *cp, CPChar c) | 90 | static LJ_NOINLINE void cp_save_grow(CPState *cp, CPChar c) |
90 | { | 91 | { |
91 | MSize newsize; | ||
92 | if (cp->sb.sz >= CPARSE_MAX_BUF/2) | 92 | if (cp->sb.sz >= CPARSE_MAX_BUF/2) |
93 | cp_err(cp, LJ_ERR_XELEM); | 93 | cp_err(cp, LJ_ERR_XELEM); |
94 | newsize = cp->sb.sz * 2; | 94 | lj_buf_grow(cp->L, &cp->sb, 0); |
95 | lj_str_resizebuf(cp->L, &cp->sb, newsize); | ||
96 | cp->sb.buf[cp->sb.n++] = (char)c; | 95 | cp->sb.buf[cp->sb.n++] = (char)c; |
97 | } | 96 | } |
98 | 97 | ||
@@ -296,7 +295,7 @@ static void cp_comment_cpp(CPState *cp) | |||
296 | /* Lexical scanner for C. Only a minimal subset is implemented. */ | 295 | /* Lexical scanner for C. Only a minimal subset is implemented. */ |
297 | static CPToken cp_next_(CPState *cp) | 296 | static CPToken cp_next_(CPState *cp) |
298 | { | 297 | { |
299 | lj_str_resetbuf(&cp->sb); | 298 | lj_buf_reset(&cp->sb); |
300 | for (;;) { | 299 | for (;;) { |
301 | if (lj_char_isident(cp->c)) | 300 | if (lj_char_isident(cp->c)) |
302 | return lj_char_isdigit(cp->c) ? cp_number(cp) : cp_ident(cp); | 301 | return lj_char_isdigit(cp->c) ? cp_number(cp) : cp_ident(cp); |
@@ -380,8 +379,7 @@ static void cp_init(CPState *cp) | |||
380 | cp->depth = 0; | 379 | cp->depth = 0; |
381 | cp->curpack = 0; | 380 | cp->curpack = 0; |
382 | cp->packstack[0] = 255; | 381 | cp->packstack[0] = 255; |
383 | lj_str_initbuf(&cp->sb); | 382 | lj_buf_init(&cp->sb); |
384 | lj_str_resizebuf(cp->L, &cp->sb, LJ_MIN_SBUF); | ||
385 | lua_assert(cp->p != NULL); | 383 | lua_assert(cp->p != NULL); |
386 | cp_get(cp); /* Read-ahead first char. */ | 384 | cp_get(cp); /* Read-ahead first char. */ |
387 | cp->tok = 0; | 385 | cp->tok = 0; |
@@ -393,7 +391,7 @@ static void cp_init(CPState *cp) | |||
393 | static void cp_cleanup(CPState *cp) | 391 | static void cp_cleanup(CPState *cp) |
394 | { | 392 | { |
395 | global_State *g = G(cp->L); | 393 | global_State *g = G(cp->L); |
396 | lj_str_freebuf(g, &cp->sb); | 394 | lj_buf_free(g, &cp->sb); |
397 | } | 395 | } |
398 | 396 | ||
399 | /* Check and consume optional token. */ | 397 | /* Check and consume optional token. */ |