mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Minor fixups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23016 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
912b71ee57
commit
51538b417a
2 changed files with 18 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
2006-06-01 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSString.m: Fix position of external function declaration.
|
||||
Fix use gf getCString methods for length error.
|
||||
|
||||
2006-05-30 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* Source/GSPrivate.h (GSCharPtr): New union type to handle
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
|
||||
#include "GSPrivate.h"
|
||||
|
||||
extern BOOL GSEncodingSupported(NSStringEncoding enc);
|
||||
|
||||
/* memcpy(), strlen(), strcmp() are gcc builtin's */
|
||||
|
||||
#include "GNUstepBase/Unicode.h"
|
||||
|
@ -439,6 +441,10 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
|
|||
void *chars = 0;
|
||||
BOOL flag = NO;
|
||||
|
||||
if (GSEncodingSupported(encoding) == NO)
|
||||
{
|
||||
return nil; // Invalid encoding
|
||||
}
|
||||
if (length > 0)
|
||||
{
|
||||
const void *original = bytes;
|
||||
|
@ -455,6 +461,10 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
|
|||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* The fixBOM() function has already copied the data and allocated
|
||||
* new memory, so we can just pass that to the designated initialiser
|
||||
*/
|
||||
chars = (void*)bytes;
|
||||
}
|
||||
}
|
||||
|
@ -469,7 +479,6 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
|
|||
encoding: (NSStringEncoding)encoding
|
||||
freeWhenDone: (BOOL)flag
|
||||
{
|
||||
extern BOOL GSEncodingSupported(NSStringEncoding enc);
|
||||
GSCharPtr chars = { .u = 0 };
|
||||
BOOL isASCII = NO;
|
||||
BOOL isLatin1 = NO;
|
||||
|
@ -4026,7 +4035,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
unsigned char tmp = _contents.c[aRange.location + length];
|
||||
|
||||
[aString getCString: (char*)&_contents.c[aRange.location]
|
||||
maxLength: length
|
||||
maxLength: length+1
|
||||
encoding: internalEncoding];
|
||||
_contents.c[aRange.location + length] = tmp;
|
||||
}
|
||||
|
@ -4040,7 +4049,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
if (l > 0)
|
||||
{
|
||||
[aString getCString: (char*)&_contents.c[aRange.location]
|
||||
maxLength: l
|
||||
maxLength: l+1
|
||||
encoding: internalEncoding];
|
||||
}
|
||||
u = [aString characterAtIndex: l];
|
||||
|
@ -4106,7 +4115,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
if (l > 0)
|
||||
{
|
||||
[aString getCString: (char*)_contents.c
|
||||
maxLength: l
|
||||
maxLength: l+1
|
||||
encoding: internalEncoding];
|
||||
}
|
||||
_contents.c[l]
|
||||
|
|
Loading…
Reference in a new issue