Commit 4317aaec authored by dcw's avatar dcw

added outstring to handle newlines in print control strings

parent 8026b92a
......@@ -4,6 +4,7 @@
#include <dcw.h>
#include "struct.h"
#include "decs.h"
#include <string.h>
typedef declnlist decln; /* JUST THE FIRST */
......@@ -37,6 +38,7 @@ static void writeproc_body( decln );
static void write_using_case( char * , char * , shapelist );
static void write_param( char * , param );
static void write_all_params( char * , shape );
static void outstring( char * );
static void write_bool( void );
static char * lookup_type( char * );
static char * lookup_write_proc( char * );
......@@ -61,6 +63,7 @@ static void writeproc_body();
static void write_using_case();
static void write_param();
static void write_all_params();
static void outstring();
static void write_bool();
static char * lookup_type();
static char * lookup_write_proc();
......@@ -249,7 +252,8 @@ static void impln_declns( globals, modulename, decs ) char *globals, *modulename
nl();
line( "FROM FIO IMPORT" );
indent();
line( "File, WriteString, WriteChar, WriteInteger, WriteReal;" );
line( "File, WriteString, WriteChar, WriteInteger," );
line( "WriteReal, WriteLine, WriteLn;" );
nl();
outdent();
line( "FROM Storage IMPORT ALLOCATE;" );
......@@ -642,8 +646,7 @@ static void write_all_params( dname, s ) char *dname; shape s;
{
if( pl->item->tag == printitem_is_str )
{
line( "WriteString( f, \"%s\" );",
pl->item->str );
outstring( pl->item->str );
} else
{
int n = pl->item->num;
......@@ -660,6 +663,39 @@ ASSERT( p != NULL,
}
static void outstring( str ) char *str;
{
char *p;
BOOL over = FALSE;
while( ! over )
{
p = strstr( str, "\\n" );
if( p == NULL )
{
line( "WriteString( f, \"%s\" );", str );
over = TRUE;
} else
{
if( p == str )
{
line( "WriteLine( f );" );
} else
{
line( "WriteLn( f, \"%.*s\" );", (p-str), str );
}
if( *(p+2) != '\0' )
{
str = p + 2;
} else
{
over = TRUE;
}
}
}
}
static void write_bool()
{
line( "PROCEDURE WriteBool( f : File; bool : BOOLEAN );" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment