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]

Re: 20010325-1 vs wide strings



[via private email] wrote:
> I believe it's obviously wrong, and it's one of the things that the
> testcase was testing for.

How's this for a fix, then?

2001-05-10  DJ Delorie  <dj@redhat.com>

	* c-common.c (combine_strings): Widen strings in a
	host-endian-independent way.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.232
diff -p -3 -r1.232 c-common.c
*** c-common.c	2001/05/01 12:11:31	1.232
--- c-common.c	2001/05/10 04:13:25
*************** combine_strings (strings)
*** 583,597 ****
  	    }
  	  else
  	    {
! 	      int i;
  	      for (i = 0; i < len; i++)
  		{
! 		  if (WCHAR_TYPE_SIZE == HOST_BITS_PER_SHORT)
! 		    ((short *) q)[i] = TREE_STRING_POINTER (t)[i];
  		  else
! 		    ((int *) q)[i] = TREE_STRING_POINTER (t)[i];
  		}
- 	      q += len * wchar_bytes;
  	    }
  	}
        if (wide_flag)
--- 583,604 ----
  	    }
  	  else
  	    {
! 	      int i, j;
  	      for (i = 0; i < len; i++)
  		{
! 		  if (BYTES_BIG_ENDIAN)
! 		    {
! 		      for (j=0; j<(WCHAR_TYPE_SIZE / BITS_PER_UNIT)-1; j++)
! 			*q++ = 0;
! 		      *q++ = TREE_STRING_POINTER (t)[i];
! 		    }
  		  else
! 		    {
! 		      *q++ = TREE_STRING_POINTER (t)[i];
! 		      for (j=0; j<(WCHAR_TYPE_SIZE / BITS_PER_UNIT)-1; j++)
! 			*q++ = 0;
! 		    }
  		}
  	    }
  	}
        if (wide_flag)


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