From 746812230bcb79139187b76364cd874dd77b5cd3 Mon Sep 17 00:00:00 2001 From: nishi Date: Sun, 5 May 2024 17:03:20 +0000 Subject: [PATCH] fix repl git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@114 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- Serenade/main.c | 4 ++-- Serenade/util.c | 7 +++++++ Serenade/util.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Serenade/main.c b/Serenade/main.c index 303ee8e..439ded5 100644 --- a/Serenade/main.c +++ b/Serenade/main.c @@ -160,7 +160,7 @@ int main(int argc, char** argv) { continue; } char* tmp = str; - str = sn_strcat(tmp, line); + str = sn_strcat3(tmp, line, "\n"); free(tmp); if(br == 0) { sn_eval(sn, str, strlen(str)); @@ -203,7 +203,7 @@ int main(int argc, char** argv) { } if(cbuf[0] != '\r' && cbuf[0] != '\n') { char* tmp = str; - str = sn_strcat(tmp, cbuf); + str = sn_strcat3(tmp, cbuf, "\n"); free(tmp); } #endif diff --git a/Serenade/util.c b/Serenade/util.c index 55693de..01a2811 100644 --- a/Serenade/util.c +++ b/Serenade/util.c @@ -42,6 +42,13 @@ char* sn_strcat(const char* str1, const char* str2) { return str; } +char* sn_strcat3(const char* str1, const char* str2, const char* str3) { + char* tmp = sn_strcat(str1, str2); + char* r = sn_strcat(tmp, str3); + free(tmp); + return r; +} + char* sn_strdup(const char* str1) { char* str = malloc(strlen(str1) + 1); memcpy(str, str1, strlen(str1)); diff --git a/Serenade/util.h b/Serenade/util.h index 0247ed8..e9e6aee 100644 --- a/Serenade/util.h +++ b/Serenade/util.h @@ -36,6 +36,7 @@ #include char* sn_strcat(const char* str1, const char* str2); +char* sn_strcat3(const char* str1, const char* str2, const char* str3); char* sn_strdup(const char* str1); void sn_print_to(FILE* f, struct sn_generic* gen); void sn_print_generic(struct sn_generic* gen); -- 2.43.0