summaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics/eoshift0.c
diff options
context:
space:
mode:
authortkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-07 22:01:41 +0000
committertkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-07 22:01:41 +0000
commit4eef4aad9a4e3edbe01a61f69887a0c9692c95ab (patch)
tree6e619479081b13e187d8cae04afbb290a97762a8 /libgfortran/intrinsics/eoshift0.c
parenta5558ca74b5e5f0c95f4c13a1d7f60b8a130c95b (diff)
downloadgcc-4eef4aad9a4e3edbe01a61f69887a0c9692c95ab.tar.gz
2005-07-07 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/21594 * intrinsics/eoshift0.c: If abs(shift) > len, fill the the whole array with the boundary value, but don't overrun it. * intrinsics/eoshift2.c: Likewise. * m4/eoshift1.m4: Likewise. * m4/eoshift3.m4: Likewise. * generated/eoshift1_4.c: Regenerated. * generated/eoshift1_8.c: Regenerated. * generated/eoshift3_4.c: Regenerated. * generated/eoshift3_8.c: Regenerated. 2005-07-07 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/21594 * gfortran.fortran-torture/execute/intrinsic_eoshift.f90: Add test cases where the shift length is greater than the array length. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101738 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics/eoshift0.c')
-rw-r--r--libgfortran/intrinsics/eoshift0.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libgfortran/intrinsics/eoshift0.c b/libgfortran/intrinsics/eoshift0.c
index b1fbd1a516a..6152e9fccbd 100644
--- a/libgfortran/intrinsics/eoshift0.c
+++ b/libgfortran/intrinsics/eoshift0.c
@@ -131,10 +131,19 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * array,
sstride0 = sstride[0];
rptr = ret->data;
sptr = array->data;
- if (shift > 0)
- len = len - shift;
+
+ if ((shift >= 0 ? shift : -shift) > len)
+ {
+ shift = len;
+ len = 0;
+ }
else
- len = len + shift;
+ {
+ if (shift > 0)
+ len = len - shift;
+ else
+ len = len + shift;
+ }
while (rptr)
{