int main (int argc, char **argv) { program_name = basename (argv[0]); char *default_dictionary = DEFAULT_DICTNAME; char *user_dictionary = NULL; hashset *hashset = new_hashset (); yy_flex_debug = false; scan_options (argc, argv, &default_dictionary, &user_dictionary); // Load the dictionaries into the hash table. load_dictionary (default_dictionary, hashset); load_dictionary (user_dictionary, hashset); if(x == true) { handle_x(hashset); return exit_status; } // Read and do spell checking on each of the files. if (optind >= argc) { yyin = stdin; spellcheck (STDIN_NAME, hashset); }else { for (int fileix = optind; 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); } } } yylex_destroy (); free_hashset(hashset); return exit_status; }
int main (int argc, char **argv) { Exec_Name = basename (argv[0]); char *default_dictionary = DEFAULT_DICTNAME; char *user_dictionary = NULL; hashset *hashset = new_hashset (); yy_flex_debug = false; Exit_Status = 0; // 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 'q': mega_debugz = true; break; case 'x': if(debugz) { mega_debugz = true; debugz = false; break; } debugz = true; 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 { for (int fileix = optind; 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); } } } if(mega_debugz) megaDebugPrint(hashset); if(debugz) debugPrint(hashset); yylex_destroy (); free_hashset(hashset); free(hashset); return Exit_Status; }