aboutsummaryrefslogtreecommitdiffstats
path: root/extension
diff options
context:
space:
mode:
Diffstat (limited to 'extension')
-rw-r--r--extension/CMakeLists.txt84
-rw-r--r--extension/ChangeLog13
-rw-r--r--extension/rwarray.c45
-rw-r--r--extension/testext.c7
4 files changed, 57 insertions, 92 deletions
diff --git a/extension/CMakeLists.txt b/extension/CMakeLists.txt
deleted file mode 100644
index 1bb4ceb1..00000000
--- a/extension/CMakeLists.txt
+++ /dev/null
@@ -1,84 +0,0 @@
-#
-# 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 69896748..52cc493c 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -66,15 +66,28 @@
2021-05-05 Arnold D. Robbins <arnold@skeeve.com>
+ * CMakeLists.txt: Removed.
+
+2021-05-05 Arnold D. Robbins <arnold@skeeve.com>
+
Get `make distcheck' working again:
* Makefile.am (EXTRA_DIST): Remove files that are now in build-aux.
* aclocal.m4: Regenerated.
+2021-03-30 Arnold D. Robbins <arnold@skeeve.com>
+
+ * rwarray.c (write_value): Add support for writing boolean values.
+ (read_value): Ditto.
+
2021-03-29 Arnold D. Robbins <arnold@skeeve.com>
* testext.c (var_test): Fix a comment. Update copyright year.
+2021-03-22 Arnold D. Robbins <arnold@skeeve.com>
+
+ * testext.c (valrep2str): Add support for AWK_BOOL.
+
2020-07-26 Arnold D. Robbins <arnold@skeeve.com>
* intdiv.c (do_intdiv): Change quotient and remainder to
diff --git a/extension/rwarray.c b/extension/rwarray.c
index 59d6b0f7..532a8da1 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -37,6 +37,7 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -63,11 +64,11 @@
#define MAGIC "awkrulz\n"
#define MAJOR 4
-#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 2.0";
+static const char *ext_version = "rwarray extension: version 2.1";
static awk_bool_t (*init_func)(void) = NULL;
int plugin_is_GPL_compatible;
@@ -113,6 +114,7 @@ static awk_bool_t read_number(FILE *fp, awk_value_t *value, uint32_t code);
#define VT_ARRAY 5
#define VT_REGEX 6
#define VT_STRNUM 7
+#define VT_BOOL 8
#define VT_UNDEFINED 20
/* do_writea --- write an array */
@@ -258,6 +260,9 @@ write_value(FILE *fp, awk_value_t *val)
case AWK_REGEX:
code = htonl(VT_REGEX);
break;
+ case AWK_BOOL:
+ code = htonl(VT_BOOL);
+ break;
case AWK_UNDEFINED:
code = htonl(VT_UNDEFINED);
break;
@@ -267,17 +272,29 @@ write_value(FILE *fp, awk_value_t *val)
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;
- len = htonl(val->str_value.len);
- if (fwrite(& len, 1, sizeof(len), fp) != sizeof(len))
- return awk_false;
+ if (code == ntohl(VT_BOOL)) {
+ len = (val->bool_value == awk_true ? 4 : 5);
+ len = htonl(len);
+ const char *s = (val->bool_value == awk_true ? "TRUE" : "FALSE");
- if (fwrite(val->str_value.str, 1, val->str_value.len, fp)
- != (ssize_t) val->str_value.len)
- return awk_false;
+ if (fwrite(& len, 1, sizeof(len), fp) != sizeof(len))
+ return awk_false;
+
+ if (fwrite(s, 1, strlen(s), fp) != (ssize_t) strlen(s))
+ return awk_false;
+ } else {
+ len = htonl(val->str_value.len);
+ if (fwrite(& len, 1, sizeof(len), fp) != sizeof(len))
+ return awk_false;
+ if (fwrite(val->str_value.str, 1, val->str_value.len, fp)
+ != (ssize_t) val->str_value.len)
+ return awk_false;
+ }
return awk_true;
}
@@ -559,6 +576,9 @@ read_value(FILE *fp, awk_value_t *value)
case VT_UNDEFINED:
value->val_type = AWK_UNDEFINED;
break;
+ case VT_BOOL:
+ value->val_type = AWK_BOOL;
+ break;
default:
/* this cannot happen! */
warning(ext_id, _("treating recovered value with unknown type code %d as a string"), code);
@@ -573,6 +593,15 @@ read_value(FILE *fp, awk_value_t *value)
return awk_false;
}
value->str_value.str[len] = '\0';
+ value->str_value.len = len;
+
+ if (code == VT_BOOL) {
+ bool val = (strcmp(value->str_value.str, "TRUE") == 0);
+
+ gawk_free(value->str_value.str);
+ value->str_value.str = NULL;
+ value->bool_value = val ? awk_true : awk_false;
+ }
}
return awk_true;
diff --git a/extension/testext.c b/extension/testext.c
index a5bef7ae..bfaa8637 100644
--- a/extension/testext.c
+++ b/extension/testext.c
@@ -88,6 +88,13 @@ valrep2str(const awk_value_t *value)
size,
value->str_value.str);
break;
+ case AWK_BOOL:
+ if (value->str_value.len + 8 < size)
+ size = value->str_value.len;
+ sprintf(buf, "<bool>: %.*s",
+ size,
+ value->str_value.str);
+ break;
case AWK_NUMBER:
sprintf(buf, "%g", value->num_value);
break;