gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, xgawk, created. b51edf37c4271bf5ec5dcad9


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, xgawk, created. b51edf37c4271bf5ec5dcad9d35169f55e38efa9
Date: Tue, 20 Mar 2012 14:49:37 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, xgawk has been created
        at  b51edf37c4271bf5ec5dcad9d35169f55e38efa9 (commit)

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=b51edf37c4271bf5ec5dcad9d35169f55e38efa9

commit b51edf37c4271bf5ec5dcad9d35169f55e38efa9
Author: Andrew J. Schorr <address@hidden>
Date:   Tue Mar 20 10:46:03 2012 -0400

    - 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.

diff --git a/ChangeLog b/ChangeLog
index f5d1a8a..eda35ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2012-03-20         Andrew J. Schorr     <address@hidden>
+
+       * Makefile.am (EXTRA_DIST): Remove extension.
+       (SUBDIRS): Add extension so libraries will be built.
+       (DEFS): Define DEFLIBPATH and SHLIBEXT so we can find shared libraries.
+       * awk.h (deflibpath): New extern declaration.
+       * configure.ac: Add support for building shared libraries by adding
+       AC_PROG_LIBTOOL and AC_SUBST for acl_shlibext and pkgextensiondir.
+       (AC_CONFIG_FILES): Add extension/Makefile.
+       * io.c (pi_awkpath, pi_awklibpath): New static structures to contain
+       path information.
+       (awkpath, max_pathlen): Remove static variables now inside pi_awkpath.
+       (init_awkpath): Operate on path_info structure to support both
+       AWKPATH and AWKLIBPATH.  No need for max_path to be static, since
+       this should be called only once for each environment variable.
+       (do_find_source): Add a path_info arg to specify which path to search.
+       Check the try_cwd parameter to decide whether to search the current
+       directory (not desirable for AWKLIBPATH).
+       (find_source): Choose appropriate path_info structure based on value
+       of the is_extlib argument.  Set EXTLIB_SUFFIX using SHLIBEXT define
+       instead of hardcoding ".so".
+       * main.c (path_environ): New function to add AWKPATH or AWKLIBPATH
+       to the ENVIRON array.
+       (load_environ): Call path_environ for AWKPATH and AWKLIBPATH.
+
 2012-01-02         Arnold D. Robbins     <address@hidden>
 
        * io.c (Read_can_timeout, Read_timeout, Read_default_timeout):
diff --git a/Makefile.am b/Makefile.am
index b947061..11932aa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -48,7 +48,6 @@ EXTRA_DIST = \
        config.rpath  \
        config.sub \
        depcomp \
-       extension \
        m4 \
        missing \
        missing_d \
@@ -76,6 +75,7 @@ SUBDIRS = \
        awklib \
        doc \
        po \
+       extension \
        test
 
 # what to make and install
@@ -136,7 +136,11 @@ pkgdatadir = $(datadir)/awk
 # stuff for compiling gawk/pgawk
 DEFPATH='".$(PATH_SEPARATOR)$(pkgdatadir)"'
 
-DEFS= -DDEFPATH=$(DEFPATH) -DHAVE_CONFIG_H -DGAWK 
-DLOCALEDIR='"$(datadir)/locale"'
+# shared library support:
+SHLIBEXT = "\"$(acl_shlibext)"\"
+DEFLIBPATH="\"$(pkgextensiondir)\""
+
+DEFS= -DDEFPATH=$(DEFPATH) -DDEFLIBPATH=$(DEFLIBPATH) -DSHLIBEXT=$(SHLIBEXT) 
-DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"$(datadir)/locale"'
 
 # Get rid of core files when cleaning
 CLEANFILES = core core.*
diff --git a/awk.h b/awk.h
index 7259390..d670780 100644
--- a/awk.h
+++ b/awk.h
@@ -1082,6 +1082,7 @@ extern const char def_strftime_format[];
 
 extern char quote;
 extern char *defpath;
+extern char *deflibpath;
 extern char envsep;
 
 extern char casetable[];       /* for case-independent regexp matching */
diff --git a/configure.ac b/configure.ac
index 3b0ba33..a7de26a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,7 @@ AC_PROG_YACC
 AC_PROG_LN_S
 AC_PROG_CC
 AC_PROG_CPP
