@@ -75,6 +75,7 @@ typedef struct {
75
75
#include < stdlib.h>
76
76
#include < unictype.h>
77
77
78
+ #include " logging.h"
78
79
#include " shape.h"
79
80
#include " tools.h"
80
81
#include " parsing.h"
@@ -199,10 +200,8 @@ config_file: config_file design_or_error | design_or_error | config_file parent_
199
200
design_or_error: design | error
200
201
{
201
202
/* reset alias list, as those are collected even when speedmode is on */
202
- #ifdef PARSER_DEBUG
203
- fprintf (stderr, " Parser: Discarding token [skipping=%s, speeding=%s]\n " ,
203
+ log_debug (__FILE__, PARSER, " Parser: Discarding token [skipping=%s, speeding=%s]\n " ,
204
204
bison_args->skipping ? " true" : " false" , bison_args->speeding ? " true" : " false" );
205
- #endif
206
205
if (curdes.aliases[0 ] != NULL ) {
207
206
BFREE (curdes.aliases);
208
207
curdes.aliases = (char **) calloc(1 , sizeof (char *));
@@ -268,10 +267,10 @@ entry: KEYWORD STRING
268
267
yyerror (bison_args, " string expected" );
269
268
YYERROR ;
270
269
}
271
- else {
272
- # ifdef PARSER_DEBUG
273
- fprintf (stderr, " Parser: Discarding entry [%s = %s].\n " , " parent" , bxs_to_output(filename) );
274
- # endif
270
+ else if (is_debug_logging(PARSER)) {
271
+ char *out_filename = bxs_to_output(filename);
272
+ log_debug (__FILE__, PARSER, " Parser: Discarding entry [%s = %s].\n " , " parent" , out_filename );
273
+ BFREE (out_filename);
275
274
}
276
275
}
277
276
@@ -284,9 +283,11 @@ entry: KEYWORD STRING
284
283
285
284
| BXWORD STRING | ASCII_ID STRING
286
285
{
287
- #ifdef PARSER_DEBUG
288
- fprintf (stderr, " Parser: Discarding entry [%s = %s].\n " , $1 , bxs_to_output($2 ));
289
- #endif
286
+ if (is_debug_logging(PARSER)) {
287
+ char *out_string = bxs_to_output($2 );
288
+ log_debug (__FILE__, PARSER, " Parser: Discarding entry [%s = %s].\n " , $1 , out_string);
289
+ BFREE (out_string);
290
+ }
290
291
}
291
292
;
292
293
@@ -323,10 +324,8 @@ block: YSAMPLE STRING YENDSAMPLE
323
324
324
325
| YPADDING ' {' wlist ' }'
325
326
{
326
- #ifdef PARSER_DEBUG
327
- fprintf (stderr, " Padding set to (l%d o%d r%d u%d)\n " ,
327
+ log_debug (__FILE__, PARSER, " Padding set to (l%d o%d r%d u%d)\n " ,
328
328
curdes.padding[BLEF], curdes.padding[BTOP], curdes.padding[BRIG], curdes.padding[BBOT]);
329
- #endif
330
329
}
331
330
;
332
331
@@ -347,9 +346,7 @@ elist: elist ',' elist_entry | elist_entry;
347
346
348
347
elist_entry: SHAPE
349
348
{
350
- #ifdef PARSER_DEBUG
351
- fprintf (stderr, " Marked \' %s\' shape as elastic\n " , shape_name[(int ) $1]);
352
- #endif
349
+ log_debug (__FILE__, PARSER, " Marked \' %s\' shape as elastic\n " , shape_name[(int ) $1]);
353
350
curdes.shape[$1 ].elastic = 1 ;
354
351
}
355
352
;
@@ -360,10 +357,8 @@ slist: slist slist_entry | slist_entry;
360
357
361
358
slist_entry: SHAPE shape_def
362
359
{
363
- #ifdef PARSER_DEBUG
364
- fprintf (stderr, " Adding shape spec for \' %s\' (width %d "
365
- " height %d)\n " , shape_name[$1 ], (int ) $2.width, (int ) $2.height);
366
- #endif
360
+ log_debug (__FILE__, PARSER, " Adding shape spec for \' %s\' (width %d height %d)\n " ,
361
+ shape_name[$1 ], (int ) $2.width, (int ) $2.height);
367
362
368
363
if (isempty (curdes.shape + $1 )) {
369
364
curdes.shape[$1 ] = $2 ;
0 commit comments