[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, feature/regex-type, updated. gawk-4.1.0-
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, feature/regex-type, updated. gawk-4.1.0-1307-gaca30f7 |
Date: |
Tue, 14 Apr 2015 12:07:10 +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, feature/regex-type has been updated
via aca30f7d82ec4fa002c6ab5ea4a2d9d77d28c2cd (commit)
via c187863b95bed5f750b08df898fdfb611a4bdb54 (commit)
via 54b3ab3109d5aa01595920e06ca25a815ad525a0 (commit)
via a830a63718f1e9a0a812e772bef6e891668afd17 (commit)
via 82ef375e5236341b6550c1c365ec87bd23c049bf (commit)
via d3d01be8a74e50ec3cb58ba9acd99f08ade5a606 (commit)
via 3de71423b3a39be0b9536413321c953cbf99b119 (commit)
via 11692d41b177e93df106309cf2eda493350bee35 (commit)
via f156eb53457a9e4e34c1b96f9e54eb130dffd8a3 (commit)
from c94c41be952af8be29166fca886bbb11b3fe3330 (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=aca30f7d82ec4fa002c6ab5ea4a2d9d77d28c2cd
commit aca30f7d82ec4fa002c6ab5ea4a2d9d77d28c2cd
Author: Arnold D. Robbins <address@hidden>
Date: Tue Apr 14 15:06:41 2015 +0300
Add more tests, make them work. Almost done...
diff --git a/ChangeLog b/ChangeLog
index 4349a97..606f54b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,10 @@
Unrelated:
* builtin.c (call_sub): Fix for indirect gensub, 3 args now works.
+ Unrelated:
+ * builtin.c (call_sub, call_match, call_split_func): Allow for
+ regex to be Node_hardregex.
+
2015-04-13 Arnold D. Robbins <address@hidden>
* regcomp.c (analyze): Prevent malloc(0).
diff --git a/builtin.c b/builtin.c
index db62cb5..12a7917 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3106,7 +3106,8 @@ call_sub(const char *name, int nargs)
* push replace
* push $0
*/
- regex = make_regnode(Node_regex, regex);
+ if (regex->type != Node_hardregex)
+ regex = make_regnode(Node_regex, regex);
PUSH(regex);
PUSH(replace);
lhs = r_get_field(zero, (Func_ptr *) 0, true);
@@ -3130,7 +3131,8 @@ call_sub(const char *name, int nargs)
* nargs++
* }
*/
- regex = make_regnode(Node_regex, regex);
+ if (regex->type != Node_hardregex)
+ regex = make_regnode(Node_regex, regex);
PUSH(regex);
PUSH(replace);
PUSH(glob_flag);
@@ -3167,7 +3169,8 @@ call_match(int nargs)
/* Don't need to pop the string just to push it back ... */
- regex = make_regnode(Node_regex, regex);
+ if (regex->type != Node_hardregex)
+ regex = make_regnode(Node_regex, regex);
PUSH(regex);
if (array)
@@ -3195,7 +3198,8 @@ call_split_func(const char *name, int nargs)
if (nargs >= 3) {
regex = POP_STRING();
- regex = make_regnode(Node_regex, regex);
+ if (regex->type != Node_hardregex)
+ regex = make_regnode(Node_regex, regex);
} else {
if (name[0] == 's') {
regex = make_regnode(Node_regex, FS_node->var_value);
diff --git a/hardregex-semantics.awk b/hardregex-semantics.awk
index 84fcef9..fc8ba80 100644
--- a/hardregex-semantics.awk
+++ b/hardregex-semantics.awk
@@ -44,7 +44,7 @@ function simple_tests( fbre, numresult, strresult)
else
print "variable as numeric value: fail"
- # Use as string value, should be string value of text
+ # Use as string value, should be string value of regexp text
strresult = "<" fbre ">"
if (strresult == "<fo+ba+r>")
print "variable as string value: ok"
@@ -75,21 +75,222 @@ function simple_tests( fbre, numresult, strresult)
print "typeof variable after conversion: fail"
}
+function match_tests( fbre, fun)
+{
+ if (match("foobaaar", @/fo+ba+r/))
+ print "match(constant): ok"
+ else
+ print "match(constant): fail"
+
+ fbre = @/fo+ba+r/
+ if (match("foobaaar", fbre))
+ print "match(variable): ok"
+ else
+ print "match(variable): fail"
+
+ fun = "match"
+ if (@fun("foobaaar", @/fo+ba+r/))
+ print "match(constant) indirect: ok"
+ else
+ print "match(constant) indirect: fail"
+
+ if (@fun("foobaaar", fbre))
+ print "match(variable) indirect: ok"
+ else
+ print "match(variable) indirect: fail"
+}
+
+function sub_tests( fbre, count, target, fun)
+{
+ target = "abc foobaar def foobar ghi"
+ count = sub(@/fo+ba+r/, "XX", target)
+ if (count == 1 && target == "abc XX def foobar ghi")
+ print "sub(constant): ok"
+ else
+ print "sub(constant): fail"
+
+ fbre = @/fo+ba+r/
+ target = "abc foobaar def foobar ghi"
+ count = sub(fbre, "XX", target)
+ if (count == 1 && target == "abc XX def foobar ghi")
+ print "sub(variable): ok"
+ else
+ print "sub(variable): fail"
+
+ fun = "sub"
+ $0 = "abc foobaar def foobar ghi"
+ count = @fun(@/fo+ba+r/, "XX")
+ if (count == 1 && $0 == "abc XX def foobar ghi")
+ print "sub(constant) indirect: ok"
+ else
+ print "sub(constant) indirect: fail"
+
+ $0 = "abc foobaar def foobar ghi"
+ count = @fun(fbre, "XX")
+ if (count == 1 && $0 == "abc XX def foobar ghi")
+ print "sub(variable) indirect: ok"
+ else
+ print "sub(variable) indirect: fail"
+}
+
+function gsub_tests( fbre, count, target, fun)
+{
+ target = "abc foobaar def foobar ghi"
+ count = gsub(@/fo+ba+r/, "XX", target)
+ if (count == 2 && target == "abc XX def XX ghi")
+ print "gsub(constant): ok"
+ else
+ print "gsub(constant): fail"
+
+ fbre = @/fo+ba+r/
+ target = "abc foobaar def foobar ghi"
+ count = gsub(fbre, "XX", target)
+ if (count == 2 && target == "abc XX def XX ghi")
+ print "gsub(variable): ok"
+ else
+ print "gsub(variable): fail"
+
+ fun = "gsub"
+ $0 = "abc foobaar def foobar ghi"
+ count = @fun(@/fo+ba+r/, "XX")
+ if (count == 2 && $0 == "abc XX def XX ghi")
+ print "gsub(constant) indirect: ok"
+ else
+ print "gsub(constant) indirect: fail"
+
+ $0 = "abc foobaar def foobar ghi"
+ count = @fun(fbre, "XX")
+ if (count == 2 && $0 == "abc XX def XX ghi")
+ print "gsub(variable) indirect: ok"
+ else
+ print "gsub(variable) indirect: fail"
+}
+
+function gensub_tests( fbre, result, target, fun)
+{
+ target = "abc foobaar def foobar ghi"
+ result = gensub(@/fo+ba+r/, "XX", "g", target)
+ if (result == "abc XX def XX ghi")
+ print "gensub(constant): ok"
+ else
+ print "gensub(constant): fail"
+
+ fbre = @/fo+ba+r/
+ target = "abc foobaar def foobar ghi"
+ result = gensub(fbre, "XX", "g", target)
+ if (result == "abc XX def XX ghi")
+ print "gensub(variable): ok"
+ else
+ print "gensub(variable): fail"
+
+ fun = "gensub"
+ $0 = "abc foobaar def foobar ghi"
+ result = @fun(@/fo+ba+r/, "XX", "g")
+ if (result == "abc XX def XX ghi")
+ print "gensub(constant) indirect: ok"
+ else
+ print "gensub(constant) indirect: fail"
+
+ $0 = "abc foobaar def foobar ghi"
+ result = @fun(fbre, "XX", "g")
+ if (result == "abc XX def XX ghi")
+ print "gensub(variable) indirect: ok"
+ else
+ print "gensub(variable) indirect: fail"
+
+ result = @fun(@/fo+ba+r/, "XX", "g", target)
+ if (result == "abc XX def XX ghi")
+ print "gensub(constant) indirect 2: ok"
+ else
+ print "gensub(constant) indirect 2: fail"
+
+ result = @fun(fbre, "XX", "g", target)
+ if (result == "abc XX def XX ghi")
+ print "gensub(variable) indirect 2: ok"
+ else
+ print "gensub(variable) indirect 2: fail"
+}
+
+function split_tests( fbre, data, seps, fun, b1)
+{
+ delete data
+ delete seps
+ b1 = split("a:b:c:d", data, @/:/, seps)
+ if (b1 == 4 && data[1] == "a" && seps[1] == ":")
+ print "split(constant): ok"
+ else
+ print "split(constant): fail"
+
+ delete data
+ delete seps
+ fbre = @/:/
+ b1 = split("a:b:c:d", data, fbre, seps)
+ if (b1 == 4 && data[1] == "a" && seps[1] == ":")
+ print "split(variable): ok"
+ else
+ print "split(variable): fail"
+
+ fun = "split"
+ delete data
+ delete seps
+ b1 = @fun("a:b:c:d", data, @/:/, seps)
+ if (b1 == 4 && data[1] == "a" && seps[1] == ":")
+ print "split(constant) indirect: ok"
+ else
+ print "split(constant) indirect: fail"
+
+ delete data
+ delete seps
+ b1 = @fun("a:b:c:d", data, fbre, seps)
+ if (b1 == 4 && data[1] == "a" && seps[1] == ":")
+ print "split(variable) indirect: ok"
+ else
+ print "split(variable) indirect: fail"
+}
+
+function patsplit_tests( fbre, data, seps, fun, b1)
+{
+ delete data
+ delete seps
+ b1 = patsplit("a:b:c:d", data, @/[a-z]+/, seps)
+ if (b1 == 4 && data[1] == "a" && seps[1] == ":")
+ print "patsplit(constant): ok"
+ else
+ print "patsplit(constant): fail"
+
+ delete data
+ delete seps
+ fbre = @/[a-z]+/
+ b1 = patsplit("a:b:c:d", data, fbre, seps)
+ if (b1 == 4 && data[1] == "a" && seps[1] == ":")
+ print "patsplit(variable): ok"
+ else
+ print "patsplit(variable): fail"
+
+ fun = "patsplit"
+ delete data
+ delete seps
+ b1 = @fun("a:b:c:d", data, @/[a-z]+/, seps)
+ if (b1 == 4 && data[1] == "a" && seps[1] == ":")
+ print "patsplit(constant) indirect: ok"
+ else
+ print "patsplit(constant) indirect: fail"
+
+ delete data
+ delete seps
+ b1 = @fun("a:b:c:d", data, fbre, seps)
+ if (b1 == 4 && data[1] == "a" && seps[1] == ":")
+ print "patsplit(variable) indirect: ok"
+ else
+ print "patsplit(variable) indirect: fail"
+}
+
BEGIN {
simple_tests()
-
- # use with match, constant
- # use with match, variable
- # use with sub, constant
- # use with sub, variable
- # use with gsub, constant
- # use with gsub, variable
- # use with gensub, constant
- # use with gensub, variable
- # use with split, constant
- # use with split, variable
- # use with patsplit, constant
- # use with patsplit, variable
-
- # indirect call tests...
+ match_tests()
+ sub_tests()
+ gsub_tests()
+ gensub_tests()
+ split_tests()
+ patsplit_tests()
}
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=c187863b95bed5f750b08df898fdfb611a4bdb54
commit c187863b95bed5f750b08df898fdfb611a4bdb54
Merge: 82ef375 54b3ab3
Author: Arnold D. Robbins <address@hidden>
Date: Tue Apr 14 15:04:42 2015 +0300
Merge branch 'master' into feature/regex-type
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=82ef375e5236341b6550c1c365ec87bd23c049bf
commit 82ef375e5236341b6550c1c365ec87bd23c049bf
Merge: c94c41b d3d01be
Author: Arnold D. Robbins <address@hidden>
Date: Tue Apr 14 14:17:26 2015 +0300
Merge branch 'master' into feature/regex-type
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 21 ++++
builtin.c | 24 +++--
hardregex-semantics.awk | 233 ++++++++++++++++++++++++++++++++++++++++++---
test/ChangeLog | 10 ++
test/Makefile.am | 10 ++-
test/Makefile.in | 9 ++-
test/indirectbuiltin.awk | 6 +
test/indirectbuiltin.ok | 1 +
test/negtime.awk | 4 +
test/negtime.ok | 1 +
10 files changed, 293 insertions(+), 26 deletions(-)
create mode 100644 test/negtime.awk
create mode 100644 test/negtime.ok
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, feature/regex-type, updated. gawk-4.1.0-1307-gaca30f7,
Arnold Robbins <=