978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
|
memcpy(buffer, characters + range.location,
range.length * sizeof(OFUnichar));
objc_autoreleasePoolPop(pool);
}
- (OFRange)rangeOfString: (OFString *)string
options: (int)options
range: (OFRange)range
{
const char *cString = string.UTF8String;
size_t cStringLength = string.UTF8StringLength;
size_t rangeLocation, rangeLength;
if (range.length > SIZE_MAX - range.location ||
|
|
|
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
|
memcpy(buffer, characters + range.location,
range.length * sizeof(OFUnichar));
objc_autoreleasePoolPop(pool);
}
- (OFRange)rangeOfString: (OFString *)string
options: (OFStringSearchOptions)options
range: (OFRange)range
{
const char *cString = string.UTF8String;
size_t cStringLength = string.UTF8StringLength;
size_t rangeLocation, rangeLength;
if (range.length > SIZE_MAX - range.location ||
|
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
|
if (cStringLength == 0)
return OFMakeRange(0, 0);
if (cStringLength > rangeLength)
return OFMakeRange(OFNotFound, 0);
if (options & OF_STRING_SEARCH_BACKWARDS) {
for (size_t i = rangeLength - cStringLength;; i--) {
if (memcmp(_s->cString + rangeLocation + i, cString,
cStringLength) == 0) {
range.location += of_string_utf8_get_index(
_s->cString + rangeLocation, i);
range.length = string.length;
|
|
|
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
|
if (cStringLength == 0)
return OFMakeRange(0, 0);
if (cStringLength > rangeLength)
return OFMakeRange(OFNotFound, 0);
if (options & OFStringSearchBackwards) {
for (size_t i = rangeLength - cStringLength;; i--) {
if (memcmp(_s->cString + rangeLocation + i, cString,
cStringLength) == 0) {
range.location += of_string_utf8_get_index(
_s->cString + rangeLocation, i);
range.length = string.length;
|
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
|
return false;
return (memcmp(_s->cString + (_s->cStringLength - cStringLength),
suffix.UTF8String, cStringLength) == 0);
}
- (OFArray *)componentsSeparatedByString: (OFString *)delimiter
options: (int)options
{
void *pool;
OFMutableArray *array;
const char *cString;
size_t cStringLength;
bool skipEmpty = (options & OF_STRING_SKIP_EMPTY);
size_t last;
OFString *component;
if (delimiter == nil)
@throw [OFInvalidArgumentException exception];
if (delimiter.length == 0)
|
|
|
|
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
|
return false;
return (memcmp(_s->cString + (_s->cStringLength - cStringLength),
suffix.UTF8String, cStringLength) == 0);
}
- (OFArray *)componentsSeparatedByString: (OFString *)delimiter
options: (OFStringSeparationOptions)options
{
void *pool;
OFMutableArray *array;
const char *cString;
size_t cStringLength;
bool skipEmpty = (options & OFStringSkipEmptyComponents);
size_t last;
OFString *component;
if (delimiter == nil)
@throw [OFInvalidArgumentException exception];
if (delimiter.length == 0)
|