+AC_PROG_LIBTOOL
 
 AC_OBJEXT
 AC_EXEEXT
@@ -99,6 +100,11 @@ fi
 
 AC_SUBST(CFLAGS)
 
+# shared library suffix for dynamic loading:
+AC_SUBST(acl_shlibext)
+# default shared library location
+AC_SUBST([pkgextensiondir], ['${pkglibdir}'/$VERSION])
+
 dnl checks for systems
 AC_ZOS_USS
 AC_ISC_POSIX
@@ -357,6 +363,7 @@ AH_BOTTOM([#include "custom.h"])
 
 AC_CONFIG_FILES(Makefile
        awklib/Makefile
+       extension/Makefile
        doc/Makefile
        po/Makefile.in
        test/Makefile)
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 2bbb982..3ff659e 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2012-03-20         Andrew J. Schorr     <address@hidden>
+
+       * gawk.texi, gawk.1: Add AWKLIBPATH.
+
 2012-02-06         Arnold D. Robbins     <address@hidden>
 
        * gawk.texi, gawk.1: And some minor edits thereunto.
diff --git a/doc/gawk.1 b/doc/gawk.1
index 07a8d0e..cc0ccae 100644
--- a/doc/gawk.1
+++ b/doc/gawk.1
@@ -330,11 +330,10 @@ these options cause an immediate, successful exit.)
 Load a shared library
 .IR lib .
 This searches for the library using the
-.B AWKPATH
-environment variable. The suffix 
-.I .so
-in the library name is optional, and
-the library initialization routine is expected to be named
+.B AWKLIBPATH
+environment variable.  If the initial search fails, another attempt will
+be made after appending the default shared library suffix for the platform.
+The library initialization routine is expected to be named
 .BR dlload() .
 .TP
 .PD 0
@@ -3596,6 +3595,16 @@ and
 options.
 .PP
 The
+.B AWKLIBPATH
+environment variable can be used to provide a list of directories that
+.I gawk
+searches when looking for files named via the
+.B \-l
+and
+.B \-\^\-load
+options.
+.PP
+The
 .B GAWK_READ_TIMEOUT
 environment variable can be used to specify a timeout
 in milliseconds for reading input from a terminal, pipe
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 5b3dd71..d0d5412 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -351,6 +351,8 @@ particular records in a file and perform operations upon 
them.
                                    uses.
 * AWKPATH Variable::               Searching directories for @command{awk}
                                    programs.
+* AWKLIBPATH Variable::            Searching directories for @command{awk}
+                                   shared libraries.
 * Other Environment Variables::    The environment variables.
 * Exit Status::                    @command{gawk}'s exit status.
 * Include Files::                  Including other files into your program.
@@ -3185,8 +3187,9 @@ that @command{gawk} accepts and then exit.
 @cindex @code{-l} option
 @cindex @code{--load} option
 @cindex loading, library
-Load a shared library @var{lib}. This searches for the library using the 
@env{AWKPATH}
-environment variable. The suffix @samp{.so} in the library name is optional.
+Load a shared library @var{lib}. This searches for the library using the 
@env{AWKLIBPATH}
+environment variable.  The correct library suffix for your platform will be
+supplied by default, so it need not be specified in the library name.
 The library initialization routine should be named @code{dlload()}.
 
 @item -L @address@hidden
@@ -3558,6 +3561,8 @@ behaves.
 @menu
 * AWKPATH Variable::            Searching directories for @command{awk}
                                 programs.
+* AWKLIBPATH Variable::         Searching directories for @command{awk}
+                                shared libraries.
 * Other Environment Variables:: The environment variables.
 @end menu
 
@@ -3633,6 +3638,21 @@ sense: the @env{AWKPATH} environment variable is used to 
find the program
 source files.  Once your program is running, all the files have been
 found, and @command{gawk} no longer needs to use @env{AWKPATH}.
 
address@hidden AWKLIBPATH Variable
address@hidden The @env{AWKLIBPATH} Environment Variable
address@hidden @env{AWKLIBPATH} environment variable
address@hidden directories, searching
address@hidden search paths
address@hidden search paths, for shared libraries
address@hidden differences in @command{awk} and @command{gawk}, 
@code{AWKLIBPATH} environment variable
+
+The @env{AWKLIBPATH} environment variable is similar to the @env{AWKPATH}
+variable, but it is used to search for shared libraries specified
+with the @option{-l} option rather than for source files.  If the library
+is not found, the path is searched again after adding the appropriate
+shared library suffix for the platform.  For example, on Linux systems,
+the suffix @samp{.so} is used.
+
 @node Other Environment Variables
 @subsection Other Environment Variables
 
@@ -12746,7 +12766,9 @@ does not affect the environment passed on to any 
programs that
 Some operating systems may not have environment variables.
 On such systems, the @code{ENVIRON} array is empty (except for
 @address@hidden"AWKPATH"]}},
