Overview
Context
Changes
Modified src/OFArray.h
from [db12216b45]
to [ac4d6f9a1b].
︙ | | |
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
-
+
-
+
-
+
-
+
|
* \param index The number of the object to return
* \return The specified object of the OFArray
*/
- (id)objectAtIndex: (size_t)index;
/**
* Returns the index of the first object that is equivalent to the specified
* object or SIZE_MAX if it was not found.
* object or OF_INVALID_INDEX if it was not found.
*
* \param obj The object whose index is returned
* \return The index of the first object equivalent to the specified object
* or SIZE_MAX if it was not found
* or OF_INVALID_INDEX if it was not found
*/
- (size_t)indexOfObject: (id)obj;
/**
* Returns the index of the first object that has the same address as the
* specified object or SIZE_MAX if it was not found.
* specified object or OF_INVALID_INDEX if it was not found.
*
* \param obj The object whose index is returned
* \return The index of the first object that has the same aaddress as
* the specified object or SIZE_MAX if it was not found
* the specified object or OF_INVALID_INDEX if it was not found
*/
- (size_t)indexOfObjectIdenticalTo: (id)obj;
/**
* Returns the first object of the array or nil.
*
* The returned object is <i>not</i> retained and autoreleased for performance
|
︙ | | |
Modified src/OFArray.m
from [526194f8ce]
to [cc2c3a4085].
︙ | | |
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
-
+
-
+
-
+
-
+
|
- (size_t)indexOfObject: (id)obj
{
id *objs = [array cArray];
size_t i, count = [array count];
if (objs == NULL)
return SIZE_MAX;
return OF_INVALID_INDEX;
for (i = 0; i < count; i++)
if ([objs[i] isEqual: obj])
return i;
return SIZE_MAX;
return OF_INVALID_INDEX;
}
- (size_t)indexOfObjectIdenticalTo: (id)obj
{
id *objs = [array cArray];
size_t i, count = [array count];
if (objs == NULL)
return SIZE_MAX;
return OF_INVALID_INDEX;
for (i = 0; i < count; i++)
if (objs[i] == obj)
return i;
return SIZE_MAX;
return OF_INVALID_INDEX;
}
- (BOOL)containsObject: (id)obj
{
id *objs = [array cArray];
size_t i, count = [array count];
|
︙ | | |
Modified src/OFObject.h
from [1c80d73d6b]
to [bcf048ad36].
︙ | | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
+
|
#ifdef OF_OBJFW_RUNTIME
# import <objfw-rt.h>
#else
# import <objc/objc.h>
#endif
#define OF_RETAIN_COUNT_MAX UINT_MAX
#define OF_INVALID_INDEX SIZE_MAX
/**
* \brief A result of a comparison.
*/
typedef enum of_comparison_result_t {
/// The left object is smaller than the right
OF_ORDERED_ASCENDING = -1,
|
︙ | | |
Modified src/OFString.h
from [76ff127a29]
to [6689e2f31d].
︙ | | |
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
-
-
+
+
-
-
+
+
|
* \param index The index of the Unicode character to return
* \return The Unicode character at the specified index
*/
- (of_unichar_t)characterAtIndex: (size_t)index;
/**
* \param str The string to search
* \return The index of the first occurrence of the string or SIZE_MAX if it
* was not found
* \return The index of the first occurrence of the string or OF_INVALID_INDEX
* if it was not found
*/
- (size_t)indexOfFirstOccurrenceOfString: (OFString*)str;
/**
* \param str The string to search
* \return The index of the last occurrence of the string or SIZE_MAX if it
* was not found
* \return The index of the last occurrence of the string or OF_INVALID_INDEX if
* it was not found
*/
- (size_t)indexOfLastOccurrenceOfString: (OFString*)str;
/**
* \param str The string to search
* \return Whether the string contains the specified string
*/
|
︙ | | |
Modified src/OFString.m
from [4c6f19272b]
to [15058207f8].
︙ | | |
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
-
+
|
of_string_index_to_position(const char *str, size_t idx, size_t len)
{
size_t i;
for (i = 0; i <= idx; i++)
if (OF_UNLIKELY((str[i] & 0xC0) == 0x80))
if (++idx > len)
return SIZE_MAX;
return OF_INVALID_INDEX;
return idx;
}
@implementation OFString
+ string
{
|
︙ | | |
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
|
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
|
-
+
-
+
-
+
-
+
|
size_t str_len = [str cStringLength];
size_t i;
if (str_len == 0)
return 0;
if (str_len > length)
return SIZE_MAX;
return OF_INVALID_INDEX;
for (i = 0; i <= length - str_len; i++)
if (!memcmp(string + i, str_c, str_len))
return of_string_position_to_index(string, i);
return SIZE_MAX;
return OF_INVALID_INDEX;
}
- (size_t)indexOfLastOccurrenceOfString: (OFString*)str
{
const char *str_c = [str cString];
size_t str_len = [str cStringLength];
size_t i;
if (str_len == 0)
return of_string_position_to_index(string, length);
if (str_len > length)
return SIZE_MAX;
return OF_INVALID_INDEX;
for (i = length - str_len;; i--) {
if (!memcmp(string + i, str_c, str_len))
return of_string_position_to_index(string, i);
/* Did not match and we're at the last char */
if (i == 0)
return SIZE_MAX;
return OF_INVALID_INDEX;
}
}
- (BOOL)containsString: (OFString*)str
{
const char *str_c = [str cString];
size_t str_len = [str cStringLength];
|
︙ | | |
Modified tests/OFStringTests.m
from [8d7cb5a07c]
to [7495b7a6ca].
︙ | | |
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
-
+
-
+
|
R(([s[0] appendFormat: @"%02X", 15])) &&
[s[0] isEqual: @"test:1230F"])
TEST(@"-[indexOfFirstOccurrenceOfString:]",
[@"πΓΆΓΆ" indexOfFirstOccurrenceOfString: @"ΓΆΓΆ"] == 1 &&
[@"πΓΆΓΆ" indexOfFirstOccurrenceOfString: @"ΓΆ"] == 1 &&
[@"πΓΆΓΆ" indexOfFirstOccurrenceOfString: @"π"] == 0 &&
[@"πΓΆΓΆ" indexOfFirstOccurrenceOfString: @"x"] == SIZE_MAX)
[@"πΓΆΓΆ" indexOfFirstOccurrenceOfString: @"x"] == OF_INVALID_INDEX)
TEST(@"-[indexOfLastOccurrenceOfString:]",
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆΓΆ"] == 1 &&
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆ"] == 2 &&
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"π"] == 0 &&
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"x"] == SIZE_MAX)
[@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"x"] == OF_INVALID_INDEX)
TEST(@"-[substringFromIndexToIndex:]",
[[@"πΓΆΓΆ" substringFromIndex: 1
toIndex: 2] isEqual: @"ΓΆ"] &&
[[@"πΓΆΓΆ" substringFromIndex: 3
toIndex: 3] isEqual: @""])
|
︙ | | |