about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/params.c5
-rw-r--r--Test/D04parameter.ztst17
3 files changed, 27 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b3b3224d..b47e6643f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-07-25  Peter Stephenson  <pws@csr.com>
+
+	* 23696: Src/params.c, Test/D04parameter.ztst: assignment
+	to negative subscripts in scalars before the start was broken.
+	Now adds at start.
+
 2007-07-24  Peter Stephenson  <pws@csr.com>
 
 	* 23694: Src/cond.c: change of infix condition features to C:
diff --git a/Src/params.c b/Src/params.c
index 46da87580..a962f850c 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2076,8 +2076,11 @@ setstrvalue(Value v, char *val)
 	    }
 	    if (v->start > zlen)
 		v->start = zlen;
-	    if (v->end < 0)
+	    if (v->end < 0) {
 		v->end += zlen + 1;
+		if (v->end < 0)
+		    v->end = 0;
+	    }
 	    else if (v->end > zlen)
 		v->end = zlen;
 	    x = (char *) zalloc(v->start + strlen(val) + zlen - v->end + 1);
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 6df466ed0..7f229e9a6 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -920,3 +920,20 @@
 0:Numeric sorting
 >a6 a17 a117 b6 b17 b117
 >b117 b17 b6 a117 a17 a6
+
+  x=sprodj
+  x[-10]=scrumf
+  print $x
+0:Out of range negative scalar subscripts
+>scrumfsprodj
+
+  a=(some sunny day)
+  a[-10]=(we\'ll meet again)
+  print -l $a
+0:Out of range negative array subscripts
+>we'll
+>meet
+>again
+>some
+>sunny
+>day