parse: lex: fix memory leaks
This commit is contained in:
@@ -21,7 +21,7 @@ static enum bshell_status word_symbol(struct bshell_lex_ctx *ctx)
|
||||
lex_state_push(ctx, BSHELL_LEX_STATE_STATEMENT, 0);
|
||||
return BSHELL_SUCCESS;
|
||||
case BSHELL_SYM_RIGHT_PAREN:
|
||||
lex_state_pop(ctx);
|
||||
lex_state_pop(ctx, false);
|
||||
|
||||
status = push_symbol(ctx, sym->id);
|
||||
if (status != BSHELL_SUCCESS) {
|
||||
@@ -92,7 +92,8 @@ static enum bshell_status word_content(struct bshell_lex_ctx *ctx)
|
||||
|
||||
static enum bshell_status word_begin(struct bshell_lex_ctx *ctx)
|
||||
{
|
||||
struct bshell_lex_token *tok = bshell_lex_token_create(BSHELL_TOK_WORD_START);
|
||||
struct bshell_lex_token *tok
|
||||
= bshell_lex_token_create(BSHELL_TOK_WORD_START);
|
||||
if (!tok) {
|
||||
return BSHELL_ERR_NO_MEMORY;
|
||||
}
|
||||
@@ -107,7 +108,8 @@ static enum bshell_status word_begin(struct bshell_lex_ctx *ctx)
|
||||
|
||||
static enum bshell_status word_end(struct bshell_lex_ctx *ctx)
|
||||
{
|
||||
struct bshell_lex_token *tok = bshell_lex_token_create(BSHELL_TOK_WORD_END);
|
||||
struct bshell_lex_token *tok
|
||||
= bshell_lex_token_create(BSHELL_TOK_WORD_END);
|
||||
if (!tok) {
|
||||
return BSHELL_ERR_NO_MEMORY;
|
||||
}
|
||||
@@ -121,12 +123,12 @@ static enum bshell_status word_pump_token(struct bshell_lex_ctx *ctx)
|
||||
fx_wchar c = peek_char(ctx);
|
||||
|
||||
if (fx_wchar_is_space(c)) {
|
||||
lex_state_pop(ctx);
|
||||
lex_state_pop(ctx, false);
|
||||
return BSHELL_SUCCESS;
|
||||
}
|
||||
|
||||
if (char_has_flags(ctx, c, BSHELL_LEX_TOKEN_TERMINATES_WORD)) {
|
||||
lex_state_pop(ctx);
|
||||
lex_state_pop(ctx, false);
|
||||
return BSHELL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user