Quotes en back-slahses moeten ook speciaal behandeld worden in strings.

This commit is contained in:
kaashoek 1988-05-29 13:52:54 +00:00
parent 2edf3315d6
commit a5b6ef2a18

View file

@ -6,18 +6,14 @@
pr_text_with_conversions( str) pr_text_with_conversions( str)
char *str; char *str;
{ {
char *s, *ptr, *next_conversion(), *pr_conversion(); char *ptr, *next_conversion(), *pr_conversion();
while ( ptr = next_conversion( str)) { while ( ptr = next_conversion( str)) {
/* ptr points to '%'-sign */ /* ptr points to '%'-sign */
*ptr = '\0'; *ptr = '\0';
out( "fprint( outfile, \""); out( "fprint( outfile, \"");
for ( s = str; *s != '\0'; s++) out_string( str);
if ( *s == '\n')
out( "\\n");
else
out( "%c", *s);
out( "\");"); out( "\");");
*ptr = '%'; *ptr = '%';
@ -25,14 +21,30 @@ char *str;
} }
out( "fprint( outfile, \""); out( "fprint( outfile, \"");
for ( s = str; *s != '\0'; s++) out_string( str);
if ( *s == '\n')
out( "\\n");
else
out( "%c", *s);
out( "\");"); out( "\");");
} }
out_string( s)
char *s;
{
for ( ; *s != '\0'; s++)
switch ( *s) {
case '"' : out( "\\\"");
break;
case '\\': out( "\\\\");
break;
case '\n': out( "\\n");
break;
default : out( "%c", *s);
}
}
char *next_conversion( str) char *next_conversion( str)
char *str; char *str;