aboutsummaryrefslogtreecommitdiffstats
path: root/extension
diff options
context:
space:
mode:
Diffstat (limited to 'extension')
-rw-r--r--extension/ChangeLog55
-rw-r--r--extension/Makefile.am2
-rw-r--r--extension/Makefile.in2
-rw-r--r--extension/build-aux/ChangeLog4
-rw-r--r--extension/configh.in20
-rwxr-xr-xextension/configure233
-rw-r--r--extension/configure.ac10
-rw-r--r--extension/filefuncs.c8
-rw-r--r--extension/gawkfts.c4
-rw-r--r--extension/inplace.c8
-rw-r--r--extension/m4/ChangeLog4
-rw-r--r--extension/readdir.c10
-rw-r--r--extension/readfile.3am20
-rw-r--r--extension/readfile.c151
-rw-r--r--extension/revtwoway.c6
-rw-r--r--extension/rwarray.c8
-rw-r--r--extension/testext.c6
-rw-r--r--extension/time.c6
18 files changed, 483 insertions, 74 deletions
diff --git a/extension/ChangeLog b/extension/ChangeLog
index ef5c725f..869c30a5 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,58 @@
+2014-04-11 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (install-data-hook): Use $(DESTDIR) when removing
+ the .la files. Thanks to Lars Wendler <polynomial-c@gentoo.org>
+ for the report and fix.
+
+2014-04-08 Arnold D. Robbins <arnold@skeeve.com>
+
+ * 4.1.1: Release tar ball made.
+
+2014-04-08 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Bump version before release.
+
+2014-04-04 Arnold D. Robbins <arnold@skeeve.com>
+
+ * time.c: Include <time.h> unconditionally to get declaration
+ of nanosleep on Linux. Avoids a warning. Thanks to Michal
+ Jaegermann.
+
+2014-03-31 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Remove -Wextra to avoid killing compilations
+ on older versions of gcc. Thanks to Antonio Diaz Diaz for
+ the report.
+
+2014-03-28 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Add AC_HEADER_TIME and AC_HEADER_DIRENT, and
+ rearrange order of macros some. May help on older systems.
+
+2014-03-27 Arnold D. Robbins <arnold@skeeve.com>
+
+ * readfile.c: Add an input parser that works off of
+ PROCINFO["readfile"].
+ * readfile.3am: Document same.
+
+2014-03-23 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawkfts.c (MAXPATHLEN): Add a default definition. Thanks to
+ Antonio Diaz Dian and Nelson H.F. Beebe.
+ * readdir.c (PATH_MAX): Add a default definition. Thanks to
+ Nelson H.F. Beebe.
+
+2014-03-08 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * filefuncs.c (read_symlink, do_fts): Replace free with gawk_free.
+ * inplace.c (at_exit, do_inplace_end): Ditto.
+ * readdir.c (dir_close): Ditto.
+ * readfile.c (do_readfile): Ditto.
+ * revtwoway.c (close_two_proc_data): Ditto.
+ * rwarray.c (read_elem): Replace realloc with gawk_realloc.
+ (read_value): Replace malloc and free with gawk_malloc and gawk_free.
+ * testext.c (try_modify_environ): Replace free with gawk_free.
+
2014-02-12 John E. Malmberg <wb8tyw@qsl.net>
* time.c: Better hack for nanosleep bug based on feedback from HP.
diff --git a/extension/Makefile.am b/extension/Makefile.am
index 9c49bb81..11826e2b 100644
--- a/extension/Makefile.am
+++ b/extension/Makefile.am
@@ -100,7 +100,7 @@ testext_la_LIBADD = $(MY_LIBS)
install-data-hook:
for i in $(pkgextension_LTLIBRARIES) ; do \
- $(RM) $(pkgextensiondir)/$$i ; \
+ $(RM) $(DESTDIR)$(pkgextensiondir)/$$i ; \
done
# Keep the uninstall check working:
diff --git a/extension/Makefile.in b/extension/Makefile.in
index 040cdb8f..d81b1696 100644
--- a/extension/Makefile.in
+++ b/extension/Makefile.in
@@ -1231,7 +1231,7 @@ uninstall-man: uninstall-man3
install-data-hook:
for i in $(pkgextension_LTLIBRARIES) ; do \
- $(RM) $(pkgextensiondir)/$$i ; \
+ $(RM) $(DESTDIR)$(pkgextensiondir)/$$i ; \
done
# Keep the uninstall check working:
diff --git a/extension/build-aux/ChangeLog b/extension/build-aux/ChangeLog
index b578de8b..697db607 100644
--- a/extension/build-aux/ChangeLog
+++ b/extension/build-aux/ChangeLog
@@ -1,3 +1,7 @@
+2014-04-08 Arnold D. Robbins <arnold@skeeve.com>
+
+ * 4.1.1: Release tar ball made.
+
2014-01-03 Arnold D. Robbins <arnold@skeeve.com>
* config.guess, config.rpath, config.sub, depcomp,
diff --git a/extension/configh.in b/extension/configh.in
index 8add211a..5842f2f4 100644
--- a/extension/configh.in
+++ b/extension/configh.in
@@ -30,7 +30,8 @@
*/
#undef HAVE_DECL_DIRFD
-/* Define to 1 if you have the <dirent.h> header file. */
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
#undef HAVE_DIRENT_H
/* Define to 1 if you have the `dirfd' function. */
@@ -75,6 +76,9 @@
/* Define to 1 if you have the `nanosleep' function. */
#undef HAVE_NANOSLEEP
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT
@@ -93,6 +97,14 @@
/* Define to 1 if `st_blksize' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_NDIR_H
+
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
@@ -108,9 +120,6 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
-/* Define to 1 if you have the <time.h> header file. */
-#undef HAVE_TIME_H
-
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
@@ -149,6 +158,9 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
diff --git a/extension/configure b/extension/configure
index 025e2723..2105648d 100755
--- a/extension/configure
+++ b/extension/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for GNU Awk Bundled Extensions 4.1.0.
+# Generated by GNU Autoconf 2.69 for GNU Awk Bundled Extensions 4.1.1.
#
# Report bugs to <bug-gawk@gnu.org>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='GNU Awk Bundled Extensions'
PACKAGE_TARNAME='gawk-extensions'
-PACKAGE_VERSION='4.1.0'
-PACKAGE_STRING='GNU Awk Bundled Extensions 4.1.0'
+PACKAGE_VERSION='4.1.1'
+PACKAGE_STRING='GNU Awk Bundled Extensions 4.1.1'
PACKAGE_BUGREPORT='bug-gawk@gnu.org'
PACKAGE_URL='http://www.gnu.org/software/gawk-extensions/'
@@ -1333,7 +1333,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures GNU Awk Bundled Extensions 4.1.0 to adapt to many kinds of systems.
+\`configure' configures GNU Awk Bundled Extensions 4.1.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1403,7 +1403,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of GNU Awk Bundled Extensions 4.1.0:";;
+ short | recursive ) echo "Configuration of GNU Awk Bundled Extensions 4.1.1:";;
esac
cat <<\_ACEOF
@@ -1518,7 +1518,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-GNU Awk Bundled Extensions configure 4.1.0
+GNU Awk Bundled Extensions configure 4.1.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1990,7 +1990,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by GNU Awk Bundled Extensions $as_me 4.1.0, which was
+It was created by GNU Awk Bundled Extensions $as_me 4.1.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -4172,7 +4172,7 @@ fi
# Define the identity of the package.
PACKAGE='gawk-extensions'
- VERSION='4.1.0'
+ VERSION='4.1.1'
cat >>confdefs.h <<_ACEOF
@@ -14034,7 +14034,7 @@ pkgextensiondir='${libdir}/gawk'
if test "$GCC" = yes
then
- CFLAGS="$CFLAGS -Wall -Wextra"
+ CFLAGS="$CFLAGS -Wall" # Don't add -Wextra, hurts older gcc
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for special development options" >&5
@@ -14052,6 +14052,177 @@ else
$as_echo "no" >&6; }
fi
+for ac_header in fnmatch.h limits.h sys/time.h sys/select.h sys/param.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+ as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
+$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
+if eval \${$as_ac_Header+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <$ac_hdr>
+
+int
+main ()
+{
+if ((DIR *) 0)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$as_ac_Header=yes"
+else
+ eval "$as_ac_Header=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_ac_Header
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+_ACEOF
+
+ac_header_dirent=$ac_hdr; break
+fi
+
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if ${ac_cv_search_opendir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' dir; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_opendir+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_opendir+:} false; then :
+
+else
+ ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if ${ac_cv_search_opendir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' x; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_opendir+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_opendir+:} false; then :
+
+else
+ ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sys/types.h defines makedev" >&5
$as_echo_n "checking whether sys/types.h defines makedev... " >&6; }
if ${ac_cv_header_sys_types_h_makedev+:} false; then :
@@ -14102,18 +14273,40 @@ fi
fi
fi
-for ac_header in dirent.h fnmatch.h limits.h time.h sys/time.h sys/select.h sys/param.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
+$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
+if ${ac_cv_header_time+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_time=yes
+else
+ ac_cv_header_time=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
+$as_echo "$ac_cv_header_time" >&6; }
+if test $ac_cv_header_time = yes; then
-done
+$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
+
+fi
for ac_func in fdopendir fnmatch gettimeofday \
@@ -14824,7 +15017,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by GNU Awk Bundled Extensions $as_me 4.1.0, which was
+This file was extended by GNU Awk Bundled Extensions $as_me 4.1.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -14892,7 +15085,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-GNU Awk Bundled Extensions config.status 4.1.0
+GNU Awk Bundled Extensions config.status 4.1.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/extension/configure.ac b/extension/configure.ac
index 412fec09..1f876a0e 100644
--- a/extension/configure.ac
+++ b/extension/configure.ac
@@ -1,7 +1,7 @@
dnl
dnl configure.ac --- autoconf input file for gawk
dnl
-dnl Copyright (C) 2012, 2013 the Free Software Foundation, Inc.
+dnl Copyright (C) 2012-2014 the Free Software Foundation, Inc.
dnl
dnl This file is part of GAWK, the GNU implementation of the
dnl AWK Programming Language.
@@ -23,7 +23,7 @@ dnl
dnl Process this file with autoconf to produce a configure script.
-AC_INIT([GNU Awk Bundled Extensions], 4.1.0, bug-gawk@gnu.org, gawk-extensions)
+AC_INIT([GNU Awk Bundled Extensions], 4.1.1, bug-gawk@gnu.org, gawk-extensions)
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
@@ -51,7 +51,7 @@ AC_SUBST([pkgextensiondir], ['${libdir}/gawk'])
if test "$GCC" = yes
then
- CFLAGS="$CFLAGS -Wall -Wextra"
+ CFLAGS="$CFLAGS -Wall" # Don't add -Wextra, hurts older gcc
fi
AC_MSG_CHECKING([for special development options])
@@ -66,8 +66,10 @@ else
AC_MSG_RESULT([no])
fi
+AC_CHECK_HEADERS(fnmatch.h limits.h sys/time.h sys/select.h sys/param.h)
+AC_HEADER_DIRENT
AC_HEADER_MAJOR
-AC_CHECK_HEADERS(dirent.h fnmatch.h limits.h time.h sys/time.h sys/select.h sys/param.h)
+AC_HEADER_TIME
AC_CHECK_FUNCS(fdopendir fnmatch gettimeofday \
getdtablesize nanosleep select GetSystemTimeAsFileTime)
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 3eb2a6b5..d5249a4e 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -9,7 +9,7 @@
*/
/*
- * Copyright (C) 2001, 2004, 2005, 2010, 2011, 2012, 2013
+ * Copyright (C) 2001, 2004, 2005, 2010, 2011, 2012, 2013, 2014
* the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
@@ -284,7 +284,7 @@ read_symlink(const char *fname, size_t bufsize, ssize_t *linksize)
returns -1 with errno == ERANGE if the buffer is
too small. */
if (errno != ERANGE) {
- free(buf);
+ gawk_free(buf);
return NULL;
}
}
@@ -293,7 +293,7 @@ read_symlink(const char *fname, size_t bufsize, ssize_t *linksize)
buf[*linksize] = '\0';
return buf;
}
- free(buf);
+ gawk_free(buf);
if (bufsize <= MAXSIZE/2)
bufsize *= 2;
else if (bufsize < MAXSIZE)
@@ -854,7 +854,7 @@ do_fts(int nargs, awk_value_t *result)
out:
if (pathvector != NULL)
- free(pathvector);
+ gawk_free(pathvector);
if (path_array != NULL)
(void) release_flattened_array(pathlist.array_cookie, path_array);
diff --git a/extension/gawkfts.c b/extension/gawkfts.c
index 25a4c108..4a712153 100644
--- a/extension/gawkfts.c
+++ b/extension/gawkfts.c
@@ -139,6 +139,10 @@ static int fts_safe_changedir(const FTS *, const FTSENT *, int,
#define _DIAGASSERT(expression)
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024 /* a guess */
+#endif
+
FTS *
fts_open(char * const *argv, int options,
int (*compar)(const FTSENT **, const FTSENT **))
diff --git a/extension/inplace.c b/extension/inplace.c
index 91b1a229..e2f8b73f 100644
--- a/extension/inplace.c
+++ b/extension/inplace.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2013 the Free Software Foundation, Inc.
+ * Copyright (C) 2013, 2014 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -96,7 +96,7 @@ at_exit(void *data, int exit_status)
(void) exit_status; /* silence warnings */
if (state.tname) {
unlink(state.tname);
- free(state.tname);
+ gawk_free(state.tname);
state.tname = NULL;
}
}
@@ -242,7 +242,7 @@ do_inplace_end(int nargs, awk_value_t *result)
if (link(filename.str_value.str, bakname) < 0)
fatal(ext_id, _("inplace_end: link(`%s', `%s') failed (%s)"),
filename.str_value.str, bakname, strerror(errno));
- free(bakname);
+ gawk_free(bakname);
}
#ifdef __MINGW32__
@@ -252,7 +252,7 @@ do_inplace_end(int nargs, awk_value_t *result)
if (rename(state.tname, filename.str_value.str) < 0)
fatal(ext_id, _("inplace_end: rename(`%s', `%s') failed (%s)"),
state.tname, filename.str_value.str, strerror(errno));
- free(state.tname);
+ gawk_free(state.tname);
state.tname = NULL;
return make_number(0, result);
}
diff --git a/extension/m4/ChangeLog b/extension/m4/ChangeLog
index 821ef9ed..349bbcc8 100644
--- a/extension/m4/ChangeLog
+++ b/extension/m4/ChangeLog
@@ -1,3 +1,7 @@
+2014-04-08 Arnold D. Robbins <arnold@skeeve.com>
+
+ * 4.1.1: Release tar ball made.
+
2013-12-21 Arnold D. Robbins <arnold@skeeve.com>
* libtool.m4, ltoptions.m4, ltversion.m4: Update to
diff --git a/extension/readdir.c b/extension/readdir.c
index 91296801..7bcabcb0 100644
--- a/extension/readdir.c
+++ b/extension/readdir.c
@@ -10,7 +10,7 @@
*/
/*
- * Copyright (C) 2012, 2013 the Free Software Foundation, Inc.
+ * Copyright (C) 2012-2014 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -67,6 +67,10 @@
#define _(msgid) gettext(msgid)
#define N_(msgid) msgid
+#ifndef PATH_MAX
+#define PATH_MAX 1024 /* a good guess */
+#endif
+
static const gawk_api_t *api; /* for convenience macros to work */
static awk_ext_id_t *ext_id;
static const char *ext_version = "readdir extension: version 1.0";
@@ -235,8 +239,8 @@ dir_close(awk_input_buf_t *iobuf)
the_dir = (open_directory_t *) iobuf->opaque;
closedir(the_dir->dp);
- free(the_dir->buf);
- free(the_dir);
+ gawk_free(the_dir->buf);
+ gawk_free(the_dir);
iobuf->fd = -1;
}
diff --git a/extension/readfile.3am b/extension/readfile.3am
index 688d9cd5..0cb2eb5b 100644
--- a/extension/readfile.3am
+++ b/extension/readfile.3am
@@ -1,4 +1,4 @@
-.TH READFILE 3am "Jan 15 2013" "Free Software Foundation" "GNU Awk Extension Modules"
+.TH READFILE 3am "Mar 24 2013" "Free Software Foundation" "GNU Awk Extension Modules"
.SH NAME
readfile \- return the entire contents of a file as a string
.SH SYNOPSIS
@@ -6,6 +6,14 @@ readfile \- return the entire contents of a file as a string
@load "readfile"
.sp
result = readfile("/some/path")
+.sp
+.ft R
+For making whole files be single records:
+.sp
+.ft CW
+@load "readfile"
+.br
+BEGIN { PROCINFO["readfile"] = 1 }
.ft R
.SH DESCRIPTION
The
@@ -18,6 +26,14 @@ the requested file.
.PP
Upon error, the function returns the empty string and sets
.BR ERRNO .
+.PP
+In addition, it adds an input parser that is activated if
+.ft CW
+PROCINFO["readfile"]
+.ft R
+exists.
+When activated, each input file is returned in its entirety as \f(CW$0\fR.
+\f(CWRT\fP is set to the null string.
... .SH NOTES
... .SH BUGS
.SH EXAMPLE
@@ -47,7 +63,7 @@ if (contents == "" && ERRNO != "") {
Arnold Robbins,
.BR arnold@skeeve.com .
.SH COPYING PERMISSIONS
-Copyright \(co 2012, 2013,
+Copyright \(co 2012, 2013, 2014,
Free Software Foundation, Inc.
.PP
Permission is granted to make and distribute verbatim copies of
diff --git a/extension/readfile.c b/extension/readfile.c
index 06889c3d..d4b4aef9 100644
--- a/extension/readfile.c
+++ b/extension/readfile.c
@@ -8,10 +8,11 @@
* Revised for new dynamic function facilities
* Mon Jun 14 14:53:07 IDT 2004
* Revised for formal API May 2012
+ * Added input parser March 2014
*/
/*
- * Copyright (C) 2002, 2003, 2004, 2011, 2012, 2013
+ * Copyright (C) 2002, 2003, 2004, 2011, 2012, 2013, 2014
* the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
@@ -61,11 +62,39 @@
static const gawk_api_t *api; /* for convenience macros to work */
static awk_ext_id_t *ext_id;
-static const char *ext_version = "readfile extension: version 1.0";
-static awk_bool_t (*init_func)(void) = NULL;
+static const char *ext_version = "readfile extension: version 2.0";
+static awk_bool_t init_readfile();
+static awk_bool_t (*init_func)(void) = init_readfile;
int plugin_is_GPL_compatible;
+/* read_file_to_buffer --- handle the mechanics of reading the file */
+
+static char *
+read_file_to_buffer(int fd, const struct stat *sbuf)
+{
+ char *text = NULL;
+ int ret;
+
+ if ((sbuf->st_mode & S_IFMT) != S_IFREG) {
+ errno = EINVAL;
+ update_ERRNO_int(errno);
+ goto done;
+ }
+
+ emalloc(text, char *, sbuf->st_size + 2, "do_readfile");
+ memset(text, '\0', sbuf->st_size + 2);
+
+ if ((ret = read(fd, text, sbuf->st_size)) != sbuf->st_size) {
+ update_ERRNO_int(errno);
+ gawk_free(text);
+ text = NULL;
+ /* fall through to return */
+ }
+done:
+ return text;
+}
+
/* do_readfile --- read a file into memory */
static awk_value_t *
@@ -90,10 +119,6 @@ do_readfile(int nargs, awk_value_t *result)
if (ret < 0) {
update_ERRNO_int(errno);
goto done;
- } else if ((sbuf.st_mode & S_IFMT) != S_IFREG) {
- errno = EINVAL;
- update_ERRNO_int(errno);
- goto done;
}
if ((fd = open(filename.str_value.str, O_RDONLY|O_BINARY)) < 0) {
@@ -101,15 +126,9 @@ do_readfile(int nargs, awk_value_t *result)
goto done;
}
- emalloc(text, char *, sbuf.st_size + 2, "do_readfile");
- memset(text, '\0', sbuf.st_size + 2);
-
- if ((ret = read(fd, text, sbuf.st_size)) != sbuf.st_size) {
- (void) close(fd);
- update_ERRNO_int(errno);
- free(text);
- goto done;
- }
+ text = read_file_to_buffer(fd, & sbuf);
+ if (text == NULL)
+ goto done; /* ERRNO already updated */
close(fd);
make_malloced_string(text, sbuf.st_size, result);
@@ -117,12 +136,110 @@ do_readfile(int nargs, awk_value_t *result)
} else if (do_lint)
lintwarn(ext_id, _("readfile: called with no arguments"));
-
done:
/* Set the return value */
return result;
}
+/* readfile_get_record --- read the whole file as one record */
+
+static int
+readfile_get_record(char **out, awk_input_buf_t *iobuf, int *errcode,
+ char **rt_start, size_t *rt_len)
+{
+ char *text;
+
+ /*
+ * The caller sets *errcode to 0, so we should set it only if an
+ * error occurs.
+ */
+
+ if (out == NULL || iobuf == NULL)
+ return EOF;
+
+ if (iobuf->opaque != NULL) {
+ /*
+ * Already read the whole file,
+ * free up stuff and return EOF
+ */
+ gawk_free(iobuf->opaque);
+ iobuf->opaque = NULL;
+ return EOF;
+ }
+
+ /* read file */
+ text = read_file_to_buffer(iobuf->fd, & iobuf->sbuf);
+ if (text == NULL)
+ return EOF;
+
+ /* set up the iobuf for next time */
+ iobuf->opaque = text;
+
+ /* set return values */
+ *rt_start = NULL;
+ *rt_len = 0;
+ *out = text;
+
+ /* return count */
+ return iobuf->sbuf.st_size;
+}
+
+/* readfile_can_take_file --- return true if we want the file */
+
+static awk_bool_t
+readfile_can_take_file(const awk_input_buf_t *iobuf)
+{
+ awk_value_t array, index, value;
+
+ if (iobuf == NULL)
+ return awk_false;
+
+ /*
+ * This could fail if PROCINFO isn't referenced from
+ * the awk program. It's not a "can't happen" error.
+ */
+ if (! sym_lookup("PROCINFO", AWK_ARRAY, & array)) {
+ return awk_false;
+ }
+
+ (void) make_const_string("readfile", 8, & index);
+
+ if (! get_array_element(array.array_cookie, & index, AWK_UNDEFINED, & value)) {
+ return awk_false;
+ }
+
+ return awk_true;
+}
+
+/* readfile_take_control_of --- take over the file */
+
+static awk_bool_t
+readfile_take_control_of(awk_input_buf_t *iobuf)
+{
+ if (iobuf == NULL)
+ return awk_false;
+
+ iobuf->get_record = readfile_get_record;
+ return awk_true;
+}
+
+static awk_input_parser_t readfile_parser = {
+ "readfile",
+ readfile_can_take_file,
+ readfile_take_control_of,
+ NULL
+};
+
+/* init_readfile --- set things up */
+
+static awk_bool_t
+init_readfile()
+{
+ register_input_parser(& readfile_parser);
+
+ return awk_true;
+}
+
static awk_ext_func_t func_table[] = {
{ "readfile", do_readfile, 1 },
};
diff --git a/extension/revtwoway.c b/extension/revtwoway.c
index 5f490825..c0d9381a 100644
--- a/extension/revtwoway.c
+++ b/extension/revtwoway.c
@@ -7,7 +7,7 @@
*/
/*
- * Copyright (C) 2012, 2013 the Free Software Foundation, Inc.
+ * Copyright (C) 2012-2014 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -119,8 +119,8 @@ close_two_proc_data(two_way_proc_data_t *proc_data)
return;
}
- free(proc_data->data);
- free(proc_data);
+ gawk_free(proc_data->data);
+ gawk_free(proc_data);
}
/*
diff --git a/extension/rwarray.c b/extension/rwarray.c
index 6185000b..aa05a0d5 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -7,7 +7,7 @@
*/
/*
- * Copyright (C) 2009, 2010, 2011, 2012, 2013 the Free Software Foundation, Inc.
+ * Copyright (C) 2009-2014 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -408,7 +408,7 @@ read_elem(FILE *fp, awk_element_t *element)
buflen = index_len;
} else if (buflen < index_len) {
/* reallocate buffer */
- char *cp = realloc(buffer, index_len);
+ char *cp = gawk_realloc(buffer, index_len);
if (cp == NULL)
return awk_false;
@@ -468,11 +468,11 @@ read_value(FILE *fp, awk_value_t *value)
len = ntohl(len);
value->val_type = AWK_STRING;
value->str_value.len = len;
- value->str_value.str = malloc(len + 2);
+ value->str_value.str = gawk_malloc(len + 2);
memset(value->str_value.str, '\0', len + 2);
if (fread(value->str_value.str, 1, len, fp) != (ssize_t) len) {
- free(value->str_value.str);
+ gawk_free(value->str_value.str);
return awk_false;
}
}
diff --git a/extension/testext.c b/extension/testext.c
index d11272b8..2dda339f 100644
--- a/extension/testext.c
+++ b/extension/testext.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2012, 2013
+ * Copyright (C) 2012, 2013, 2014
* the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
@@ -237,8 +237,8 @@ try_modify_environ(int nargs, awk_value_t *result)
printf("try_modify_environ: set_array_element of ENVIRON passed\n");
} else {
printf("try_modify_environ: set_array_element of ENVIRON failed\n");
- free(index.str_value.str);
- free(value.str_value.str);
+ gawk_free(index.str_value.str);
+ gawk_free(value.str_value.str);
}
if (! flatten_array(environ_array, & flat_array)) {
diff --git a/extension/time.c b/extension/time.c
index c336df88..e6b2b39f 100644
--- a/extension/time.c
+++ b/extension/time.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2012, 2013
+ * Copyright (C) 2012, 2013, 2014
* the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
@@ -85,15 +85,13 @@ static awk_bool_t (*init_func)(void) = NULL;
int plugin_is_GPL_compatible;
+#include <time.h>
#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif
#if defined(HAVE_SELECT) && defined(HAVE_SYS_SELECT_H)
#include <sys/select.h>
#endif
-#if defined(HAVE_NANOSLEEP) && defined(HAVE_TIME_H)
-#include <time.h>
-#endif
#if defined(HAVE_GETSYSTEMTIMEASFILETIME)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>