diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/name-value.c | 14 | ||||
-rw-r--r-- | common/name-value.h | 3 |
2 files changed, 11 insertions, 6 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; } diff --git a/common/name-value.h b/common/name-value.h index cf854e04d..504b5d0f0 100644 --- a/common/name-value.h +++ b/common/name-value.h @@ -75,7 +75,8 @@ nve_t nve_next_value (nve_t entry, const char *name); /* Return the string for the first entry in NVC with NAME or NULL. */ const char *nvc_get_string (nvc_t nvc, const char *name); -/* Return a boolean value for the first entry in NVC with NAME. */ +/* Return a boolean value (zero or non-zero) for the first entry in + * NVC with NAME. */ int nvc_get_boolean (nvc_t nvc, const char *name); |