From d861be8ad569d3928727a8c8162fc843835035db Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Thu, 7 Jun 2018 17:10:33 +0200 Subject: [PATCH] Escape spaces in target path. cc65 escapes spaces in paths it writes to dependency files (see WriteEscaped() in cc65/input.c). Given that the output of OptPrintTargetPath() is supposed to be used in Makefiles in pretty much the same way it is appropriate to escape spaces here too. --- src/cl65/main.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index afd3e97e3..f8acb57a0 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -1165,19 +1165,28 @@ static void OptPrintTargetPath (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the target file path */ { - SearchPaths* TargetPath = NewSearchPath (); - AddSubSearchPathFromEnv (TargetPath, "CC65_HOME", "target"); + char* TargetPath; + + SearchPaths* TargetPaths = NewSearchPath (); + AddSubSearchPathFromEnv (TargetPaths, "CC65_HOME", "target"); #if defined(CL65_TGT) && !defined(_WIN32) - AddSearchPath (TargetPath, STRINGIZE (CL65_TGT)); + AddSearchPath (TargetPaths, STRINGIZE (CL65_TGT)); #endif - AddSubSearchPathFromWinBin (TargetPath, "target"); + AddSubSearchPathFromWinBin (TargetPaths, "target"); - printf ("%s\n", GetSearchPath (TargetPath, 0)); + TargetPath = GetSearchPath (TargetPaths, 0); + while (*TargetPath) { + if (*TargetPath == ' ') { + /* Escape spaces */ + putchar ('\\'); + } + putchar (*TargetPath++); + } + putchar ('\n'); exit (EXIT_SUCCESS); } - static void OptRegisterSpace (const char* Opt attribute ((unused)), const char* Arg) /* Handle the --register-space option */ { -- 2.39.5