Bugfix byte swapping

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22970 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-05-22 13:01:00 +00:00
parent 2dbae8ac85
commit ddfbd134e1
2 changed files with 7 additions and 5 deletions

View file

@ -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 <rfm@gnu.org>

View file

@ -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 */