address@hidden Variable}).
address@hidden Variable} and
address@hidden@code{ENVIRON["AWKLIBPATH"]}},
address@hidden Variable}).
 
 @cindex @command{gawk}, @code{ERRNO} variable in
 @cindex @code{ERRNO} variable
@@ -27025,6 +27047,11 @@ the @option{-f} command-line option
 (@pxref{Options}).
 
 @item
+The @env{AWKLIBPATH} environment variable for specifying a path search for
+the @option{-l} command-line option
+(@pxref{Options}).
+
address@hidden
 The ability to use GNU-style long-named options that start with @option{--}
 and the
 @option{--characters-as-bytes},
@@ -29534,11 +29561,11 @@ anywhere in the program.
 
 @command{gawk} has a list of directories where it searches for libraries.
 By default, the list includes directories that depend upon how gawk was built
-and installed (@pxref{AWKPATH Variable}). If you want @command{gawk}
+and installed (@pxref{AWKLIBPATH Variable}). If you want @command{gawk}
 to look for libraries in your private directory, you have to tell it.
-The way to do it is to set the @env{AWKPATH} environment variable
-(@pxref{AWKPATH Variable}).
address@hidden supplies the default suffix @samp{.so} if it is not
+The way to do it is to set the @env{AWKLIBPATH} environment variable
+(@pxref{AWKLIBPATH Variable}).
address@hidden supplies the default shared library platform suffix if it is not
 present in the name of the library.
 If the name of your library is @file{mylib.so}, you can simply type
 
@@ -29550,7 +29577,7 @@ and @command{gawk} will do everything necessary to load 
in your library,
 and then call your @code{dlload()} routine.
 
 You can always specify the library using an absolute pathname, in which
-case @command{gawk} will not use @env{AWKPATH} to search for it.
+case @command{gawk} will not use @env{AWKLIBPATH} to search for it.
 
 @node Sample Library
 @appendixsubsec Example: Directory and File Operation Built-ins
diff --git a/extension/ChangeLog b/extension/ChangeLog
index dff4cf6..251f86c 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,10 @@
+2012-03-20         Andrew J. Schorr     <address@hidden>
+
+       * Makefile.am: New file to build and install shared libraries.
+       * arrayparm.c (do_mkarray): Get it to compile by removing 2nd arg
+       to assoc_clear.
+       * filefuncs.c (do_stat): Ditto.
+
 2011-08-31         John Haque     <address@hidden>
         * arrayparm.c, filefuncs.c, fork.c, ordchr.c, readfile.c,
         rwarray.c, testarg.c: Updated.
