static void parse_options(int argc, char *argv[]) { int c; int i; String_List *tmp_slist; int seen_f_option = 0; /* ** The set of options for mkinit and mkinit_erl should be ** kept in sync, even if they may not necessarily make sense. */ while ((c = getopt(argc, argv, "A:c:f:g:iI:lm:o:r:tw:xX:ks")) != EOF) { switch (c) { case 'A': /* ** Add the argument to the end of the list of always executed ** initialization functions. */ if (optarg[0] != '\0') { tmp_slist = (String_List *) checked_malloc(sizeof(String_List)); tmp_slist->next = NULL; tmp_slist->data = (char *) checked_malloc(strlen(optarg) + 1); strcpy(tmp_slist->data, optarg); *always_exec_funcs_tail = tmp_slist; always_exec_funcs_tail = &tmp_slist->next; } break; case 'c': if (sscanf(optarg, "%d", &maxcalls) != 1) { usage(); } break; case 'f': process_file_list_file(optarg); seen_f_option = 1; break; case 'g': grade = optarg; break; case 'i': need_initialization_code = MR_TRUE; break; case 'I': add_init_file_dir(optarg); break; case 'l': output_main_func = MR_FALSE; break; case 'o': if (strcmp(optarg, "-") == 0) { output_file_name = NULL; /* output to stdout */ } else { output_file_name = optarg; } break; case 'r': /* ** Add the argument to the end of the list of runtime flags. */ if (optarg[0] != '\0') { tmp_slist = (String_List *) checked_malloc(sizeof(String_List)); tmp_slist->next = NULL; tmp_slist->data = (char *) checked_malloc(strlen(optarg) + 1); strcpy(tmp_slist->data, optarg); *runtime_flags_tail = tmp_slist; runtime_flags_tail = &tmp_slist->next; } break; case 't': need_tracing = MR_TRUE; need_initialization_code = MR_TRUE; break; case 'w': hl_entry_point = entry_point = optarg; break; case 'x': /* We always assume this option. */ break; case 'X': experimental_complexity = optarg; break; case 'k': output_task = TASK_OUTPUT_LIB_INIT; break; case 's': output_task = TASK_OUTPUT_STANDALONE_INIT; output_main_func = MR_FALSE; /* -s implies -l */ break; case 'm': /* Used by mkinit_erl. */ usage(); default: usage(); } } if (seen_f_option) { /* ** -f could be made compatible if we copied the filenames ** from argv into files. ** */ if ((argc - optind) > 0) { fprintf(stderr, "%s: -f incompatible with filenames on the command line\n", MR_progname); exit(EXIT_FAILURE); } } else { num_files = argc - optind; files = argv + optind; } if (num_files <= 0) { usage(); } }
static void parse_options(int argc, char *argv[]) { int c; int seen_f_option = 0; /* ** The set of options for mkinit and mkinit_erl should be ** kept in sync, even if they may not necessarily make sense. */ while ((c = getopt(argc, argv, "A:c:f:g:iI:lo:r:tw:xX:ksm:")) != EOF) { switch (c) { case 'f': process_file_list_file(optarg); seen_f_option = 1; break; case 'g': grade = optarg; break; case 'I': add_init_file_dir(optarg); break; case 'm': module_name = optarg; break; case 'o': if (strcmp(optarg, "-") == 0) { output_file_name = NULL; /* output to stdout */ } else { output_file_name = optarg; } break; case 'x': /* We always assume this option. */ break; case 'k': output_task = TASK_OUTPUT_LIB_INIT; break; case 'A': case 'c': case 'l': case 'i': case 'r': case 't': case 'w': case 'X': case 's': /* Used by mkinit. */ usage(); default: usage(); } } if (seen_f_option) { /* ** -f could be made compatible if we copied the filenames ** from argv into files. ** */ if ((argc - optind) > 0) { fprintf(stderr, "%s: -f incompatible with filenames on the command line\n", MR_progname); exit(EXIT_FAILURE); } } else { num_files = argc - optind; files = argv + optind; } if (num_files <= 0) { usage(); } }