diff options
Diffstat (limited to 'booki.c')
| -rw-r--r-- | booki.c | 8 | 
1 files changed, 8 insertions, 0 deletions
| @@ -765,6 +765,11 @@ struct search_opt parse_search_options(int argc, char* argv[]) {                  edit = true;                  break;              case '?': +                if (!argv[optind] || argv[optind][0] == '-') { +                    printf("%s requires an operand\n", argv[optind-1]); +                    opt_out.count = -1; +                    return opt_out; +                }                  // optind points at the argument (one past the option)                  opt_out.opts[count] = argv[optind-1] + 2;  // '--example' -> 'example'                  opt_out.args[count] = argv[optind]; @@ -786,6 +791,9 @@ struct search_opt parse_search_options(int argc, char* argv[]) {  void search(int argc, char* argv[], char* booki_file) {      struct search_opt search_opts = parse_search_options(argc, argv); +    if (search_opts.count == -1) { +        return; +    }      // get the books array      char* data = load_file(booki_file); | 
