int main (int argc, char **argv) { program_name = basename (argv[0]); scan_options (argc, argv); stack *stack = new_stack (); bool quit = false; yy_flex_debug = false; while (! quit) { int token = yylex(); if (token == YYEOF) break; switch (token) { case NUMBER: do_push (stack, yytext); break; case '+': do_binop (stack, add_bigint); break; case '-': do_binop (stack, sub_bigint); break; case '*': do_binop (stack, mul_bigint); break; case 'c': do_clear (stack); break; case 'f': do_print_all (stack); break; case 'p': do_print (stack); break; case 'q': quit = true; break; default: unimplemented (token); break; } } yycleanup(); DEBUGF ('m', "EXIT %d\n", exit_status); do_clear(stack); free_stack(stack); return EXIT_SUCCESS; }
int main (int argc, char **argv) { Exec_Name = basename (argv[0]); char *default_dictionary = DEFAULT_DICTNAME; char *user_dictionary = NULL; hashset_ref hashset = new_hashset (); yy_flex_debug = false; // Scan the arguments and set flags. opterr = false; for (;;) { int option = getopt (argc, argv, "nxyd:@:"); if (option == EOF) break; switch (option) { char optopt_string[16]; // used in default: case 'd': user_dictionary = optarg; break; case 'n': default_dictionary = NULL; break; case 'x': option_x(hashset); break; case 'y': yy_flex_debug = true; break; case '@': set_debugflags (optarg); if (strpbrk (optarg, "@y")) yy_flex_debug = true; break; default : sprintf (optopt_string, "-%c", optopt); print_error (optopt_string, "invalid option"); break; } } // Load the dictionaries into the hash table. load_dictionary (default_dictionary, hashset); load_dictionary (user_dictionary, hashset); // Read and do spell checking on each of the files. if (optind >= argc) { yyin = stdin; spellcheck (STDIN_NAME, hashset); }else { int fileix = optind; for (; fileix < argc; ++fileix) { DEBUGF ('m', "argv[%d] = \"%s\"\n", fileix, argv[fileix]); char *filename = argv[fileix]; if (strcmp (filename, STDIN_NAME) == 0) { yyin = stdin; spellcheck (STDIN_NAME, hashset); }else { yyin = open_infile (filename); if (yyin == NULL) continue; spellcheck (filename, hashset); fclose (yyin); } } } yycleanup (); return Exit_Status; }