From a1c4536b99879458aa6c2eaef9e5297a280c725f Mon Sep 17 00:00:00 2001 From: rfm Date: Mon, 22 May 2006 13:01:00 +0000 Subject: [PATCH] Bugfix byte swapping git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22970 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 2 ++ Source/Additions/Unicode.m | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55f09dd63..7cce9c8c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ * Source/GSString.m: Make sure inline strings have 'free' flag set and add comments to say we use it to indicate ownership of buffer rather than whether to free the data. Maybe we should change the flag name? + * Source/Additions/Unicode.m: Fix missing brackets in byte order + handling for UTF-16. Problem pointed out by David Ayers 2006-05-20 Richard Frith-Macdonald diff --git a/Source/Additions/Unicode.m b/Source/Additions/Unicode.m index 225442625..9f9154ae7 100644 --- a/Source/Additions/Unicode.m +++ b/Source/Additions/Unicode.m @@ -1901,7 +1901,7 @@ GSFromUnicode(unsigned char **dst, unsigned int *size, const unichar *src, u1 = src[spos++]; if (swapped == YES) { - u1 = ((u1 & 0xff00 >> 8) + ((u1 & 0x00ff) << 8)); + u1 = (((u1 & 0xff00) >> 8) + ((u1 & 0x00ff) << 8)); } if (u1 == 0xfffe || u1 == 0xffff // unexpcted BOM || (u1 >= 0xfdd0 && u1 <= 0xfdef) // invalid character @@ -1932,7 +1932,7 @@ GSFromUnicode(unsigned char **dst, unsigned int *size, const unichar *src, u2 = src[spos++]; if (swapped == YES) { - u2 = ((u2 & 0xff00 >> 8) + ((u2 & 0x00ff) << 8)); + u2 = (((u2 & 0xff00) >> 8) + ((u2 & 0x00ff) << 8)); } if ((u2 < 0xdc00) && (u2 > 0xdfff)) @@ -2033,7 +2033,7 @@ bases: if (swapped == YES) { - u = ((u & 0xff00 >> 8) + ((u & 0x00ff) << 8)); + u = (((u & 0xff00) >> 8) + ((u & 0x00ff) << 8)); } if (dpos >= bsize) @@ -2058,7 +2058,7 @@ bases: if (swapped == YES) { - u = ((u & 0xff00 >> 8) + ((u & 0x00ff) << 8)); + u = (((u & 0xff00) >> 8) + ((u & 0x00ff) << 8)); } if (dpos >= bsize) { @@ -2138,7 +2138,7 @@ tables: /* Swap byte order if necessary */ if (swapped == YES) { - u = ((u & 0xff00 >> 8) + ((u & 0x00ff) << 8)); + u = (((u & 0xff00) >> 8) + ((u & 0x00ff) << 8)); } /* Grow output buffer to make room if necessary */