aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-11-25 21:43:58 +0200
committerArnold D. Robbins <arnold@skeeve.com>2014-11-25 21:43:58 +0200
commit7efd4d794abbbd1b6abc2110cd43fd7896e0cb47 (patch)
treecd7a86571fcc397f64a17598a9e4fe99297818c3
parent2513062a4c89b0b60c3717d506fce841d44d871e (diff)
downloadegawk-7efd4d794abbbd1b6abc2110cd43fd7896e0cb47.tar.gz
egawk-7efd4d794abbbd1b6abc2110cd43fd7896e0cb47.tar.bz2
egawk-7efd4d794abbbd1b6abc2110cd43fd7896e0cb47.zip
Improve warnings in gensub.
-rw-r--r--ChangeLog5
-rw-r--r--builtin.c6
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f47aeded..175c9298 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-25 Arnold D. Robbins <arnold@skeeve.com>
+
+ * builtin.c (do_sub): For gensub, add more warnings for invalid
+ third argument.
+
2014-11-23 Arnold D. Robbins <arnold@skeeve.com>
* awk.h: Move all inline functions to the bottom of the file.
diff --git a/builtin.c b/builtin.c
index 75e4f580..3aeee744 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2696,6 +2696,8 @@ do_sub(int nargs, unsigned int flags)
if ((t1->flags & NUMCUR) != 0)
goto set_how_many;
+ warning(_("gensub: third argument of `%.*s' treated as 1"),
+ (int) t1->stlen, t1->stptr);
how_many = 1;
}
} else {
@@ -2708,8 +2710,8 @@ set_how_many:
how_many = d;
else
how_many = LONG_MAX;
- if (d == 0)
- warning(_("gensub: third argument of 0 treated as 1"));
+ if (d <= 0)
+ warning(_("gensub: third argument of %g treated as 1"), d);
}
DEREF(t1);