===================================================================
@@ -90,7 +90,7 @@ compare_string (gfc_charlen_type len1, const CHART
gfc_charlen_type len;
int res;
- res = memcmp (s1, s2, ((len1 < len2) ? len1 : len2) * sizeof (CHARTYPE));
+ res = MEMCMP (s1, s2, ((len1 < len2) ? len1 : len2));
if (res != 0)
return res;
===================================================================
@@ -51,7 +51,24 @@ memset_char4 (gfc_char4_t *b, gfc_char4_t c, size_
return b;
}
+/* Compare wide character types, which are handled internally as
+ unsigned 4-byte integers. */
+int
+memcmp_char4 (const void *a, const void *b, size_t len)
+{
+ const GFC_UINTEGER_4 *pa = a;
+ const GFC_UINTEGER_4 *pb = b;
+ while (len-- > 0)
+ {
+ if (*pa != *pb)
+ return *pa < *pb ? -1 : 1;
+ pa ++;
+ pb ++;
+ }
+ return 0;
+}
+
/* All other functions are defined using a few generic macros in
string_intrinsics_inc.c, so we avoid code duplication between the
various character type kinds. */
@@ -64,6 +81,8 @@ memset_char4 (gfc_char4_t *b, gfc_char4_t c, size_
#define SUFFIX(x) x
#undef MEMSET
#define MEMSET memset
+#undef MEMCMP
+#define MEMCMP memcmp
#include "string_intrinsics_inc.c"
@@ -76,6 +95,8 @@ memset_char4 (gfc_char4_t *b, gfc_char4_t c, size_
#define SUFFIX(x) x ## _char4
#undef MEMSET
#define MEMSET memset_char4
+#undef MEMCMP
+#define MEMCMP memcmp_char4
#include "string_intrinsics_inc.c"
===================================================================
@@ -1266,6 +1266,10 @@ extern int compare_string_char4 (gfc_charlen_type,
gfc_charlen_type, const gfc_char4_t *);
iexport_proto(compare_string_char4);
+extern int memcmp_char4 (const void *, const void *, size_t);
+internal_proto(memcmp_char4);
+
+
/* random.c */
extern void random_seed_i4 (GFC_INTEGER_4 * size, gfc_array_i4 * put,