| 430 | } |
| 431 | |
| 432 | void copy_union() |
| 433 | { |
| 434 | FILE *dc_file; |
| 435 | register int c; |
| 436 | int depth; |
| 437 | int u_lineno = lineno; |
| 438 | char *u_line = dup_line(); |
| 439 | char *u_cptr = u_line + (cptr - line - 6); |
| 440 | |
| 441 | if (unionized) over_unionized(cptr - 6); |
| 442 | unionized = 1; |
| 443 | |
| 444 | if (!lflag) |
| 445 | fprintf(text_file, line_format, lineno, (inc_file?inc_file_name:input_file_name)); |
| 446 | |
| 447 | /* VM: Print to either code file or defines file but not to both */ |
| 448 | dc_file = dflag ? union_file : text_file; |
| 449 | |
| 450 | fprintf(dc_file, "\ntypedef union"); |
| 451 | |
| 452 | depth = 0; |
| 453 | loop: |
| 454 | c = *cptr++; |
| 455 | putc(c, dc_file); |
| 456 | switch (c) { |
| 457 | case '\n': |
| 458 | get_line(); |
| 459 | if (line == 0) unterminated_union(u_lineno, u_line, u_cptr); |
| 460 | goto loop; |
| 461 | case '{': |
| 462 | ++depth; |
| 463 | goto loop; |
| 464 | case '}': |
| 465 | if (--depth == 0) { |
| 466 | fprintf(dc_file, " YYSTYPE;\n"); |
| 467 | FREE(u_line); |
| 468 | return; } |
| 469 | goto loop; |
| 470 | case '\'': |
| 471 | case '"': |
| 472 | copy_string(c, dc_file, 0); |
| 473 | goto loop; |
| 474 | case '/': |
| 475 | copy_comment(dc_file, 0); |
| 476 | goto loop; |
| 477 | default: |
| 478 | goto loop; |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | int hexval(int c) |
| 483 | { |
no test coverage detected