diff options
Diffstat (limited to 'yacc/main.c')
-rw-r--r-- | yacc/main.c | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/yacc/main.c b/yacc/main.c index 65845b1d8..8f8590c28 100644 --- a/yacc/main.c +++ b/yacc/main.c @@ -51,19 +51,19 @@ char *text_file_name; char *union_file_name; char *verbose_file_name; -FILE *action_file; /* a temp file, used to save actions associated */ - /* with rules until the parser is written */ +FILE *action_file; /* a temp file, used to save actions associated */ + /* with rules until the parser is written */ FILE *entry_file; -FILE *code_file; /* y.code.c (used when the -r option is specified) */ -FILE *defines_file; /* y.tab.h */ -FILE *input_file; /* the input file */ -FILE *output_file; /* y.tab.c */ -FILE *text_file; /* a temp file, used to save text until all */ - /* symbols have been defined */ -FILE *union_file; /* a temp file, used to save the union */ - /* definition until all symbol have been */ - /* defined */ -FILE *verbose_file; /* y.output */ +FILE *code_file; /* y.code.c (used when the -r option is specified) */ +FILE *defines_file; /* y.tab.h */ +FILE *input_file; /* the input file */ +FILE *output_file; /* y.tab.c */ +FILE *text_file; /* a temp file, used to save text until all */ + /* symbols have been defined */ +FILE *union_file; /* a temp file, used to save the union */ + /* definition until all symbol have been */ + /* defined */ +FILE *verbose_file; /* y.output */ FILE *interface_file; int nitems; @@ -119,15 +119,15 @@ void set_signals(void) { #ifdef SIGINT if (signal(SIGINT, SIG_IGN) != SIG_IGN) - signal(SIGINT, onintr); + signal(SIGINT, onintr); #endif #ifdef SIGTERM if (signal(SIGTERM, SIG_IGN) != SIG_IGN) - signal(SIGTERM, onintr); + signal(SIGTERM, onintr); #endif #ifdef SIGHUP if (signal(SIGHUP, SIG_IGN) != SIG_IGN) - signal(SIGHUP, onintr); + signal(SIGHUP, onintr); #endif } @@ -147,51 +147,51 @@ void getargs(int argc, char **argv) if (argc > 0) myname = argv[0]; for (i = 1; i < argc; ++i) { - s = argv[i]; - if (*s != '-') break; - switch (*++s) - { - case '\0': - input_file = stdin; - if (i + 1 < argc) usage(); - return; - - case '-': - ++i; - goto no_more_options; + s = argv[i]; + if (*s != '-') break; + switch (*++s) + { + case '\0': + input_file = stdin; + if (i + 1 < argc) usage(); + return; + + case '-': + ++i; + goto no_more_options; case 'v': vflag = 1; break; - case 'b': - if (*++s) - file_prefix = s; - else if (++i < argc) - file_prefix = argv[i]; - else - usage(); - continue; - - default: - usage(); - } - - for (;;) - { - switch (*++s) - { - case '\0': - goto end_of_option; - - case 'v': - vflag = 1; - break; - - default: - usage(); - } - } + case 'b': + if (*++s) + file_prefix = s; + else if (++i < argc) + file_prefix = argv[i]; + else + usage(); + continue; + + default: + usage(); + } + + for (;;) + { + switch (*++s) + { + case '\0': + goto end_of_option; + + case 'v': + vflag = 1; + break; + + default: + usage(); + } + } end_of_option:; } @@ -223,8 +223,8 @@ allocate(unsigned int n) p = NULL; if (n) { - p = CALLOC(1, n); - if (!p) no_space(); + p = CALLOC(1, n); + if (!p) no_space(); } return (p); } @@ -244,7 +244,7 @@ void create_file_names(void) len = strlen(tmpdir); i = len + sizeof(temp_form); if (len && tmpdir[len-1] != '/') - ++i; + ++i; #endif action_file_name = MALLOC(i); @@ -264,11 +264,11 @@ void create_file_names(void) if (len && tmpdir[len - 1] != '/') { - action_file_name[len] = '/'; - entry_file_name[len] = '/'; - text_file_name[len] = '/'; - union_file_name[len] = '/'; - ++len; + action_file_name[len] = '/'; + entry_file_name[len] = '/'; + text_file_name[len] = '/'; + union_file_name[len] = '/'; + ++len; } #endif @@ -293,7 +293,7 @@ void create_file_names(void) output_file_name = MALLOC(len + 7); if (output_file_name == 0) - no_space(); + no_space(); strcpy(output_file_name, file_prefix); strcpy(output_file_name + len, OUTPUT_SUFFIX); @@ -301,16 +301,16 @@ void create_file_names(void) if (vflag) { - verbose_file_name = MALLOC(len + 8); - if (verbose_file_name == 0) - no_space(); - strcpy(verbose_file_name, file_prefix); - strcpy(verbose_file_name + len, VERBOSE_SUFFIX); + verbose_file_name = MALLOC(len + 8); + if (verbose_file_name == 0) + no_space(); + strcpy(verbose_file_name, file_prefix); + strcpy(verbose_file_name + len, VERBOSE_SUFFIX); } interface_file_name = MALLOC(len + 8); if (interface_file_name == 0) - no_space(); + no_space(); strcpy(interface_file_name, file_prefix); strcpy(interface_file_name + len, INTERFACE_SUFFIX); @@ -323,52 +323,52 @@ void open_files(void) if (input_file == 0) { - input_file = fopen(input_file_name, "r"); - if (input_file == 0) - open_error(input_file_name); + input_file = fopen(input_file_name, "r"); + if (input_file == 0) + open_error(input_file_name); } action_file = fopen(action_file_name, "w"); if (action_file == 0) - open_error(action_file_name); + open_error(action_file_name); entry_file = fopen(entry_file_name, "w"); if (entry_file == 0) - open_error(entry_file_name); + open_error(entry_file_name); text_file = fopen(text_file_name, "w"); if (text_file == 0) - open_error(text_file_name); + open_error(text_file_name); if (vflag) { - verbose_file = fopen(verbose_file_name, "w"); - if (verbose_file == 0) - open_error(verbose_file_name); + verbose_file = fopen(verbose_file_name, "w"); + if (verbose_file == 0) + open_error(verbose_file_name); } if (dflag) { - defines_file = fopen(defines_file_name, "w"); - if (defines_file == 0) - open_error(defines_file_name); - union_file = fopen(union_file_name, "w"); - if (union_file == 0) - open_error(union_file_name); + defines_file = fopen(defines_file_name, "w"); + if (defines_file == 0) + open_error(defines_file_name); + union_file = fopen(union_file_name, "w"); + if (union_file == 0) + open_error(union_file_name); } output_file = fopen(output_file_name, "w"); if (output_file == 0) - open_error(output_file_name); + open_error(output_file_name); if (rflag) { - code_file = fopen(code_file_name, "w"); - if (code_file == 0) - open_error(code_file_name); + code_file = fopen(code_file_name, "w"); + if (code_file == 0) + open_error(code_file_name); } else - code_file = output_file; + code_file = output_file; interface_file = fopen(interface_file_name, "w"); |