deps/opts-parser: Skip parsing of empty strings

master
Richard Stanway 2022-07-20 03:12:32 +02:00
parent 91c353c774
commit 009fc43bee
No known key found for this signature in database
GPG Key ID: 4F96FCA24BCE7BA1
1 changed files with 15 additions and 9 deletions

View File

@ -24,16 +24,13 @@ static bool getparam(const char *param, char **name, const char **value)
struct obs_options obs_parse_options(const char *options_string) struct obs_options obs_parse_options(const char *options_string)
{ {
if (!options_string || !*options_string)
goto failure;
char **input_words = strlist_split(options_string, ' ', false); char **input_words = strlist_split(options_string, ' ', false);
if (!input_words) { if (!input_words)
return (struct obs_options){ goto failure;
.count = 0,
.options = NULL,
.ignored_word_count = 0,
.ignored_words = NULL,
.input_words = NULL,
};
}
size_t input_option_count = 0; size_t input_option_count = 0;
for (char **input_word = input_words; *input_word; ++input_word) for (char **input_word = input_words; *input_word; ++input_word)
input_option_count += 1; input_option_count += 1;
@ -59,6 +56,15 @@ struct obs_options obs_parse_options(const char *options_string)
.ignored_words = ignored_words, .ignored_words = ignored_words,
.input_words = input_words, .input_words = input_words,
}; };
failure:
return (struct obs_options){
.count = 0,
.options = NULL,
.ignored_word_count = 0,
.ignored_words = NULL,
.input_words = NULL,
};
} }
void obs_free_options(struct obs_options options) void obs_free_options(struct obs_options options)