mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fix bug in abstract implementation by calling method of concrete class.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23264 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3c1a4c536f
commit
d6c63b551a
2 changed files with 15 additions and 40 deletions
|
@ -2,6 +2,10 @@
|
|||
|
||||
* Source/GSString.m: getCString_c() call getCString_u() to do the
|
||||
work if external encoding != internal encoding.
|
||||
* Source/NSScanner.m: Fix for utf8
|
||||
* Source/GSFormat.m: remove call to deprecated method.
|
||||
* Source/NSString.m: remove calls to deprecated methods.
|
||||
Fix getCstring... by using concrete class implementation.
|
||||
|
||||
2006-08-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -2603,47 +2603,18 @@ handle_printf_atsign (FILE *stream,
|
|||
range: (NSRange)aRange
|
||||
remainingRange: (NSRange*)leftoverRange
|
||||
{
|
||||
unsigned len;
|
||||
unsigned count;
|
||||
unichar (*caiImp)(NSString*, SEL, unsigned int);
|
||||
NSString *s;
|
||||
|
||||
len = [self cStringLength];
|
||||
GS_RANGE_CHECK(aRange, len);
|
||||
|
||||
caiImp = (unichar (*)())[self methodForSelector: caiSel];
|
||||
|
||||
if (maxLength < aRange.length)
|
||||
{
|
||||
len = maxLength;
|
||||
if (leftoverRange)
|
||||
{
|
||||
leftoverRange->location = 0;
|
||||
leftoverRange->length = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = aRange.length;
|
||||
if (leftoverRange)
|
||||
{
|
||||
leftoverRange->location = aRange.location + maxLength;
|
||||
leftoverRange->length = aRange.length - maxLength;
|
||||
}
|
||||
}
|
||||
count = 0;
|
||||
while (count < len)
|
||||
{
|
||||
buffer[count] = encode_unitochar(
|
||||
(*caiImp)(self, caiSel, aRange.location + count),
|
||||
_DefaultStringEncoding);
|
||||
if (buffer[count] == 0)
|
||||
{
|
||||
[NSException raise: NSCharacterConversionException
|
||||
format: @"unable to convert to cString"];
|
||||
}
|
||||
count++;
|
||||
}
|
||||
buffer[len] = '\0';
|
||||
/* As this is a deprecated method, keep things simple (but inefficient)
|
||||
* by copying the receiver to a new instance of a base library built-in
|
||||
* class, and use the implementation provided by that class.
|
||||
* We need an autorelease to avoid a memory leak if there is an exception.
|
||||
*/
|
||||
s = AUTORELEASE([(NSString*)defaultPlaceholderString initWithString: self]);
|
||||
[s getCString: buffer
|
||||
maxLength: maxLength
|
||||
range: aRange
|
||||
remainingRange: leftoverRange];
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue