[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, extgawk, updated. 518a62884ff2b87b94cbfa
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, extgawk, updated. 518a62884ff2b87b94cbfa1e2fa759f1829f6bd9 |
Date: |
Sun, 15 Jul 2012 19:39:09 +0000 |
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, extgawk has been updated
via 518a62884ff2b87b94cbfa1e2fa759f1829f6bd9 (commit)
from 77036f5ae0d0c4e2e1551838c193dd2ca877a54e (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=518a62884ff2b87b94cbfa1e2fa759f1829f6bd9
commit 518a62884ff2b87b94cbfa1e2fa759f1829f6bd9
Author: Arnold D. Robbins <address@hidden>
Date: Sun Jul 15 22:38:46 2012 +0300
Additional test for AWK_SCALAR.
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 6982758..f62f37a 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2012-07-15 Arnold D. Robbins <address@hidden>
+
+ * testext.c (test_scalar): New function and new tests.
+ (init_testext): Add a new variable.
+
2012-07-13 Arnold D. Robbins <address@hidden>
* filefuncs.c (fill_stat_array): New function to do the work
diff --git a/extension/testext.c b/extension/testext.c
index 0eff62b..44b6a87 100644
--- a/extension/testext.c
+++ b/extension/testext.c
@@ -483,6 +483,59 @@ out:
return result;
}
+/*
+BEGIN {
+ n = split("1 3 5 7 9 11", nums)
+ m = split("the quick brown fox jumps over the lazy dog", strings)
+ for (i in nums) {
+ ret = test_scalar(nums[i] + 0)
+ printf("test_scalar(%d) returned %d, the_scalar is %d\n",
nums[i], ret, the_scalar)
+ }
+ for (i in strings) {
+ ret = test_scalar(strings[i])
+ printf("test_scalar(%s) returned %d, the_scalar is %s\n",
strings[i], ret, the_scalar)
+ }
+}
+*/
+
+/* test_scalar --- test scalar cookie */
+
+static awk_value_t *
+test_scalar(int nargs, awk_value_t *result)
+{
+ awk_value_t new_value, new_value2;
+ awk_value_t the_scalar;
+
+ make_number(0.0, result);
+
+ if (! sym_lookup("the_scalar", AWK_SCALAR, & the_scalar)) {
+ printf("test_scalar: could not get scalar cookie\n");
+ goto out;
+ }
+
+ if (! get_argument(0, AWK_UNDEFINED, & new_value)) {
+ printf("test_scalar: could not get argument\n");
+ goto out;
+ } else if (new_value.val_type != AWK_STRING && new_value.val_type !=
AWK_NUMBER) {
+ printf("test_scalar: argument is not a scalar\n");
+ goto out;
+ }
+
+ if (new_value.val_type == AWK_STRING) {
+ make_const_string(new_value.str_value.str,
new_value.str_value.len, & new_value2);
+ } else {
+ new_value2 = new_value;
+ }
+
+ if (! sym_update_scalar(the_scalar.scalar_cookie, & new_value2)) {
+ }
+
+ make_number(1.0, result);
+
+out:
+ return result;
+}
+
/* fill_in_array --- fill in a new array */
static void
@@ -574,6 +627,7 @@ static awk_ext_func_t func_table[] = {
{ "test_array_elem", test_array_elem, 2 },
{ "test_array_param", test_array_param, 1 },
{ "print_do_lint", print_do_lint, 0 },
+ { "test_scalar", test_scalar, 1 },
};
/* init_testext --- additional initialization function */
@@ -582,6 +636,7 @@ static awk_bool_t init_testext(void)
{
awk_value_t value;
static const char message[] = "hello, world"; /* of course */
+ static const char message2[] = "i am a scalar";
/* add at_exit functions */
awk_atexit(at_exit0, NULL);
@@ -606,6 +661,10 @@ BEGIN {
make_const_string(message, strlen(message), & value)))
printf("testext: sym_update(\"answer_num\") failed!\n");
+ if (! sym_update("the_scalar",
+ make_const_string(message2, strlen(message2), & value)))
+ printf("testext: sym_update(\"the_scalar\") failed!\n");
+
create_new_array();
return 1;
diff --git a/test/ChangeLog b/test/ChangeLog
index 50dcd27..bb270e9 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2012-07-15 Arnold D. Robbins <address@hidden>
+
+ * testext.ok: Update contents.
+
2012-07-12 Arnold D. Robbins <address@hidden>
* Makefile.am (fnmatch): New test.
diff --git a/test/testext.ok b/test/testext.ok
index 619d97b..132179c 100644
--- a/test/testext.ok
+++ b/test/testext.ok
@@ -42,6 +42,21 @@ Changed value of LINT is 1
print_do_lint: lint = 1
print_do_lint() returned 1
+test_scalar(1) returned 1, the_scalar is 1
+test_scalar(3) returned 1, the_scalar is 3
+test_scalar(5) returned 1, the_scalar is 5
+test_scalar(7) returned 1, the_scalar is 7
+test_scalar(9) returned 1, the_scalar is 9
+test_scalar(11) returned 1, the_scalar is 11
+test_scalar(the) returned 1, the_scalar is the
+test_scalar(quick) returned 1, the_scalar is quick
+test_scalar(brown) returned 1, the_scalar is brown
+test_scalar(fox) returned 1, the_scalar is fox
+test_scalar(jumps) returned 1, the_scalar is jumps
+test_scalar(over) returned 1, the_scalar is over
+test_scalar(the) returned 1, the_scalar is the
+test_scalar(lazy) returned 1, the_scalar is lazy
+test_scalar(dog) returned 1, the_scalar is dog
answer_num = 42
message_string = hello, world
new_array["hello"] = "world"
-----------------------------------------------------------------------
Summary of changes:
extension/ChangeLog | 5 ++++
extension/testext.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
test/ChangeLog | 4 +++
test/testext.ok | 15 +++++++++++++
4 files changed, 83 insertions(+), 0 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, extgawk, updated. 518a62884ff2b87b94cbfa1e2fa759f1829f6bd9,
Arnold Robbins <=