gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, extgawk, updated. 49658bfd0ef5d4efccd210


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, extgawk, updated. 49658bfd0ef5d4efccd210c48560c43bf455ee16
Date: Wed, 08 Aug 2012 19:52:19 +0000

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

The branch, extgawk has been updated
       via  49658bfd0ef5d4efccd210c48560c43bf455ee16 (commit)
      from  88e81c931345aa485e55c6d6c7f3ad61dc200fed (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=49658bfd0ef5d4efccd210c48560c43bf455ee16

commit 49658bfd0ef5d4efccd210c48560c43bf455ee16
Author: Arnold D. Robbins <address@hidden>
Date:   Wed Aug 8 22:51:53 2012 +0300

    Move struct stat into IOBUF_PUBLIC.

diff --git a/ChangeLog b/ChangeLog
index f0f5ff2..ca35faf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,13 @@
        * gawkapi.c (api_sym_update): For an array, pass the new cookie
        back out to the extension.
 
+       * awk.h (IOBUF): Move struct stat into IOBUF_PUBLIC.
+       (os_isreadable): Change to take an IOBUF_PUBLIC.
+       * gawkapi.h (IOBUF_PUBLIC): Received struct stat.
+       (INVALID_HANDLE): Moves to here.
+       * io.c (iop_alloc): Stat the fd and fill in stat buf.
+       (iop_finish): Use passed in stat info.
+
 2012-08-01         Arnold D. Robbins     <address@hidden>
 
        * io.c (iop_finish): New function.
diff --git a/awk.h b/awk.h
index 52c6ac4..e799862 100644
--- a/awk.h
+++ b/awk.h
@@ -889,7 +889,6 @@ typedef struct exp_instruction {
 
 typedef struct iobuf {
        IOBUF_PUBLIC public;    /* exposed to extensions */
-       struct stat sbuf;       /* stat buf */
        char *buf;              /* start data buffer */
        char *off;              /* start of current record in buffer */
        char *dataend;          /* first byte in buffer to hold new data,
@@ -1533,7 +1532,7 @@ extern int os_devopen(const char *name, int flag);
 extern void os_close_on_exec(int fd, const char *name, const char *what, const 
char *dir);
 extern int os_isatty(int fd);
 extern int os_isdir(int fd);
-extern int os_isreadable(int fd, bool *isdir);
+extern int os_isreadable(const IOBUF_PUBLIC *iobuf, bool *isdir);
 extern int os_is_setuid(void);
 extern int os_setbinmode(int fd, int mode);
 extern void os_restore_mode(int fd);
@@ -1694,8 +1693,6 @@ extern uintmax_t adjust_uint(uintmax_t n);
 #define adjust_uint(n) (n)
 #endif
 
-#define INVALID_HANDLE (-1)
-
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
 #endif
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 6b7c2bc..22b7201 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -8,6 +8,9 @@
        * stack.h, stack.c: New files.
        * Makefile.am: Update list of files.
 
+       * readdir.c (dir_can_take_file): Use members in iobuf.
+       * rwarray.c (do_writea): Initialize fp to NULL.
+
 2012-08-03         Andrew J. Schorr     <address@hidden>
 
        * readdir.c (dir_get_record): Fix for systems where ino_t is
diff --git a/extension/readdir.c b/extension/readdir.c
index 2c25a95..c28764e 100644
--- a/extension/readdir.c
+++ b/extension/readdir.c
@@ -184,14 +184,10 @@ dir_close(struct iobuf_public *iobuf)
 static int
 dir_can_take_file(const IOBUF_PUBLIC *iobuf)
 {
-       struct stat sbuf;
-       int fd;
-
        if (iobuf == NULL)
                return 0;
 
-       fd = iobuf->fd;
-       return (fd >= 0 && fstat(fd, & sbuf) >= 0 && S_ISDIR(sbuf.st_mode));
+       return (iobuf->fd != INVALID_HANDLE && S_ISDIR(iobuf->sbuf.st_mode));
 }
 
 /*
diff --git a/extension/rwarray.c b/extension/rwarray.c
index e45a499..0eca977 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -93,7 +93,7 @@ static awk_value_t *
 do_writea(int nargs, awk_value_t *result)
 {
        awk_value_t filename, array;
-       FILE *fp;
+       FILE *fp = NULL;
        uint32_t major = MAJOR;
        uint32_t minor = MINOR;
 
diff --git a/gawkapi.h b/gawkapi.h
index f345d07..b516787 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -100,6 +100,7 @@ extern "C" {
 typedef struct iobuf_public {
        const char *name;       /* filename */
        int fd;                 /* file descriptor */
+#define INVALID_HANDLE (-1)
        void *opaque;           /* private data for input parsers */
        /*
         * The get_record function is called to read the next record of data.
@@ -127,6 +128,9 @@ typedef struct iobuf_public {
         * Gawk itself will close the fd unless close_func sets it to -1.
         */
        void (*close_func)(struct iobuf_public *);
+
+       /* put last, for alignment. bleah */
+       struct stat sbuf;       /* stat buf */
                                                        
 } IOBUF_PUBLIC;
 
diff --git a/io.c b/io.c
index d37c0b3..589abbf 100644
--- a/io.c
+++ b/io.c
@@ -2734,6 +2734,9 @@ iop_alloc(int fd, const char *name, int errno_val)
        iop->valid = false;
        iop->errcode = errno_val;
 
+       if (fd != INVALID_HANDLE)
+               fstat(fd, & iop->public.sbuf);
+
        return iop;
 }
 
@@ -2743,10 +2746,9 @@ static IOBUF *
 iop_finish(IOBUF *iop)
 {
        bool isdir = false;
-       struct stat sbuf;
 
        if (iop->public.fd != INVALID_HANDLE) {
-               if (os_isreadable(iop->public.fd, & isdir))
+               if (os_isreadable(& iop->public, & isdir))
                        iop->valid = true;
                else {
                        if (isdir)
@@ -2769,9 +2771,8 @@ iop_finish(IOBUF *iop)
        if (os_isatty(iop->public.fd))
                iop->flag |= IOP_IS_TTY;
 
-       iop->readsize = iop->size = optimal_bufsize(iop->public.fd, & sbuf);
-       iop->sbuf = sbuf;
-       if (do_lint && S_ISREG(sbuf.st_mode) && sbuf.st_size == 0)
+       iop->readsize = iop->size = optimal_bufsize(iop->public.fd, & 
iop->public.sbuf);
+       if (do_lint && S_ISREG(iop->public.sbuf.st_mode) && 
iop->public.sbuf.st_size == 0)
                lintwarn(_("data file `%s' is empty"), iop->public.name);
        iop->errcode = errno = 0;
        iop->count = iop->scanoff = 0;
diff --git a/pc/ChangeLog b/pc/ChangeLog
index 28dfb72..57ffabe 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,6 +1,11 @@
+2012-08-08         Arnold D. Robbins     <address@hidden>
+
+       * gawkmisc.pc (os_isreadable): Take IOBUF_PUBLIC instead of fd and
+       use passed in info.
+
 2012-07-29         Arnold D. Robbins     <address@hidden>
 
-       * gawkmisc.c (os_isreadable): Add isdir pointer parameter to be
+       * gawkmisc.pc (os_isreadable): Add isdir pointer parameter to be
        set to true if fd is for a directory.
 
 2012-07-26         Arnold D. Robbins     <address@hidden>
diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc
index d79a320..e2f114e 100644
--- a/pc/gawkmisc.pc
+++ b/pc/gawkmisc.pc
@@ -235,16 +235,11 @@ int fd;
 /* os_isreadable --- fd can be read from */
 
 int
-os_isreadable(int fd, bool *isdir)
+os_isreadable(const IOBUF_PUBLIC *iobuf, bool *isdir)
 {
-       struct stat sbuf;
-
        *isdir = false;
 
-       if (fstat(fd, &sbuf) != 0)
-               return false;
-
-       switch (sbuf.st_mode & S_IFMT) {
+       switch (iobuf->sbuf.st_mode & S_IFMT) {
        case S_IFREG:
        case S_IFCHR:   /* ttys, /dev/null, .. */
 #ifdef S_IFSOCK
diff --git a/posix/ChangeLog b/posix/ChangeLog
index d49ff49..982f6bd 100644
--- a/posix/ChangeLog
+++ b/posix/ChangeLog
@@ -1,3 +1,8 @@
+2012-08-08         Arnold D. Robbins     <address@hidden>
+
+       * gawkmisc.pc (os_isreadable): Take IOBUF_PUBLIC instead of fd and
+       use passed in info.
+
 2012-07-29         Arnold D. Robbins     <address@hidden>
 
        * gawkmisc.c (os_isreadable): Add isdir pointer parameter to be
diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c
index a5c3a61..ebcee8a 100644
--- a/posix/gawkmisc.c
+++ b/posix/gawkmisc.c
@@ -207,16 +207,14 @@ os_isdir(int fd)
 /* os_isreadable --- fd can be read from */
 
 int
-os_isreadable(int fd, bool *isdir)
+os_isreadable(const IOBUF_PUBLIC *iobuf, bool *isdir)
 {
-       struct stat sbuf;
-
        *isdir = false;
 
-       if (fstat(fd, &sbuf) != 0)
+       if (iobuf->fd == INVALID_HANDLE)
                return false;
 
-       switch (sbuf.st_mode & S_IFMT) {
+       switch (iobuf->sbuf.st_mode & S_IFMT) {
        case S_IFREG:
        case S_IFCHR:   /* ttys, /dev/null, .. */
 #ifdef S_IFSOCK
diff --git a/vms/ChangeLog b/vms/ChangeLog
index f65274f..725a223 100644
--- a/vms/ChangeLog
+++ b/vms/ChangeLog
@@ -1,6 +1,11 @@
+2012-08-08         Arnold D. Robbins     <address@hidden>
+
+       * gawkmisc.pc (os_isreadable): Take IOBUF_PUBLIC instead of fd and
+       use passed in info.
+
 2012-07-29         Arnold D. Robbins     <address@hidden>
 
-       * gawkmisc.c (os_isreadable): Add isdir pointer parameter to be
+       * gawkmisc.vms (os_isreadable): Add isdir pointer parameter to be
        set to true if fd is for a directory.
 
 2012-07-26         Arnold D. Robbins     <address@hidden>
diff --git a/vms/gawkmisc.vms b/vms/gawkmisc.vms
index 773b355..0ca3e0b 100644
--- a/vms/gawkmisc.vms
+++ b/vms/gawkmisc.vms
@@ -147,16 +147,11 @@ int fd;
 /* os_isreadable --- fd can be read from */
 
 int
-os_isreadable(int fd, bool *isdir)
+os_isreadable(const IOBUF_PUBLIC *iobuf, bool *isdir)
 {
-       struct stat sbuf;
-
        *isdir = false;
 
-       if (fstat(fd, &sbuf) != 0)
-               return false;
-
-       switch (sbuf.st_mode & S_IFMT) {
+       switch (iobuf->sbuf.st_mode & S_IFMT) {
        case S_IFREG:
        case S_IFCHR:   /* ttys, /dev/null, .. */
 #ifdef S_IFSOCK

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

Summary of changes:
 ChangeLog           |    7 +++++++
 awk.h               |    5 +----
 extension/ChangeLog |    3 +++
 extension/readdir.c |    6 +-----
 extension/rwarray.c |    2 +-
 gawkapi.h           |    4 ++++
 io.c                |   11 ++++++-----
 pc/ChangeLog        |    7 ++++++-
 pc/gawkmisc.pc      |    9 ++-------
 posix/ChangeLog     |    5 +++++
 posix/gawkmisc.c    |    8 +++-----
 vms/ChangeLog       |    7 ++++++-
 vms/gawkmisc.vms    |    9 ++-------
 13 files changed, 47 insertions(+), 36 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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