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.c40
-rw-r--r--extension/testext.c7
4 files changed, 53 insertions, 91 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 d937cdbf..2ceeecc2 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -32,15 +32,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 45f9c734..a534a5a4 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -8,7 +8,7 @@
*/
/*
- * Copyright (C) 2009-2014, 2017, 2018, 2020 the Free Software Foundation, Inc.
+ * Copyright (C) 2009-2014, 2017, 2018, 2020, 2021 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -36,6 +36,7 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -249,6 +250,9 @@ write_value(FILE *fp, awk_value_t *val)
case AWK_UNDEFINED:
code = htonl(5);
break;
+ case AWK_BOOL:
+ code = htonl(6);
+ break;
default:
/* XXX can this happen? */
code = htonl(0);
@@ -258,13 +262,25 @@ write_value(FILE *fp, awk_value_t *val)
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(6)) {
+ 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;
@@ -484,6 +500,9 @@ read_value(FILE *fp, awk_value_t *value)
case 5:
value->val_type = AWK_UNDEFINED;
break;
+ case 6:
+ 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);
@@ -498,6 +517,13 @@ read_value(FILE *fp, awk_value_t *value)
return awk_false;
}
value->str_value.str[len] = '\0';
+ value->str_value.len = len;
+ if (code == 6) {
+ /* bool type */
+ bool val = (strcmp(value->str_value.str, "TRUE") == 0);
+ gawk_free(value->str_value.str);
+ 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;