From: f Date: Thu, 26 Nov 2015 17:00:47 +0000 (+0200) Subject: Implemented escaping of spaces in ca65 dependency files. Largely based on input.c... X-Git-Tag: V2.16~198^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4dc4ea60eed898841e7d64cf60cebcb68ec62105;p=cc65 Implemented escaping of spaces in ca65 dependency files. Largely based on input.c from cc65 (WriteEscaped was copied verbatim). --- 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);