ecore_getopt: allow empty strings as parameters.

Sometimes we want to specify an empty string, that should be allowed.
This commit is contained in:
Gustavo Sverzut Barbieri 2016-10-27 20:57:47 -02:00
parent 1ea6a42f7a
commit c05152fcd4
1 changed files with 18 additions and 4 deletions

View File

@ -1694,8 +1694,15 @@ _ecore_getopt_parse_arg_long(const Ecore_Getopt *parser,
arg_val = NULL;
}
if (arg_val && arg_val[0] == '\0')
arg_val = NULL;
/* empty strings are still valid values */
if (!(((desc->action == ECORE_GETOPT_ACTION_STORE) &&
(desc->action_param.store.type == ECORE_GETOPT_TYPE_STR)) ||
((desc->action == ECORE_GETOPT_ACTION_APPEND) &&
(desc->action_param.append_type == ECORE_GETOPT_TYPE_STR))))
{
if (arg_val && arg_val[0] == '\0')
arg_val = NULL;
}
if ((!arg_val) && (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES))
{
@ -1773,8 +1780,15 @@ _ecore_getopt_parse_arg_short(const Ecore_Getopt *parser,
arg_val = NULL;
}
if (arg_val && arg_val[0] == '\0')
arg_val = NULL;
/* empty strings are still valid values */
if (!(((desc->action == ECORE_GETOPT_ACTION_STORE) &&
(desc->action_param.store.type == ECORE_GETOPT_TYPE_STR)) ||
((desc->action == ECORE_GETOPT_ACTION_APPEND) &&
(desc->action_param.append_type == ECORE_GETOPT_TYPE_STR))))
{
if (arg_val && arg_val[0] == '\0')
arg_val = NULL;
}
if ((!arg_val) &&
(arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES))