From e107d281b20df39b3c0374cd5796b13e64095937 Mon Sep 17 00:00:00 2001 From: nishi Date: Tue, 23 Apr 2024 06:22:18 +0000 Subject: [PATCH] parsing segfaults git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@15 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- Makefile | 2 +- Serenade/parser.c | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3c117fe..f350eae 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # $Id$ CC = cc -CFLAGS = -std=c99 +CFLAGS = -std=c99 -g LDFLAGS = LIBS = SUFFIX = diff --git a/Serenade/parser.c b/Serenade/parser.c index 00247c6..3fd3b11 100644 --- a/Serenade/parser.c +++ b/Serenade/parser.c @@ -91,9 +91,6 @@ struct sn_generic* sn_expr_parse(char* data, unsigned long long size){ char c = data[i]; if(c == '"'){ dq = !dq; - if(!dq){ - PUSH_STACK(br - 1); - } }else if(dq){ argbufmode = SN_TYPE_STRING; char cbuf[2]; @@ -102,6 +99,7 @@ struct sn_generic* sn_expr_parse(char* data, unsigned long long size){ char* tmp = argbuf; argbuf = sn_strcat(tmp, cbuf); free(tmp); + }else if(c == '\n'){ }else if(c == '('){ br++; gn_stack[br - 1] = malloc(sizeof(*gn_stack)); @@ -118,6 +116,7 @@ struct sn_generic* sn_expr_parse(char* data, unsigned long long size){ gn_stack[br - 1]->tree->op->name = sn_strdup(op_stack[br - 1]); } br_stack[br - 1] = 0; + PUSH_STACK(br - 1); if(br_stack[br - 2] > 0){ int j; struct sn_generic** old_args = gn_stack[br - 2]->tree->args; @@ -129,8 +128,6 @@ struct sn_generic* sn_expr_parse(char* data, unsigned long long size){ gn_stack[br - 2]->tree->args[j] = gn_stack[br - 1]; gn_stack[br - 2]->tree->args[j + 1] = NULL; free(old_args); - PUSH_STACK(br - 1); - }else if(strlen(argbuf) > 0){ } br--; }else if(br > 0){ -- 2.43.0