Commit 31a62e63 authored by dcw's avatar dcw

fixed some unbelievable errors;

eg. malloc(sizeof(t)) should be malloc(sizeof(struct t)) !!
parent 92ef1de2
......@@ -185,14 +185,17 @@ static void protos( d, prot ) declnlist d; BOOL prot;
for( ; d != NULL; d = d->next )
{
shapes = d->shapes;
if( d->UseNull )
{
shapes = shapes->next;
}
for( s = shapes; s != NULL; s = s->next )
if( d->Struct )
{
one_proto( d->name, s, prot );
shapes = d->shapes;
if( d->UseNull )
{
shapes = shapes->next;
}
for( s = shapes; s != NULL; s = s->next )
{
one_proto( d->name, s, prot );
}
}
fprintf( outfile, "extern void print_%s(", d->name );
if( prot )
......@@ -406,22 +409,27 @@ static void print_fns( d ) declnlist d;
line( "exit(1);" );
outdent();
line( "}" );
} else if( d->Struct ) /* only one shape left */
} else if( ! d->TagField && d->Struct ) /* one shape left */
{
print_all_params( d, shapes );
} else /* enumerated type */
} else if( ! d->Struct && d->Defines ) /* enumerated type */
{
line( "switch( p )" );
line( "{" );
for( s = shapes; s != NULL; s = s->next )
{
line( "case %s_%s:", d->name, s->name );
line( "case %s_%s():", d->name, s->name );
indent();
print_all_params( d, s );
line( "break;" );
outdent();
}
line( "}" );
} else
{
fprintf( stderr,
"datadec: internal error in print_fns\n" );
exit(1);
}
outdent();
line( "}\n" );
......@@ -457,7 +465,7 @@ static void h_declns( basename, exports, d ) char *basename, *exports; declnlist
line( "typedef char BOOL;" );
line( "#define TRUE 1" );
line( "#define FALSE 0\n" );
line( "#define NEW(t) ((t)malloc(sizeof(t)))\n\n" );
line( "#define NEW(t) ((t)malloc(sizeof(struct t)))\n\n" );
line( exports );
......@@ -496,6 +504,7 @@ static void c_declns( basename, globals, d ) char *basename, *globals; declnlist
line( " * Automatically Generated by DataDec" );
line( " */\n" );
line( "#include <stdio.h>" );
line( "#include <malloc.h>" );
line( "#include \"%s.h\"\n\n", basename );
line( globals );
......
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