gawk-diffs
[Top][All Lists]
Advanced

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

[SCM] gawk branch, gawk-5.3-stable, updated. gawk-4.1.0-5437-g605a7738


From: Eli Zaretskii
Subject: [SCM] gawk branch, gawk-5.3-stable, updated. gawk-4.1.0-5437-g605a7738
Date: Tue, 12 Dec 2023 07:38:59 -0500 (EST)

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

The branch, gawk-5.3-stable has been updated
       via  605a77387523a07e3636d3a72c7a612dc15a5b31 (commit)
      from  68ceb5871bcb3ccb66c90201c3ab6a4a12a6f9fb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

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

commit 605a77387523a07e3636d3a72c7a612dc15a5b31
Author: Eli Zaretskii <eliz@gnu.org>
Date:   Tue Dec 12 14:37:33 2023 +0200

    Fix reading directories on MinGW when they come from variables.

diff --git a/ChangeLog b/ChangeLog
index 9a1f42eb..4a3d20da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-12-12  Eli Zaretskii  <eliz@gnu.org>
+
+       * io.c (redirect_string): Check registered parsers before failing
+       due to EISDIR.
+
 2023-12-02         Arnold D. Robbins     <arnold@skeeve.com>
 
        * debug.c (print_array): Fix printing of multidimensional arrays.
diff --git a/io.c b/io.c
index c595c009..3ffac799 100644
--- a/io.c
+++ b/io.c
@@ -797,6 +797,7 @@ redirect_string(const char *str, size_t explen, bool 
not_string,
        static struct redirect *save_rp = NULL; /* hold onto rp that should
                                                 * be freed for reuse
                                                 */
+       int save_errno;
 
        if (do_sandbox)
                fatal(_("redirection not allowed in sandbox mode"));
@@ -979,15 +980,20 @@ redirect_string(const char *str, size_t explen, bool 
not_string,
                case redirect_input:
                        direction = "from";
                        fd = (extfd >= 0) ? extfd : devopen(str, binmode("r"));
-                       if (fd == INVALID_HANDLE && errno == EISDIR) {
-                               *errflg = EISDIR;
-                               /* do not free rp, saving it for reuse (save_rp 
= rp) */
-                               return NULL;
-                       }
+                       save_errno = errno;
+                       /* don't fail before letting registered
+                          parsers a chance to take control */
                        rp->iop = iop_alloc(fd, str, errno);
                        find_input_parser(rp->iop);
                        iop_finish(rp->iop);
                        if (! rp->iop->valid) {
+                               if (fd == INVALID_HANDLE && save_errno == 
EISDIR) {
+                                       *errflg = EISDIR;
+                                       iop_close(rp->iop);
+                                       rp->iop = NULL;
+                                       /* do not free rp, saving it for reuse 
(save_rp = rp) */
+                                       return NULL;
+                               }
                                if (! do_traditional && rp->iop->errcode != 0)
                                        update_ERRNO_int(rp->iop->errcode);
                                iop_close(rp->iop);
diff --git a/pc/ChangeLog b/pc/ChangeLog
index 1f883407..fd3c949d 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,8 @@
+2023-12-12  Eli Zaretskii  <eliz@gnu.org>
+
+       * gawkmisc.pc (optimal_bufsize): Return DEFBLKSIZE for directories
+       "opened" by the readdir extension.
+
 2023-12-02         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.tst: Regenerated.
diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc
index 131aace8..221c869a 100644
--- a/pc/gawkmisc.pc
+++ b/pc/gawkmisc.pc
@@ -106,9 +106,6 @@ optimal_bufsize(fd, stb)
 int fd;
 struct stat *stb;
 {
-       /* force all members to zero in case OS doesn't use all of them. */
-       memset(stb, '\0', sizeof(struct stat));
-
        /*
         * DOS doesn't have the file system block size in the
         * stat structure. So we have to make some sort of reasonable
@@ -117,6 +114,12 @@ struct stat *stb;
         */
 #define        DEFBLKSIZE      BUFSIZ
 
+       if (S_ISDIR(stb->st_mode))
+               return DEFBLKSIZE;
+
+       /* force all members to zero in case OS doesn't use all of them. */
+       memset(stb, '\0', sizeof(struct stat));
+
        if (fstat(fd, stb) == -1)
                fatal("can't stat fd %d (%s)", fd, strerror(errno));
        if (S_ISREG(stb->st_mode)

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

Summary of changes:
 ChangeLog      |  5 +++++
 io.c           | 16 +++++++++++-----
 pc/ChangeLog   |  5 +++++
 pc/gawkmisc.pc |  9 ++++++---
 4 files changed, 27 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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