aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--builtin.c15
-rw-r--r--test/ChangeLog6
-rw-r--r--test/Makefile.am6
-rw-r--r--test/Makefile.in11
-rw-r--r--test/Maketests5
-rw-r--r--test/typeof5.awk10
-rw-r--r--test/typeof5.in1
-rw-r--r--test/typeof5.ok4
9 files changed, 55 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index e73ebfbf..cadb6c22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * builtin.c (do_typeof): Handle arguments that have
+ the NULL_FIELD flag set.
+
2017-02-03 Andrew J. Schorr <aschorr@telemetry-investments.com>
* awkgram.y (set_profile_text): Improve code clarity by using emalloc
diff --git a/builtin.c b/builtin.c
index a6082ee0..4d816687 100644
--- a/builtin.c
+++ b/builtin.c
@@ -4001,7 +4001,7 @@ NODE *
do_typeof(int nargs)
{
NODE *arg;
- char *res = "unknown";
+ char *res = NULL;
bool deref = true;
arg = POP();
@@ -4013,9 +4013,6 @@ do_typeof(int nargs)
break;
case Node_val:
switch (fixtype(arg)->flags & (STRING|NUMBER|USER_INPUT|REGEX)) {
- case STRING:
- res = "string";
- break;
case NUMBER:
res = "number";
break;
@@ -4025,14 +4022,20 @@ do_typeof(int nargs)
case REGEX:
res = "regexp";
break;
+ case STRING:
+ res = "string";
+ // fall through
case NUMBER|STRING:
- if (arg == Nnull_string) {
+ if (arg == Nnull_string || (arg->flags & NULL_FIELD) != 0) {
res = "unassigned";
break;
}
/* fall through */
default:
- warning(_("typeof detected invalid flags combination `%s'; please file a bug report."), flags2str(arg->flags));
+ if (res == NULL) {
+ warning(_("typeof detected invalid flags combination `%s'; please file a bug report."), flags2str(arg->flags));
+ res = "unknown";
+ }
break;
}
break;
diff --git a/test/ChangeLog b/test/ChangeLog
index 4aa98610..918c16c5 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2017-02-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (typeof5): New test.
+ * typeof5.awk, typeof5.in, typeof5.ok: New files.
+ Thanks to Andrew Schorr for part of the tests.
+
2017-01-27 Andrew J. Schorr <aschorr@telemetry-investments.com>
* Makefile.am (gensub3): New test.
diff --git a/test/Makefile.am b/test/Makefile.am
index dfedcd64..00d50a0a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1113,6 +1113,9 @@ EXTRA_DIST = \
typeof3.ok \
typeof4.awk \
typeof4.ok \
+ typeof5.awk \
+ typeof5.in \
+ typeof5.ok \
uninit2.awk \
uninit2.ok \
uninit3.awk \
@@ -1237,7 +1240,8 @@ GAWK_EXT_TESTS = \
splitarg4 strftime strftfld \
strtonum strtonum1 switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \
symtab7 symtab8 symtab9 symtab10 \
- typedregex1 typedregex2 typedregex3 typeof1 typeof2 typeof3 typeof4 \
+ typedregex1 typedregex2 typedregex3 \
+ typeof1 typeof2 typeof3 typeof4 typeof5 \
timeout \
watchpoint1
diff --git a/test/Makefile.in b/test/Makefile.in
index af75a6a9..727fdb4b 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1371,6 +1371,9 @@ EXTRA_DIST = \
typeof3.ok \
typeof4.awk \
typeof4.ok \
+ typeof5.awk \
+ typeof5.in \
+ typeof5.ok \
uninit2.awk \
uninit2.ok \
uninit3.awk \
@@ -1494,7 +1497,8 @@ GAWK_EXT_TESTS = \
splitarg4 strftime strftfld \
strtonum strtonum1 switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \
symtab7 symtab8 symtab9 symtab10 \
- typedregex1 typedregex2 typedregex3 typeof1 typeof2 typeof3 typeof4 \
+ typedregex1 typedregex2 typedregex3 \
+ typeof1 typeof2 typeof3 typeof4 typeof5 \
timeout \
watchpoint1
@@ -4339,6 +4343,11 @@ typeof4:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+typeof5:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
timeout:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 9036ff99..ac3cedca 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1532,6 +1532,11 @@ typeof4:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+typeof5:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
timeout:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/typeof5.awk b/test/typeof5.awk
new file mode 100644
index 00000000..30cd6aca
--- /dev/null
+++ b/test/typeof5.awk
@@ -0,0 +1,10 @@
+BEGIN {
+ print typeof($0)
+ print typeof($1)
+}
+
+{
+ $3 = $1
+ print typeof($2)
+ print typeof($3)
+}
diff --git a/test/typeof5.in b/test/typeof5.in
new file mode 100644
index 00000000..9daeafb9
--- /dev/null
+++ b/test/typeof5.in
@@ -0,0 +1 @@
+test
diff --git a/test/typeof5.ok b/test/typeof5.ok
new file mode 100644
index 00000000..80f8cf51
--- /dev/null
+++ b/test/typeof5.ok
@@ -0,0 +1,4 @@
+unassigned
+unassigned
+unassigned
+string