diff --git a/extension/Makefile.am b/extension/Makefile.am
new file mode 100644
index 0000000..27bdff4
--- /dev/null
+++ b/extension/Makefile.am
@@ -0,0 +1,73 @@
+#
+# extension/Makefile.am --- automake input file for gawk
+#
+# Copyright (C) 1995-2006 the Free Software Foundation, Inc.
+#
+# This file is part of GAWK, the GNU implementation of the
+# AWK Programming Language.
+#
+# GAWK is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# GAWK is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA
+#
+
+## Process this file with automake to produce Makefile.in.
+
+INCLUDES = -I.. -I$(top_srcdir) -I$(top_srcdir)/intl 
+
+lib_LTLIBRARIES =      \
+       libarrayparm.la \
+       libfilefuncs.la \
+       libfork.la      \
+       libordchr.la    \
+       libreadfile.la  \
+       libtestarg.la
+
+# The arrayparm, zaxxon, and testarg libraries do not do anything useful,
+# so do not install them...
+
+install_libraries =    \
+       libfilefuncs.la \
+       libfork.la      \
+       libordchr.la    \
+       libreadfile.la
+
+libarrayparm_la_SOURCES  = arrayparm.c
+libfilefuncs_la_SOURCES  = filefuncs.c
+libfork_la_SOURCES       = fork.c
+libordchr_la_SOURCES     = ordchr.c
+libreadfile_la_SOURCES   = readfile.c
+libtestarg_la_SOURCES    = testarg.c
+
+install: $(install_libraries)
+       for p in $(install_libraries); do \
+               . ./$$p ; \
+               f=`echo $$dlname | sed -e 's/^lib//' -e 's/\.0//g'` ; \
+               echo "Installing $$dlname in $(DESTDIR)$(pkgextensiondir)/$$f" 
; \
+               $(INSTALL_PROGRAM) .libs/$$dlname 
$(DESTDIR)$(pkgextensiondir)/$$f ; \
+       done
+
+uninstall: $(install_libraries)
+       for p in $(install_libraries); do \
+               . ./$$p ; \
+               f=`echo $$dlname | sed -e 's/^lib//' -e 's/\.0//g'` ; \
+               echo "Removing $$dlname in $(DESTDIR)$(pkgextensiondir)/$$f" ; \
+               rm -f $(DESTDIR)$(pkgextensiondir)/$$f ; \
+       done
+
+EXTRA_DIST = \
+       ChangeLog \
+       ChangeLog.0 \
+       *.awk \
+       doit \
+       steps
diff --git a/extension/arrayparm.c b/extension/arrayparm.c
index b0aee33..1e28811 100644
--- a/extension/arrayparm.c
+++ b/extension/arrayparm.c
@@ -60,7 +60,7 @@ do_mkarray(int nargs)
        printf("sub->type = %s\n", nodetype2str(sub->type));
        printf("val->type = %s\n", nodetype2str(val->type));
 
-       assoc_clear(var, NULL);
+       assoc_clear(var);
 
        elemval = assoc_lookup(var, sub);
        *elemval = dupnode(val);
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 1a0a86e..dd1b29a 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -177,7 +177,7 @@ do_stat(int nargs)
        array = get_array_argument(1, FALSE);
 
        /* empty out the array */
-       assoc_clear(array, NULL);
+       assoc_clear(array);
 
        /* lstat the file, if error, set ERRNO and return */
        (void) force_string(file);
diff --git a/io.c b/io.c
index 25f32e2..5a110e0 100644
--- a/io.c
+++ b/io.c
@@ -2311,35 +2311,45 @@ do_getline(int intovar, IOBUF *iop)
        return make_number((AWKNUM) 1.0);
 }
 
+typedef struct {
+   const char *envname;
+   char **dfltp;
+   char try_cwd;               /* always search current directory? */
+   char **awkpath;             /* array containing library search paths */ 
+   int max_pathlen;            /* length of the longest item in awkpath */ 
+} path_info;
+
+static path_info pi_awkpath = {
+   .envname = "AWKPATH",
+   .dfltp = &defpath,
+   .try_cwd = TRUE,
+};
 
-static char **awkpath = NULL;  /* array containing library search paths */ 
-static int max_pathlen;                /* length of the longest item in 
awkpath */ 
+static path_info pi_awklibpath = {
+   .envname = "AWKLIBPATH",
+   .dfltp = &deflibpath,
+   .try_cwd = FALSE,
+};
 
 /* init_awkpath --- split path(=$AWKPATH) into components */
 
 static void
