aboutsummaryrefslogtreecommitdiffstats
path: root/extension
diff options
context:
space:
mode:
Diffstat (limited to 'extension')
-rw-r--r--extension/CMakeLists.txt84
-rw-r--r--extension/ChangeLog267
-rw-r--r--extension/build-aux/ChangeLog5
-rwxr-xr-xextension/build-aux/compile9
-rwxr-xr-xextension/build-aux/config.guess12
-rwxr-xr-xextension/build-aux/config.sub21
-rwxr-xr-xextension/build-aux/depcomp41
-rw-r--r--extension/configure.ac4
-rw-r--r--extension/filefuncs.c47
-rw-r--r--extension/fnmatch.c19
-rw-r--r--extension/fork.c32
-rw-r--r--extension/inplace.c20
-rw-r--r--extension/ordchr.c38
-rw-r--r--extension/readdir.c10
-rw-r--r--extension/readfile.c21
-rw-r--r--extension/revoutput.c10
-rw-r--r--extension/revtwoway.c10
-rw-r--r--extension/rwarray.c73
-rw-r--r--extension/rwarray0.c30
-rw-r--r--extension/stack.c10
-rw-r--r--extension/testext.c268
-rw-r--r--extension/time.c14
22 files changed, 780 insertions, 265 deletions
diff --git a/extension/CMakeLists.txt b/extension/CMakeLists.txt
new file mode 100644
index 00000000..1bb4ceb1
--- /dev/null
+++ b/extension/CMakeLists.txt
@@ -0,0 +1,84 @@
+#
+# extension/CMakeLists.txt --- CMake input file for gawk
+#
+# Copyright (C) 2013
+# 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 CMake to produce Makefile
+
+# Remove the definition of GAWK because of gawkapi.h.
+remove_definitions(-DGAWK)
+
+MACRO(BuildExtension name sources)
+ add_library (${name} MODULE ${sources} ${ARGN})
+ target_link_libraries(${name} ${EXTRA_LIBS})
+ set_target_properties(${name} PROPERTIES PREFIX "")
+ install(PROGRAMS ${CMAKE_BINARY_DIR}/extension/${name}${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION lib)
+ENDMACRO(BuildExtension)
+
+if (${HAVE_STRUCT_STAT_ST_BLKSIZE})
+ BuildExtension(filefuncs filefuncs.c stack.c gawkfts.c)
+else()
+ message(STATUS "extension filefuncs cannot be built because HAVE_STRUCT_STAT_ST_BLKSIZE is missing")
+endif()
+
+if (HAVE_FNMATCH AND HAVE_FNMATCH_H)
+ BuildExtension(fnmatch fnmatch.c)
+else()
+ message(STATUS "extension fnmatch cannot be built because function fnmatch or fnmatch.h is missing")
+endif()
+
+if (${HAVE_SYS_WAIT_H})
+ BuildExtension(fork fork.c)
+else()
+ message(STATUS "extension fork cannot be built because HAVE_SYS_WAIT_H is missing")
+endif()
+
+if (${HAVE_MKSTEMP})
+ BuildExtension(inplace inplace.c)
+else()
+ message(STATUS "extension inplace cannot be built because HAVE_MKSTEMP is missing")
+endif()
+
+BuildExtension(ordchr ordchr.c)
+
+if (HAVE_DIRENT_H AND HAVE_DIRFD)
+ BuildExtension(readdir readdir.c)
+else()
+ message(STATUS "extension readdir cannot be built because function readdir is missing")
+endif()
+
+BuildExtension(readfile readfile.c)
+
+BuildExtension(revoutput revoutput.c)
+
+if (${HAVE_GETDTABLESIZE})
+ BuildExtension(revtwoway revtwoway.c)
+else()
+ message(STATUS "extension revtwoway cannot be built because function getdtablesize is missing")
+endif()
+
+BuildExtension(rwarray rwarray.c)
+
+BuildExtension(time time.c)
+
+BuildExtension(testext testext.c)
+
diff --git a/extension/ChangeLog b/extension/ChangeLog
index f8d1517e..89be82da 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,80 @@
+2017-01-21 Eli Zaretskii <eliz@gnu.org>
+
+ * testext.c (getuid) [__MINGW32__]: New function, mirrors what
+ pc/getid.c does in Gawk.
+ * rwarray.c [__MINGW32__]: Include stdint.h, otherwise using
+ uint32_t causes compilation errors.
+ * inplace.c (_XOPEN_SOURCE): Define to 1, not to nothing. MinGW
+ system headers assume that if this is defined, it must have a
+ numeric value.
+
+2016-12-22 Arnold D. Robbins <arnold@skeeve.com>
+
+ * testext.c (valrep2str): Update for new API types.
+
+2016-12-16 Arnold D. Robbins <arnold@skeeve.com>
+
+ * filefuncs.c: Update func_table again.
+
+2016-12-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * filefuncs.c: Update do_xxx to match new API. Update func_table.
+ * fnmatch.c: Ditto.
+ * fork.c: Ditto.
+ * inplace.c: Ditto.
+ * ordchr.c: Ditto.
+ * readdir.c: Ditto.
+ * readfile.c: Ditto.
+ * revoutput.c: Ditto.
+ * revtwoway.c: Ditto.
+ * rwarray.c: Ditto.
+ * rwarray0.c: Ditto.
+ * testext.c: Ditto.
+ * time.c: Ditto.
+
+2016-12-12 Arnold D. Robbins <arnold@skeeve.com>
+
+ * filefuncs.c (func_table): Adjust ordering of min and max
+ for stat.
+
+2016-12-06 Arnold D. Robbins <arnold@skeeve.com>
+
+ Add minimum required and maximum expected number of arguments
+ to the API.
+
+ * filefuncs.c: Update with max expected value. Remove lint
+ checks since that's now done by gawk.
+ * fnmatch.c: Ditto.
+ * fork.c: Ditto.
+ * inplace.c: Ditto.
+ * ordchr.c: Ditto.
+ * readdir.c: Ditto.
+ * readfile.c: Ditto.
+ * rwarray.c: Ditto.
+ * rwarray0.c: Ditto.
+ * testext.c: Ditto.
+ * time.c: Ditto.
+
+2016-12-05 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * rwarray.c: Adjust to read and write strnum values.
+ (write_value): When writing a string value, code should use htonl.
+ There are now 3 string types: string, strnum, and regex.
+ (read_value): Support 3 string types: string, strnum, and regex.
+
+2016-11-30 Arnold D. Robbins <arnold@skeeve.com>
+
+ * rwarray.c: Restore read comparion of major and minor versions
+ to use !=.
+
+2016-11-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * rwarray.c: Adjust to read and write regexes also.
+
+2016-10-23 Arnold D. Robbins <arnold@skeeve.com>
+
+ * General: Remove trailing whitespace from all relevant files.
+
2016-08-25 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.4: Release tar ball made.
@@ -11,6 +88,11 @@
where configure didn't work correctly. Thanks to Nelson Beebe.
Update copyright year.
+2016-05-26 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * filefuncs.c (func_table): Update "stat" to indicate that the
+ max # of expected args is 3, not 2.
+
2016-01-27 Arnold D. Robbins <arnold@skeeve.com>
* filefuncs.c (do_statvfs): Define out f_fsid on AIX.
@@ -81,11 +163,19 @@
* 4.1.2: Release tar ball made.
+2015-04-16 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Updated by autoupdate.
+
2015-04-08 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am, filefuncs.c, inplace.3am, inplace.c:
Update copyright years.
+2015-03-27 Arnold D. Robbins <arnold@skeeve.com>
+
+ * testext.c: Move test for deferred variables here.
+
2015-03-18 Arnold D. Robbins <arnold@skeeve.com>
* configure: Updated to libtool 2.4.6.
@@ -122,11 +212,86 @@
* testext.c (var_test): Adjust for PROCINFO now being there.
+2015-01-06 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * testext.c (test_deferred): New function to help with testing
+ of deferred variable instantiation.
+ (do_get_file): Remove unused variable array.
+ (func_table): Add test_deferred.
+
+2015-01-05 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * testext.c (test_get_file): Fix error message.
+ (do_get_file): Implement new function providing low-level access
+ to the get_file API.
+ (func_table): Add "get_file" -> do_get_file.
+ (init_testext): If TESTEXT_QUIET has been set to a numeric value,
+ return quietly.
+
+2015-01-02 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * testext.c (test_get_file): The get_file hook no longer takes a
+ typelen argument.
+
+2015-01-02 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ Remove the select extension, since it will be part of gawkextlib.
+ * select.c, siglist.h: Deleted.
+ * Makefile.am (pkgextension_LTLIBRARIES): Remove select.la.
+ (select_la_SOURCES, select_la_LDFLAGS, select_la_LIBADD): Remove.
+ (EXTRA_DIST): Remove siglist.h.
+ * configure.ac (AC_CHECK_HEADERS): Remove signal.h.
+ (AC_CHECK_FUNCS): Remove fcntl, kill, sigaction, and sigprocmask.
+
+2014-12-14 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ Remove the errno extension, since it is now part of gawkextlib.
+ * errno.c, errlist.h: Deleted.
+ * Makefile.am (pkgextension_LTLIBRARIES): Remove errno.la.
+ (errno_la_SOURCES, errno_la_LDFLAGS, errno_la_LIBADD): Remove.
+ (EXTRA_DIST): Remove errlist.h.
+
+2014-12-14 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * readfile.c (read_file_to_buffer): Do not waste a byte at the end of
+ a string.
+ * rwarray.c (read_value): Ditto.
+ * rwarray0.c (read_value): Ditto.
+
2014-11-23 Arnold D. Robbins <arnold@skeeve.com>
* inplace.c (do_inplace_begin): Jump through hoops to silence
GCC warnings about return value of chown.
+2014-11-09 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * select.c (do_input_fd): New function to return the input file
+ descriptor associated with a file/command.
+ (do_output_fd): New function to return the output file descriptor
+ associated with a file/command.
+ (func_table): Add new functions "input_fd" and "output_fd".
+ * testext.c (test_get_file): Do not use __func__, since it is a C99
+ feature, and gawk does not assume C99.
+
+2014-11-06 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * errno.c (do_errno2name, do_name2errno): Remove unused variable 'str'.
+ * select.c (do_signal): Remove unused variable 'override'.
+ (grabfd): New helper function to map a gawk file to the appropriate
+ fd for use in the arguments to selectd.
+ (do_select): get_file has 3 new arguments and returns info about both
+ the input and output buf.
+ (do_set_non_blocking): Support changes to get_file API.
+ * testext.c (test_get_file): New test function to check that extension
+ file creation via the get_file API is working.
+
+2014-11-05 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * select.c (set_retry): New function to set PROCINFO[<name>, "RETRY"].
+ (do_set_non_blocking): If called with a file name as opposed to a file
+ descriptor, call the set_retry function to configure PROCINFO to tell
+ io.c to retry I/O for temporary failures.
+
2014-10-12 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (uninstall-so): Remove *.lib too, per suggestion
@@ -298,6 +463,108 @@
* gawkdirfd.h (FAKE_FD_VALUE): Move definition up in the file to give
clean compile on MinGW.
+2013-07-07 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * configure.ac (AC_CHECK_FUNCS): Check for fcntl.
+ * select.c (set_non_blocking): Check that fcntl and O_NONBLOCK are
+ available.
+
+2013-07-07 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * select.c (signal_handler): On platforms lacking sigaction, reset
+ the signal handler each time a signal is trapped to protect in case
+ the system resets it to default.
+
+2013-07-05 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * select.c (signal_result): New function to set result string from
+ signal function and detect when we need to roll back.
+ (do_signal): Now takes an optional 3rd override argument. Instead
+ of returning -1 or 0, we now return information about the previously
+ installed signal handler: default, ignore, trap, or unknown. An
+ empty string is returned on error. If it is an unknown handler,
+ and override is not non-zero, we roll back the handler and return "".
+
+2013-07-05 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * select.c (set_non_blocking): Do not attempt F_SETFL if F_GETFL fails.
+ (do_set_non_blocking): Add support for case when called with a single
+ "" argument.
+
+2013-07-05 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * select.c (do_signal): If sigaction is unavailable, fall back to
+ signal and hope that it does the right thing.
+
+2013-07-05 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * configure.ac (AC_CHECK_FUNCS): Add kill and sigprocmask.
+ * select.c (get_signal_number): Change error messages since now may
+ be called by "kill" as well as "select_signal".
+ (do_signal): Add a lint warning if there are more than 2 args.
+ (do_kill): Add new function to send a signal.
+ (do_select): Support platforms where sigprocmask is not available.
+ There will be a race condition on such platforms, but that is not
+ easily avoided.
+
+2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * select.c (do_select): Now that the API flatten_array call has been
+ patched to ensure that the index values are strings, we can remove
+ the code to check for the AWK_NUMBER case.
+
+2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * select.c (do_select): Do not treat a numeric command value as a
+ file descriptor unless the command type is empty.
+
+2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * Makefile.am (EXTRA_DIST): Add errlist.h and siglist.h.
+
+2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * select.c (set_non_blocking): New helper function to call fcntl.
+ (do_set_non_blocking): Add support for the case where there's a single
+ integer fd argument.
+
+2013-07-01 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * select.c (do_set_non_blocking): Implement new set_non_blocking
+ function.
+ (func_table): Add set_non_blocking.
+
+2013-07-01 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * errlist.h: New file containing a list of all the errno values I could
+ find.
+ * errno.c: Implement a new errno extension providing strerror,
+ errno2name, and name2errno.
+ * Makefile.am (pkgextension_LTLIBRARIES): Add errno.la.
+ (errno_la_SOURCES, errno_la_LDFLAGS, errno_la_LIBADD): Build new errno
+ extension.
+ * select.c (ext_version): Fix version string.
+ * siglist.h: Update to newest glibc version.
+
+2013-07-01 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * siglist.h: New file copied from glibc to provide a mapping between
+ signal number and name.
+ * select.c: Add a new "select_signal" function and provide support
+ for trapping signals.
+ (do_select): Add support for a 5th argument to contain an array
+ of returned signals. Improve the argument processing, and add
+ better warning messages.
+
+2013-06-30 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * Makefile.am (pkgextension_LTLIBRARIES): Add select.la.
+ (select_la_SOURCES, select_la_LDFLAGS, select_la_LIBADD): Build new
+ select extension.
+ * configure.ac (AC_CHECK_HEADERS): Add signal.h.
+ (AC_CHECK_FUNCS): Add sigaction.
+ * select.c: Implement the new select extension.
+
2013-06-10 Arnold D. Robbins <arnold@skeeve.com>
* configure.ac (AC_HEADER_MAJOR): New macro added.
diff --git a/extension/build-aux/ChangeLog b/extension/build-aux/ChangeLog
index b6e8cc11..35e5cfd8 100644
--- a/extension/build-aux/ChangeLog
+++ b/extension/build-aux/ChangeLog
@@ -1,3 +1,8 @@
+2017-01-04 Arnold Robbins <arnold@skeeve.com>
+
+ * config.guess, config.sub, compile, depcomp: Sync from latest
+ in GNULIB.
+
2016-08-25 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.4: Release tar ball made.
diff --git a/extension/build-aux/compile b/extension/build-aux/compile
index a85b723c..2ab71e4e 100755
--- a/extension/build-aux/compile
+++ b/extension/build-aux/compile
@@ -1,9 +1,9 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
-scriptversion=2012-10-14.11; # UTC
+scriptversion=2016-01-11.22; # UTC
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
@@ -255,7 +255,8 @@ EOF
echo "compile $scriptversion"
exit $?
;;
- cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+ cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
@@ -342,6 +343,6 @@ exit $ret
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/extension/build-aux/config.guess b/extension/build-aux/config.guess
index c4bd827a..bbd48b60 100755
--- a/extension/build-aux/config.guess
+++ b/extension/build-aux/config.guess
@@ -1,8 +1,8 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright 1992-2016 Free Software Foundation, Inc.
+# Copyright 1992-2017 Free Software Foundation, Inc.
-timestamp='2016-05-15'
+timestamp='2017-01-01'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright 1992-2016 Free Software Foundation, Inc.
+Copyright 1992-2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -1000,6 +1000,9 @@ EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
;;
+ mips64el:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
openrisc*:Linux:*:*)
echo or1k-unknown-linux-${LIBC}
exit ;;
@@ -1032,6 +1035,9 @@ EOF
ppcle:Linux:*:*)
echo powerpcle-unknown-linux-${LIBC}
exit ;;
+ riscv32:Linux:*:* | riscv64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
exit ;;
diff --git a/extension/build-aux/config.sub b/extension/build-aux/config.sub
index 9feb73bf..7e792b4a 100755
--- a/extension/build-aux/config.sub
+++ b/extension/build-aux/config.sub
@@ -1,8 +1,8 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright 1992-2016 Free Software Foundation, Inc.
+# Copyright 1992-2017 Free Software Foundation, Inc.
-timestamp='2016-06-20'
+timestamp='2017-01-01'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -67,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright 1992-2016 Free Software Foundation, Inc.
+Copyright 1992-2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -117,7 +117,7 @@ case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
- kopensolaris*-gnu* | \
+ kopensolaris*-gnu* | cloudabi*-eabi* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
@@ -301,6 +301,7 @@ case $basic_machine in
| open8 | or1k | or1knd | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
+ | pru \
| pyramid \
| riscv32 | riscv64 \
| rl78 | rx \
@@ -428,6 +429,7 @@ case $basic_machine in
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+ | pru-* \
| pyramid-* \
| riscv32-* | riscv64-* \
| rl78-* | romp-* | rs6000-* | rx-* \
@@ -1030,7 +1032,7 @@ case $basic_machine in
ppc-* | ppcbe-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
+ ppcle | powerpclittle)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
@@ -1040,7 +1042,7 @@ case $basic_machine in
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ ppc64le | powerpc64little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
@@ -1395,7 +1397,7 @@ case $os in
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* | -cegcc* \
+ | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
@@ -1407,7 +1409,7 @@ case $os in
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
- | -onefs* | -tirtos* | -phoenix*)
+ | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1636,6 +1638,9 @@ case $basic_machine in
sparc-* | *-sun)
os=-sunos4.1.1
;;
+ pru-*)
+ os=-elf
+ ;;
*-be)
os=-beos
;;
diff --git a/extension/build-aux/depcomp b/extension/build-aux/depcomp
index fc98710e..b6872321 100755
--- a/extension/build-aux/depcomp
+++ b/extension/build-aux/depcomp
@@ -1,9 +1,9 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
-scriptversion=2013-05-30.07; # UTC
+scriptversion=2016-01-11.22; # UTC
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -251,41 +251,6 @@ hp)
exit 1
;;
-sgi)
- if test "$libtool" = yes; then
- "$@" "-Wp,-MDupdate,$tmpdepfile"
- else
- "$@" -MDupdate "$tmpdepfile"
- fi
- stat=$?
- if test $stat -ne 0; then
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
-
- if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
- echo "$object : \\" > "$depfile"
- # Clip off the initial element (the dependent). Don't try to be
- # clever and replace this with sed code, as IRIX sed won't handle
- # lines with more than a fixed number of characters (4096 in
- # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
- # the IRIX cc adds comments like '#:fec' to the end of the
- # dependency line.
- tr ' ' "$nl" < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
- | tr "$nl" ' ' >> "$depfile"
- echo >> "$depfile"
- # The second pass generates a dummy entry for each header file.
- tr ' ' "$nl" < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
- >> "$depfile"
- else
- make_dummy_depfile
- fi
- rm -f "$tmpdepfile"
- ;;
-
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
@@ -786,6 +751,6 @@ exit 0
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/extension/configure.ac b/extension/configure.ac
index d0eed3cc..b5b27d03 100644
--- a/extension/configure.ac
+++ b/extension/configure.ac
@@ -23,7 +23,7 @@ dnl
dnl Process this file with autoconf to produce a configure script.
-AC_INIT([GNU Awk Bundled Extensions], 4.1.4, bug-gawk@gnu.org, gawk-extensions)
+AC_INIT([GNU Awk Bundled Extensions],[4.1.4],[bug-gawk@gnu.org],[gawk-extensions])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
@@ -42,7 +42,7 @@ AC_CHECK_MEMBERS([struct stat.st_blksize])
AM_PROG_AR
AC_SYS_LARGEFILE
AC_DISABLE_STATIC
-AC_PROG_LIBTOOL
+LT_INIT
dnl AC_PROG_INSTALL
AC_SUBST([pkgextensiondir], ['${libdir}/gawk'])
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index b33fcf1f..394de504 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -12,20 +12,20 @@
/*
* Copyright (C) 2001, 2004, 2005, 2010-2016
* 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
@@ -153,16 +153,13 @@ int plugin_is_GPL_compatible;
/* do_chdir --- provide dynamically loaded chdir() function for gawk */
static awk_value_t *
-do_chdir(int nargs, awk_value_t *result)
+do_chdir(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t newdir;
int ret = -1;
assert(result != NULL);
- if (do_lint && nargs != 1)
- lintwarn(ext_id, _("chdir: called with incorrect number of arguments, expecting 1"));
-
if (get_argument(0, AWK_STRING, & newdir)) {
ret = chdir(newdir.str_value.str);
if (ret < 0)
@@ -461,7 +458,7 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf)
/* do_stat --- provide a stat() function for gawk */
static awk_value_t *
-do_stat(int nargs, awk_value_t *result)
+do_stat(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t file_param, array_param;
char *name;
@@ -472,19 +469,13 @@ do_stat(int nargs, awk_value_t *result)
assert(result != NULL);
- if (nargs != 2 && nargs != 3) {
- if (do_lint)
- lintwarn(ext_id, _("stat: called with wrong number of arguments"));
- return make_number(-1, result);
- }
-
/* file is first arg, array to hold results is second */
if ( ! get_argument(0, AWK_STRING, & file_param)
|| ! get_argument(1, AWK_ARRAY, & array_param)) {
warning(ext_id, _("stat: bad parameters"));
return make_number(-1, result);
}
-
+
if (nargs == 3) {
statfunc = stat;
}
@@ -512,7 +503,7 @@ do_stat(int nargs, awk_value_t *result)
/* do_statvfs --- provide a statvfs() function for gawk */
static awk_value_t *
-do_statvfs(int nargs, awk_value_t *result)
+do_statvfs(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t file_param, array_param;
char *name;
@@ -522,12 +513,6 @@ do_statvfs(int nargs, awk_value_t *result)
assert(result != NULL);
- if (nargs != 2) {
- if (do_lint)
- lintwarn(ext_id, _("statvfs: called with wrong number of arguments"));
- return make_number(-1, result);
- }
-
/* file is first arg, array to hold results is second */
if ( ! get_argument(0, AWK_STRING, & file_param)
|| ! get_argument(1, AWK_ARRAY, & array_param)) {
@@ -561,7 +546,7 @@ do_statvfs(int nargs, awk_value_t *result)
#endif
array_set_numeric(array, "flag", vfsbuf.f_flag); /* mount flags */
array_set_numeric(array, "namemax", vfsbuf.f_namemax); /* maximum filename length */
-
+
return make_number(ret, result);
}
@@ -614,7 +599,7 @@ init_filefuncs(void)
*/
static awk_value_t *
-do_fts(int nargs, awk_value_t *result)
+do_fts(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
fatal(ext_id, _("fts is not supported on this system"));
@@ -829,7 +814,7 @@ process(FTS *heirarchy, awk_array_t destarray, int seedot)
*/
static awk_value_t *
-do_fts(int nargs, awk_value_t *result)
+do_fts(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t pathlist, flagval, dest;
awk_flat_array_t *path_array = NULL;
@@ -845,7 +830,7 @@ do_fts(int nargs, awk_value_t *result)
assert(result != NULL);
fts_errors = 0; /* ensure a fresh start */
- if (do_lint && nargs != 3)
+ if (nargs > 3)
lintwarn(ext_id, _("fts: called with incorrect number of arguments, expecting 3"));
if (! get_argument(0, AWK_ARRAY, & pathlist)) {
@@ -928,13 +913,13 @@ out:
#endif /* ! __MINGW32__ */
static awk_ext_func_t func_table[] = {
- { "chdir", do_chdir, 1 },
- { "stat", do_stat, 2 },
+ { "chdir", do_chdir, 1, 1, awk_false, NULL },
+ { "stat", do_stat, 3, 2, awk_false, NULL },
#ifndef __MINGW32__
- { "fts", do_fts, 3 },
+ { "fts", do_fts, 3, 3, awk_false, NULL },
#endif
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
- { "statvfs", do_statvfs, 2 },
+ { "statvfs", do_statvfs, 2, 2, awk_false, NULL },
#endif
};
diff --git a/extension/fnmatch.c b/extension/fnmatch.c
index a85bcc78..5382e4bc 100644
--- a/extension/fnmatch.c
+++ b/extension/fnmatch.c
@@ -8,20 +8,20 @@
/*
* Copyright (C) 2012, 2013 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
@@ -95,7 +95,7 @@ int plugin_is_GPL_compatible;
/* do_fnmatch --- implement the fnmatch interface */
static awk_value_t *
-do_fnmatch(int nargs, awk_value_t *result)
+do_fnmatch(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
#ifdef HAVE_FNMATCH_H
static int flags_mask =
@@ -107,13 +107,8 @@ do_fnmatch(int nargs, awk_value_t *result)
int int_flags, retval;
make_number(-1.0, result); /* default return */
-#ifdef HAVE_FNMATCH
- if (nargs < 3) {
- warning(ext_id, _("fnmatch: called with less than three arguments"));
- goto out;
- } else if (do_lint && nargs > 3)
- lintwarn(ext_id, _("fnmatch: called with more than three arguments"));
+#ifdef HAVE_FNMATCH
if (! get_argument(0, AWK_STRING, & pattern)) {
warning(ext_id, _("fnmatch: could not get first argument"));
goto out;
@@ -199,7 +194,7 @@ init_fnmatch(void)
}
static awk_ext_func_t func_table[] = {
- { "fnmatch", do_fnmatch, 3 },
+ { "fnmatch", do_fnmatch, 3, 3, awk_false, NULL },
};
/* define the dl_load function using the boilerplate macro */
diff --git a/extension/fork.c b/extension/fork.c
index 0ca0a0e0..823506dd 100644
--- a/extension/fork.c
+++ b/extension/fork.c
@@ -7,20 +7,20 @@
/*
* Copyright (C) 2001, 2004, 2011, 2012, 2013 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
@@ -71,15 +71,12 @@ array_set_numeric(awk_array_t array, const char *sub, double num)
/* do_fork --- provide dynamically loaded fork() builtin for gawk */
static awk_value_t *
-do_fork(int nargs, awk_value_t *result)
+do_fork(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
int ret = -1;
assert(result != NULL);
- if (do_lint && nargs > 0)
- lintwarn(ext_id, _("fork: called with too many arguments"));
-
ret = fork();
if (ret < 0)
@@ -106,7 +103,7 @@ do_fork(int nargs, awk_value_t *result)
/* do_waitpid --- provide dynamically loaded waitpid() builtin for gawk */
static awk_value_t *
-do_waitpid(int nargs, awk_value_t *result)
+do_waitpid(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t pid;
int ret = -1;
@@ -114,16 +111,12 @@ do_waitpid(int nargs, awk_value_t *result)
assert(result != NULL);
- if (do_lint && nargs > 1)
- lintwarn(ext_id, _("waitpid: called with too many arguments"));
-
if (get_argument(0, AWK_NUMBER, &pid)) {
options = WNOHANG|WUNTRACED;
ret = waitpid(pid.num_value, NULL, options);
if (ret < 0)
update_ERRNO_int(errno);
- } else if (do_lint)
- lintwarn(ext_id, _("wait: called with no arguments"));
+ }
/* Set the return value */
return make_number(ret, result);
@@ -133,15 +126,12 @@ do_waitpid(int nargs, awk_value_t *result)
/* do_wait --- provide dynamically loaded wait() builtin for gawk */
static awk_value_t *
-do_wait(int nargs, awk_value_t *result)
+do_wait(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
int ret;
assert(result != NULL);
- if (do_lint && nargs > 0)
- lintwarn(ext_id, _("wait: called with too many arguments"));
-
ret = wait(NULL);
if (ret < 0)
update_ERRNO_int(errno);
@@ -151,9 +141,9 @@ do_wait(int nargs, awk_value_t *result)
}
static awk_ext_func_t func_table[] = {
- { "fork", do_fork, 0 },
- { "waitpid", do_waitpid, 1 },
- { "wait", do_wait, 0 },
+ { "fork", do_fork, 0, 0, awk_false, NULL },
+ { "waitpid", do_waitpid, 1, 1, awk_false, NULL },
+ { "wait", do_wait, 0, 0, awk_false, NULL },
};
/* define the dl_load function using the boilerplate macro */
diff --git a/extension/inplace.c b/extension/inplace.c
index c7eb5564..ecc3afdc 100644
--- a/extension/inplace.c
+++ b/extension/inplace.c
@@ -4,20 +4,20 @@
/*
* Copyright (C) 2013-2015 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
@@ -28,7 +28,7 @@
#endif
#ifndef _XOPEN_SOURCE
-# define _XOPEN_SOURCE
+# define _XOPEN_SOURCE 1
#endif
#ifndef _XOPEN_SOURCE_EXTENDED
# define _XOPEN_SOURCE_EXTENDED 1
@@ -118,7 +118,7 @@ invalid_filename(const awk_string_t *filename)
/* do_inplace_begin --- start in-place editing */
static awk_value_t *
-do_inplace_begin(int nargs, awk_value_t *result)
+do_inplace_begin(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t filename;
struct stat sbuf;
@@ -132,7 +132,7 @@ do_inplace_begin(int nargs, awk_value_t *result)
if (nargs != 2)
fatal(ext_id, _("inplace_begin: expects 2 arguments but called with %d"), nargs);
-
+
if (! get_argument(0, AWK_STRING, &filename))
fatal(ext_id, _("inplace_begin: cannot retrieve 1st argument as a string filename"));
@@ -201,7 +201,7 @@ do_inplace_begin(int nargs, awk_value_t *result)
/* do_inplace_end --- finish in-place editing */
static awk_value_t *
-do_inplace_end(int nargs, awk_value_t *result)
+do_inplace_end(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t filename, suffix;
@@ -262,8 +262,8 @@ do_inplace_end(int nargs, awk_value_t *result)
}
static awk_ext_func_t func_table[] = {
- { "inplace_begin", do_inplace_begin, 2 },
- { "inplace_end", do_inplace_end, 2 },
+ { "inplace_begin", do_inplace_begin, 2, 2, awk_false, NULL },
+ { "inplace_end", do_inplace_end, 2, 2, awk_false, NULL },
};
static awk_bool_t init_inplace(void)
diff --git a/extension/ordchr.c b/extension/ordchr.c
index 8ec9de3f..c7451f6d 100644
--- a/extension/ordchr.c
+++ b/extension/ordchr.c
@@ -10,20 +10,20 @@
/*
* Copyright (C) 2001, 2004, 2011, 2012, 2013 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
@@ -58,24 +58,17 @@ int plugin_is_GPL_compatible;
/* do_ord --- return numeric value of first char of string */
static awk_value_t *
-do_ord(int nargs, awk_value_t *result)
+do_ord(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t str;
double ret = -1;
assert(result != NULL);
- if (do_lint && nargs > 1)
- lintwarn(ext_id, _("ord: called with too many arguments"));
-
if (get_argument(0, AWK_STRING, & str)) {
ret = str.str_value.str[0];
- } else if (do_lint) {
- if (nargs == 0)
- lintwarn(ext_id, _("ord: called with no arguments"));
- else
- lintwarn(ext_id, _("ord: called with inappropriate argument(s)"));
- }
+ } else if (do_lint)
+ lintwarn(ext_id, _("ord: called with inappropriate argument(s)"));
/* Set the return value */
return make_number(ret, result);
@@ -84,7 +77,7 @@ do_ord(int nargs, awk_value_t *result)
/* do_chr --- turn numeric value into a string */
static awk_value_t *
-do_chr(int nargs, awk_value_t *result)
+do_chr(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t num;
unsigned int ret = 0;
@@ -95,29 +88,22 @@ do_chr(int nargs, awk_value_t *result)
assert(result != NULL);
- if (do_lint && nargs > 1)
- lintwarn(ext_id, _("chr: called with too many arguments"));
-
if (get_argument(0, AWK_NUMBER, & num)) {
val = num.num_value;
ret = val; /* convert to int */
ret &= 0xff;
str[0] = ret;
str[1] = '\0';
- } else if (do_lint) {
- if (nargs == 0)
- lintwarn(ext_id, _("chr: called with no arguments"));
- else
- lintwarn(ext_id, _("chr: called with inappropriate argument(s)"));
- }
+ } else if (do_lint)
+ lintwarn(ext_id, _("chr: called with inappropriate argument(s)"));
/* Set the return value */
return make_const_string(str, 1, result);
}
static awk_ext_func_t func_table[] = {
- { "ord", do_ord, 1 },
- { "chr", do_chr, 1 },
+ { "ord", do_ord, 1, 1, awk_false, NULL },
+ { "chr", do_chr, 1, 1, awk_false, NULL },
};
/* define the dl_load function using the boilerplate macro */
diff --git a/extension/readdir.c b/extension/readdir.c
index 4578b864..39acba68 100644
--- a/extension/readdir.c
+++ b/extension/readdir.c
@@ -11,20 +11,20 @@
/*
* Copyright (C) 2012-2014 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
@@ -316,7 +316,7 @@ init_readdir()
}
static awk_ext_func_t func_table[] = {
- { NULL, NULL, 0 }
+ { NULL, NULL, 0, 0, awk_false, NULL }
};
/* define the dl_load function using the boilerplate macro */
diff --git a/extension/readfile.c b/extension/readfile.c
index d4b4aef9..b453da21 100644
--- a/extension/readfile.c
+++ b/extension/readfile.c
@@ -14,20 +14,20 @@
/*
* 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
* 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
@@ -82,8 +82,8 @@ read_file_to_buffer(int fd, const struct stat *sbuf)
goto done;
}
- emalloc(text, char *, sbuf->st_size + 2, "do_readfile");
- memset(text, '\0', sbuf->st_size + 2);
+ emalloc(text, char *, sbuf->st_size + 1, "do_readfile");
+ memset(text, '\0', sbuf->st_size + 1);
if ((ret = read(fd, text, sbuf->st_size)) != sbuf->st_size) {
update_ERRNO_int(errno);
@@ -98,7 +98,7 @@ done:
/* do_readfile --- read a file into memory */
static awk_value_t *
-do_readfile(int nargs, awk_value_t *result)
+do_readfile(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t filename;
int ret;
@@ -109,9 +109,6 @@ do_readfile(int nargs, awk_value_t *result)
assert(result != NULL);
make_null_string(result); /* default return value */
- if (do_lint && nargs > 1)
- lintwarn(ext_id, _("readfile: called with too many arguments"));
-
unset_ERRNO();
if (get_argument(0, AWK_STRING, &filename)) {
@@ -134,7 +131,7 @@ do_readfile(int nargs, awk_value_t *result)
make_malloced_string(text, sbuf.st_size, result);
goto done;
} else if (do_lint)
- lintwarn(ext_id, _("readfile: called with no arguments"));
+ lintwarn(ext_id, _("readfile: called with wrong kind of argument"));
done:
/* Set the return value */
@@ -241,7 +238,7 @@ init_readfile()
}
static awk_ext_func_t func_table[] = {
- { "readfile", do_readfile, 1 },
+ { "readfile", do_readfile, 1, 1, awk_false, NULL },
};
/* define the dl_load function using the boilerplate macro */
diff --git a/extension/revoutput.c b/extension/revoutput.c
index 69257167..5862ed6e 100644
--- a/extension/revoutput.c
+++ b/extension/revoutput.c
@@ -8,20 +8,20 @@
/*
* Copyright (C) 2012, 2013, 2015 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
@@ -134,7 +134,7 @@ init_revoutput()
}
static awk_ext_func_t func_table[] = {
- { NULL, NULL, 0 }
+ { NULL, NULL, 0, 0, awk_false, NULL }
};
/* define the dl_load function using the boilerplate macro */
diff --git a/extension/revtwoway.c b/extension/revtwoway.c
index dfe58a1e..ac4e22cf 100644
--- a/extension/revtwoway.c
+++ b/extension/revtwoway.c
@@ -8,20 +8,20 @@
/*
* Copyright (C) 2012-2014, 2016 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
@@ -336,7 +336,7 @@ init_revtwoway()
}
static awk_ext_func_t func_table[] = {
- { NULL, NULL, 0 }
+ { NULL, NULL, 0, 0, awk_false, NULL }
};
/* define the dl_load function using the boilerplate macro */
diff --git a/extension/rwarray.c b/extension/rwarray.c
index 155cc47c..a7d752cf 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -8,20 +8,20 @@
/*
* Copyright (C) 2009-2014 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
@@ -41,6 +41,7 @@
#ifdef __MINGW32__
#include <winsock2.h>
+#include <stdint.h>
#else
#include <arpa/inet.h>
#endif
@@ -55,11 +56,11 @@
#define MAGIC "awkrulz\n"
#define MAJOR 3
-#define MINOR 0
+#define MINOR 1
static const gawk_api_t *api; /* for convenience macros to work */
static awk_ext_id_t *ext_id;
-static const char *ext_version = "rwarray extension: version 1.0";
+static const char *ext_version = "rwarray extension: version 1.1";
static awk_bool_t (*init_func)(void) = NULL;
int plugin_is_GPL_compatible;
@@ -80,11 +81,11 @@ static awk_bool_t read_value(FILE *fp, awk_value_t *value);
* Minor version 4 bytes - network order
* Element count 4 bytes - network order
* Elements
- *
+ *
* For each element:
* Length of index val: 4 bytes - network order
* Index val as characters (N bytes)
- * Value type 4 bytes (0 = string, 1 = number, 2 = array)
+ * Value type 4 bytes (0 = string, 1 = number, 2 = array, 3 = regex, 4 = strnum)
* IF string:
* Length of value 4 bytes
* Value as characters (N bytes)
@@ -99,7 +100,7 @@ static awk_bool_t read_value(FILE *fp, awk_value_t *value);
/* do_writea --- write an array */
static awk_value_t *
-do_writea(int nargs, awk_value_t *result)
+do_writea(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t filename, array;
FILE *fp = NULL;
@@ -109,9 +110,6 @@ do_writea(int nargs, awk_value_t *result)
assert(result != NULL);
make_number(0.0, result);
- if (do_lint && nargs > 2)
- lintwarn(ext_id, _("writea: called with too many arguments"));
-
if (nargs < 2)
goto out;
@@ -213,7 +211,7 @@ write_elem(FILE *fp, awk_element_t *element)
return write_value(fp, & element->value);
}
-/* write_value --- write a number or a string or a array */
+/* write_value --- write a number or a string or a strnum or a regex or an array */
static awk_bool_t
write_value(FILE *fp, awk_value_t *val)
@@ -235,7 +233,22 @@ write_value(FILE *fp, awk_value_t *val)
if (fwrite(& val->num_value, 1, sizeof(val->num_value), fp) != sizeof(val->num_value))
return awk_false;
} else {
- code = 0;
+ switch (val->val_type) {
+ case AWK_STRING:
+ code = htonl(0);
+ break;
+ case AWK_STRNUM:
+ code = htonl(4);
+ break;
+ case AWK_REGEX:
+ code = htonl(3);
+ break;
+ default:
+ /* XXX can this happen? */
+ code = htonl(0);
+ warning(ext_id, _("array value has unknown type %d"), val->val_type);
+ break;
+ }
if (fwrite(& code, 1, sizeof(code), fp) != sizeof(code))
return awk_false;
@@ -254,7 +267,7 @@ write_value(FILE *fp, awk_value_t *val)
/* do_reada --- read an array */
static awk_value_t *
-do_reada(int nargs, awk_value_t *result)
+do_reada(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t filename, array;
FILE *fp = NULL;
@@ -265,9 +278,6 @@ do_reada(int nargs, awk_value_t *result)
assert(result != NULL);
make_number(0.0, result);
- if (do_lint && nargs > 2)
- lintwarn(ext_id, _("reada: called with too many arguments"));
-
if (nargs < 2)
goto out;
@@ -436,7 +446,7 @@ read_value(FILE *fp, awk_value_t *value)
awk_array_t array = create_array();
if (! read_array(fp, array))
- return awk_false;
+ return awk_false;
/* hook into value */
value->val_type = AWK_ARRAY;
@@ -455,10 +465,25 @@ read_value(FILE *fp, awk_value_t *value)
return awk_false;
}
len = ntohl(len);
- value->val_type = AWK_STRING;
+ switch (code) {
+ case 0:
+ value->val_type = AWK_STRING;
+ break;
+ case 3:
+ value->val_type = AWK_REGEX;
+ break;
+ case 4:
+ value->val_type = AWK_STRNUM;
+ break;
+ default:
+ /* this cannot happen! */
+ warning(ext_id, _("treating recovered value with unknown type code %d as a string"), code);
+ value->val_type = AWK_STRING;
+ break;
+ }
value->str_value.len = len;
- value->str_value.str = gawk_malloc(len + 2);
- memset(value->str_value.str, '\0', len + 2);
+ value->str_value.str = gawk_malloc(len + 1);
+ memset(value->str_value.str, '\0', len + 1);
if (fread(value->str_value.str, 1, len, fp) != (ssize_t) len) {
gawk_free(value->str_value.str);
@@ -470,8 +495,8 @@ read_value(FILE *fp, awk_value_t *value)
}
static awk_ext_func_t func_table[] = {
- { "writea", do_writea, 2 },
- { "reada", do_reada, 2 },
+ { "writea", do_writea, 2, 2, awk_false, NULL },
+ { "reada", do_reada, 2, 2, awk_false, NULL },
};
diff --git a/extension/rwarray0.c b/extension/rwarray0.c
index e2de3cf5..faa73783 100644
--- a/extension/rwarray0.c
+++ b/extension/rwarray0.c
@@ -8,20 +8,20 @@
/*
* Copyright (C) 2009, 2010, 2011, 2012, 2013 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
@@ -76,7 +76,7 @@ static awk_bool_t read_value(int fd, awk_value_t *value);
* Minor version 4 bytes - network order
* Element count 4 bytes - network order
* Elements
- *
+ *
* For each element:
* Length of index val: 4 bytes - network order
* Index val as characters (N bytes)
@@ -95,7 +95,7 @@ static awk_bool_t read_value(int fd, awk_value_t *value);
/* do_writea --- write an array */
static awk_value_t *
-do_writea(int nargs, awk_value_t *result)
+do_writea(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t filename, array;
int fd = -1;
@@ -105,9 +105,6 @@ do_writea(int nargs, awk_value_t *result)
assert(result != NULL);
make_number(0.0, result);
- if (do_lint && nargs > 2)
- lintwarn(ext_id, _("writea: called with too many arguments"));
-
if (nargs < 2)
goto out;
@@ -250,7 +247,7 @@ write_value(int fd, awk_value_t *val)
/* do_reada --- read an array */
static awk_value_t *
-do_reada(int nargs, awk_value_t *result)
+do_reada(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t filename, array;
int fd = -1;
@@ -261,9 +258,6 @@ do_reada(int nargs, awk_value_t *result)
assert(result != NULL);
make_number(0.0, result);
- if (do_lint && nargs > 2)
- lintwarn(ext_id, _("reada: called with too many arguments"));
-
if (nargs < 2)
goto out;
@@ -431,7 +425,7 @@ read_value(int fd, awk_value_t *value)
awk_array_t array = create_array();
if (read_array(fd, array) != 0)
- return awk_false;
+ return awk_false;
/* hook into value */
value->val_type = AWK_ARRAY;
@@ -452,8 +446,8 @@ read_value(int fd, awk_value_t *value)
len = ntohl(len);
value->val_type = AWK_STRING;
value->str_value.len = len;
- value->str_value.str = malloc(len + 2);
- memset(value->str_value.str, '\0', len + 2);
+ value->str_value.str = malloc(len + 1);
+ memset(value->str_value.str, '\0', len + 1);
if (read(fd, value->str_value.str, len) != (ssize_t) len) {
free(value->str_value.str);
@@ -465,8 +459,8 @@ read_value(int fd, awk_value_t *value)
}
static awk_ext_func_t func_table[] = {
- { "writea", do_writea, 2 },
- { "reada", do_reada, 2 },
+ { "writea", do_writea, 2, 2, awk_false, NULL },
+ { "reada", do_reada, 2, 2, awk_false, NULL },
};
diff --git a/extension/stack.c b/extension/stack.c
index 6150442c..637378e2 100644
--- a/extension/stack.c
+++ b/extension/stack.c
@@ -2,22 +2,22 @@
* stack.c -- Implementation for stack functions for use by extensions.
*/
-/*
+/*
* Copyright (C) 2012, 2013 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
diff --git a/extension/testext.c b/extension/testext.c
index 4a1e7032..572475e0 100644
--- a/extension/testext.c
+++ b/extension/testext.c
@@ -5,20 +5,20 @@
/*
* Copyright (C) 2012, 2013, 2014, 2015
* 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
@@ -37,6 +37,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <fcntl.h>
#include "gawkapi.h"
@@ -48,6 +49,15 @@ int plugin_is_GPL_compatible;
static void fill_in_array(awk_value_t *value);
+#ifdef __MINGW32__
+unsigned int
+getuid (void)
+{
+ /* See pc/getid.c. */
+ return 0;
+}
+#endif
+
/* valrep2str --- turn a value into a string */
static const char *
@@ -69,6 +79,8 @@ valrep2str(const awk_value_t *value)
case AWK_VALUE_COOKIE:
strcpy(buf, "<value-cookie>");
break;
+ case AWK_REGEX:
+ case AWK_STRNUM:
case AWK_STRING:
if (value->str_value.len < size)
size = value->str_value.len;
@@ -106,7 +118,7 @@ BEGIN {
}
*/
static awk_value_t *
-dump_array_and_delete(int nargs, awk_value_t *result)
+dump_array_and_delete(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t value, value2, value3;
awk_flat_array_t *flat_array;
@@ -200,7 +212,7 @@ BEGIN {
*/
static awk_value_t *
-try_modify_environ(int nargs, awk_value_t *result)
+try_modify_environ(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t value, index, newvalue;
awk_flat_array_t *flat_array;
@@ -289,7 +301,7 @@ BEGIN {
*/
static awk_value_t *
-var_test(int nargs, awk_value_t *result)
+var_test(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t value, value2;
awk_value_t *valp;
@@ -356,7 +368,7 @@ BEGIN {
}
*/
static awk_value_t *
-test_errno(int nargs, awk_value_t *result)
+test_errno(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
assert(result != NULL);
make_number(0.0, result);
@@ -374,6 +386,84 @@ out:
}
/*
+ * 3/2015: This test is no longer strictly necessary,
+ * since PROCINFO is no longer a deferred variable.
+ * But we leave it in for safety, anyway.
+ */
+/*
+BEGIN {
+ print "test_deferred returns", test_deferred()
+ print ""
+}
+*/
+static awk_value_t *
+test_deferred(int nargs, awk_value_t *result, struct awk_ext_func *unused)
+{
+ awk_value_t arr;
+ awk_value_t index, value;
+ const struct nval {
+ const char *name;
+ double val;
+ } seed[] = {
+ { "fubar", 9.0, },
+ { "rumpus", -5.0, },
+ };
+ struct nval sysval[] = {
+ { "uid", getuid(), },
+ { "api_major", GAWK_API_MAJOR_VERSION, },
+ };
+ size_t i;
+
+ assert(result != NULL);
+ make_number(0.0, result);
+
+ if (nargs != 0) {
+ printf("test_deferred: nargs not right (%d should be 0)\n", nargs);
+ goto out;
+ }
+
+ if (! sym_lookup("PROCINFO", AWK_ARRAY, & arr)) {
+ printf("test_deferred: %d: sym_lookup failed\n", __LINE__);
+ goto out;
+ }
+
+ for (i = 0; i < sizeof(seed)/sizeof(seed[0]); i++) {
+ make_const_string(seed[i].name, strlen(seed[i].name), & index);
+ make_number(seed[i].val, & value);
+ if (! set_array_element(arr.array_cookie, & index, & value)) {
+ printf("test_deferred: %d: set_array_element(%s) failed\n", __LINE__, seed[i].name);
+ goto out;
+ }
+ }
+
+ /* test that it still contains the values we loaded */
+ for (i = 0; i < sizeof(seed)/sizeof(seed[0]); i++) {
+ make_const_string(seed[i].name, strlen(seed[i].name), & index);
+ make_null_string(& value);
+ if (! get_array_element(arr.array_cookie, &index, AWK_NUMBER, & value)) {
+ printf("test_deferred: %d: get_array_element(%s) failed\n", __LINE__, seed[i].name);
+ goto out;
+ }
+ printf("%s = %g\n", seed[i].name, value.num_value);
+ }
+
+ /* check a few automatically-supplied values */
+ for (i = 0; i < sizeof(sysval)/sizeof(sysval[0]); i++) {
+ make_const_string(sysval[i].name, strlen(sysval[i].name), & index);
+ make_null_string(& value);
+ if (! get_array_element(arr.array_cookie, &index, AWK_NUMBER, & value)) {
+ printf("test_deferred: %d: get_array_element(%s) failed\n", __LINE__, sysval[i].name);
+ goto out;
+ }
+ printf("%s matches %d\n", sysval[i].name, (value.num_value == sysval[i].val));
+ }
+
+ make_number(1.0, result);
+out:
+ return result;
+}
+
+/*
BEGIN {
for (i = 1; i <= 10; i++)
test_array[i] = i + 2
@@ -386,7 +476,7 @@ BEGIN {
*/
static awk_value_t *
-test_array_size(int nargs, awk_value_t *result)
+test_array_size(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t value;
size_t count = 0;
@@ -450,7 +540,7 @@ BEGIN {
}
*/
static awk_value_t *
-test_array_elem(int nargs, awk_value_t *result)
+test_array_elem(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t array, index, index2, value;
@@ -538,7 +628,7 @@ BEGIN {
*/
static awk_value_t *
-test_array_param(int nargs, awk_value_t *result)
+test_array_param(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t new_array;
awk_value_t arg0;
@@ -581,7 +671,7 @@ BEGIN {
}
*/
static awk_value_t *
-print_do_lint(int nargs, awk_value_t *result)
+print_do_lint(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
assert(result != NULL);
make_number(0.0, result);
@@ -617,7 +707,7 @@ BEGIN {
/* test_scalar --- test scalar cookie */
static awk_value_t *
-test_scalar(int nargs, awk_value_t *result)
+test_scalar(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t new_value, new_value2;
awk_value_t the_scalar;
@@ -664,7 +754,7 @@ BEGIN {
/* test_scalar_reserved --- test scalar cookie on special variable */
static awk_value_t *
-test_scalar_reserved(int nargs, awk_value_t *result)
+test_scalar_reserved(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t new_value;
awk_value_t the_scalar;
@@ -710,13 +800,14 @@ BEGIN {
ret = test_indirect_vars() # should get correct value of NR
printf("test_indirect_var() return %d\n", ret)
delete ARGV[1]
+ print ""
}
*/
/* test_indirect_vars --- test that access to NR, NF, get correct vales */
static awk_value_t *
-test_indirect_vars(int nargs, awk_value_t *result)
+test_indirect_vars(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t value;
char *name = "NR";
@@ -742,6 +833,124 @@ out:
return result;
}
+/*
+BEGIN {
+ outfile = "testexttmp.txt"
+ alias = ".test.alias"
+ print "line 1" > outfile
+ print "line 2" > outfile
+ print "line 3" > outfile
+ close(outfile)
+ ret = test_get_file(outfile, alias)
+ printf "test_get_file returned %d\n", ret
+ nr = 0
+ while ((getline < alias) > 0)
+ printf "File [%s] nr [%s]: %s\n", alias, ++nr, $0
+ close(alias)
+ system("rm " outfile)
+ print ""
+}
+*/
+
+/* test_get_file --- test that we can create a file */
+
+static awk_value_t *
+test_get_file(int nargs, awk_value_t *result, struct awk_ext_func *unused)
+{
+ awk_value_t filename, alias;
+ int fd;
+ const awk_input_buf_t *ibuf;
+ const awk_output_buf_t *obuf;
+
+ if (nargs != 2) {
+ printf("%s: nargs not right (%d should be 2)\n", "test_get_file", nargs);
+ return make_number(-1.0, result);
+ }
+
+ if (! get_argument(0, AWK_STRING, & filename)) {
+ printf("%s: cannot get first arg\n", "test_get_file");
+ return make_number(-1.0, result);
+ }
+ if (! get_argument(1, AWK_STRING, & alias)) {
+ printf("%s: cannot get second arg\n", "test_get_file");
+ return make_number(-1.0, result);
+ }
+ if ((fd = open(filename.str_value.str, O_RDONLY)) < 0) {
+ printf("%s: open(%s) failed\n", "test_get_file", filename.str_value.str);
+ return make_number(-1.0, result);
+ }
+ if (! get_file(alias.str_value.str, strlen(alias.str_value.str), "<", fd, &ibuf, &obuf)) {
+ printf("%s: get_file(%s) failed\n", "test_get_file", alias.str_value.str);
+ return make_number(-1.0, result);
+ }
+ if (! ibuf || ibuf->fd != fd) {
+ printf("%s: get_file(%s) returned fd %d instead of %d\n", "test_get_file", alias.str_value.str, ibuf ? ibuf->fd : -1, fd);
+ return make_number(-1.0, result);
+ }
+ return make_number(0.0, result);
+}
+
+/* do_get_file --- provide access to get_file API */
+
+static awk_value_t *
+do_get_file(int nargs, awk_value_t *result, struct awk_ext_func *unused)
+{
+ awk_value_t filename, filetype, fd, res;
+ const awk_input_buf_t *ibuf;
+ const awk_output_buf_t *obuf;
+
+ if (nargs != 4) {
+ printf("%s: nargs not right (%d should be 4)\n", "get_file", nargs);
+ return make_number(-1.0, result);
+ }
+
+ if (! get_argument(0, AWK_STRING, & filename)) {
+ printf("%s: cannot get first arg\n", "get_file");
+ return make_number(-1.0, result);
+ }
+ if (! get_argument(1, AWK_STRING, & filetype)) {
+ printf("%s: cannot get second arg\n", "get_file");
+ return make_number(-1.0, result);
+ }
+ if (! get_argument(2, AWK_NUMBER, & fd)) {
+ printf("%s: cannot get third arg\n", "get_file");
+ return make_number(-1.0, result);
+ }
+ if (! get_argument(3, AWK_ARRAY, & res)) {
+ printf("%s: cannot get fourth arg\n", "get_file");
+ return make_number(-1.0, result);
+ }
+ clear_array(res.array_cookie);
+
+ if (! get_file(filename.str_value.str, strlen(filename.str_value.str), filetype.str_value.str, fd.num_value, &ibuf, &obuf)) {
+ printf("%s: get_file(%s, %s, %d) failed\n", "get_file", filename.str_value.str, filetype.str_value.str, (int)(fd.num_value));
+ return make_number(0.0, result);
+ }
+
+ if (ibuf) {
+ awk_value_t idx, val;
+ set_array_element(res.array_cookie,
+ make_const_string("input", 5, & idx),
+ make_number(ibuf->fd, & val));
+ if (ibuf->name)
+ set_array_element(res.array_cookie,
+ make_const_string("input_name", 10, & idx),
+ make_const_string(ibuf->name, strlen(ibuf->name), & val));
+ }
+ if (obuf) {
+ awk_value_t idx, val;
+ set_array_element(res.array_cookie,
+ make_const_string("output", 6, & idx),
+ make_number(obuf->fp ? fileno(obuf->fp) : -1,
+ & val));
+ if (obuf->name)
+ set_array_element(res.array_cookie,
+ make_const_string("output_name", 11, & idx),
+ make_const_string(obuf->name, strlen(obuf->name), & val));
+ }
+ return make_number(1.0, result);
+}
+
/* fill_in_array --- fill in a new array */
static void
@@ -826,17 +1035,20 @@ static void at_exit2(void *data, int exit_status)
}
static awk_ext_func_t func_table[] = {
- { "dump_array_and_delete", dump_array_and_delete, 2 },
- { "try_modify_environ", try_modify_environ, 0 },
- { "var_test", var_test, 1 },
- { "test_errno", test_errno, 0 },
- { "test_array_size", test_array_size, 1 },
- { "test_array_elem", test_array_elem, 2 },
- { "test_array_param", test_array_param, 1 },
- { "print_do_lint", print_do_lint, 0 },
- { "test_scalar", test_scalar, 1 },
- { "test_scalar_reserved", test_scalar_reserved, 0 },
- { "test_indirect_vars", test_indirect_vars, 0 },
+ { "dump_array_and_delete", dump_array_and_delete, 2, 2, awk_false, NULL },
+ { "try_modify_environ", try_modify_environ, 0, 0, awk_false, NULL },
+ { "var_test", var_test, 1, 1, awk_false, NULL },
+ { "test_deferred", test_deferred, 0, 0, awk_false, NULL },
+ { "test_errno", test_errno, 0, 0, awk_false, NULL },
+ { "test_array_size", test_array_size, 1, 1, awk_false, NULL },
+ { "test_array_elem", test_array_elem, 2, 2, awk_false, NULL },
+ { "test_array_param", test_array_param, 1, 1, awk_false, NULL },
+ { "print_do_lint", print_do_lint, 0, 0, awk_false, NULL },
+ { "test_scalar", test_scalar, 1, 1, awk_false, NULL },
+ { "test_scalar_reserved", test_scalar_reserved, 0, 0, awk_false, NULL },
+ { "test_indirect_vars", test_indirect_vars, 0, 0, awk_false, NULL },
+ { "test_get_file", test_get_file, 2, 2, awk_false, NULL },
+ { "get_file", do_get_file, 4, 4, awk_false, NULL },
};
/* init_testext --- additional initialization function */
@@ -847,6 +1059,10 @@ static awk_bool_t init_testext(void)
static const char message[] = "hello, world"; /* of course */
static const char message2[] = "i am a scalar";
+ /* This is used by the getfile test */
+ if (sym_lookup("TESTEXT_QUIET", AWK_NUMBER, & value))
+ return awk_true;
+
/* add at_exit functions */
awk_atexit(at_exit0, NULL);
awk_atexit(at_exit1, & data_for_1);
diff --git a/extension/time.c b/extension/time.c
index e6b2b39f..01be7784 100644
--- a/extension/time.c
+++ b/extension/time.c
@@ -103,15 +103,12 @@ int plugin_is_GPL_compatible;
* on the platform
*/
static awk_value_t *
-do_gettimeofday(int nargs, awk_value_t *result)
+do_gettimeofday(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
double curtime;
assert(result != NULL);
- if (do_lint && nargs > 0)
- lintwarn(ext_id, _("gettimeofday: ignoring arguments"));
-
#if defined(HAVE_GETTIMEOFDAY)
{
struct timeval tv;
@@ -153,7 +150,7 @@ do_gettimeofday(int nargs, awk_value_t *result)
* did not complete successfully (perhaps interrupted)
*/
static awk_value_t *
-do_sleep(int nargs, awk_value_t *result)
+do_sleep(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{
awk_value_t num;
double secs;
@@ -161,9 +158,6 @@ do_sleep(int nargs, awk_value_t *result)
assert(result != NULL);
- if (do_lint && nargs > 1)
- lintwarn(ext_id, _("sleep: called with too many arguments"));
-
if (! get_argument(0, AWK_NUMBER, &num)) {
update_ERRNO_string(_("sleep: missing required numeric argument"));
return make_number(-1, result);
@@ -212,8 +206,8 @@ do_sleep(int nargs, awk_value_t *result)
}
static awk_ext_func_t func_table[] = {
- { "gettimeofday", do_gettimeofday, 0 },
- { "sleep", do_sleep, 1 },
+ { "gettimeofday", do_gettimeofday, 0, 0, awk_false, NULL },
+ { "sleep", do_sleep, 1, 1, awk_false, NULL },
};
/* define the dl_load function using the boilerplate macro */