From 8998c4165d5fd718058d570a13ffaf11daa32608 Mon Sep 17 00:00:00 2001 From: kaashoek Date: Fri, 27 May 1988 08:56:47 +0000 Subject: [PATCH] Bij het vervangen van @text2() door print-statements zorgen dat het resultaat ook 1 statement is: zet er '{' en '}' omheen. Tevens kunnen de argumenten van een @reloc4() over meerdere regels staan. Dit levert problemen met het in een string zetten om ze te printen, alle newlines vervangen door '\\n'. --- util/ceg/as_parser/eval/eval.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/util/ceg/as_parser/eval/eval.c b/util/ceg/as_parser/eval/eval.c index f9b57c770..af3a788f3 100644 --- a/util/ceg/as_parser/eval/eval.c +++ b/util/ceg/as_parser/eval/eval.c @@ -192,13 +192,18 @@ char *str; pr_call( call) char *call; { + char c; + + printf( "{"); if ( strncmp( "text", call, 4) == 0 && isdigit( *(call+4))) printf( "cur_pos += %d;", *(call+4) - '0'); else if ( strncmp( "reloc", call, 5) == 0 && isdigit( *(call+5))) printf( "cur_pos += %d;", *(call+5) - '0'); pr_text_with_conversions( call); - printf( "fprint( outfile, \";\")"); + printf( "fprint( outfile, \";\");"); + printf( "}"); + for (; ( c = getchar()) != ';' ; putchar( c)); /* skip ';' */ } pr_elsif( quest) @@ -220,16 +225,32 @@ char *quest; pr_text_with_conversions( str) char *str; { - char *ptr, *next_conversion(), *pr_conversion(); + char *s, *ptr, *next_conversion(), *pr_conversion(); while ( ptr = next_conversion( str)) { /* ptr points to '%'-sign */ *ptr = '\0'; - printf( "fprint( outfile, \"%s\");", str); + printf( "fprint( outfile, \""); + + for ( s = str; *s != '\0'; s++) + if ( *s == '\n') + printf( "\\n"); + else + putchar( *s); + + printf( "\");"); *ptr = '%'; str = pr_conversion( ptr); } - printf( "fprint( outfile, \"%s\");", str); + printf( "fprint( outfile, \""); + + for ( s = str; *s != '\0'; s++) + if ( *s == '\n') + printf( "\\n"); + else + putchar( *s); + + printf( "\");"); } char *next_conversion( str)