-init_awkpath(char *path)
+init_awkpath(path_info *pi)
 {
+       char *path;
        char *start, *end, *p;
        int len, i;
-       static int max_path = 0;
+       int max_path;           /* (# of allocated paths)-1 */
 
 #define INC_PATH 5
 
-       max_pathlen = 0;
-       if (path == NULL || *path == '\0')
-               path = defpath;
-
-       for (i = 0; i < max_path && awkpath[i]; i++) {
-               efree(awkpath[i]);
-               awkpath[i] = NULL;
-       }
+       pi->max_pathlen = 0;
+       if ((path = getenv(pi->envname)) == NULL || *path == '\0')
+               path = *(pi->dfltp);
 
-       if (max_path == 0) {
-               max_path = INC_PATH;
-               emalloc(awkpath, char **, (max_path + 1) * sizeof(char *), 
"init_awkpath");
-               memset(awkpath, 0, (max_path + 1) * sizeof(char *));
-       }
+       max_path = INC_PATH;
+       emalloc(pi->awkpath, char **, (max_path + 1) * sizeof(char *), 
"init_awkpath");
+       memset(pi->awkpath, 0, (max_path + 1) * sizeof(char *));
 
        end = start = path;
        i = 0;
@@ -2358,12 +2368,12 @@ init_awkpath(char *path)
 
                        if (i == max_path) {
                                max_path += INC_PATH;
-                               erealloc(awkpath, char **, (max_path + 1) * 
sizeof(char *), "init_awkpath");
-                               memset(awkpath + i, 0, (INC_PATH + 1) * 
sizeof(char *));
+                               erealloc(pi->awkpath, char **, (max_path + 1) * 
sizeof(char *), "init_awkpath");
+                               memset(pi->awkpath + i, 0, (INC_PATH + 1) * 
sizeof(char *));
                        }
-                       awkpath[i++] = p;
-                       if (len > max_pathlen)
-                               max_pathlen = len;
+                       pi->awkpath[i++] = p;
+                       if (len > pi->max_pathlen)
+                               pi->max_pathlen = len;
                }
 
                /* skip one or more envsep char */
@@ -2371,7 +2381,7 @@ init_awkpath(char *path)
                        end++;
                start = end;
        }
-       awkpath[i] = NULL;
+       pi->awkpath[i] = NULL;
 
 #undef INC_PATH
 }
@@ -2403,7 +2413,7 @@ get_cwd ()
 /* do_find_source --- search $AWKPATH for file, return NULL if not found */ 
 
 static char *
-do_find_source(const char *src, struct stat *stb, int *errcode)
+do_find_source(const char *src, struct stat *stb, int *errcode, path_info *pi)
 {
        char *path;
        int i;
@@ -2422,7 +2432,7 @@ do_find_source(const char *src, struct stat *stb, int 
*errcode)
        }
 
        /* try current directory before $AWKPATH search */
