[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[NSString getCString:maxLength:range:remainingRange:]
From: |
Michael Scheibler |
Subject: |
[NSString getCString:maxLength:range:remainingRange:] |
Date: |
Wed, 20 Jun 2001 12:39:26 +0200 |
GSString.m:
static inline void
getCString_c(ivars self, char *buffer, unsigned int maxLength,
NSRange aRange, NSRange *leftoverRange)
{
int len;
if (maxLength > self->_count)
{
maxLength = self->_count;
}
if (maxLength < aRange.length)
{
len = maxLength;
if (leftoverRange != 0)
{
leftoverRange->location = 0; // 1a
leftoverRange->length = 0; // 2a
}
}
else
{
len = aRange.length;
if (leftoverRange != 0)
{
leftoverRange->location = aRange.location + maxLength; // 1b
leftoverRange->length = aRange.length - maxLength; // 2b
}
}
memcpy(buffer, &self->_contents.c[aRange.location], len);
buffer[len] = '\0';
}
I think the lines 1a and 2a have to be swapped with lines 1b and 2b.
Michael
- [NSString getCString:maxLength:range:remainingRange:],
Michael Scheibler <=