@@ -210,7 +210,7 @@ print_groups(FILE *f, const struct fsm_options *opt,
210210}
211211
212212static int
213- print_case (FILE * f , const struct ir * ir ,
213+ print_case (FILE * f , const struct ir * ir , fsm_state_t state_id ,
214214 const struct fsm_options * opt ,
215215 const struct fsm_hooks * hooks ,
216216 const char * cp ,
@@ -222,10 +222,16 @@ print_case(FILE *f, const struct ir *ir,
222222 assert (f != NULL );
223223 assert (cs != NULL );
224224
225+ assert (state_id < ir -> n );
226+ const struct fsm_state_metadata state_metadata = {
227+ .end_ids = ir -> states [state_id ].endids .ids ,
228+ .end_id_count = ir -> states [state_id ].endids .count ,
229+ };
230+
225231 switch (cs -> strategy ) {
226232 case IR_NONE :
227233 fprintf (f , "\t\t\t" );
228- if (-1 == print_hook_reject (f , opt , hooks , default_reject , NULL )) {
234+ if (-1 == print_hook_reject (f , opt , hooks , & state_metadata , default_reject , NULL )) {
229235 return -1 ;
230236 }
231237 fprintf (f , "\n" );
@@ -254,7 +260,7 @@ print_case(FILE *f, const struct ir *ir,
254260 print_groups (f , opt , ir_indexof (ir , cs ), cs -> u .partial .groups , cs -> u .partial .n );
255261
256262 fprintf (f , "\t\t\tdefault: " );
257- if (-1 == print_hook_reject (f , opt , hooks , default_reject , NULL )) {
263+ if (-1 == print_hook_reject (f , opt , hooks , & state_metadata , default_reject , NULL )) {
258264 return -1 ;
259265 }
260266 fprintf (f , "\n" );
@@ -285,7 +291,7 @@ print_case(FILE *f, const struct ir *ir,
285291
286292 print_ranges (f , opt , cs -> u .error .error .ranges , cs -> u .error .error .n );
287293 fprintf (f , " " );
288- if (-1 == print_hook_reject (f , opt , hooks , default_reject , NULL )) {
294+ if (-1 == print_hook_reject (f , opt , hooks , & state_metadata , default_reject , NULL )) {
289295 return -1 ;
290296 }
291297 fprintf (f , "\n" );
@@ -398,7 +404,7 @@ print_endstates(FILE *f,
398404
399405 /* unexpected EOT */
400406 fprintf (f , "\tdefault: " );
401- if (-1 == print_hook_reject (f , opt , hooks , default_reject , NULL )) {
407+ if (-1 == print_hook_reject (f , opt , hooks , NULL , default_reject , NULL )) {
402408 return -1 ;
403409 }
404410 fprintf (f , "\n" );
@@ -435,7 +441,7 @@ fsm_print_cfrag(FILE *f, const struct ir *ir,
435441 }
436442 fprintf (f , "\n" );
437443
438- if (-1 == print_case (f , ir , opt , hooks , cp , & ir -> states [i ])) {
444+ if (-1 == print_case (f , ir , i , opt , hooks , cp , & ir -> states [i ])) {
439445 return -1 ;
440446 }
441447
@@ -500,6 +506,12 @@ fsm_print_c_body(FILE *f, const struct ir *ir,
500506 break ;
501507 }
502508
509+ if (hooks -> advance != NULL ) {
510+ if (-1 == hooks -> advance (f , opt , cp , hooks -> hook_opaque )) {
511+ return -1 ;
512+ }
513+ }
514+
503515 if (-1 == fsm_print_cfrag (f , ir , opt , hooks , cp )) {
504516 return -1 ;
505517 }
0 commit comments