diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-08-01 16:02:09 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-08-01 16:02:09 +0100 |
commit | 7a37f1c767ace97a1dafa258198ca6ca0c9c1830 (patch) | |
tree | 8f24f24baa38a109653f6240ac7ac9b2e2e101ed /util | |
parent | 993f3648b2d11598901e92e81606dea6fcc50adc (diff) |
mc-tool: make bool parsing sane.
Previously, mc-tool update acct bool:foo=true would set foo to False!
Particularly ridiculous given that mc-tool show produces 'true' and
'false', not '1' and '0'.
I'm *sure* I've fixed this before.
Diffstat (limited to 'util')
-rw-r--r-- | util/mc-tool.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/util/mc-tool.c b/util/mc-tool.c index f762203c..98e2dc44 100644 --- a/util/mc-tool.c +++ b/util/mc-tool.c @@ -221,8 +221,23 @@ set_param (GHashTable *parameters, else if (strcmp (type, "bool") == 0 || strcmp (type, "boolean") == 0) { g_value_init (gvalue, G_TYPE_BOOLEAN); - g_value_set_boolean (gvalue, atoi (value)); - ret = TRUE; + if (g_ascii_strcasecmp (value, "1") == 0 || + g_ascii_strcasecmp (value, "true") == 0 || + /* "yes please!" / "yes sir, captain tightpants" */ + g_ascii_strncasecmp (value, "yes", 3) == 0 || + g_ascii_strcasecmp (value, "mos def") == 0) + { + g_value_set_boolean (gvalue, TRUE); + ret = TRUE; + } + else if (g_ascii_strcasecmp (value, "0") == 0 || + g_ascii_strcasecmp (value, "false") == 0 || + g_ascii_strcasecmp (value, "no") == 0 || + g_ascii_strcasecmp (value, "nope") == 0) + { + g_value_set_boolean (gvalue, FALSE); + ret = TRUE; + } } else if (strcmp (type, "string") == 0) { |