gawk-diffs
[Top][All Lists]
Advanced

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

[SCM] gawk branch, gawk-5.2-stable, updated. gawk-4.1.0-5063-g84e5c897


From: Arnold Robbins
Subject: [SCM] gawk branch, gawk-5.2-stable, updated. gawk-4.1.0-5063-g84e5c897
Date: Thu, 25 May 2023 05:01:01 -0400 (EDT)

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.2-stable has been updated
       via  84e5c8971aad5ba87ff1c8bf3ce5297d92cef27f (commit)
      from  0f0bb263dcd493a9a3db44ee881111ff2606f383 (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=84e5c8971aad5ba87ff1c8bf3ce5297d92cef27f

commit 84e5c8971aad5ba87ff1c8bf3ce5297d92cef27f
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Thu May 25 12:00:35 2023 +0300

    Merge readdir.c and readdir_test.c, revise test cases.

diff --git a/extension/ChangeLog b/extension/ChangeLog
index e5099128..85c3d3a8 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2023-05-25         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * readdir.c: Synced fully with readdir_test.c.
+       * readdir_test.c: Removed.
+
 2023-05-25         Arnold D. Robbins     <arnold@skeeve.com>
 
        * readdir_test.c: Sync somewhat with readdir.c. A full
diff --git a/extension/Makefile.am b/extension/Makefile.am
index 28208c5a..ec51377c 100644
--- a/extension/Makefile.am
+++ b/extension/Makefile.am
@@ -48,7 +48,6 @@ pkgextension_LTLIBRARIES =    \
        time.la
 
 noinst_LTLIBRARIES =   \
-       readdir_test.la \
        testext.la
 
 MY_MODULE_FLAGS = -module -avoid-version -no-undefined
@@ -115,13 +114,6 @@ testext_la_SOURCES    = testext.c
 testext_la_LDFLAGS    = $(MY_MODULE_FLAGS) -rpath /foo
 testext_la_LIBADD     = $(MY_LIBS) $(LIBMPFR)
 
-# N.B. Because we are not installing readdir_test, we must specify -rpath in
-# LDFLAGS to get automake to build a shared library, since it needs
-# an installation path.
-readdir_test_la_SOURCES = readdir_test.c
-readdir_test_la_LDFLAGS = $(MY_MODULE_FLAGS) -rpath /foo
-readdir_test_la_LIBADD  = $(MY_LIBS)
-
 install-data-hook:
        for i in $(pkgextension_LTLIBRARIES) ; do \
                $(RM) $(DESTDIR)$(pkgextensiondir)/$$i ; \
diff --git a/extension/Makefile.in b/extension/Makefile.in
index 6c8937c0..7a6a8283 100644
--- a/extension/Makefile.in
+++ b/extension/Makefile.in
@@ -220,13 +220,6 @@ readdir_la_OBJECTS = $(am_readdir_la_OBJECTS)
 readdir_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(readdir_la_LDFLAGS) $(LDFLAGS) -o $@
-readdir_test_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
-am_readdir_test_la_OBJECTS = readdir_test.lo
-readdir_test_la_OBJECTS = $(am_readdir_test_la_OBJECTS)
-readdir_test_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
-       $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
-       $(AM_CFLAGS) $(CFLAGS) $(readdir_test_la_LDFLAGS) $(LDFLAGS) \
-       -o $@
 readfile_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
 am_readfile_la_OBJECTS = readfile.lo
 readfile_la_OBJECTS = $(am_readfile_la_OBJECTS)
@@ -282,11 +275,10 @@ am__depfiles_remade = ./$(DEPDIR)/filefuncs.Plo \
        ./$(DEPDIR)/fnmatch.Plo ./$(DEPDIR)/fork.Plo \
        ./$(DEPDIR)/gawkfts.Plo ./$(DEPDIR)/inplace.Plo \
        ./$(DEPDIR)/intdiv.Plo ./$(DEPDIR)/ordchr.Plo \
-       ./$(DEPDIR)/readdir.Plo ./$(DEPDIR)/readdir_test.Plo \
-       ./$(DEPDIR)/readfile.Plo ./$(DEPDIR)/revoutput.Plo \
-       ./$(DEPDIR)/revtwoway.Plo ./$(DEPDIR)/rwarray.Plo \
-       ./$(DEPDIR)/stack.Plo ./$(DEPDIR)/testext.Plo \
-       ./$(DEPDIR)/time.Plo
+       ./$(DEPDIR)/readdir.Plo ./$(DEPDIR)/readfile.Plo \
+       ./$(DEPDIR)/revoutput.Plo ./$(DEPDIR)/revtwoway.Plo \
+       ./$(DEPDIR)/rwarray.Plo ./$(DEPDIR)/stack.Plo \
+       ./$(DEPDIR)/testext.Plo ./$(DEPDIR)/time.Plo
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
        $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -309,15 +301,15 @@ am__v_CCLD_1 =
 SOURCES = $(filefuncs_la_SOURCES) $(fnmatch_la_SOURCES) \
        $(fork_la_SOURCES) $(inplace_la_SOURCES) $(intdiv_la_SOURCES) \
        $(ordchr_la_SOURCES) $(readdir_la_SOURCES) \
-       $(readdir_test_la_SOURCES) $(readfile_la_SOURCES) \
-       $(revoutput_la_SOURCES) $(revtwoway_la_SOURCES) \
-       $(rwarray_la_SOURCES) $(testext_la_SOURCES) $(time_la_SOURCES)
+       $(readfile_la_SOURCES) $(revoutput_la_SOURCES) \
+       $(revtwoway_la_SOURCES) $(rwarray_la_SOURCES) \
+       $(testext_la_SOURCES) $(time_la_SOURCES)
 DIST_SOURCES = $(filefuncs_la_SOURCES) $(fnmatch_la_SOURCES) \
        $(fork_la_SOURCES) $(inplace_la_SOURCES) $(intdiv_la_SOURCES) \
        $(ordchr_la_SOURCES) $(readdir_la_SOURCES) \
-       $(readdir_test_la_SOURCES) $(readfile_la_SOURCES) \
-       $(revoutput_la_SOURCES) $(revtwoway_la_SOURCES) \
-       $(rwarray_la_SOURCES) $(testext_la_SOURCES) $(time_la_SOURCES)
+       $(readfile_la_SOURCES) $(revoutput_la_SOURCES) \
+       $(revtwoway_la_SOURCES) $(rwarray_la_SOURCES) \
+       $(testext_la_SOURCES) $(time_la_SOURCES)
 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
        ctags-recursive dvi-recursive html-recursive info-recursive \
        install-data-recursive install-dvi-recursive \
@@ -585,7 +577,6 @@ pkgextension_LTLIBRARIES = \
        time.la
 
 noinst_LTLIBRARIES = \
-       readdir_test.la \
        testext.la
 
 MY_MODULE_FLAGS = -module -avoid-version -no-undefined
@@ -642,13 +633,6 @@ time_la_LIBADD = $(MY_LIBS)
 testext_la_SOURCES = testext.c
 testext_la_LDFLAGS = $(MY_MODULE_FLAGS) -rpath /foo
 testext_la_LIBADD = $(MY_LIBS) $(LIBMPFR)
-
-# N.B. Because we are not installing readdir_test, we must specify -rpath in
-# LDFLAGS to get automake to build a shared library, since it needs
-# an installation path.
-readdir_test_la_SOURCES = readdir_test.c
-readdir_test_la_LDFLAGS = $(MY_MODULE_FLAGS) -rpath /foo
-readdir_test_la_LIBADD = $(MY_LIBS)
 EXTRA_DIST = \
        ChangeLog \
        ChangeLog.0 \
@@ -789,9 +773,6 @@ ordchr.la: $(ordchr_la_OBJECTS) $(ordchr_la_DEPENDENCIES) 
$(EXTRA_ordchr_la_DEPE
 readdir.la: $(readdir_la_OBJECTS) $(readdir_la_DEPENDENCIES) 
$(EXTRA_readdir_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(readdir_la_LINK) -rpath $(pkgextensiondir) 
$(readdir_la_OBJECTS) $(readdir_la_LIBADD) $(LIBS)
 
-readdir_test.la: $(readdir_test_la_OBJECTS) $(readdir_test_la_DEPENDENCIES) 
$(EXTRA_readdir_test_la_DEPENDENCIES) 
-       $(AM_V_CCLD)$(readdir_test_la_LINK)  $(readdir_test_la_OBJECTS) 
$(readdir_test_la_LIBADD) $(LIBS)
-
 readfile.la: $(readfile_la_OBJECTS) $(readfile_la_DEPENDENCIES) 
$(EXTRA_readfile_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(readfile_la_LINK) -rpath $(pkgextensiondir) 
$(readfile_la_OBJECTS) $(readfile_la_LIBADD) $(LIBS)
 
@@ -824,7 +805,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intdiv.Plo@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ordchr.Plo@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readdir.Plo@am__quote@ # 
am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readdir_test.Plo@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readfile.Plo@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/revoutput.Plo@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/revtwoway.Plo@am__quote@ # 
am--include-marker
@@ -1267,7 +1247,6 @@ distclean: distclean-recursive
        -rm -f ./$(DEPDIR)/intdiv.Plo
        -rm -f ./$(DEPDIR)/ordchr.Plo
        -rm -f ./$(DEPDIR)/readdir.Plo
-       -rm -f ./$(DEPDIR)/readdir_test.Plo
        -rm -f ./$(DEPDIR)/readfile.Plo
        -rm -f ./$(DEPDIR)/revoutput.Plo
        -rm -f ./$(DEPDIR)/revtwoway.Plo
@@ -1331,7 +1310,6 @@ maintainer-clean: maintainer-clean-recursive
        -rm -f ./$(DEPDIR)/intdiv.Plo
        -rm -f ./$(DEPDIR)/ordchr.Plo
        -rm -f ./$(DEPDIR)/readdir.Plo
-       -rm -f ./$(DEPDIR)/readdir_test.Plo
        -rm -f ./$(DEPDIR)/readfile.Plo
        -rm -f ./$(DEPDIR)/revoutput.Plo
        -rm -f ./$(DEPDIR)/revtwoway.Plo
diff --git a/extension/readdir.c b/extension/readdir.c
index c2d59b2b..45b19993 100644
--- a/extension/readdir.c
+++ b/extension/readdir.c
@@ -11,7 +11,7 @@
  */
 
 /*
- * Copyright (C) 2012-2014, 2018, 2019, 2021, 2023,
+ * Copyright (C) 2012-2014, 2017, 2018, 2019, 2021, 2023,
  * the Free Software Foundation, Inc.
  *
  * This file is part of GAWK, the GNU implementation of the
@@ -75,7 +75,7 @@
 
 static const gawk_api_t *api;  /* for convenience macros to work */
 static awk_ext_id_t ext_id;
-static const char *ext_version = "readdir extension: version 2.0";
+static const char *ext_version = "readdir extension: version 3.0";
 
 static awk_bool_t init_readdir(void);
 static awk_bool_t (*init_func)(void) = init_readdir;
@@ -87,7 +87,12 @@ int plugin_is_GPL_compatible;
 typedef struct open_directory {
        DIR *dp;
        char *buf;
+       union {
+               awk_fieldwidth_info_t fw;
+               char buf[awk_fieldwidth_info_size(3)];
+       } u;
 } open_directory_t;
+#define fw u.fw
 
 /* ftype --- return type of file as a single character string */
 
@@ -174,11 +179,11 @@ get_inode(struct dirent *entry, const char *dirname)
 static int
 dir_get_record(char **out, awk_input_buf_t *iobuf, int *errcode,
                char **rt_start, size_t *rt_len,
-               const awk_fieldwidth_info_t **unused)
+               const awk_fieldwidth_info_t **field_width)
 {
        DIR *dp;
        struct dirent *dirent;
-       int len;
+       int len, flen;
        open_directory_t *the_dir;
        const char *ftstr;
        unsigned long long ino;
@@ -207,18 +212,24 @@ dir_get_record(char **out, awk_input_buf_t *iobuf, int 
*errcode,
        ino = get_inode(dirent, iobuf->name);
 
 #if __MINGW32__
-       len = sprintf(the_dir->buf, "%I64u/%s", ino, dirent->d_name);
+       len = sprintf(the_dir->buf, "%I64u", ino);
 #else
-       len = sprintf(the_dir->buf, "%llu/%s", ino, dirent->d_name);
+       len = sprintf(the_dir->buf, "%llu", ino);
 #endif
+       the_dir->fw.fields[0].len = len;
+       len += (flen = sprintf(the_dir->buf + len, "/%s", dirent->d_name));
+       the_dir->fw.fields[1].len = flen-1;
 
        ftstr = ftype(dirent, iobuf->name);
-       len += sprintf(the_dir->buf + len, "/%s", ftstr);
+       len += (flen = sprintf(the_dir->buf + len, "/%s", ftstr));
+       the_dir->fw.fields[2].len = flen-1;
 
        *out = the_dir->buf;
 
        *rt_start = NULL;
        *rt_len = 0;    /* set RT to "" */
+       if (field_width)
+               *field_width = & the_dir->fw;
        return len;
 }
 
@@ -285,6 +296,12 @@ dir_take_control_of(awk_input_buf_t *iobuf)
 
        emalloc(the_dir, open_directory_t *, sizeof(open_directory_t), 
"dir_take_control_of");
        the_dir->dp = dp;
+       /* pre-populate the field_width struct with constant values: */
+       the_dir->fw.use_chars = awk_false;
+       the_dir->fw.nf = 3;
+       the_dir->fw.fields[0].skip = 0; /* no leading space */
+       the_dir->fw.fields[1].skip = 1; /* single '/' separator */
+       the_dir->fw.fields[2].skip = 1; /* single '/' separator */
        size = sizeof(struct dirent) + 21 /* max digits in inode */ + 2 /* 
slashes */;
        emalloc(the_dir->buf, char *, size, "dir_take_control_of");
 
diff --git a/extension/readdir_test.c b/extension/readdir_test.c
deleted file mode 100644
index 45b19993..00000000
--- a/extension/readdir_test.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * readdir.c --- Provide an input parser to read directories
- *
- * Arnold Robbins
- * arnold@skeeve.com
- * Written 7/2012
- *
- * Andrew Schorr and Arnold Robbins: further fixes 8/2012.
- * Simplified 11/2012.
- * Improved 3/2019.
- */
-
-/*
- * Copyright (C) 2012-2014, 2017, 2018, 2019, 2021, 2023,
- * 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
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#define _BSD_SOURCE
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#ifdef HAVE_DIRENT_H
-#include <dirent.h>
-#else
-#error Cannot compile the readdir extension on this system!
-#endif
-
-#ifdef __MINGW32__
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#endif
-
-#include "gawkapi.h"
-
-#include "gawkdirfd.h"
-
-#include "gettext.h"
-#define _(msgid)  gettext(msgid)
-#define N_(msgid) msgid
-
-#ifndef PATH_MAX
-#define PATH_MAX       1024    /* a good guess */
-#endif
-
-static const gawk_api_t *api;  /* for convenience macros to work */
-static awk_ext_id_t ext_id;
-static const char *ext_version = "readdir extension: version 3.0";
-
-static awk_bool_t init_readdir(void);
-static awk_bool_t (*init_func)(void) = init_readdir;
-
-int plugin_is_GPL_compatible;
-
-/* data type for the opaque pointer: */
-
-typedef struct open_directory {
-       DIR *dp;
-       char *buf;
-       union {
-               awk_fieldwidth_info_t fw;
-               char buf[awk_fieldwidth_info_size(3)];
-       } u;
-} open_directory_t;
-#define fw u.fw
-
-/* ftype --- return type of file as a single character string */
-
-static const char *
-ftype(struct dirent *entry, const char *dirname)
-{
-#ifdef DT_BLK
-       (void) dirname;         /* silence warnings */
-       switch (entry->d_type) {
-       case DT_BLK:    return "b";
-       case DT_CHR:    return "c";
-       case DT_DIR:    return "d";
-       case DT_FIFO:   return "p";
-       case DT_LNK:    return "l";
-       case DT_REG:    return "f";
-       case DT_SOCK:   return "s";
-       default:
-       case DT_UNKNOWN: break; // JFS returns 'u', so fall through and stat
-       }
-#endif
-       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";
-}
-
-/* get_inode --- get the inode of a file */
-
-static long long
-get_inode(struct dirent *entry, const char *dirname)
-{
-#ifdef __MINGW32__
-       char fname[PATH_MAX];
-       HANDLE fh;
-       BOOL ok;
-       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;
-       ok = GetFileInformationByHandle(fh, &info);
-       CloseHandle(fh);
-       if (ok) {
-               long long inode = info.nFileIndexHigh;
-
-               inode <<= 32;
-               inode += info.nFileIndexLow;
-               return inode;
-       }
-       return 0;
-#else
-       (void) dirname;         /* silence warnings */
-       return entry->d_ino;
-#endif
-}
-
-/* dir_get_record --- get one record at a time out of a directory */
-
-static int
-dir_get_record(char **out, awk_input_buf_t *iobuf, int *errcode,
-               char **rt_start, size_t *rt_len,
-               const awk_fieldwidth_info_t **field_width)
-{
-       DIR *dp;
-       struct dirent *dirent;
-       int len, flen;
-       open_directory_t *the_dir;
-       const char *ftstr;
-       unsigned long long ino;
-
-       /*
-        * The caller sets *errcode to 0, so we should set it only if an
-        * error occurs.
-        */
-
-       if (out == NULL || iobuf == NULL || iobuf->opaque == NULL)
-               return EOF;
-
-       the_dir = (open_directory_t *) iobuf->opaque;
-       dp = the_dir->dp;
-
-       /*
-        * Initialize errno, since readdir does not set it to zero on EOF.
-        */
-       errno = 0;
-       dirent = readdir(dp);
-       if (dirent == NULL) {
-               *errcode = errno;       /* in case there was an error */
-               return EOF;
-       }
-
-       ino = get_inode(dirent, iobuf->name);
-
-#if __MINGW32__
-       len = sprintf(the_dir->buf, "%I64u", ino);
-#else
-       len = sprintf(the_dir->buf, "%llu", ino);
-#endif
-       the_dir->fw.fields[0].len = len;
-       len += (flen = sprintf(the_dir->buf + len, "/%s", dirent->d_name));
-       the_dir->fw.fields[1].len = flen-1;
-
-       ftstr = ftype(dirent, iobuf->name);
-       len += (flen = sprintf(the_dir->buf + len, "/%s", ftstr));
-       the_dir->fw.fields[2].len = flen-1;
-
-       *out = the_dir->buf;
-
-       *rt_start = NULL;
-       *rt_len = 0;    /* set RT to "" */
-       if (field_width)
-               *field_width = & the_dir->fw;
-       return len;
-}
-
-/* dir_close --- close up when done */
-
-static void
-dir_close(awk_input_buf_t *iobuf)
-{
-       open_directory_t *the_dir;
-
-       if (iobuf == NULL || iobuf->opaque == NULL)
-               return;
-
-       the_dir = (open_directory_t *) iobuf->opaque;
-
-       closedir(the_dir->dp);
-       gawk_free(the_dir->buf);
-       gawk_free(the_dir);
-
-       iobuf->fd = -1;
-}
-
-/* dir_can_take_file --- return true if we want the file */
-
-static awk_bool_t
-dir_can_take_file(const awk_input_buf_t *iobuf)
-{
-       if (iobuf == NULL)
-               return awk_false;
-
-       return (S_ISDIR(iobuf->sbuf.st_mode));
-}
-
-/*
- * dir_take_control_of --- set up input parser.
- * We can assume that dir_can_take_file just returned true,
- * and no state has changed since then.
- */
-
-static awk_bool_t
-dir_take_control_of(awk_input_buf_t *iobuf)
-{
-       DIR *dp;
-       open_directory_t *the_dir;
-       size_t size;
-
-       errno = 0;
-#ifdef HAVE_FDOPENDIR
-       dp = fdopendir(iobuf->fd);
-#else
-       dp = opendir(iobuf->name);
-       if (dp != NULL) {
-               if (iobuf->fd != INVALID_HANDLE)
-                       (void) close(iobuf->fd);
-               iobuf->fd = dirfd(dp);
-       }
-#endif
-       if (dp == NULL) {
-               warning(ext_id, _("dir_take_control_of: %s: opendir/fdopendir 
failed: %s"),
-                               iobuf->name, strerror(errno));
-               update_ERRNO_int(errno);
-               return awk_false;
-       }
-
-       emalloc(the_dir, open_directory_t *, sizeof(open_directory_t), 
"dir_take_control_of");
-       the_dir->dp = dp;
-       /* pre-populate the field_width struct with constant values: */
-       the_dir->fw.use_chars = awk_false;
-       the_dir->fw.nf = 3;
-       the_dir->fw.fields[0].skip = 0; /* no leading space */
-       the_dir->fw.fields[1].skip = 1; /* single '/' separator */
-       the_dir->fw.fields[2].skip = 1; /* single '/' separator */
-       size = sizeof(struct dirent) + 21 /* max digits in inode */ + 2 /* 
slashes */;
-       emalloc(the_dir->buf, char *, size, "dir_take_control_of");
-
-       iobuf->opaque = the_dir;
-       iobuf->get_record = dir_get_record;
-       iobuf->close_func = dir_close;
-
-       return awk_true;
-}
-
-static awk_input_parser_t readdir_parser = {
-       "readdir",
-       dir_can_take_file,
-       dir_take_control_of,
-       NULL
-};
-
-#ifdef TEST_DUPLICATE
-static awk_input_parser_t readdir_parser2 = {
-       "readdir2",
-       dir_can_take_file,
-       dir_take_control_of,
-       NULL
-};
-#endif
-
-/* init_readdir --- set things ups */
-
-static awk_bool_t
-init_readdir()
-{
-       register_input_parser(& readdir_parser);
-#ifdef TEST_DUPLICATE
-       register_input_parser(& readdir_parser2);
-#endif
-
-       return awk_true;
-}
-
-static awk_ext_func_t func_table[] = {
-       { NULL, NULL, 0, 0, awk_false, NULL }
-};
-
-/* define the dl_load function using the boilerplate macro */
-
-dl_load_func(func_table, readdir, "")
diff --git a/pc/ChangeLog b/pc/ChangeLog
index 80e3ddda..4c0782be 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,7 @@
+2023-05-25         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * Makefile.tst: Regenerated.
+
 2023-05-07         Arnold D. Robbins     <arnold@skeeve.com>
 
        * 5.2.2: Release tar ball made.
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index d012f626..52602e62 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -348,7 +348,7 @@ GENTESTS_UNUSED = Makefile.in checknegtime.awk dtdgport.awk 
fix-fmtspcl.awk \
        fmtspcl-mpfr.ok fmtspcl.awk fmtspcl.tok gtlnbufv.awk hello.awk \
        inchello.awk inclib.awk inplace.1.in inplace.2.in inplace.in \
        printfloat.awk readdir0.awk valgrind.awk xref.awk \
-       readall1.awk readall2.awk
+       readall1.awk readall2.awk check_retest.awk
 
 
 # List of tests on MinGW that need a different cmp program
@@ -1099,14 +1099,18 @@ readdir:
 readdir_test:
        @echo $@
        @-$(AWK) -lreaddir -F$(SLASH) '{printf "[%s] [%s] [%s] [%s]\n", $$1, 
$$2, $$3, $$4}' "$(top_srcdir)" > $@.ok
-       @-$(AWK) -lreaddir_test '{printf "[%s] [%s] [%s] [%s]\n", $$1, $$2, 
$$3, $$4}' "$(top_srcdir)" > _$@
+       @-$(AWK) -lreaddir '{printf "[%s] [%s] [%s] [%s]\n", $$1, $$2, $$3, 
$$4}' "$(top_srcdir)" > _$@
        @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
 
 readdir_retest:
        @echo $@
-       @-$(AWK) -lreaddir -F$(SLASH) -f "$(srcdir)"/$@.awk "$(top_srcdir)" > 
$@.ok
-       @-$(AWK) -lreaddir_test -F$(SLASH) -f "$(srcdir)"/$@.awk 
"$(top_srcdir)" > _$@
-       @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+       @-$(AWK) -lreaddir -F$(SLASH) -f "$(srcdir)"/$@.awk "$(top_srcdir)" > 
_$@
+       @-if $(AWK) -f "$(srcdir)"/check_retest.awk _$@ ; \
+       then \
+               rm -f _$@ ; \
+       else \
+               echo EXIT CODE: $$? >> _$@ ; \
+       fi
 
 readall:
        @echo $@
diff --git a/test/ChangeLog b/test/ChangeLog
index 155275ba..b060650f 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,12 @@
+2023-05-25         Arnold D. Robbins     <arnold@skeeve.com>
+
+       Deal with removal of extension/readdir_test.c.
+
+       * Makefile.am (EXTRA_DIST, GENTEST_UNUSED): New file: check_retest.awk.
+       (readdir_test): Simplified.
+       (readdir_retest): Revised.
+       * check_retest.awk: New file.
+
 2023-05-07         Arnold D. Robbins     <arnold@skeeve.com>
 
        * 5.2.2: Release tar ball made.
diff --git a/test/Makefile.am b/test/Makefile.am
index cc99dfa9..4605547e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -174,6 +174,7 @@ EXTRA_DIST = \
        charasbytes.in \
        charasbytes.ok \
        checknegtime.awk \
+       check_retest.awk \
        childin.awk \
        childin.in \
        childin.ok \
@@ -1663,7 +1664,7 @@ GENTESTS_UNUSED = Makefile.in checknegtime.awk 
dtdgport.awk fix-fmtspcl.awk \
        fmtspcl-mpfr.ok fmtspcl.awk fmtspcl.tok gtlnbufv.awk hello.awk \
        inchello.awk inclib.awk inplace.1.in inplace.2.in inplace.in \
        printfloat.awk readdir0.awk valgrind.awk xref.awk \
-       readall1.awk readall2.awk
+       readall1.awk readall2.awk check_retest.awk
 
 # List of tests on MinGW that need a different cmp program
 NEED_TESTOUTCMP = \
@@ -2423,14 +2424,18 @@ readdir:
 readdir_test:
        @echo $@
        @-$(AWK) -lreaddir -F/ '{printf "[%s] [%s] [%s] [%s]\n", $$1, $$2, $$3, 
$$4}' "$(top_srcdir)" > $@.ok
-       @-$(AWK) -lreaddir_test '{printf "[%s] [%s] [%s] [%s]\n", $$1, $$2, 
$$3, $$4}' "$(top_srcdir)" > _$@
+       @-$(AWK) -lreaddir '{printf "[%s] [%s] [%s] [%s]\n", $$1, $$2, $$3, 
$$4}' "$(top_srcdir)" > _$@
        @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
 
 readdir_retest:
        @echo $@
