Quotes en back-slashes moeten ook speciaal behandeld wordeni in strings.

This commit is contained in:
kaashoek 1988-05-29 13:55:56 +00:00
parent 953ac2b514
commit 95b5bdcdc5

View file

@ -225,34 +225,42 @@ char *quest;
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';
printf( "fprint( outfile, \""); printf( "fprint( outfile, \"");
pr_string( str);
for ( s = str; *s != '\0'; s++)
if ( *s == '\n')
printf( "\\n");
else
putchar( *s);
printf( "\");"); printf( "\");");
*ptr = '%'; *ptr = '%';
str = pr_conversion( ptr); str = pr_conversion( ptr);
} }
printf( "fprint( outfile, \""); printf( "fprint( outfile, \"");
pr_string( str);
for ( s = str; *s != '\0'; s++)
if ( *s == '\n')
printf( "\\n");
else
putchar( *s);
printf( "\");"); printf( "\");");
} }
pr_string( s)
char *s;
{
for ( ; *s != '\0'; s++)
switch ( *s) {
case '"' : printf( "\\\"");
break;
case '\\': printf( "\\\\");
break;
case '\n': printf( "\\n");
break;
default : printf( "%c", *s);
}
}
char *next_conversion( str) char *next_conversion( str)
char *str; char *str;
{ {