-       if (stat(src, stb) == 0) {
+       if (pi->try_cwd && (stat(src, stb) == 0)) {
                path = get_cwd();
                if (path == NULL) {
                        *errcode = errno;
@@ -2434,16 +2444,15 @@ do_find_source(const char *src, struct stat *stb, int 
*errcode)
                return path;
        }
 
-       if (awkpath == NULL)
-               init_awkpath(getenv("AWKPATH"));
+       if (pi->awkpath == NULL)
+               init_awkpath(pi);
 
-       emalloc(path, char *, max_pathlen + strlen(src) + 1, "do_find_source"); 
-       for (i = 0; awkpath[i] != NULL; i++) {
-               if (strcmp(awkpath[i], "./") == 0 || strcmp(awkpath[i], ".") == 
0) {
-                       /* FIXME: already tried CWD above; Why do it again ? */
+       emalloc(path, char *, pi->max_pathlen + strlen(src) + 1, 
"do_find_source"); 
+       for (i = 0; pi->awkpath[i] != NULL; i++) {
+               if (strcmp(pi->awkpath[i], "./") == 0 || strcmp(pi->awkpath[i], 
".") == 0)
                        *path = '\0';
-               } else
-                       strcpy(path, awkpath[i]);
+               else
+                       strcpy(path, pi->awkpath[i]);
                strcat(path, src);
                if (stat(path, stb) == 0)
                        return path;
@@ -2461,11 +2470,12 @@ char *
 find_source(const char *src, struct stat *stb, int *errcode, int is_extlib)
 {
        char *path;
+       path_info *pi = (is_extlib ? &pi_awklibpath : &pi_awkpath);
 
        *errcode = 0;
        if (src == NULL || *src == '\0')
                return NULL;
-       path = do_find_source(src, stb, errcode);
+       path = do_find_source(src, stb, errcode, pi);
 
        if (path == NULL && is_extlib) {
                char *file_ext;
@@ -2473,7 +2483,7 @@ find_source(const char *src, struct stat *stb, int 
*errcode, int is_extlib)
                size_t src_len;
                size_t suffix_len;
 
-#define EXTLIB_SUFFIX  ".so"
+#define EXTLIB_SUFFIX  "." SHLIBEXT
                src_len = strlen(src);
                suffix_len = strlen(EXTLIB_SUFFIX);
 
@@ -2485,7 +2495,7 @@ find_source(const char *src, struct stat *stb, int 
*errcode, int is_extlib)
                save_errno = errno;
                emalloc(file_ext, char *, src_len + suffix_len + 1, 
"find_source");
                sprintf(file_ext, "%s%s", src, EXTLIB_SUFFIX);
-               path = do_find_source(file_ext, stb, errcode);
+               path = do_find_source(file_ext, stb, errcode, pi);
                efree(file_ext);
                if (path == NULL)
                        errno = save_errno;
@@ -2505,7 +2515,7 @@ find_source(const char *src, struct stat *stb, int 
*errcode, int is_extlib)
                emalloc(file_awk, char *, strlen(src) +
                        sizeof(DEFAULT_FILETYPE) + 1, "find_source");
                sprintf(file_awk, "%s%s", src, DEFAULT_FILETYPE);
-               path = do_find_source(file_awk, stb, errcode);
+               path = do_find_source(file_awk, stb, errcode, pi);
                efree(file_awk);
                if (path == NULL) {
                        errno = save_errno;
diff --git a/main.c b/main.c
index 8899db5..693db0f 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;
 }
 
diff --git a/pc/ChangeLog b/pc/ChangeLog
index 5f287dd..a5ce600 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,7 @@
+2012-03-20         Andrew J. Schorr     <address@hidden>
+
+       * gawkmisc.pc (deflibpath): New global variable.
+
 2011-12-12   Scott Deifik  <address@hidden>
 
        * Makefile.tst: Sync with mainline version.
diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc
index 64b4239..cb1e209 100644
--- a/pc/gawkmisc.pc
+++ b/pc/gawkmisc.pc
@@ -31,6 +31,8 @@ char *defpath = DEFPATH;
 # else
 char *defpath = ".;c:\\lib\\awk;c:\\gnu\\lib\\awk";
 # endif
+/* the Makefile should define DEFLIBPATH */
+char *deflibpath = DEFLIBPATH;
 
 #ifdef __EMX__
 #include<io.h>
diff --git a/posix/ChangeLog b/posix/ChangeLog
index 8aaeb41..e899a6c 100644
--- a/posix/ChangeLog
+++ b/posix/ChangeLog
@@ -1,3 +1,7 @@
+2012-03-20         Andrew J. Schorr     <address@hidden>
+
+       * gawkmisc.c (deflibpath): New global variable.
+
 2011-06-23         Arnold D. Robbins     <address@hidden>
 
        * ChangeLog.0: Rotated ChangeLog into this file.
diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c
index acc3c9d..270872a 100644
--- a/posix/gawkmisc.c
+++ b/posix/gawkmisc.c
@@ -26,6 +26,7 @@
 
 char quote = '\'';
 char *defpath = DEFPATH;
+char *deflibpath = DEFLIBPATH;
 char envsep = ':';
 
 #ifndef INVALID_HANDLE
diff --git a/vms/ChangeLog b/vms/ChangeLog
index a39f112..90a6e75 100644
--- a/vms/ChangeLog
+++ b/vms/ChangeLog
@@ -1,3 +1,7 @@
+2012-03-20         Andrew J. Schorr     <address@hidden>
+
+       * gawkmisc.vms (deflibpath): New global variable.
+
 2011-12-31         Arnold D. Robbins     <address@hidden>
 
        * vms_misc.c: [STREQ, STREQN]: Change use of macros to call
diff --git a/vms/gawkmisc.vms b/vms/gawkmisc.vms
index 346a1e8..90b2530 100644
--- a/vms/gawkmisc.vms
+++ b/vms/gawkmisc.vms
@@ -25,6 +25,7 @@
 
 char quote = '\'';
 char *defpath = DEFPATH;
+char *deflibpath = DEFLIBPATH;
 char envsep  = ',';
 
 /* gawk_name --- pull out the "gawk" part from how the OS called us */

-----------------------------------------------------------------------


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]