-       @-$(AWK) -lreaddir -F/ -f "$(srcdir)"/$@.awk "$(top_srcdir)" > $@.ok
-       @-$(AWK) -lreaddir_test -F/ -f "$(srcdir)"/$@.awk "$(top_srcdir)" > _$@
-       @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+       @-$(AWK) -lreaddir -F/ -f "$(srcdir)"/$@.awk "$(top_srcdir)" > _$@
+       @-if $(AWK) -f "$(srcdir)"/check_retest.awk _$@ ; \
+       then \
+               rm -f _$@ ; \
+       else \
+               echo EXIT CODE: $$? >> _$@ ; \
+       fi
 
 readall:
        @echo $@
diff --git a/test/Makefile.in b/test/Makefile.in
index 3ed140cc..4e7ff1d9 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -442,6 +442,7 @@ EXTRA_DIST = \
        charasbytes.in \
        charasbytes.ok \
        checknegtime.awk \
+       check_retest.awk \
        childin.awk \
        childin.in \
        childin.ok \
@@ -1931,7 +1932,7 @@ GENTESTS_UNUSED = Makefile.in checknegtime.awk 
dtdgport.awk fix-fmtspcl.awk \
        fmtspcl-mpfr.ok fmtspcl.awk fmtspcl.tok gtlnbufv.awk hello.awk \
        inchello.awk inclib.awk inplace.1.in inplace.2.in inplace.in \
        printfloat.awk readdir0.awk valgrind.awk xref.awk \
