barbieri pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=c05152fcd4b2b358d206432b430a0b3591132ae2
commit c05152fcd4b2b358d206432b430a0b3591132ae2 Author: Gustavo Sverzut Barbieri <[email protected]> Date: Thu Oct 27 20:57:47 2016 -0200 ecore_getopt: allow empty strings as parameters. Sometimes we want to specify an empty string, that should be allowed. --- src/lib/ecore/ecore_getopt.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/lib/ecore/ecore_getopt.c b/src/lib/ecore/ecore_getopt.c index 50f3c7c..c85a71a 100644 --- a/src/lib/ecore/ecore_getopt.c +++ b/src/lib/ecore/ecore_getopt.c @@ -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)) --
