+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, InputType Types)
/* Helper function. Writes all file names that match Types to the output */
{
fputc (' ', F);
}
- /* Print the dependency */
- fputs (IF->Name, F);
+ /* Print the dependency escaping spaces */
+ WriteEscaped (F, IF->Name);
}
}
* all files with the given types there.
*/
{
- const char* Target;
-
/* Open the file */
FILE* F = fopen (Name, "w");
if (F == 0) {
* file name as target, followed by a tab character.
*/
if (SB_IsEmpty (&DepTarget)) {
- Target = OutputFilename;
+ WriteEscaped (F, OutputFilename);
} else {
- Target = SB_GetConstBuf (&DepTarget);
+ WriteEscaped (F, SB_GetConstBuf (&DepTarget));
}
- fprintf (F, "%s:\t", Target);
+ fputs (":\t", F);
/* Write out the dependencies for the output file */
WriteDep (F, Types);