-       readall1.awk readall2.awk
+       readall1.awk readall2.awk check_retest.awk
 
 
 # List of tests on MinGW that need a different cmp program
@@ -2877,14 +2878,18 @@ readdir:
 readdir_test:
        @echo $@
        @-$(AWK) -lreaddir -F/ '{printf "[%s] [%s] [%s] [%s]\n", $$1, $$2, $$3, 
$$4}' "$(top_srcdir)" > $@.ok
-       @-$(AWK) -lreaddir_test '{printf "[%s] [%s] [%s] [%s]\n", $$1, $$2, 
$$3, $$4}' "$(top_srcdir)" > _$@
+       @-$(AWK) -lreaddir '{printf "[%s] [%s] [%s] [%s]\n", $$1, $$2, $$3, 
$$4}' "$(top_srcdir)" > _$@
        @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
 
 readdir_retest:
        @echo $@
-       @-$(AWK) -lreaddir -F/ -f "$(srcdir)"/$@.awk "$(top_srcdir)" > $@.ok
-       @-$(AWK) -lreaddir_test -F/ -f "$(srcdir)"/$@.awk "$(top_srcdir)" > _$@
-       @-$(CMP) $@.ok _$@ && rm -f $@.ok _$@
+       @-$(AWK) -lreaddir -F/ -f "$(srcdir)"/$@.awk "$(top_srcdir)" > _$@
+       @-if $(AWK) -f "$(srcdir)"/check_retest.awk _$@ ; \
+       then \
+               rm -f _$@ ; \
+       else \
+               echo EXIT CODE: $$? >> _$@ ; \
+       fi
 
 readall:
        @echo $@
diff --git a/test/check_retest.awk b/test/check_retest.awk
new file mode 100644
index 00000000..b023a533
--- /dev/null
+++ b/test/check_retest.awk
@@ -0,0 +1,2 @@
+FNR == 1 { save = $0 }
+FNR %2 == 0 { if ($0 != save) exit 1 }

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

Summary of changes:
 extension/ChangeLog      |   5 +
 extension/Makefile.am    |   8 --
 extension/Makefile.in    |  42 ++----
 extension/readdir.c      |  31 ++++-
 extension/readdir_test.c | 350 -----------------------------------------------
 pc/ChangeLog             |   4 +
 pc/Makefile.tst          |  14 +-
 test/ChangeLog           |   9 ++
 test/Makefile.am         |  15 +-
 test/Makefile.in         |  15 +-
 test/check_retest.awk    |   2 +
 11 files changed, 83 insertions(+), 412 deletions(-)
 delete mode 100644 extension/readdir_test.c
 create mode 100644 test/check_retest.awk


hooks/post-receive
-- 
gawk



reply via email to

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