From 9bb5280c44a9ca3fd0daf4f342eaa6947510a175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Wed, 29 Jan 2025 20:23:58 +0500 Subject: [PATCH] Do not add spaces between dots. --- src/compile.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compile.c b/src/compile.c index 2344d2b..76e90bf 100644 --- a/src/compile.c +++ b/src/compile.c @@ -136,7 +136,7 @@ void compile_genexec(char** result, tSyntaxElement* se){ string_append(result,")"); } -char* compile_gensplit(tSyntaxElement* se, char* operator) { +char* compile_gensplit(tSyntaxElement* se, char* operator, bool dosplit) { tSyntaxElement* token = se; char* result = malloc(sizeof(char)); result[0] = '\0'; @@ -151,9 +151,11 @@ char* compile_gensplit(tSyntaxElement* se, char* operator) { if (token->next->next != NULL) { - string_append(&result," "); + if (dosplit) + string_append(&result," "); string_append(&result,operator); - string_append(&result," "); + if (dosplit) + string_append(&result," "); } @@ -198,7 +200,7 @@ char* compile_expression(tSyntaxElement* syntaxelement) { char* operator = token->content.string; - string_append_free(&result, compile_gensplit(token, operator)); + string_append_free(&result, compile_gensplit(token, operator, !!strcmp(".", token->content.string))); } else { @@ -232,13 +234,13 @@ char* compile_expression(tSyntaxElement* syntaxelement) { } else if (strcmp(token->content.string, "list") == 0) { string_append(&result,"["); - string_append_free(&result,compile_gensplit(token, ",")); + string_append_free(&result,compile_gensplit(token, ",", true)); string_append(&result,"]"); } else if (strcmp(token->content.string, "range") == 0) { string_append(&result,"["); - string_append_free(&result,compile_gensplit(token, "..")); + string_append_free(&result,compile_gensplit(token, "..", true)); string_append(&result,"]"); } else if (strcmp(token->content.string, "map") == 0) {