summaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics/eoshift2.c
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-28 21:11:39 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-28 21:11:39 +0000
commit329f13ad8e6dc4f4d79b9fab510e7aef577518d3 (patch)
treea956a38d25628c3640e2911e48de624e53210afa /libgfortran/intrinsics/eoshift2.c
parent69eee21db577b8a270fae4da3cc5f8686ca93057 (diff)
downloadgcc-329f13ad8e6dc4f4d79b9fab510e7aef577518d3.tar.gz
PR fortran/36319
* intrinsic.c (gfc_convert_chartype): Don't mark conversion function as pure. * trans-array.c (gfc_trans_array_ctor_element): Divide element size by the size of one character to obtain length. * iresolve.c (gfc_resolve_cshift): Call the _char4 variant when appropriate. (gfc_resolve_eoshift): Likewise. * trans-intrinsic.c (gfc_conv_intrinsic_ctime): Minor beautification. (gfc_conv_intrinsic_fdate): Minor beautification. (gfc_conv_intrinsic_ttynam): Minor beautification. (gfc_conv_intrinsic_minmax_char): Allow all character kinds. (size_of_string_in_bytes): New function. (gfc_conv_intrinsic_size): Call size_of_string_in_bytes for character expressions. (gfc_conv_intrinsic_sizeof): Likewise. (gfc_conv_intrinsic_array_transfer): Likewise. (gfc_conv_intrinsic_trim): Allow all character kinds. Minor beautification. (gfc_conv_intrinsic_repeat): Fix comment typo. * simplify.c (gfc_convert_char_constant): Take care of conversion of array constructors. * intrinsics/string_intrinsics_inc.c (string_index): Return correct value for zero-length substring. * intrinsics/cshift0.c: Add _char4 variant. * intrinsics/eoshift0.c (eoshift0): Allow filler to be a pattern wider than a single byte. Add _char4 variant and use above functionality. * intrinsics/eoshift2.c (eoshift2): Likewise. * m4/eoshift1.m4: Likewise. * m4/eoshift3.m4: Likewise. * m4/cshift1.m4: Add _char4 variants. * gfortran.map (GFORTRAN_1.1): Add _gfortran_cshift0_1_char4, _gfortran_cshift0_2_char4, _gfortran_cshift0_4_char4, _gfortran_cshift0_8_char4, _gfortran_cshift1_16_char4, _gfortran_cshift1_4_char4, _gfortran_cshift1_8_char4, _gfortran_eoshift0_1_char4, _gfortran_eoshift0_2_char4, _gfortran_eoshift0_4_char4, _gfortran_eoshift0_8_char4, _gfortran_eoshift1_16_char4, _gfortran_eoshift1_4_char4, _gfortran_eoshift1_8_char4, _gfortran_eoshift2_1_char4, _gfortran_eoshift2_2_char4, _gfortran_eoshift2_4_char4, _gfortran_eoshift2_8_char4, _gfortran_eoshift3_16_char4, _gfortran_eoshift3_4_char4 and _gfortran_eoshift3_8_char4. * generated/eoshift3_4.c: Regenerate. * generated/eoshift1_8.c: Regenerate. * generated/eoshift1_16.c: Regenerate. * generated/cshift1_4.c: Regenerate. * generated/eoshift1_4.c: Regenerate. * generated/eoshift3_8.c: Regenerate. * generated/eoshift3_16.c: Regenerate. * generated/cshift1_8.c: Regenerate. * generated/cshift1_16.c: Regenerate. * gfortran.dg/widechar_5.f90: New file. * gfortran.dg/widechar_6.f90: New file. * gfortran.dg/widechar_7.f90: New file. * gfortran.dg/widechar_intrinsics_5.f90: Uncomment the lines testing the SPREAD intrinsic. * gfortran.dg/widechar_intrinsics_6.f90: New file. * gfortran.dg/widechar_intrinsics_7.f90: New file. * gfortran.dg/widechar_intrinsics_8.f90: New file. * gfortran.dg/widechar_intrinsics_9.f90: New file. * gfortran.dg/widechar_intrinsics_10.f90: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@136129 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics/eoshift2.c')
-rw-r--r--libgfortran/intrinsics/eoshift2.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/libgfortran/intrinsics/eoshift2.c b/libgfortran/intrinsics/eoshift2.c
index f74cb01fec8..239d9714a99 100644
--- a/libgfortran/intrinsics/eoshift2.c
+++ b/libgfortran/intrinsics/eoshift2.c
@@ -39,7 +39,7 @@ Boston, MA 02110-1301, USA. */
static void
eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
int shift, const gfc_array_char *bound, int which,
- index_type size, char filler)
+ index_type size, const char *filler, index_type filler_len)
{
/* r.* indicates the return array. */
index_type rstride[GFC_MAX_DIMENSIONS];
@@ -192,7 +192,14 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
else
while (n--)
{
- memset (dest, filler, size);
+ index_type i;
+
+ if (filler_len == 1)
+ memset (dest, filler[0], size);
+ else
+ for (i = 0; i < size ; i += filler_len)
+ memcpy (&dest[i], filler, filler_len);
+
dest += roffset;
}
@@ -243,7 +250,7 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
const GFC_INTEGER_##N *pdim) \
{ \
eoshift2 (ret, array, *pshift, pbound, pdim ? *pdim : 1, \
- GFC_DESCRIPTOR_SIZE (array), 0); \
+ GFC_DESCRIPTOR_SIZE (array), "\0", 1); \
} \
\
extern void eoshift2_##N##_char (gfc_array_char *, GFC_INTEGER_4, \
@@ -265,7 +272,31 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
GFC_INTEGER_4 bound_length __attribute__((unused))) \
{ \
eoshift2 (ret, array, *pshift, pbound, pdim ? *pdim : 1, \
- array_length, ' '); \
+ array_length, " ", 1); \
+ } \
+ \
+ extern void eoshift2_##N##_char4 (gfc_array_char *, GFC_INTEGER_4, \
+ const gfc_array_char *, \
+ const GFC_INTEGER_##N *, \
+ const gfc_array_char *, \
+ const GFC_INTEGER_##N *, \
+ GFC_INTEGER_4, GFC_INTEGER_4); \
+ export_proto(eoshift2_##N##_char4); \
+ \
+ void \
+ eoshift2_##N##_char4 (gfc_array_char *ret, \
+ GFC_INTEGER_4 ret_length __attribute__((unused)), \
+ const gfc_array_char *array, \
+ const GFC_INTEGER_##N *pshift, \
+ const gfc_array_char *pbound, \
+ const GFC_INTEGER_##N *pdim, \
+ GFC_INTEGER_4 array_length, \
+ GFC_INTEGER_4 bound_length __attribute__((unused))) \
+ { \
+ static const gfc_char4_t space = (unsigned char) ' '; \
+ eoshift2 (ret, array, *pshift, pbound, pdim ? *pdim : 1, \
+ array_length * sizeof (gfc_char4_t), (const char *) &space, \
+ sizeof (gfc_char4_t)); \
}
DEFINE_EOSHIFT (1);