From 2072cca806ac43a5ee0d422749e9e0c5f7611d47 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 30 Sep 2014 09:55:51 -0400 Subject: Fix minor bug: the "-h" option should not require an argument. --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 645a4561..03decbb8 100644 --- a/main.c +++ b/main.c @@ -212,7 +212,7 @@ main(int argc, char **argv) /* * The + on the front tells GNU getopt not to rearrange argv. */ - const char *optlist = "+F:f:v:W;bcCd::D::e:E:gh:i:l:L:nNo::Op::MPrStVY"; + const char *optlist = "+F:f:v:W;bcCd::D::e:E:ghi:l:L:nNo::Op::MPrStVY"; bool stopped_early = false; int old_optind; int i; -- cgit v1.2.3 From 74ee0dcab17240a1626b77ed998b07f0f6560a48 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 15 Oct 2014 11:40:12 +0300 Subject: Sanitize handling of AWKPATH / AWKLIBPATH. --- main.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 03decbb8..3bee0488 100644 --- a/main.c +++ b/main.c @@ -1078,18 +1078,23 @@ path_environ(const char *pname, const char *dflt) NODE *tmp; tmp = make_string(pname, strlen(pname)); - if (! in_array(ENVIRON_node, tmp)) { - /* - * On VMS, environ[] only holds a subset of what getenv() can - * find, so look AWKPATH up before resorting to default path. - */ - val = getenv(pname); - if (val == NULL) - val = dflt; - aptr = assoc_lookup(ENVIRON_node, tmp); + /* + * On VMS, environ[] only holds a subset of what getenv() can + * find, so look AWKPATH up before resorting to default path. + */ + val = getenv(pname); + if (val == NULL || *val == '\0') + val = dflt; + aptr = assoc_lookup(ENVIRON_node, tmp); + /* + * If original value was the empty string, set it to + * the default value. + */ + if ((*aptr)->stlen == 0) { unref(*aptr); *aptr = make_string(val, strlen(val)); } + unref(tmp); } @@ -1136,6 +1141,11 @@ load_environ() /* * Put AWKPATH and AWKLIBPATH into ENVIRON if not already there. * This allows querying it from within awk programs. + * + * October 2014: + * If their values are "", override with the default values; + * since 2.10 AWKPATH used default value if environment's + * value was "". */ path_environ("AWKPATH", defpath); path_environ("AWKLIBPATH", deflibpath); -- cgit v1.2.3