From bf640567d4f5b40bda13f46732cb355e7a8ad39e Mon Sep 17 00:00:00 2001 From: Fierelier Date: Thu, 22 Feb 2024 19:26:25 +0100 Subject: [PATCH] Update _call_proc for Windows --- lua-5.3/compile.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lua-5.3/compile.c b/lua-5.3/compile.c index faa2b17..7b150ff 100644 --- a/lua-5.3/compile.c +++ b/lua-5.3/compile.c @@ -66,14 +66,28 @@ int _call_proc(char * argv[]) { int i; for (i = 0; argv[i] != NULL; i++) { commandLength += strlen(argv[i]) + 3; + int si; + for (si = 0; argv[i][si] != 0; si++) { + if (argv[i][si] == '"') { + commandLength++; + } + } } + commandLength += 1; command = malloc(commandLength); command[0] = 0; for (i = 0; argv[i] != NULL; i++) { + int si; strcat(command,"\""); - strcat(command,argv[i]); + for (si = 0; argv[i][si] != 0; si++) { + if (argv[i][si] == '"') { + strcat(command,"\\"); + } + strncat(command,(char *)&argv[i][si],1); + } + strcat(command,"\" "); } command[commandLength - 2] = 0;