From b51edf37c4271bf5ec5dcad9d35169f55e38efa9 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 20 Mar 2012 10:46:03 -0400 Subject: - Add new environment variable AWKLIBPATH to use when searching for shared libraries. - Instead of hardcoding the default ".so" suffix for shared libraries, use autoconf to get the right value for this platform. - Build and install some of the bundled shared library extensions so that they will now be available using the default AWKLIBPATH. --- main.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 8899db59..693db0f4 100644 --- a/main.c +++ b/main.c @@ -973,6 +973,29 @@ init_vars() /* load_environ --- populate the ENVIRON array */ +static void +path_environ(const char *pname, const char *dflt) +{ + char *val; + NODE **aptr; + 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); + unref(*aptr); + *aptr = make_string(val, strlen(val)); + } + unref(tmp); +} + static NODE * load_environ() { @@ -1006,23 +1029,11 @@ load_environ() *--val = '='; } /* - * Put AWKPATH into ENVIRON if it's not there. + * Put AWKPATH and AWKLIBPATh into ENVIRON if not already there. * This allows querying it from within awk programs. */ - tmp = make_string("AWKPATH", 7); - 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("AWKPATH"); - if (val == NULL) - val = defpath; - aptr = assoc_lookup(ENVIRON_node, tmp); - unref(*aptr); - *aptr = make_string(val, strlen(val)); - } - unref(tmp); + path_environ("AWKPATH", defpath); + path_environ("AWKLIBPATH", deflibpath); return ENVIRON_node; } -- cgit v1.2.3