(output_quoted_string): New function.
authorPaul Eggert <eggert@gnu.org>
Tue, 28 Sep 1993 00:23:58 +0000 (00:23 +0000)
committerPaul Eggert <eggert@gnu.org>
Tue, 28 Sep 1993 00:23:58 +0000 (00:23 +0000)
(output_file_directive): Quote special characters in file names.

From-SVN: r5499

gcc/toplev.c

index b513c5ecbe25bcb890fc3562c2d4004303b7fca9..42902835e17e3fff9005c563f29581844c686c35 100644 (file)
@@ -1498,6 +1498,24 @@ strip_off_ending (name, len)
     name[len - 4] = 0;
 }
 
+/* Output a quoted string.  */
+void
+output_quoted_string (asm_file, string)
+     FILE *asm_file;
+     char *string;
+{
+  char c;
+
+  putc ('\"', asm_file);
+  while ((c = *string++) != 0)
+    {
+      if (c == '\"' || c == '\\')
+       putc ('\\', asm_file);
+      putc (c, asm_file);
+    }
+  putc ('\"', asm_file);
+}
+
 /* Output a file name in the form wanted by System V.  */
 
 void
@@ -1522,7 +1540,9 @@ output_file_directive (asm_file, input_name)
 #ifdef ASM_OUTPUT_SOURCE_FILENAME
   ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
 #else
-  fprintf (asm_file, "\t.file\t\"%s\"\n", na);
+  fprintf (asm_file, "\t.file\t");
+  output_quoted_string (asm_file, na);
+  fputc ('\n', asm_file);
 #endif
 #endif
 }