aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2011-03-03 21:29:09 +0200
committerArnold D. Robbins <arnold@skeeve.com>2011-03-03 21:29:09 +0200
commit9a5422582e93056b5398c8d0c566cf356248e8a3 (patch)
tree926e2fccf407da2c847179f198ab1ba15a898362
parent1584660b0ae4f89307609573120259c781e3e986 (diff)
downloadegawk-9a5422582e93056b5398c8d0c566cf356248e8a3.tar.gz
egawk-9a5422582e93056b5398c8d0c566cf356248e8a3.tar.bz2
egawk-9a5422582e93056b5398c8d0c566cf356248e8a3.zip
Fixes for asort, asorti, split, patsplit.
-rw-r--r--ChangeLog8
-rw-r--r--array.c4
-rw-r--r--field.c10
3 files changed, 18 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 70b8b100..5d9d9c2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Mar 2 08:15:02 2011 John Haque <j.eh@mchsi.com>
+
+ * array.c (asort_actual): Handle the case when the same array
+ is used as the source and destination.
+ * field.c (do_split): Make it fatal if attempting to use the same
+ array for both second and fourth arguments.
+ (do_patsplit): Ditto.
+
Sun Feb 27 08:01:04 2011 Arnold D. Robbins <arnold@skeeve.com>
Update copryright in all relevant files.
diff --git a/array.c b/array.c
index 2b3b07f4..b821b5e4 100644
--- a/array.c
+++ b/array.c
@@ -1239,7 +1239,6 @@ asort_actual(int nargs, ASORT_TYPE how)
_("asort: second argument not an array") :
_("asorti: second argument not an array"));
}
- assoc_clear(dest);
}
array = POP_PARAM();
@@ -1249,7 +1248,8 @@ asort_actual(int nargs, ASORT_TYPE how)
_("asorti: first argument not an array"));
}
- if (dest != NULL) {
+ if (dest != NULL && dest != array) {
+ assoc_clear(dest);
dup_table(array, dest);
array = dest;
}
diff --git a/field.c b/field.c
index bf953304..659574ec 100644
--- a/field.c
+++ b/field.c
@@ -957,8 +957,11 @@ do_split(int nargs)
fatal(_("split: second argument is not an array"));
assoc_clear(arr);
- if (sep_arr != NULL)
+ if (sep_arr != NULL) {
+ if (sep_arr == arr)
+ fatal(_("split: can not use the same array for second and fourth args"));
assoc_clear(sep_arr);
+ }
src = TOP_STRING();
if (src->stlen == 0) {
@@ -1051,8 +1054,11 @@ do_patsplit(int nargs)
fatal(_("patsplit: third argument must be non-null"));
}
assoc_clear(arr);
- if (sep_arr != NULL)
+ if (sep_arr != NULL) {
+ if (sep_arr == arr)
+ fatal(_("patsplit: can not use the same array for second and fourth args"));
assoc_clear(sep_arr);
+ }
rp = re_update(sep);