Changeset: f57b7d902923 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f57b7d902923 Modified Files: pathfinder/compiler/debug/abssynprint.c pathfinder/compiler/debug/prettyp.c pathfinder/compiler/include/prettyp.h pathfinder/compiler/sql/lalg2sql.brg pathfinder/compiler/sql/sqlprint.c Branch: default Log Message:
Properly initialize static variables. diffs (116 lines): diff -r dc198a96657a -r f57b7d902923 pathfinder/compiler/debug/abssynprint.c --- a/pathfinder/compiler/debug/abssynprint.c Wed Jun 16 11:49:23 2010 +0200 +++ b/pathfinder/compiler/debug/abssynprint.c Wed Jun 16 16:39:53 2010 +0200 @@ -565,6 +565,9 @@ { PFchar_array_t *a = PFchar_array (500); + /* Initialize the pretty-printing data structures */ + PFprettyp_init (); + PFprettyprintf ("%c", START_BLOCK); abssyn_pretty (t, qnames_resolved); PFprettyprintf ("%c", END_BLOCK); diff -r dc198a96657a -r f57b7d902923 pathfinder/compiler/debug/prettyp.c --- a/pathfinder/compiler/debug/prettyp.c Wed Jun 16 11:49:23 2010 +0200 +++ b/pathfinder/compiler/debug/prettyp.c Wed Jun 16 16:39:53 2010 +0200 @@ -58,7 +58,7 @@ /** * buffer to collect material to be pretty-printed later */ -static PFarray_t *collect = 0; +static PFarray_t *collect; /** * You'll find an explanation of the variables below in [Oppen80]. @@ -388,6 +388,17 @@ } } +void +PFprettyp_init (void) +{ + /* Initialize the collect, stream, and size arrays. */ + collect = PFarray (sizeof (char), 512); + stream = PFarray (sizeof (char *), 50); + size = PFarray (sizeof (int), 50); + + assert (collect && stream && size); +} + /** * Print a chunk of characters (with prettyprinting markup) to a * dynamically growing buffer. You need to call this routine @@ -421,17 +432,6 @@ { va_list reps; - /* initialize the collect, stream, and size arrays if this is the - * first material to be printed - */ - if (! collect) { - collect = PFarray (sizeof (char), 512); - stream = PFarray (sizeof (char *), 50); - size = PFarray (sizeof (int), 50); - - assert (collect && stream && size); - } - va_start (reps, rep); if (PFarray_vprintf (collect, rep, reps) < 0) diff -r dc198a96657a -r f57b7d902923 pathfinder/compiler/include/prettyp.h --- a/pathfinder/compiler/include/prettyp.h Wed Jun 16 11:49:23 2010 +0200 +++ b/pathfinder/compiler/include/prettyp.h Wed Jun 16 16:39:53 2010 +0200 @@ -58,6 +58,8 @@ #define START_BLOCK '\x01' #define END_BLOCK '\x02' +void PFprettyp_init (void); + void PFprettyprintf (const char *rep, ...) __attribute__ ((format (printf, 1, 2))); diff -r dc198a96657a -r f57b7d902923 pathfinder/compiler/sql/lalg2sql.brg --- a/pathfinder/compiler/sql/lalg2sql.brg Wed Jun 16 11:49:23 2010 +0200 +++ b/pathfinder/compiler/sql/lalg2sql.brg Wed Jun 16 16:39:53 2010 +0200 @@ -451,7 +451,7 @@ } /* static variable that holds the actual table-number */ -static unsigned int table_varno = PF_SQL_RES_TABLE_COUNT; +static unsigned int table_varno; /** * Returns a new table name. @@ -463,7 +463,7 @@ } /* static variable that holds the actual alias-number */ -static unsigned int alias_varno = PF_SQL_RES_ALIAS_COUNT; +static unsigned int alias_varno; /** * Returns a new alias. @@ -529,7 +529,7 @@ /* static variable that holds the current col-number */ -static unsigned int col_varno = PF_SQL_RES_COLUMN_COUNT; +static unsigned int col_varno; /** * Returns a new column name diff -r dc198a96657a -r f57b7d902923 pathfinder/compiler/sql/sqlprint.c --- a/pathfinder/compiler/sql/sqlprint.c Wed Jun 16 11:49:23 2010 +0200 +++ b/pathfinder/compiler/sql/sqlprint.c Wed Jun 16 16:39:53 2010 +0200 @@ -1085,6 +1085,9 @@ assert (L(n)); /* serialize info */ assert (R(n)); /* common table expression */ + /* Initialize the pretty-printing data structures */ + PFprettyp_init (); + /* first print all schema information */ print_schema_information (a, L(n)); _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list