From bda244f5645a636ec7a76d30198e473d956736cf Mon Sep 17 00:00:00 2001 From: hniksic Date: Wed, 10 Sep 2003 13:21:21 -0700 Subject: [PATCH] [svn] Allow --foo=yes/no in addition to --foo=on/off. --- NEWS | 3 +++ src/ChangeLog | 5 +++++ src/init.c | 30 ++++++++++++++++++++---------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 27b5b5a3..073a95bd 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,9 @@ log on to the proxy as "username@host". ** The new option `--retry-connrefused' makes Wget retry downloads even in the face of refused connections, which are otherwise considered a fatal error. + +** The new option `--dns-cache=off' may be used to prevent Wget from +caching DNS lookups. * Wget 1.8.1 is a bugfix release with no user-visible changes. diff --git a/src/ChangeLog b/src/ChangeLog index e9137edd..26efc224 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-09-10 Hrvoje Niksic + + * init.c (cmd_boolean): Accept yes/no along with on/off. + (cmd_lockable_boolean): Ditto. + 2003-09-10 Hrvoje Niksic * init.c: New command dns_cache. diff --git a/src/init.c b/src/init.c index 16ef2561..124bfb10 100644 --- a/src/init.c +++ b/src/init.c @@ -543,12 +543,22 @@ static int cmd_boolean (const char *com, const char *val, void *closure) { int bool_value; + const char *v = val; +#define LC(x) TOLOWER(x) - if (!strcasecmp (val, "on") - || (*val == '1' && !*(val + 1))) + if ((LC(v[0]) == 'o' && LC(v[1]) == 'n' && !v[2]) + || + (LC(v[0]) == 'y' && LC(v[1]) == 'e' && LC(v[2]) == 's' && !v[3]) + || + (v[0] == '1' && !v[1])) + /* "on", "yes" and "1" mean true. */ bool_value = 1; - else if (!strcasecmp (val, "off") - || (*val == '0' && !*(val + 1))) + else if ((LC(v[0]) == 'o' && LC(v[1]) == 'f' && LC(v[2]) == 'f' && !v[3]) + || + (LC(v[0]) == 'n' && LC(v[1]) == 'o' && !v[2]) + || + (v[0] == '0' && !v[1])) + /* "off", "no" and "0" mean false. */ bool_value = 0; else { @@ -582,17 +592,17 @@ cmd_lockable_boolean (const char *com, const char *val, void *closure) if (*(int *)closure == -1 || *(int *)closure == 2) return 1; - if (!strcasecmp (val, "always") - || (*val == '2' && !*(val + 1))) + if (!strcasecmp (val, "always") || !strcmp (val, "2")) lockable_boolean_value = 2; else if (!strcasecmp (val, "on") - || (*val == '1' && !*(val + 1))) + || !strcasecmp (val, "yes") + || !strcmp (val, "1")) lockable_boolean_value = 1; else if (!strcasecmp (val, "off") - || (*val == '0' && !*(val + 1))) + || !strcasecmp (val, "no") + || !strcmp (val, "0")) lockable_boolean_value = 0; - else if (!strcasecmp (val, "never") - || (*val == '-' && *(val + 1) == '1' && !*(val + 2))) + else if (!strcasecmp (val, "never") || !strcmp (val, "-1")) lockable_boolean_value = -1; else {