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)
95
95
#endif
96
96
)
97
97
{
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" );
101
114
102
115
return line ;
103
116
}
You can’t perform that action at this time.
0 commit comments