]> Nishi Git Mirror - serenade.git/commitdiff
parsing segfaults
authornishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Tue, 23 Apr 2024 06:22:18 +0000 (06:22 +0000)
committernishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Tue, 23 Apr 2024 06:22:18 +0000 (06:22 +0000)
git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@15 0f02c867-ac3d-714e-8a88-971ba1f6efcf

Makefile
Serenade/parser.c

index 3c117fe319a883d17adb2c5bf7366e08fd244ff8..f350eae84e460716353070bc1120f465a09c8ab2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # $Id$
 
 CC = cc
-CFLAGS = -std=c99
+CFLAGS = -std=c99 -g
 LDFLAGS =
 LIBS =
 SUFFIX =
index 00247c61020f99f387a6d9ba3853095f3e6139d4..3fd3b11999f5a157abc2c4a06ee99f8d987dfdca 100644 (file)
@@ -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){