This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran,patch] PR fortran/27715


The attached patch is a fix for PR fortran/27715, which basically is
because string comparisons in the front-end are done by comparing
chars (which are signed chars for example on i686-linux), and not
unsigned chars. This is not especially bad in itself (although it's
not the "usual" ordering for strings), but it conflicts with the way
the library does comparisons, by memcmp, that is comparing unsigned
chars.

Regtested on i686-linux, OK for mainline and 4.1?

FX

:ADDPATCH fortran:

Attachment: pr27715.ChangeLog
Description: Binary data

Index: simplify.c
===================================================================
--- simplify.c	(revision 113849)
+++ simplify.c	(working copy)
@@ -67,7 +67,7 @@
 /* Static table for converting non-ascii character sets to ascii.
    The xascii_table[] is the inverse table.  */
 
-static int ascii_table[256] = {
+static unsigned char ascii_table[256] = {
   '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
   '\b', '\t', '\n', '\v', '\0', '\r', '\0', '\0',
   '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
@@ -86,7 +86,7 @@
   'x', 'y', 'z', '{', '|', '}', '~', '\?'
 };
 
-static int xascii_table[256];
+static unsigned int xascii_table[256];
 
 
 /* Range checks an expression node.  If all goes well, returns the
@@ -1196,7 +1196,7 @@
       return &gfc_bad_expr;
     }
 
-  index = xascii_table[(int) e->value.character.string[0] & 0xFF];
+  index = xascii_table[(unsigned char) e->value.character.string[0] & 0xFF];
 
   result = gfc_int_expr (index);
   result->where = e->where;
@@ -4016,9 +4016,9 @@
 /* Given a collating table, create the inverse table.  */
 
 static void
-invert_table (const int *table, int *xtable)
+invert_table (const unsigned char *table, unsigned int *xtable)
 {
-  int i;
+  unsigned int i;
 
   for (i = 0; i < 256; i++)
     xtable[i] = 0;
Index: arith.c
===================================================================
--- arith.c	(revision 113849)
+++ arith.c	(working copy)
@@ -1122,9 +1122,10 @@
    collating sequence.  */
 
 int
-gfc_compare_string (gfc_expr * a, gfc_expr * b, const int *xcoll_table)
+gfc_compare_string (gfc_expr * a, gfc_expr * b, const unsigned int *xcoll_table)
 {
-  int len, alen, blen, i, ac, bc;
+  int len, alen, blen, i;
+  unsigned char ac, bc;
 
   alen = a->value.character.length;
   blen = b->value.character.length;
Index: arith.h
===================================================================
--- arith.h	(revision 113849)
+++ arith.h	(working copy)
@@ -41,7 +41,7 @@
 arith gfc_range_check (gfc_expr *);
 
 int gfc_compare_expr (gfc_expr *, gfc_expr *);
-int gfc_compare_string (gfc_expr *, gfc_expr *, const int *);
+int gfc_compare_string (gfc_expr *, gfc_expr *, const unsigned int *);
 
 /* Constant folding for gfc_expr trees.  */
 gfc_expr *gfc_uplus (gfc_expr * op);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]