summaryrefslogtreecommitdiff
path: root/src/lib/ecore/ecore_getopt.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-10-27 20:57:47 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-10-31 19:38:22 -0200
commitc05152fcd4b2b358d206432b430a0b3591132ae2 (patch)
treeda65889bebcdd1dc5e36d78f465f9052c5a2b004 /src/lib/ecore/ecore_getopt.c
parent1ea6a42f7a15a3b0a6e09a2bbdd5ddc46d14446f (diff)
ecore_getopt: allow empty strings as parameters.
Sometimes we want to specify an empty string, that should be allowed.
Diffstat (limited to 'src/lib/ecore/ecore_getopt.c')
-rw-r--r--src/lib/ecore/ecore_getopt.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/lib/ecore/ecore_getopt.c b/src/lib/ecore/ecore_getopt.c
index 50f3c7c814..c85a71a15d 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,
1694 arg_val = NULL; 1694 arg_val = NULL;
1695 } 1695 }
1696 1696
1697 if (arg_val && arg_val[0] == '\0') 1697 /* empty strings are still valid values */
1698 arg_val = NULL; 1698 if (!(((desc->action == ECORE_GETOPT_ACTION_STORE) &&
1699 (desc->action_param.store.type == ECORE_GETOPT_TYPE_STR)) ||
1700 ((desc->action == ECORE_GETOPT_ACTION_APPEND) &&
1701 (desc->action_param.append_type == ECORE_GETOPT_TYPE_STR))))
1702 {
1703 if (arg_val && arg_val[0] == '\0')
1704 arg_val = NULL;
1705 }
1699 1706
1700 if ((!arg_val) && (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) 1707 if ((!arg_val) && (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES))
1701 { 1708 {
@@ -1773,8 +1780,15 @@ _ecore_getopt_parse_arg_short(const Ecore_Getopt *parser,
1773 arg_val = NULL; 1780 arg_val = NULL;
1774 } 1781 }
1775 1782
1776 if (arg_val && arg_val[0] == '\0') 1783 /* empty strings are still valid values */
1777 arg_val = NULL; 1784 if (!(((desc->action == ECORE_GETOPT_ACTION_STORE) &&
1785 (desc->action_param.store.type == ECORE_GETOPT_TYPE_STR)) ||
1786 ((desc->action == ECORE_GETOPT_ACTION_APPEND) &&
1787 (desc->action_param.append_type == ECORE_GETOPT_TYPE_STR))))
1788 {
1789 if (arg_val && arg_val[0] == '\0')
1790 arg_val = NULL;
1791 }
1778 1792
1779 if ((!arg_val) && 1793 if ((!arg_val) &&
1780 (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) 1794 (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES))