1.1 --- a/src/tools/gendec.c Thu Jan 22 00:45:15 2009 +0000
1.2 +++ b/src/tools/gendec.c Wed Feb 04 00:58:54 2009 +0000
1.7 -static void fprint_indent( char *action, int depth, FILE *f )
1.8 +static void fprint_indent( const char *action, int depth, FILE *f )
1.10 int spaces = 0, needed = depth*8, i;
1.11 - char *text = action;
1.12 + const char *text = action;
1.14 /* Determine number of spaces in first line of input */
1.15 for( i=0; isspace(action[i]); i++ ) {
1.20 -static void fprint_action( struct rule *rule, char *action, int depth, FILE *f )
1.21 +static void fprint_action( struct rule *rule, const struct action *action, int depth, FILE *f )
1.24 if( action == NULL ) {
1.25 @@ -154,14 +154,15 @@
1.29 - if( action[0] != '\0' ) {
1.30 - fprint_indent( action, depth, f );
1.31 + if( action->text && action->text[0] != '\0' ) {
1.32 + fprintf( f, "#line %d \"%s\"\n", action->lineno, action->filename );
1.33 + fprint_indent( action->text, depth, f );
1.35 fprintf( f, "%*c}\n", depth*8, ' ' );
1.39 -static void split_and_generate( struct ruleset *rules, char **actions,
1.40 +static void split_and_generate( struct ruleset *rules, const struct action *actions,
1.41 int ruleidx[], int rule_count, int input_mask,
1.42 int depth, FILE *f ) {
1.45 if( rule_count == 0 ) {
1.46 fprintf( f, "%*cUNDEF(ir);\n", depth*8, ' ' );
1.47 } else if( rule_count == 1 ) {
1.48 - fprint_action( rules->rules[ruleidx[0]], actions[ruleidx[0]], depth, f );
1.49 + fprint_action( rules->rules[ruleidx[0]], &actions[ruleidx[0]], depth, f );
1.52 mask = find_mask(rules, ruleidx, rule_count, input_mask);
1.54 actiontoken_t token = action_file_next(af);
1.55 while( token->symbol != END ) {
1.56 if( token->symbol == TEXT ) {
1.57 + fprintf( out, "#line %d \"%s\"\n", token->lineno, token->filename );
1.58 fputs( token->text, out );
1.59 } else if( token->symbol == ERROR ) {
1.60 fprintf( stderr, "Error parsing action file" );
1.62 fputs( "%%\n", out );
1.63 for( i=0; i<rules->rule_count; i++ ) {
1.64 fprintf( out, "%s {: %s :}\n", rules->rules[i]->format,
1.65 - token->actions[i] == NULL ? "" : token->actions[i] );
1.66 + token->actions[i].text == NULL ? "" : token->actions[i].text );
1.68 fputs( "%%\n", out );