aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2012-03-20 10:46:03 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2012-03-20 10:46:03 -0400
commitb51edf37c4271bf5ec5dcad9d35169f55e38efa9 (patch)
tree66653936b87078aa96a562e05f66660b4d616d8e /main.c
parentcd44d957787e162df4348028c22e8b9621000790 (diff)
downloadegawk-b51edf37c4271bf5ec5dcad9d35169f55e38efa9.tar.gz
egawk-b51edf37c4271bf5ec5dcad9d35169f55e38efa9.tar.bz2
egawk-b51edf37c4271bf5ec5dcad9d35169f55e38efa9.zip
- 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.
Diffstat (limited to 'main.c')
-rw-r--r--main.c41
1 files changed, 26 insertions, 15 deletions
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;
}