diff options
author | Werner Koch <[email protected]> | 2023-01-24 08:29:04 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2023-01-24 09:07:02 +0000 |
commit | f35e7dbf9e71f847f3c7da40542bd6c37f43711e (patch) | |
tree | 68d822b9b43bd3b7e0961449fc7a438dee3653e0 /common/name-value.c | |
parent | doc: Remove profile and systemd example files. (diff) | |
download | gnupg-f35e7dbf9e71f847f3c7da40542bd6c37f43711e.tar.gz gnupg-f35e7dbf9e71f847f3c7da40542bd6c37f43711e.zip |
common: Slight redefinition of nvc_get_boolean.
* common/name-value.c (nvc_get_boolean): Rewrite.
--
The function may now return a positive or negative number instead of
just 1 for true. All callers were already prepared for this.
GnuPG-bug-id: 6212
Diffstat (limited to 'common/name-value.c')
-rw-r--r-- | common/name-value.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/common/name-value.c b/common/name-value.c index d1d0a3f6f..67429e47f 100644 --- a/common/name-value.c +++ b/common/name-value.c @@ -608,13 +608,14 @@ nvc_get_string (nvc_t nvc, const char *name) } -/* Return true if NAME exists and its value is true; that is either - * "yes", "true", or a decimal value unequal to 0. */ +/* Return true (ie. a non-zero value) if NAME exists and its value is + * true; that is either "yes", "true", or a decimal value unequal to 0. */ int nvc_get_boolean (nvc_t nvc, const char *name) { nve_t item; const char *s; + int n; if (!nvc) return 0; @@ -622,9 +623,12 @@ nvc_get_boolean (nvc_t nvc, const char *name) if (!item) return 0; s = nve_value (item); - if (s && (atoi (s) - || !ascii_strcasecmp (s, "yes") - || !ascii_strcasecmp (s, "true"))) + if (!s) + return 0; + n = atoi (s); + if (n) + return n; + if (!ascii_strcasecmp (s, "yes") || !ascii_strcasecmp (s, "true")) return 1; return 0; } |