aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--README_d/ChangeLog4
-rw-r--r--README_d/README.pc15
-rw-r--r--awklib/eg/prog/cut.awk2
-rw-r--r--doc/ChangeLog7
-rw-r--r--doc/gawk.info142
-rw-r--r--doc/gawk.texi9
-rw-r--r--doc/gawktexi.in9
-rw-r--r--extension/ChangeLog43
-rw-r--r--extension/Makefile.am5
-rw-r--r--extension/Makefile.in33
-rw-r--r--extension/configh.in7
-rwxr-xr-xextension/configure70
-rw-r--r--extension/configure.ac2
-rw-r--r--extension/filefuncs.c29
-rw-r--r--extension/gawkdirfd.h8
-rw-r--r--extension/inplace.c18
-rw-r--r--extension/readdir.c86
-rw-r--r--extension/rwarray.c4
-rw-r--r--gawkapi.h4
-rw-r--r--io.c11
-rw-r--r--pc/ChangeLog13
-rw-r--r--pc/Makefile2
-rw-r--r--pc/Makefile.ext75
-rw-r--r--pc/Makefile.tst31
-rw-r--r--po/it.po5
-rw-r--r--test/ChangeLog9
-rw-r--r--test/Makefile.in8
-rw-r--r--test/filefuncs.awk4
29 files changed, 546 insertions, 121 deletions
diff --git a/ChangeLog b/ChangeLog
index fcf4e04b..d52168fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2013-05-14 Eli Zaretskii <eliz@gnu.org>
+
+ * io.c (devopen) [__EMX__ || __MINGW32__]: Produce EISDIR on MinGW
+ when an attempt to open() a directory fails.
+ (two_way_open) [__EMX__ || __MINGW32__]: When trying to open() a
+ directory fails with EISDIR, assign FAKE_FD_VALUE to the file
+ descriptor and attributes of a directory to its mode bits. This
+ is needed to support the readdir extension.
+
+ * gawkapi.h (FAKE_FD_VALUE): New macro, used in io.h and in
+ extension/gawkdirfd.h.
+
2013-05-09 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.0: Release tar ball made.
diff --git a/README_d/ChangeLog b/README_d/ChangeLog
index 814b2724..3bd99ad0 100644
--- a/README_d/ChangeLog
+++ b/README_d/ChangeLog
@@ -1,3 +1,7 @@
+2013-05-14 Eli Zaretskii <eliz@gnu.org>
+
+ * README.pc: Update the pc build and test instructions.
+
2013-05-09 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.0: Release tar ball made.
diff --git a/README_d/README.pc b/README_d/README.pc
index d989e5ca..9971d7ba 100644
--- a/README_d/README.pc
+++ b/README_d/README.pc
@@ -28,7 +28,8 @@ Copy the files in the `pc' directory (EXCEPT for `ChangeLog') to the
directory with the rest of the gawk sources. (The subdirectories of
`pc' need not be copied.) The Makefile contains a configuration
section with comments, and may need to be edited in order to work
-with your make utility.
+with your make utility. If you are building with MinGW, copy the
+file Makefile.ext to extension/Makefile.
The "prefix" line in the Makefile is used during the install of gawk
(and in building igawk.bat and igawk.cmd). Since the libraries for
@@ -40,6 +41,10 @@ OS/2 versions. A list of targets will be printed if the make command is
given without a target. As an example, to build gawk using the djgpp
tools, enter "make djgpp".
+For the MinGW build, after you build in the top-level directory, chdir
+to the extension subdirectory and say "make" there to build the
+extensions.
+
Testing and installing gawk
---------------------------
@@ -54,9 +59,11 @@ and batch files. See the configuration section of the makefile.
The file test/Makefile will need some editing (especially for DOS). A
sample makefile with comments appears in pc/Makefile.tst, and can be
-used to modify test/Makefile for your platform. In addition, some
-files in the test directory may need to have their end-of-line markers
-converted, as described in Makefile.tst.
+used to modify test/Makefile for your platform. For starters, just
+copy pc/Makefile.tst to test/Makefile, then walk through the variables
+defined at the beginning and change them as appropriate for your
+setup. In addition, some files in the test directory may need to have
+their end-of-line markers converted, as described in Makefile.tst.
As with building gawk, the OS, shell, and long filename issues come into
play when testing, too. If you are testing gawk on a LFN aware system with
diff --git a/awklib/eg/prog/cut.awk b/awklib/eg/prog/cut.awk
index fb4717c1..16b4bdaa 100644
--- a/awklib/eg/prog/cut.awk
+++ b/awklib/eg/prog/cut.awk
@@ -126,7 +126,7 @@ function set_charlist( field, i, j, f, g, t,
nfields = j - 1
}
{
- if (by_fields && suppress && index($0, FS) != 0)
+ if (by_fields && suppress && index($0, FS) == 0)
next
for (i = 1; i <= nfields; i++) {
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 9a732435..91919fb1 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-16 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (gawkextlib): Add a note to use make install on
+ gawkextlib itself. Thanks to Hermann Peifer.
+ (Cut program): Fix test for skipping lines if -s was supplied.
+ Thanks to David Ward <bamberward@gmail.com> for the bug report.
+
2013-05-09 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.0: Release tar ball made.
diff --git a/doc/gawk.info b/doc/gawk.info
index 94c10b3b..6685ba83 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -15551,7 +15551,7 @@ the next field also has data, then the separator character is written
out between the fields:
{
- if (by_fields && suppress && index($0, FS) != 0)
+ if (by_fields && suppress && index($0, FS) == 0)
next
for (i = 1; i <= nfields; i++) {
@@ -24753,6 +24753,12 @@ follows. First, build and install `gawk':
You may have to run this command twice
./configure --with-gawk=/tmp/newgawk Configure, point at "installed" gawk
make && make check Build and check that all is OK
+ make install Install the extensions
+
+ If you have installed `gawk' in the standard way, then you will
+likely not need the `--with-gawk' option when configuring `gawkextlib'.
+You may also need to use the `sudo' utility to install both `gawk' and
+`gawkextlib', depending upon how your system works.
If you write an extension that you wish to share with other `gawk'
users, please consider doing so through the `gawkextlib' project. See
@@ -32497,72 +32503,72 @@ Node: Extension Sample Readfile990564
Node: Extension Sample API Tests991382
Node: Extension Sample Time991907
Node: gawkextlib993271
-Node: Language History995702
-Node: V7/SVR3.1997224
-Node: SVR4999545
-Node: POSIX1000987
-Node: BTL1002373
-Node: POSIX/GNU1003107
-Node: Common Extensions1008642
-Node: Ranges and Locales1009948
-Ref: Ranges and Locales-Footnote-11014566
-Ref: Ranges and Locales-Footnote-21014593
-Ref: Ranges and Locales-Footnote-31014853
-Node: Contributors1015074
-Node: Installation1019953
-Node: Gawk Distribution1020847
-Node: Getting1021331
-Node: Extracting1022157
-Node: Distribution contents1023849
-Node: Unix Installation1029110
-Node: Quick Installation1029727
-Node: Additional Configuration Options1031689
-Node: Configuration Philosophy1033166
-Node: Non-Unix Installation1035508
-Node: PC Installation1035966
-Node: PC Binary Installation1037265
-Node: PC Compiling1039113
-Node: PC Testing1042057
-Node: PC Using1043233
-Node: Cygwin1047418
-Node: MSYS1048418
-Node: VMS Installation1048932
-Node: VMS Compilation1049535
-Ref: VMS Compilation-Footnote-11050542
-Node: VMS Installation Details1050600
-Node: VMS Running1052235
-Node: VMS Old Gawk1053842
-Node: Bugs1054316
-Node: Other Versions1058168
-Node: Notes1063769
-Node: Compatibility Mode1064569
-Node: Additions1065352
-Node: Accessing The Source1066279
-Node: Adding Code1067719
-Node: New Ports1073764
-Node: Derived Files1077899
-Ref: Derived Files-Footnote-11083220
-Ref: Derived Files-Footnote-21083254
-Ref: Derived Files-Footnote-31083854
-Node: Future Extensions1083952
-Node: Implementation Limitations1084533
-Node: Extension Design1085785
-Node: Old Extension Problems1086939
-Ref: Old Extension Problems-Footnote-11088447
-Node: Extension New Mechanism Goals1088504
-Ref: Extension New Mechanism Goals-Footnote-11091870
-Node: Extension Other Design Decisions1092056
-Node: Extension Future Growth1094162
-Node: Old Extension Mechanism1094998
-Node: Basic Concepts1096738
-Node: Basic High Level1097419
-Ref: figure-general-flow1097690
-Ref: figure-process-flow1098289
-Ref: Basic High Level-Footnote-11101518
-Node: Basic Data Typing1101703
-Node: Glossary1105058
-Node: Copying1130520
-Node: GNU Free Documentation License1168077
-Node: Index1193214
+Node: Language History996031
+Node: V7/SVR3.1997553
+Node: SVR4999874
+Node: POSIX1001316
+Node: BTL1002702
+Node: POSIX/GNU1003436
+Node: Common Extensions1008971
+Node: Ranges and Locales1010277
+Ref: Ranges and Locales-Footnote-11014895
+Ref: Ranges and Locales-Footnote-21014922
+Ref: Ranges and Locales-Footnote-31015182
+Node: Contributors1015403
+Node: Installation1020282
+Node: Gawk Distribution1021176
+Node: Getting1021660
+Node: Extracting1022486
+Node: Distribution contents1024178
+Node: Unix Installation1029439
+Node: Quick Installation1030056
+Node: Additional Configuration Options1032018
+Node: Configuration Philosophy1033495
+Node: Non-Unix Installation1035837
+Node: PC Installation1036295
+Node: PC Binary Installation1037594
+Node: PC Compiling1039442
+Node: PC Testing1042386
+Node: PC Using1043562
+Node: Cygwin1047747
+Node: MSYS1048747
+Node: VMS Installation1049261
+Node: VMS Compilation1049864
+Ref: VMS Compilation-Footnote-11050871
+Node: VMS Installation Details1050929
+Node: VMS Running1052564
+Node: VMS Old Gawk1054171
+Node: Bugs1054645
+Node: Other Versions1058497
+Node: Notes1064098
+Node: Compatibility Mode1064898
+Node: Additions1065681
+Node: Accessing The Source1066608
+Node: Adding Code1068048
+Node: New Ports1074093
+Node: Derived Files1078228
+Ref: Derived Files-Footnote-11083549
+Ref: Derived Files-Footnote-21083583
+Ref: Derived Files-Footnote-31084183
+Node: Future Extensions1084281
+Node: Implementation Limitations1084862
+Node: Extension Design1086114
+Node: Old Extension Problems1087268
+Ref: Old Extension Problems-Footnote-11088776
+Node: Extension New Mechanism Goals1088833
+Ref: Extension New Mechanism Goals-Footnote-11092199
+Node: Extension Other Design Decisions1092385
+Node: Extension Future Growth1094491
+Node: Old Extension Mechanism1095327
+Node: Basic Concepts1097067
+Node: Basic High Level1097748
+Ref: figure-general-flow1098019
+Ref: figure-process-flow1098618
+Ref: Basic High Level-Footnote-11101847
+Node: Basic Data Typing1102032
+Node: Glossary1105387
+Node: Copying1130849
+Node: GNU Free Documentation License1168406
+Node: Index1193543

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 95719786..b8856115 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -21710,7 +21710,7 @@ written out between the fields:
@example
@c file eg/prog/cut.awk
@{
- if (by_fields && suppress && index($0, FS) != 0)
+ if (by_fields && suppress && index($0, FS) == 0)
next
for (i = 1; i <= nfields; i++) @{
@@ -32824,8 +32824,15 @@ cd .../path/to/gawkextlib-code
@ii{You may have to run this command twice}
./configure --with-gawk=/tmp/newgawk @ii{Configure, point at ``installed'' gawk}
make && make check @ii{Build and check that all is OK}
+make install @ii{Install the extensions}
@end example
+If you have installed @command{gawk} in the standard way, then you
+will likely not need the @option{--with-gawk} option when configuring
+@code{gawkextlib}. You may also need to use the @command{sudo} utility
+to install both @command{gawk} and @code{gawkextlib}, depending upon
+how your system works.
+
If you write an extension that you wish to share with other
@command{gawk} users, please consider doing so through the
@code{gawkextlib} project.
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 40870076..d79093bf 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -20859,7 +20859,7 @@ written out between the fields:
@example
@c file eg/prog/cut.awk
@{
- if (by_fields && suppress && index($0, FS) != 0)
+ if (by_fields && suppress && index($0, FS) == 0)
next
for (i = 1; i <= nfields; i++) @{
@@ -31973,8 +31973,15 @@ cd .../path/to/gawkextlib-code
@ii{You may have to run this command twice}
./configure --with-gawk=/tmp/newgawk @ii{Configure, point at ``installed'' gawk}
make && make check @ii{Build and check that all is OK}
+make install @ii{Install the extensions}
@end example
+If you have installed @command{gawk} in the standard way, then you
+will likely not need the @option{--with-gawk} option when configuring
+@code{gawkextlib}. You may also need to use the @command{sudo} utility
+to install both @command{gawk} and @code{gawkextlib}, depending upon
+how your system works.
+
If you write an extension that you wish to share with other
@command{gawk} users, please consider doing so through the
@code{gawkextlib} project.
diff --git a/extension/ChangeLog b/extension/ChangeLog
index e01d6d14..66f7d355 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,46 @@
+2013-05-16 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * Makefile.am (install-data-hook): Remove .la files installed by
+ Automake. Leaves less clutter, if not (yet) less noise.
+
+2013-05-16 Arnold D. Robbins <arnold@skeeve.com>
+
+ * filefuncs.c (fill_stat_array): For _WIN32 use a blocksize of
+ 4096 for the "blksize" element, per Eli Zaretskii.
+
+ * configure.ac [AC_STRUCT_ST_BLKSIZE]: Add call that was missing.
+ ARGH!!!!
+
+2013-05-14 Eli Zaretskii <eliz@gnu.org>
+
+ * rwarray.c [__MINGW32__]: Include winsock2.h instead of
+ arpa/inet.h.
+
+ * readdir.c [__MINGW32__]: Include windows.h.
+ Include gawkapi.h before gawkdirfd.h, since the former defines
+ FAKE_FD_VALUE needed by the latter.
+ (ftype): Accept an additional argument, the directory that is
+ being read. Callers changed.
+ [!DT_BLK]: Produce the file's type by calling 'stat' on it, if the
+ dirent structure doesn't provide that.
+ (get_inode): New function, to produce inode values on MS-Windows.
+ (dir_get_record): Use it.
+
+ * inplace.c (chown, link) [__MINGW32__]: Redirect to existing
+ library functions.
+ (mkstemp) [__MINGW32__]: New function, for MinGW, which doesn't
+ have it in its library.
+ (do_inplace_end) [__MINGW32__]: Remove the old file before
+ renaming the new, since 'rename' on Windows cannot overwrite
+ existing files.
+
+ * gawkdirfd.h (ENOTSUP): Define to ENOSYS if not already defined.
+ (DIR_TO_FD): If not defined yet, define to FAKE_FD_VALUE.
+
+ * filefuncs.c (get_inode) [_WIN32]: New function, produces the
+ file index used on Windows as its inode.
+ (fill_stat_array) [_WIN32]: Use it.
+
2013-05-09 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.0: Release tar ball made.
diff --git a/extension/Makefile.am b/extension/Makefile.am
index b51b6c06..7b52b14b 100644
--- a/extension/Makefile.am
+++ b/extension/Makefile.am
@@ -98,6 +98,11 @@ testext_la_SOURCES = testext.c
testext_la_LDFLAGS = $(MY_MODULE_FLAGS)
testext_la_LIBADD = $(MY_LIBS)
+install-data-hook:
+ for i in $(pkgextension_LTLIBRARIES) ; do \
+ $(RM) $(pkgextensiondir)/$$i ; \
+ done
+
EXTRA_DIST = build-aux/config.rpath \
ChangeLog \
ChangeLog.0 \
diff --git a/extension/Makefile.in b/extension/Makefile.in
index 1bd4750b..8d0a2869 100644
--- a/extension/Makefile.in
+++ b/extension/Makefile.in
@@ -1114,7 +1114,8 @@ info: info-recursive
info-am:
install-data-am: install-man install-pkgextensionLTLIBRARIES
-
+ @$(NORMAL_INSTALL)
+ $(MAKE) $(AM_MAKEFLAGS) install-data-hook
install-dvi: install-dvi-recursive
install-dvi-am:
@@ -1165,7 +1166,8 @@ uninstall-am: uninstall-man uninstall-pkgextensionLTLIBRARIES
uninstall-man: uninstall-man3
-.MAKE: $(am__recursive_targets) all install-am install-strip
+.MAKE: $(am__recursive_targets) all install-am install-data-am \
+ install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
@@ -1176,17 +1178,22 @@ uninstall-man: uninstall-man3
distclean-hdr distclean-libtool distclean-tags distcleancheck \
distdir distuninstallcheck dvi dvi-am html html-am info \
info-am install install-am install-data install-data-am \
- install-dvi install-dvi-am install-exec install-exec-am \
- install-html install-html-am install-info install-info-am \
- install-man install-man3 install-pdf install-pdf-am \
- install-pkgextensionLTLIBRARIES install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- installdirs-am maintainer-clean maintainer-clean-generic \
- mostlyclean mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
- uninstall-am uninstall-man uninstall-man3 \
- uninstall-pkgextensionLTLIBRARIES
-
+ install-data-hook install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-man3 install-pdf \
+ install-pdf-am install-pkgextensionLTLIBRARIES install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs installdirs-am maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags tags-am uninstall uninstall-am uninstall-man \
+ uninstall-man3 uninstall-pkgextensionLTLIBRARIES
+
+
+install-data-hook:
+ for i in $(pkgextension_LTLIBRARIES) ; do \
+ $(RM) $(pkgextensiondir)/$$i ; \
+ done
# This is an ugly hack, initially for MirBSD but probably needed for other
# systems. If gawk doesn't have the API built in, don't try to build the
diff --git a/extension/configh.in b/extension/configh.in
index 9162ce4d..cc84f4d0 100644
--- a/extension/configh.in
+++ b/extension/configh.in
@@ -87,6 +87,13 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if `st_blksize' is a member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_BLKSIZE
+
+/* Define to 1 if your `struct stat' has `st_blksize'. Deprecated, use
+ `HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */
+#undef HAVE_ST_BLKSIZE
+
/* Define to 1 if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
diff --git a/extension/configure b/extension/configure
index f848b9be..23b050d3 100755
--- a/extension/configure
+++ b/extension/configure
@@ -1817,6 +1817,63 @@ fi
} # ac_fn_c_try_link
+# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
+# ----------------------------------------------------
+# Tries to find if the field MEMBER exists in type AGGR, after including
+# INCLUDES, setting cache variable VAR accordingly.
+ac_fn_c_check_member ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
+$as_echo_n "checking for $2.$3... " >&6; }
+if eval \${$4+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$5
+int
+main ()
+{
+static $2 ac_aggr;
+if (ac_aggr.$3)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$4=yes"
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$5
+int
+main ()
+{
+static $2 ac_aggr;
+if (sizeof ac_aggr.$3)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$4=yes"
+else
+ eval "$4=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$4
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_member
+
# ac_fn_c_check_func LINENO FUNC VAR
# ----------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -6382,6 +6439,19 @@ $as_echo "#define HAVE_DCGETTEXT 1" >>confdefs.h
+ac_fn_c_check_member "$LINENO" "struct stat" "st_blksize" "ac_cv_member_struct_stat_st_blksize" "$ac_includes_default"
+if test "x$ac_cv_member_struct_stat_st_blksize" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
+_ACEOF
+
+
+$as_echo "#define HAVE_ST_BLKSIZE 1" >>confdefs.h
+
+fi
+
+
if test -n "$ac_tool_prefix"; then
for ac_prog in ar lib "link -lib"
diff --git a/extension/configure.ac b/extension/configure.ac
index 53ed588e..40f29681 100644
--- a/extension/configure.ac
+++ b/extension/configure.ac
@@ -38,6 +38,8 @@ AM_INIT_AUTOMAKE([-Wall -Werror])
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.18.1])
+dnl checks for structure members
+AC_STRUCT_ST_BLKSIZE
AM_PROG_AR
AC_SYS_LARGEFILE
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 1e8fc8d0..5117b32f 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -73,6 +73,29 @@
#define S_ISVTX 0
#define major(s) (s)
#define minor(s) (0)
+
+#include <windows.h>
+
+/* get_inode --- get the inode of a file */
+static long long
+get_inode(const char *fname)
+{
+ HANDLE fh;
+ BY_HANDLE_FILE_INFORMATION info;
+
+ fh = CreateFile(fname, 0, 0, NULL, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (fh == INVALID_HANDLE_VALUE)
+ return 0;
+ if (GetFileInformationByHandle(fh, &info)) {
+ long long inode = info.nFileIndexHigh;
+
+ inode <<= 32;
+ inode += info.nFileIndexLow;
+ return inode;
+ }
+ return 0;
+}
#endif
static const gawk_api_t *api; /* for convenience macros to work */
@@ -302,7 +325,11 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf)
/* fill in the array */
array_set(array, "name", make_const_string(name, strlen(name), & tmp));
array_set_numeric(array, "dev", sbuf->st_dev);
+#ifdef _WIN32
+ array_set_numeric(array, "ino", (double)get_inode (name));
+#else
array_set_numeric(array, "ino", sbuf->st_ino);
+#endif
array_set_numeric(array, "mode", sbuf->st_mode);
array_set_numeric(array, "nlink", sbuf->st_nlink);
array_set_numeric(array, "uid", sbuf->st_uid);
@@ -326,6 +353,8 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf)
#ifdef HAVE_ST_BLKSIZE
array_set_numeric(array, "blksize", sbuf->st_blksize);
+#elif defined(_WIN32)
+ array_set_numeric(array, "blksize", 4096);
#endif /* HAVE_ST_BLKSIZE */
pmode = format_mode(sbuf->st_mode);
diff --git a/extension/gawkdirfd.h b/extension/gawkdirfd.h
index 1fbd6f57..e75f9bce 100644
--- a/extension/gawkdirfd.h
+++ b/extension/gawkdirfd.h
@@ -21,6 +21,14 @@
#include <config.h>
+#ifndef ENOTSUP
+# define ENOTSUP ENOSYS
+#endif
+
+#ifndef DIR_TO_FD
+# define DIR_TO_FD(d) (FAKE_FD_VALUE)
+#endif
+
#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0)
int
dirfd (DIR *dir_p)
diff --git a/extension/inplace.c b/extension/inplace.c
index ded4746c..ad6f0e23 100644
--- a/extension/inplace.c
+++ b/extension/inplace.c
@@ -51,6 +51,20 @@
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
+#ifdef __MINGW32__
+# define chown(x,y,z) (0)
+# define link(f1,f2) rename(f1,f2)
+int
+mkstemp (char *template)
+{
+ char *tmp_fname = _mktemp (template);
+
+ if (tmp_fname)
+ return _open (tmp_fname, O_RDWR | O_CREAT | O_EXCL, S_IREAD | S_IWRITE);
+ return -1;
+}
+#endif
+
static const gawk_api_t *api; /* for convenience macros to work */
static awk_ext_id_t *ext_id;
static const char *ext_version = "inplace extension: version 1.0";
@@ -225,6 +239,10 @@ do_inplace_end(int nargs, awk_value_t *result)
free(bakname);
}
+#ifdef __MINGW32__
+ unlink(filename.str_value.str);
+#endif
+
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));
diff --git a/extension/readdir.c b/extension/readdir.c
index 5ca4dc63..9d53ad9a 100644
--- a/extension/readdir.c
+++ b/extension/readdir.c
@@ -50,10 +50,14 @@
#error Cannot compile the dirent extension on this system!
#endif
-#include "gawkdirfd.h"
+#ifdef __MINGW32__
+#include <windows.h>
+#endif
#include "gawkapi.h"
+#include "gawkdirfd.h"
+
#include "gettext.h"
#define _(msgid) gettext(msgid)
#define N_(msgid) msgid
@@ -77,7 +81,7 @@ typedef struct open_directory {
/* ftype --- return type of file as a single character string */
static const char *
-ftype(struct dirent *entry)
+ftype(struct dirent *entry, const char *dirname)
{
#ifdef DT_BLK
switch (entry->d_type) {
@@ -92,10 +96,67 @@ ftype(struct dirent *entry)
case DT_UNKNOWN: return "u";
}
#else
+ char fname[PATH_MAX];
+ struct stat sbuf;
+
+ strcpy(fname, dirname);
+ strcat(fname, "/");
+ strcat(fname, entry->d_name);
+ if (stat(fname, &sbuf) == 0) {
+ if (S_ISBLK(sbuf.st_mode))
+ return "b";
+ if (S_ISCHR(sbuf.st_mode))
+ return "c";
+ if (S_ISDIR(sbuf.st_mode))
+ return "d";
+ if (S_ISFIFO(sbuf.st_mode))
+ return "p";
+ if (S_ISREG(sbuf.st_mode))
+ return "f";
+#ifdef S_ISLNK
+ if (S_ISLNK(sbuf.st_mode))
+ return "l";
+#endif
+#ifdef S_ISSOCK
+ if (S_ISSOCK(sbuf.st_mode))
+ return "s";
+#endif
+ }
return "u";
#endif
}
+/* get_inode --- get the inode of a file */
+#ifdef ZOS_USS
+static long
+#else
+static long long
+#endif
+get_inode(struct dirent *entry, const char *dirname)
+{
+#ifdef __MINGW32__
+ char fname[PATH_MAX];
+ HANDLE fh;
+ BY_HANDLE_FILE_INFORMATION info;
+
+ sprintf(fname, "%s\\%s", dirname, entry->d_name);
+ fh = CreateFile(fname, 0, 0, NULL, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (fh == INVALID_HANDLE_VALUE)
+ return 0;
+ if (GetFileInformationByHandle(fh, &info)) {
+ long long inode = info.nFileIndexHigh;
+
+ inode <<= 32;
+ inode += info.nFileIndexLow;
+ return inode;
+ }
+ return 0;
+#else
+ return entry->d_ino;
+#endif
+}
+
/* dir_get_record --- get one record at a time out of a directory */
static int
@@ -107,6 +168,11 @@ dir_get_record(char **out, awk_input_buf_t *iobuf, int *errcode,
int len;
open_directory_t *the_dir;
const char *ftstr;
+#ifdef ZOS_USS
+ unsigned long ino;
+#else
+ unsigned long long ino;
+#endif
/*
* The caller sets *errcode to 0, so we should set it only if an
@@ -129,17 +195,17 @@ dir_get_record(char **out, awk_input_buf_t *iobuf, int *errcode,
return EOF;
}
-#ifdef ZOS_USS
- len = sprintf(the_dir->buf, "%lu/%s",
- (unsigned long) dirent->d_ino,
- dirent->d_name);
+ ino = get_inode (dirent, iobuf->name);
+
+#if defined(ZOS_USS)
+ len = sprintf(the_dir->buf, "%lu/%s", ino, dirent->d_name);
+#elif __MINGW32__
+ len = sprintf(the_dir->buf, "%I64u/%s", ino, dirent->d_name);
#else
- len = sprintf(the_dir->buf, "%llu/%s",
- (unsigned long long) dirent->d_ino,
- dirent->d_name);
+ len = sprintf(the_dir->buf, "%llu/%s", ino, dirent->d_name);
#endif
- ftstr = ftype(dirent);
+ ftstr = ftype(dirent, iobuf->name);
len += sprintf(the_dir->buf + len, "/%s", ftstr);
*out = the_dir->buf;
diff --git a/extension/rwarray.c b/extension/rwarray.c
index d7b26c4a..6185000b 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -39,7 +39,11 @@
#include <string.h>
#include <unistd.h>
+#ifdef __MINGW32__
+#include <winsock2.h>
+#else
#include <arpa/inet.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/gawkapi.h b/gawkapi.h
index cc50bba3..c5cc4607 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -113,6 +113,10 @@ extern "C" {
#define awk_const const
#endif
+/* This is for fake directory file descriptors on systems that don't
+ allow to open() a directory. */
+#define FAKE_FD_VALUE 42
+
typedef enum awk_bool {
awk_false = 0,
awk_true
diff --git a/io.c b/io.c
index 7e3626bf..6024c4f9 100644
--- a/io.c
+++ b/io.c
@@ -1625,9 +1625,10 @@ devopen(const char *name, const char *mode)
strictopen:
if (openfd == INVALID_HANDLE)
openfd = open(name, flag, 0666);
-#ifdef __EMX__
+#if defined(__EMX__) || defined(__MINGW32__)
if (openfd == INVALID_HANDLE && errno == EACCES) {
- /* on OS/2 directory access via open() is not permitted */
+ /* On OS/2 and Windows directory access via open() is
+ not permitted. */
struct stat buf;
if (stat(name, & buf) == 0 && S_ISDIR(buf.st_mode))
@@ -2883,6 +2884,12 @@ iop_alloc(int fd, const char *name, int errno_val)
if (fd != INVALID_HANDLE)
fstat(fd, & iop->public.sbuf);
+#if defined(__EMX__) || defined(__MINGW32__)
+ else if (errno_val == EISDIR) {
+ iop->public.sbuf.st_mode = (_S_IFDIR | _S_IRWXU);
+ iop->public.fd = FAKE_FD_VALUE;
+ }
+#endif
return iop;
}
diff --git a/pc/ChangeLog b/pc/ChangeLog
index eeae9767..2c246fc2 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,16 @@
+2013-05-14 Eli Zaretskii <eliz@gnu.org>
+
+ * Makefile.tst (AWK): Set AWKLIBPATH so extensions could be found.
+ (LS): New variable.
+ (check): Add back shlib-tests and shlib-msg-end.
+ (readdir): Add a warning regarding inode reporting by ls.exe.
+ (fts, fork, fork2): Add message about expected failure on MinGW.
+
+ * Makefile (install): Install the extensions.
+ (install-strip): Likewise.
+
+ * Makefile.ext: New file.
+
2013-05-09 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.0: Release tar ball made.
diff --git a/pc/Makefile b/pc/Makefile
index b2344460..4152ed24 100644
--- a/pc/Makefile
+++ b/pc/Makefile
@@ -263,6 +263,7 @@ alloca$O: alloca.c
install: install$(install)
+ -$(MAKE) -C extension install-extensions
install1:
echo extproc sh $(prefix)/bin/igawk.cmd > igawk.cmd
@@ -286,6 +287,7 @@ install2:
install-strip: install$(install)
strip "$(prefix)/bin"/*.exe
+ -$(MAKE) -C extension $@
clean:
-rm -rf gawk *.exe gawk.map *.o *.obj core a.out $(RSPFILE) $(PRSPFILE) $(DRSPFILE) $(DYN_EXP)
diff --git a/pc/Makefile.ext b/pc/Makefile.ext
new file mode 100644
index 00000000..8971014b
--- /dev/null
+++ b/pc/Makefile.ext
@@ -0,0 +1,75 @@
+# extension/Makefile for the MinGW build
+#
+# Copyright (C) 2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+prefix = c:/gnu
+pkgdatadir = $(prefix)/lib/awk
+pkgextensiondir = $(prefix)/lib/gawk
+includedir = $(prefix)/include
+libdir = $(prefix)/lib
+datadir = $(prefix)/share
+pkgdatadir = $(datadir)/gawk-extensions
+pkgincludedir = $(includedir)/gawk-extensions
+pkglibdir = $(libdir)/gawk-extensions
+pkglibexecdir = $(libexecdir)/gawk-extensions
+
+SOEXT = dll
+SIMPLE_EXTENSIONS = inplace.$(SOEXT) ordchr.$(SOEXT) readfile.$(SOEXT)\
+ revoutput.$(SOEXT) revtwoway.$(SOEXT) testext.$(SOEXT)
+ALL_EXTENSIONS = filefuncs.$(SOEXT) fnmatch.$(SOEXT) inplace.$(SOEXT)\
+ ordchr.$(SOEXT) readdir.$(SOEXT) readfile.$(SOEXT) revoutput.$(SOEXT)\
+ revtwoway.$(SOEXT) rwarray.$(SOEXT) testext.$(SOEXT) time.$(SOEXT)
+
+extensions: $(ALL_EXTENSIONS)
+
+fnmatch.$(SOEXT): fnmatch.c
+ gcc -I.. -I../missing_d -DHAVE_FNMATCH_H -shared -gdwarf-2 -g3 -o $@ fnmatch.c
+
+readdir.$(SOEXT): readdir.c gawkdirfd.h
+ gcc -I.. -DHAVE_DIRENT_H -shared -gdwarf-2 -g3 -o $@ readdir.c
+
+rwarray.$(SOEXT): rwarray.c
+ gcc -I.. -shared -gdwarf-2 -g3 -o $@ rwarray.c -lws2_32
+
+filefuncs.$(SOEXT): filefuncs.c stack.c stack.h gawkfts.h
+ gcc -I.. -shared -gdwarf-2 -g3 -o $@ filefuncs.c stack.c
+
+time.$(SOEXT): time.c
+ gcc -DHAVE_GETSYSTEMTIMEASFILETIME -I.. -shared -gdwarf-2 -g3 -o $@ time.c
+
+$(SIMPLE_EXTENSIONS):
+ gcc -I.. -shared -gdwarf-2 -g3 -o $@ $(@:.$(SOEXT)=.c)
+
+$(ALL_EXTENSIONS): ../gawkapi.h ../gettext.h
+
+inplace.$(SOEXT): inplace.c
+ordchr.$(SOEXT): ordchr.c
+readfile.$(SOEXT): readfile.c
+revoutput.$(SOEXT): revoutput.c
+rwarray.$(SOEXT): rwarray.c
+testext.$(SOEXT): testext.c
+time.$(SOEXT): time.c
+
+# This must not be called 'install' because there's a file INSTALL,
+# and case-insensitive filesystems will gladly accept it.
+install-extensions:
+ -mkdir "$(pkgextensiondir)"
+ cp *.$(SOEXT) "$(pkgextensiondir)"
+ -mkdir "$(prefix)/share/man/man3"
+ cp *.3am "$(prefix)/share/man/man3"
+
+install-strip: install-extensions
+ strip --strip-unneeded "$(pkgextensiondir)"/*.$(SOEXT)
+
+clean:
+ -rm -f *.$(SOEXT)
+
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index dff0cacb..cc188fda 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -60,11 +60,16 @@
SHELL = /bin/sh
# Point to gawk
-AWK = ../gawk.exe
+AWK = AWKLIBPATH=../extension ../gawk.exe
# Also point to gawk but for DOS commands needing backslashes. We need
# the forward slash version too or 'arrayparam' fails.
AWK2 = '..\gawk.exe'
AWKPROG = ../gawk.exe
+# Point $(LS) to a version of ls.exe that reports true Windows file
+# index numbers, because this is what the readdir test expects.
+# Otherwise, the readdir test will fail. (The MSYS ls.exe doesn't
+# report full index values.)
+LS = ls.exe
# Define PGAWK
PGAWK = ../gawk.exe -p
@@ -100,12 +105,13 @@ CP = cp
#CP = : && command -c copy
#CP = command.com /c copy
-MV = cmd.exe /c ren
+#MV = cmd.exe /c ren
+MV = mv
-#MKDIR = mkdir
+MKDIR = mkdir
#MKDIR = gmkdir
#MKDIR = : && command -c mkdir
-MKDIR = command.com /c mkdir
+#MKDIR = command.com /c mkdir
# Set your unix-style date function here
#DATE = date
@@ -237,13 +243,10 @@ check: msg \
extend-msg-start gawk-extensions extend-msg-end \
machine-msg-start machine-tests machine-msg-end \
charset-msg-start charset-tests charset-msg-end \
- shlib-msg-start \
+ shlib-msg-start shlib-tests shlib-msg-end \
mpfr-msg-start mpfr-tests mpfr-msg-end \
pass-fail
-# Removed from 'check': shlib-tests shlib-msg-end
-# FIXME: add back when the extensions are built by default.
-
basic: $(BASIC_TESTS)
unix-tests: $(UNIX_TESTS)
@@ -1007,17 +1010,15 @@ readdir:
echo If it does, try rerunning on an ext'[234]' filesystem. ; \
fi
@echo $@
+ @echo This test may fail if $(LS) does not report full Windows file index as the inode
@$(AWK) -f $(srcdir)/readdir.awk $(top_srcdir) > _$@
- @ls -afli $(top_srcdir) | sed 1d | $(AWK) -f $(srcdir)/readdir0.awk -v extout=_$@ > $@.ok
+ @$(LS) -afli $(top_srcdir) | sed 1d | $(AWK) -f $(srcdir)/readdir0.awk -v extout=_$@ > $@.ok
@-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
fts:
- @if [ "`uname`" = IRIX ]; then \
- echo This test may fail on IRIX systems when run on an NFS filesystem.; \
- echo If it does, try rerunning on an xfs filesystem. ; \
- fi
@echo $@
- @$(AWK) -f $(srcdir)/fts.awk
+ @echo Expect $@ to fail with MinGW because function 'fts' is not defined.
+ @-$(AWK) -f $(srcdir)/fts.awk
@-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
charasbytes:
@@ -2362,11 +2363,13 @@ filefuncs:
fork:
@echo $@
+ @echo Expect $@ to fail with MinGW because fork.dll is not available
@AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
fork2:
@echo $@
+ @echo Expect $@ to fail with MinGW because fork.dll is not available
@AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
diff --git a/po/it.po b/po/it.po
index a472aa8f..5e2c5a1b 100644
--- a/po/it.po
+++ b/po/it.po
@@ -7,7 +7,7 @@ msgstr ""
"Project-Id-Version: GNU Awk 4.0.73, API: 0.0\n"
"Report-Msgid-Bugs-To: arnold@skeeve.com\n"
"POT-Creation-Date: 2013-05-09 16:05+0300\n"
-"PO-Revision-Date: 2013-04-18 12:36+0100\n"
+"PO-Revision-Date: 2013-05-10 11:52+0100\n"
"Last-Translator: Antonio Colombo <azc100@gmail.com>\n"
"Language-Team: Italian <it@li.org>\n"
"Language: it\n"
@@ -430,9 +430,8 @@ msgstr ""
"uso scorretto di dcngettext(_\"...\"): togliere il carattere '_' iniziale"
#: awkgram.y:3992
-#, fuzzy
msgid "index: regexp constant as second argument is not allowed"
-msgstr "index: il secondo argomento non è una stringa"
+msgstr "index: espressione regolare come secondo argomento non consentita"
#: awkgram.y:4045
#, c-format
diff --git a/test/ChangeLog b/test/ChangeLog
index 20b4d6e2..fda3b681 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,12 @@
+2013-05-14 Eli Zaretskii <eliz@gnu.org>
+
+ * Makefile.in (mpfr-tests, shlib-tests): Add a blank character
+ between ' and /FOO/ in Gawk command lines, for the benefit of
+ testing under MSYS Bash.
+
+ * filefuncs.awk (BEGIN): Call 'stat' on gawkapi.o, not on gawk,
+ which does not exist on systems that produce gawk.exe.
+
2013-05-09 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.0: Release tar ball made.
diff --git a/test/Makefile.in b/test/Makefile.in
index 46e7f57a..bfecafc0 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1453,14 +1453,18 @@ inet: inetmesg $(INET_TESTS)
machine-tests: $(MACHINE_TESTS)
+# The blank between ' and /MPFR/ is for running tests on Windows under
+# MSYS, which thinks /MPFR is a Unix-style file name and converts it
+# to Windows format, butchering it in the process. Likewise for /API/
+# in the next shlib-tests.
mpfr-tests:
- @if $(AWK) --version | $(AWK) '/MPFR/ { exit 1 }' ; then \
+ @if $(AWK) --version | $(AWK) ' /MPFR/ { exit 1 }' ; then \
echo MPFR tests not supported on this system ; \
else $(MAKE) $(MPFR_TESTS) ; \
fi
shlib-tests:
- @if $(AWK) --version | $(AWK) '/API/ { exit 1 }' ; then \
+ @if $(AWK) --version | $(AWK) ' /API/ { exit 1 }' ; then \
echo shlib tests not supported on this system ; \
else $(MAKE) shlib-real-tests ; \
fi
diff --git a/test/filefuncs.awk b/test/filefuncs.awk
index aa532741..4bbfcb55 100644
--- a/test/filefuncs.awk
+++ b/test/filefuncs.awk
@@ -6,8 +6,8 @@ BEGIN {
exit 1
}
- if (stat(ARGV[0], st) < 0) {
- printf "Error: stat(%s) failed with ERRNO %s\n", ARGV[0], ERRNO
+ if (stat(ARGV[0] "api.o", st) < 0) {
+ printf "Error: stat(%s) failed with ERRNO %s\n", ARGV[0] "api.o", ERRNO
exit 1
}