diff --git a/ask.c b/ask.c index fcde6fd..b7df3ce 100644 --- a/ask.c +++ b/ask.c @@ -188,7 +188,7 @@ static char *get_input(FILE *in, FILE *out, const char *prompt, const char *init } int start = 0, backtrack = 0; - while (1) { + for (;;) { case_sensitive = 0; for (const char *p = buf; *p; ++p) case_sensitive |= ('A' <= *p && *p <= 'Z'); @@ -391,12 +391,17 @@ int main(int argc, char *argv[]) case '0': delim = '\0'; break; case 'y': yes = 1; quickpick = 1; break; case 'n': no = 1; quickpick = 1; break; + case 'p': + if (a + 1 >= argc) goto help_flag; + prompt = argv[++a]; + break; + case 'q': + if (a + 1 >= argc) goto help_flag; + query = argv[++a]; + break; + default: goto help_flag; } } - } else if (strcmp(argv[a], "-p") == 0) { - prompt = argv[++a]; - } else if (strcmp(argv[a], "-q") == 0) { - query = argv[++a]; } else if (strncmp(argv[a], "--read0", strlen("--read0")) == 0) { delim = '\0'; } else if (strncmp(argv[a], "--prompt=", strlen("--prompt=")) == 0) {