From 4dc4ea60eed898841e7d64cf60cebcb68ec62105 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 26 Nov 2015 19:00:47 +0200 Subject: [PATCH] Implemented escaping of spaces in ca65 dependency files. Largely based on input.c from cc65 (WriteEscaped was copied verbatim). --- src/ca65/filetab.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/ca65/filetab.c b/src/ca65/filetab.c index fbe163f51..ce4b15c03 100644 --- a/src/ca65/filetab.c +++ b/src/ca65/filetab.c @@ -262,6 +262,21 @@ void WriteFiles (void) +static void WriteEscaped (FILE* F, const char* Name) +/* Write a file name to a dependency file escaping spaces */ +{ + while (*Name) { + if (*Name == ' ') { + /* Escape spaces */ + fputc ('\\', F); + } + fputc (*Name, F); + ++Name; + } +} + + + static void WriteDep (FILE* F, FileType Types) /* Helper function. Writes all file names that match Types to the output */ { @@ -285,9 +300,9 @@ static void WriteDep (FILE* F, FileType Types) fputc (' ', F); } - /* Print the dependency */ + /* Print the dependency escaping spaces */ Filename = GetStrBuf (E->Name); - fprintf (F, "%*s", SB_GetLen (Filename), SB_GetConstBuf (Filename)); + WriteEscaped (F, SB_GetConstBuf (Filename)); } } @@ -305,7 +320,8 @@ static void CreateDepFile (const char* Name, FileType Types) } /* Print the output file followed by a tab char */ - fprintf (F, "%s:\t", OutFile); + WriteEscaped (F, OutFile); + fputs (":\t", F); /* Write out the dependencies for the output file */ WriteDep (F, Types); -- 2.39.5