static const char zeros[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-extern void eoshift1_4 (const gfc_array_char *,
+extern void eoshift1_4 (gfc_array_char *,
const gfc_array_char *,
const gfc_array_i4 *, const char *,
const GFC_INTEGER_4 *);
export_proto(eoshift1_4);
void
-eoshift1_4 (const gfc_array_char *ret,
+eoshift1_4 (gfc_array_char *ret,
const gfc_array_char *array,
const gfc_array_i4 *h, const char *pbound,
const GFC_INTEGER_4 *pwhich)
extent[0] = 1;
count[0] = 0;
size = GFC_DESCRIPTOR_SIZE (array);
+
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->base = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+ }
+ }
+
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
{
rstride[n] = ret->dim[dim].stride * size;
sstride[n] = array->dim[dim].stride * size;
- hstride[n] = h->dim[n].stride;
+ hstride[n] = h->dim[n].stride * size;
n++;
}
}
{
/* Do the shift for this dimension. */
sh = *hptr;
- delta = (sh >= 0) ? sh: -sh;
+ if (( sh >= 0 ? sh : -sh ) > len)
+ {
+ delta = len;
+ sh = len;
+ }
+ else
+ delta = (sh >= 0) ? sh: -sh;
+
if (sh > 0)
{
src = &sptr[delta * soffset];