From 197634a19f35a4eee05d8e4275ee33923c0ebe0b Mon Sep 17 00:00:00 2001 From: nishi Date: Fri, 26 Apr 2024 03:24:57 +0000 Subject: [PATCH] fix git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@40 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- Makefile | 1 + Serenade/interpreter.c | 20 ++++++++++++++++++-- Serenade/interpreter.h | 1 + cmdline | 2 ++ platforms/win32.mk | 1 + platforms/win64.mk | 1 + 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a41d0f8..8a6d0a1 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ CPP = cpp CC = cc +CPP = cpp CFLAGS = -std=c99 -g LDFLAGS = LIBS = `$(CPP) -DLIBS cmdline | grep -vE "^\#" | tr '\\n' ' '` diff --git a/Serenade/interpreter.c b/Serenade/interpreter.c index 3f08927..29a8a72 100644 --- a/Serenade/interpreter.c +++ b/Serenade/interpreter.c @@ -125,6 +125,8 @@ struct sn_interpreter* sn_create_interpreter(void) { struct sn_interpreter* sn = malloc(sizeof(struct sn_interpreter)); sn->variables = malloc(sizeof(struct sn_interpreter_kv*)); sn->variables[0] = NULL; + sn->generics = malloc(sizeof(struct sn_generic**)); + sn->generics[0] = NULL; sn_set_handler(sn, "+", math_handler); sn_set_handler(sn, "-", math_handler); @@ -148,6 +150,12 @@ void sn_interpreter_free(struct sn_interpreter* sn) { free(sn->variables[i]); } free(sn->variables); + for(i = 0; sn->generics[i] != NULL; i++){ + int j; + for(j = 0; sn->generics[i][j] != NULL; j++) sn_generic_free(sn->generics[i][j]); + free(sn->generics[i]); + } + free(sn->generics); free(sn); } @@ -216,8 +224,16 @@ int sn_eval(struct sn_interpreter* sn, char* data, unsigned long long len) { } } } - for(i = 0; gens[i] != NULL; i++) sn_generic_free(gens[i]); - free(gens); + int j; + struct sn_generic*** oldgens = sn->generics; + for(j = 0; oldgens[j] != NULL; j++); + sn->generics = malloc(sizeof(struct sn_generic**) * (j + 2)); + for(j = 0; oldgens[j] != NULL; j++){ + sn->generics[j] = oldgens[j]; + } + sn->generics[j] = gens; + sn->generics[j + 1] = NULL; + free(oldgens); } return r; } diff --git a/Serenade/interpreter.h b/Serenade/interpreter.h index fb3dbcf..686be99 100644 --- a/Serenade/interpreter.h +++ b/Serenade/interpreter.h @@ -35,6 +35,7 @@ struct sn_interpreter { struct sn_interpreter_kv** variables; + struct sn_generic*** generics; }; struct sn_interpreter_kv { diff --git a/cmdline b/cmdline index 860c096..b219df6 100644 --- a/cmdline +++ b/cmdline @@ -6,9 +6,11 @@ -lffi #endif #ifdef __linux__ +#ifndef __MINGW32__ -ldl #endif #endif +#endif #ifdef OBJS #ifdef HAS_FFI_SUPPORT diff --git a/platforms/win32.mk b/platforms/win32.mk index 40135de..5007c30 100644 --- a/platforms/win32.mk +++ b/platforms/win32.mk @@ -3,4 +3,5 @@ CPP = i686-w64-mingw32-cpp CC = i686-w64-mingw32-gcc +CPP = i686-w64-mingw32-cpp SUFFIX = .exe diff --git a/platforms/win64.mk b/platforms/win64.mk index 30fea52..5a788ee 100644 --- a/platforms/win64.mk +++ b/platforms/win64.mk @@ -3,4 +3,5 @@ CPP = x86_64-w64-mingw32-cpp CC = x86_64-w64-mingw32-gcc +CPP = x86_64-w64-mingw32-cpp SUFFIX = .exe -- 2.43.0