From 52306503277c1259eeb704d6b94aed0392536e76 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 12 Aug 2014 06:22:43 +0300 Subject: Rebuild record upon OFS being changed. --- eval.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index ac9e7729..16a928d0 100644 --- a/eval.c +++ b/eval.c @@ -803,9 +803,35 @@ set_BINMODE() void set_OFS() { + static bool first = true; + size_t new_ofs_len; + + if (first) /* true when called from init_vars() in main() */ + first = false; + else { + /* rebuild $0 using OFS that was current when $0 changed */ + if (! field0_valid) { + get_field(UNLIMITED - 1, NULL); + rebuild_record(); + } + } + + /* + * Save OFS value for use in building record and in printing. + * Can't just have OFS point into the OFS_node since it's + * already updated when we come into this routine, and we need + * the old value to rebuild the record (see above). + */ OFS_node->var_value = force_string(OFS_node->var_value); - OFS = OFS_node->var_value->stptr; - OFSlen = OFS_node->var_value->stlen; + new_ofs_len = OFS_node->var_value->stlen; + + if (OFS == NULL) + emalloc(OFS, char *, new_ofs_len + 2, "set_OFS"); + else if (OFSlen < new_ofs_len) + erealloc(OFS, char *, new_ofs_len + 2, "set_OFS"); + + memcpy(OFS, OFS_node->var_value->stptr, OFS_node->var_value->stlen); + OFSlen = new_ofs_len; OFS[OFSlen] = '\0'; } -- cgit v1.2.3 From 0f5cb955662136ad4a93e35db5721dd986dfd55b Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 5 Sep 2014 11:21:38 +0300 Subject: Add builtin functions to FUNCTAB and PROCINFO["identifiers"] and doc. --- eval.c | 1 + 1 file changed, 1 insertion(+) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 16a928d0..5649797f 100644 --- a/eval.c +++ b/eval.c @@ -241,6 +241,7 @@ static const char *const nodetypes[] = { "Node_func", "Node_ext_func", "Node_old_ext_func", + "Node_builtin_func", "Node_array_ref", "Node_array_tree", "Node_array_leaf", -- cgit v1.2.3 From 3fcce8a32e825dd10384d5276c420c2514442fe2 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 15 Sep 2014 19:47:03 +0300 Subject: Finish excising isalpha and isalnum. Document. --- eval.c | 1 + 1 file changed, 1 insertion(+) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 5649797f..0d6a07b6 100644 --- a/eval.c +++ b/eval.c @@ -216,6 +216,7 @@ load_casetable(void) return; #ifndef ZOS_USS + /* use of isalpha is ok here (see is_alpha in awkgram.y) */ for (i = 0200; i <= 0377; i++) { if (isalpha(i) && islower(i) && i != toupper(i)) casetable[i] = toupper(i); -- cgit v1.2.3