]> git.sur5r.net Git - cc65/blobdiff - src/cl65/main.c
Escape spaces in target path.
[cc65] / src / cl65 / main.c
index 5a2103b242e221ece19d30729dd83f06f7d2e659..f8acb57a0fd18c59fc65936f405d44d3d3fffa19 100644 (file)
@@ -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 */
 {
@@ -1444,35 +1453,24 @@ int main (int argc, char* argv [])
                     /* Print version number */
                     OptVersion (Arg, 0);
                     break;
-                
+
                 case 'E':
                     /* Forward -E to compiler */
                     CmdAddArg (&CC65, Arg);  
                     DisableAssemblingAndLinking ();
                     break;
-                    
+
                 case 'W':
-                    /* avoid && with'\0' in if clauses */
-                    if (Arg[3] == '\0') {
-                        switch (Arg[2]) {
-                        case 'a':
-                            /* -Wa: Pass options to assembler */
-                            OptAsmArgs (Arg, GetArg (&I, 3));
-                            break;
-                        case 'c':
-                            /* -Wc: Pass options to compiler 
-                            ** Remember -Wc sub arguments in cc65 arg struct 
-                            */
-                            OptCCArgs (Arg, GetArg (&I, 3));
-                            break;
-                        case 'l':
-                            /* -Wl: Pass options to linker */
-                            OptLdArgs (Arg, GetArg (&I, 3));
-                            break;
-                        default:
-                            UnknownOption (Arg);
-                            break;
-                       }
+                    if (Arg[2] == 'a' && Arg[3] == '\0') {
+                        /* -Wa: Pass options to assembler */
+                        OptAsmArgs (Arg, GetArg (&I, 3));
+                    } else if (Arg[2] == 'c' && Arg[3] == '\0') {
+                        /* -Wc: Pass options to compiler */
+                        /* Remember -Wc sub arguments in cc65 arg struct */ 
+                        OptCCArgs (Arg, GetArg (&I, 3));
+                    } else if (Arg[2] == 'l' && Arg[3] == '\0') {
+                        /* -Wl: Pass options to linker */
+                        OptLdArgs (Arg, GetArg (&I, 3));
                     } else {
                         /* Anything else: Suppress warnings (compiler) */
                         CmdAddArg2 (&CC65, "-W", GetArg (&I, 2));