File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
src/interfaces/ecpg/preproc Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -95,9 +95,22 @@ hashline_number(void)
9595#endif
9696 )
9797 {
98- char * line = mm_alloc (strlen ("\n#line %d \"%s\"\n" ) + sizeof (int ) * CHAR_BIT * 10 / 3 + strlen (input_filename ));
99-
100- sprintf (line , "\n#line %d \"%s\"\n" , yylineno , input_filename );
98+ /* "* 2" here is for escaping \s below */
99+ char * line = mm_alloc (strlen ("\n#line %d \"%s\"\n" ) + sizeof (int ) * CHAR_BIT * 10 / 3 + strlen (input_filename ) * 2 );
100+ char * src ,
101+ * dest ;
102+
103+ sprintf (line , "\n#line %d \"" , yylineno );
104+ src = input_filename ;
105+ dest = line + strlen (line );
106+ while (* src )
107+ {
108+ if (* src == '\\' )
109+ * dest ++ = '\\' ;
110+ * dest ++ = * src ++ ;
111+ }
112+ * dest = '\0' ;
113+ strcat (dest , "\"\n" );
101114
102115 return line ;
103116 }
You can’t perform that action at this time.
0 commit comments