[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] gawk branch, master, updated. gawk-4.1.0-4570-g0c02a53
From: |
Arnold Robbins |
Subject: |
[SCM] gawk branch, master, updated. gawk-4.1.0-4570-g0c02a53 |
Date: |
Thu, 18 Nov 2021 14:16:13 -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, master has been updated
via 0c02a53775a80fe10dcd2b0ae5e857c1f22f8727 (commit)
via dc2613b0af11a8cf97232d55c322d40eda35c224 (commit)
via 5fd15d010b98f179d117eb3a476e626b3d298aad (commit)
from 6892647d502182ca383a4934c20bb0457fc44a51 (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=0c02a53775a80fe10dcd2b0ae5e857c1f22f8727
commit 0c02a53775a80fe10dcd2b0ae5e857c1f22f8727
Merge: 6892647 dc2613b
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Thu Nov 18 21:15:59 2021 +0200
Merge branch 'gawk-5.1-stable'
diff --cc extension/rwarray.c
index a534a5a,9a8d15e..9a8c1e4
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@@ -57,12 -62,12 +63,12 @@@
#define N_(msgid) msgid
#define MAGIC "awkrulz\n"
- #define MAJOR 3
+ #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 1.2";
-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;
@@@ -99,6 -106,15 +107,16 @@@ static awk_bool_t read_number(FILE *fp
* END IF
*/
+ #define VT_STRING 1
+ #define VT_NUMBER 2
+ #define VT_GMP 3
+ #define VT_MPFR 4
+ #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 */
static awk_value_t *
@@@ -229,36 -245,54 +247,69 @@@ write_value(FILE *fp, awk_value_t *val
return write_array(fp, val->array_cookie);
}
- if (val->val_type == AWK_NUMBER) {
- code = htonl(1);
- if (fwrite(& code, 1, sizeof(code), fp) != sizeof(code))
+ if (val->val_type == AWK_NUMBER)
+ return write_number(fp, val);
+
+ switch (val->val_type) {
+ case AWK_STRING:
+ code = htonl(VT_STRING);
+ break;
+ case AWK_STRNUM:
+ code = htonl(VT_STRNUM);
+ break;
+ case AWK_REGEX:
+ code = htonl(VT_REGEX);
+ break;
++ case AWK_BOOL:
++ code = htonl(VT_BOOL);
++ break;
+ case AWK_UNDEFINED:
+ code = htonl(VT_UNDEFINED);
+ break;
+ default:
+ /* XXX can this happen? */
+ code = htonl(VT_UNDEFINED);
+ 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(& val->num_value, 1, sizeof(val->num_value), fp) !=
sizeof(val->num_value))
++ if (fwrite(s, 1, strlen(s), fp) != (ssize_t) strlen(s))
+ return awk_false;
+ } else {
- switch (val->val_type) {
- case AWK_STRING:
- code = htonl(0);
- break;
- case AWK_STRNUM:
- code = htonl(4);
- break;
- case AWK_REGEX:
- code = htonl(3);
- break;
- case AWK_UNDEFINED:
- code = htonl(5);
- break;
- case AWK_BOOL:
- code = htonl(6);
- break;
- default:
- /* XXX can this happen? */
- code = htonl(0);
- warning(ext_id, _("array value has unknown type %d"),
val->val_type);
- break;
- }
++ 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;
+ }
+
+ /* write_number --- write a double, GMP or MPFR number */
+
+ static awk_bool_t
+ write_number(FILE *fp, awk_value_t *val)
+ {
+ uint32_t len, code;
+ char buffer[BUFSIZ];
+
+ if (val->num_type == AWK_NUMBER_TYPE_DOUBLE) {
+ uint32_t network_order_len;
+
+ code = htonl(VT_NUMBER);
if (fwrite(& code, 1, sizeof(code), fp) != sizeof(code))
return awk_false;
@@@ -488,21 -528,18 +545,21 @@@ read_value(FILE *fp, awk_value_t *value
}
len = ntohl(len);
switch (code) {
- case 0:
+ case VT_STRING:
value->val_type = AWK_STRING;
break;
- case 3:
+ case VT_REGEX:
value->val_type = AWK_REGEX;
break;
- case 4:
+ case VT_STRNUM:
value->val_type = AWK_STRNUM;
break;
- case 5:
+ case VT_UNDEFINED:
value->val_type = AWK_UNDEFINED;
break;
- case 6:
++ 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);
@@@ -517,13 -554,6 +574,15 @@@
return awk_false;
}
value->str_value.str[len] = '\0';
+ value->str_value.len = len;
- if (code == 6) {
- /* bool type */
++
++ 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 --cc test/rwarray.awk
index eae2230,c06fec2..dfd74ce
--- a/test/rwarray.awk
+++ b/test/rwarray.awk
@@@ -11,9 -11,11 +11,14 @@@ BEGIN
split("-2.4", f)
dict[strnum_sub] = f[1]
+ bool_sub = "bool-sub"
+ dict[bool_sub] = mkbool(1)
+
+ dict["x"] = "x"
+
+ dict["42"] = 42
+ dict["42.42"] = 42.42
+
n = asorti(dict, dictindices)
for (i = 1; i <= n; i++)
printf("dict[%s] = %s\n", dictindices[i], dict[dictindices[i]])
> "orig.out"
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 5 ++
NEWS | 3 +
extension/ChangeLog | 6 ++
extension/rwarray.c | 224 ++++++++++++++++++++++++++++++++++++++--------------
gawkapi.c | 3 +-
test/ChangeLog | 10 +++
test/iolint.awk | 19 +++--
test/iolint.ok | 5 +-
test/rwarray.awk | 5 ++
9 files changed, 213 insertions(+), 67 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] gawk branch, master, updated. gawk-4.1.0-4570-g0c02a53,
Arnold Robbins <=