ObjFW  Check-in [00476e4430]

Overview
Comment:Fix shadowed variables and enable -Wshadow
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 00476e4430eb0d46ba4553fb01820e20517abcdd045f1ab6c9c518de13fd7c00
User & Date: js on 2017-10-11 20:53:10
Other Links: manifest | tags
Context
2017-10-12
23:50
Xcode project: More closely match warnings check-in: 627d939ae3 user: js tags: trunk
2017-10-11
20:53
Fix shadowed variables and enable -Wshadow check-in: 00476e4430 user: js tags: trunk
2017-10-07
15:19
OFHTTPClient: Fix missing exception handling check-in: e3de40a9b9 user: js tags: trunk
Changes

Modified ObjFW.xcodeproj/project.pbxproj from [ec91098d79] to [3e0ddca419].

3931
3932
3933
3934
3935
3936
3937

3938
3939
3940
3941
3942
3943
3944
				ENABLE_TESTABILITY = YES;
				GCC_C_LANGUAGE_STANDARD = c11;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_OPTIMIZATION_LEVEL = 2;
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES;
				GCC_WARN_PEDANTIC = YES;

				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				ONLY_ACTIVE_ARCH = YES;
				OTHER_CFLAGS = (
					"-fexceptions",







>







3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
				ENABLE_TESTABILITY = YES;
				GCC_C_LANGUAGE_STANDARD = c11;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_OPTIMIZATION_LEVEL = 2;
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES;
				GCC_WARN_PEDANTIC = YES;
				GCC_WARN_SHADOW = YES;
				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				ONLY_ACTIVE_ARCH = YES;
				OTHER_CFLAGS = (
					"-fexceptions",
3984
3985
3986
3987
3988
3989
3990

3991
3992
3993
3994
3995
3996
3997
				ENABLE_STRICT_OBJC_MSGSEND = YES;
				GCC_C_LANGUAGE_STANDARD = c11;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_OPTIMIZATION_LEVEL = 2;
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES;
				GCC_WARN_PEDANTIC = YES;

				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				OTHER_CFLAGS = (
					"-fexceptions",
					"-fconstant-string-class=OFConstantString",







>







3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
				ENABLE_STRICT_OBJC_MSGSEND = YES;
				GCC_C_LANGUAGE_STANDARD = c11;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_OPTIMIZATION_LEVEL = 2;
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES;
				GCC_WARN_PEDANTIC = YES;
				GCC_WARN_SHADOW = YES;
				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				OTHER_CFLAGS = (
					"-fexceptions",
					"-fconstant-string-class=OFConstantString",

Modified configure.ac from [f20413e5a9] to [4d72ed7d39].

173
174
175
176
177
178
179


180
181
182
183
184
185
186
AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [
	OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"
	AC_SUBST(NO_CONST_CFSTRINGS, "-fno-constant-cfstrings")
])
AX_CHECK_COMPILER_FLAGS([-Wsign-compare -Werror],
	[OBJCFLAGS="$OBJCFLAGS -Wsign-compare"])


AX_CHECK_COMPILER_FLAGS([-Wshorten-64-to-32 -Werror],
	[OBJCFLAGS="$OBJCFLAGS -Wshorten-64-to-32"])
AX_CHECK_COMPILER_FLAGS([-Wundeclared-selector -Werror],
	[OBJCFLAGS="$OBJCFLAGS -Wundeclared-selector"])
AX_CHECK_COMPILER_FLAGS([-Wsemicolon-before-method-body -Werror],
	[OBJCFLAGS="$OBJCFLAGS -Wsemicolon-before-method-body"])
AX_CHECK_COMPILER_FLAGS([-Wobjc-missing-property-synthesis -Werror],







>
>







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [
	OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"
	AC_SUBST(NO_CONST_CFSTRINGS, "-fno-constant-cfstrings")
])
AX_CHECK_COMPILER_FLAGS([-Wsign-compare -Werror],
	[OBJCFLAGS="$OBJCFLAGS -Wsign-compare"])
AX_CHECK_COMPILER_FLAGS([-Wshadow -Werror],
	[OBJCFLAGS="$OBJCFLAGS -Wshadow"])
AX_CHECK_COMPILER_FLAGS([-Wshorten-64-to-32 -Werror],
	[OBJCFLAGS="$OBJCFLAGS -Wshorten-64-to-32"])
AX_CHECK_COMPILER_FLAGS([-Wundeclared-selector -Werror],
	[OBJCFLAGS="$OBJCFLAGS -Wundeclared-selector"])
AX_CHECK_COMPILER_FLAGS([-Wsemicolon-before-method-body -Werror],
	[OBJCFLAGS="$OBJCFLAGS -Wsemicolon-before-method-body"])
AX_CHECK_COMPILER_FLAGS([-Wobjc-missing-property-synthesis -Werror],

Modified src/OFArray.m from [3fb8497b42] to [1c7667e82c].

271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
- (id)objectAtIndexedSubscript: (size_t)index
{
	return [self objectAtIndex: index];
}

- (id)valueForKey: (OFString *)key
{
	OFMutableArray *ret;

	if ([key hasPrefix: @"@"]) {
		void *pool = objc_autoreleasePoolPush();
		id ret;

		key = [key substringWithRange: of_range(1, [key length] - 1)];
		ret = [[super valueForKey: key] retain];

		objc_autoreleasePoolPop(pool);

		return [ret autorelease];







|



<







271
272
273
274
275
276
277
278
279
280
281

282
283
284
285
286
287
288
- (id)objectAtIndexedSubscript: (size_t)index
{
	return [self objectAtIndex: index];
}

- (id)valueForKey: (OFString *)key
{
	id ret;

	if ([key hasPrefix: @"@"]) {
		void *pool = objc_autoreleasePoolPush();


		key = [key substringWithRange: of_range(1, [key length] - 1)];
		ret = [[super valueForKey: key] retain];

		objc_autoreleasePoolPop(pool);

		return [ret autorelease];
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
	for (id object in self)
		[object performSelector: selector];
}

- (void)makeObjectsPerformSelector: (SEL)selector
			withObject: (id)object
{
	for (id object in self)
		[object performSelector: selector
			     withObject: object];
}

- (OFArray *)sortedArray
{
	OFMutableArray *new = [[self mutableCopy] autorelease];

	[new sort];







|
|
|







727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
	for (id object in self)
		[object performSelector: selector];
}

- (void)makeObjectsPerformSelector: (SEL)selector
			withObject: (id)object
{
	for (id objectIter in self)
		[objectIter performSelector: selector
				 withObject: object];
}

- (OFArray *)sortedArray
{
	OFMutableArray *new = [[self mutableCopy] autorelease];

	[new sort];

Modified src/OFINICategory.m from [e8548169a5] to [95cd2a6086].

506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
		if ([line isKindOfClass: [OFINICategory_Comment class]]) {
			OFINICategory_Comment *comment = line;
			[stream writeFormat: @"%@\r\n", comment->_comment];
		} else if ([line isKindOfClass: [OFINICategory_Pair class]]) {
			OFINICategory_Pair *pair = line;
			OFString *key = escapeString(pair->_key);
			OFString *value = escapeString(pair->_value);
			OFString *line = [OFString
			    stringWithFormat: @"%@=%@\r\n", key, value];

			[stream writeString: line
				   encoding: encoding];
		} else
			@throw [OFInvalidArgumentException exception];
	}

	return true;
}
@end







|


|








506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
		if ([line isKindOfClass: [OFINICategory_Comment class]]) {
			OFINICategory_Comment *comment = line;
			[stream writeFormat: @"%@\r\n", comment->_comment];
		} else if ([line isKindOfClass: [OFINICategory_Pair class]]) {
			OFINICategory_Pair *pair = line;
			OFString *key = escapeString(pair->_key);
			OFString *value = escapeString(pair->_value);
			OFString *tmp = [OFString
			    stringWithFormat: @"%@=%@\r\n", key, value];

			[stream writeString: tmp
				   encoding: encoding];
		} else
			@throw [OFInvalidArgumentException exception];
	}

	return true;
}
@end

Modified src/OFMapTable.m from [73724a7b07] to [2c59c12f0d].

205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
	if (mapTable->_count != _count ||
	    mapTable->_keyFunctions.equal != _keyFunctions.equal ||
	    mapTable->_objectFunctions.equal != _objectFunctions.equal)
		return false;

	for (uint32_t i = 0; i < _capacity; i++) {
		if (_buckets[i] != NULL && _buckets[i] != &deleted) {
			void *object =
			    [mapTable objectForKey: _buckets[i]->key];

			if (!_objectFunctions.equal(object,
			    _buckets[i]->object))
				return false;
		}
	}

	return true;
}







|


|







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
	if (mapTable->_count != _count ||
	    mapTable->_keyFunctions.equal != _keyFunctions.equal ||
	    mapTable->_objectFunctions.equal != _objectFunctions.equal)
		return false;

	for (uint32_t i = 0; i < _capacity; i++) {
		if (_buckets[i] != NULL && _buckets[i] != &deleted) {
			void *objectIter =
			    [mapTable objectForKey: _buckets[i]->key];

			if (!_objectFunctions.equal(objectIter,
			    _buckets[i]->object))
				return false;
		}
	}

	return true;
}

Modified src/OFSet.m from [876ac85821] to [9a3d14535d].

209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
- (size_t)count
{
	OF_UNRECOGNIZED_SELECTOR
}

- (id)valueForKey: (OFString *)key
{
	OFMutableSet *ret;

	if ([key hasPrefix: @"@"]) {
		void *pool = objc_autoreleasePoolPush();
		id ret;

		key = [key substringWithRange: of_range(1, [key length] - 1)];
		ret = [[super valueForKey: key] retain];

		objc_autoreleasePoolPop(pool);

		return [ret autorelease];







|



<







209
210
211
212
213
214
215
216
217
218
219

220
221
222
223
224
225
226
- (size_t)count
{
	OF_UNRECOGNIZED_SELECTOR
}

- (id)valueForKey: (OFString *)key
{
	id ret;

	if ([key hasPrefix: @"@"]) {
		void *pool = objc_autoreleasePoolPush();


		key = [key substringWithRange: of_range(1, [key length] - 1)];
		ret = [[super valueForKey: key] retain];

		objc_autoreleasePoolPop(pool);

		return [ret autorelease];

Modified src/OFString+XMLUnescaping.m from [d6e6b667b8] to [9667538219].

125
126
127
128
129
130
131
132
133
134
135
136
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
166
167
168
					    length: 1];
			else if (entityLength == 3 &&
			    memcmp(entity, "amp", 3) == 0)
				[ret appendCString: "&"
					  encoding: OF_STRING_ENCODING_ASCII
					    length: 1];
			else if (entity[0] == '#') {
				void *pool;
				OFString *tmp;

				pool = objc_autoreleasePoolPush();
				tmp = parseNumericEntity(entity,
				    entityLength);

				if (tmp == nil)
					@throw [OFInvalidFormatException
					    exception];

				[ret appendString: tmp];

				objc_autoreleasePoolPop(pool);
			} else {
				void *pool;
				OFString *name, *tmp;

				pool = objc_autoreleasePoolPush();

				name = [OFString
				    stringWithUTF8String: entity
						  length: entityLength];
				tmp = lookup(context, self, name);

				if (tmp == nil)
					@throw [OFUnknownXMLEntityException
					    exceptionWithEntityName: name];

				[ret appendString: tmp];

				objc_autoreleasePoolPop(pool);
			}

			last = i + 1;
			inEntity = false;
		}
	}








|


|








>
|

|


|











>
|







125
126
127
128
129
130
131
132
133
134
135
136
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
166
167
168
169
170
					    length: 1];
			else if (entityLength == 3 &&
			    memcmp(entity, "amp", 3) == 0)
				[ret appendCString: "&"
					  encoding: OF_STRING_ENCODING_ASCII
					    length: 1];
			else if (entity[0] == '#') {
				void *pool2;
				OFString *tmp;

				pool2 = objc_autoreleasePoolPush();
				tmp = parseNumericEntity(entity,
				    entityLength);

				if (tmp == nil)
					@throw [OFInvalidFormatException
					    exception];

				[ret appendString: tmp];

				objc_autoreleasePoolPop(pool2);
			} else {
				void *pool2;
				OFString *name, *tmp;

				pool2 = objc_autoreleasePoolPush();

				name = [OFString
				    stringWithUTF8String: entity
						  length: entityLength];
				tmp = lookup(context, self, name);

				if (tmp == nil)
					@throw [OFUnknownXMLEntityException
					    exceptionWithEntityName: name];

				[ret appendString: tmp];

				objc_autoreleasePoolPop(pool2);
			}

			last = i + 1;
			inEntity = false;
		}
	}

Modified src/OFURL.m from [114ec293ed] to [2082375f0b].

132
133
134
135
136
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
				_user = [[OFString alloc]
				    initWithUTF8String: UTF8String];

			UTF8String = tmp2;
		}

		if ((tmp2 = strchr(UTF8String, ':')) != NULL) {
			void *pool;
			OFString *portString;

			*tmp2 = '\0';
			tmp2++;

			_host = [[OFString alloc]
			    initWithUTF8String: UTF8String];

			pool = objc_autoreleasePoolPush();
			portString = [OFString stringWithUTF8String: tmp2];

			if ([portString decimalValue] > 65535)
				@throw [OFInvalidFormatException exception];

			_port = [portString decimalValue];

			objc_autoreleasePoolPop(pool);
		} else {
			_host = [[OFString alloc]
			    initWithUTF8String: UTF8String];

			if ([_scheme isEqual: @"http"])
				_port = 80;
			else if ([_scheme isEqual: @"https"])







|








|







|







132
133
134
135
136
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
				_user = [[OFString alloc]
				    initWithUTF8String: UTF8String];

			UTF8String = tmp2;
		}

		if ((tmp2 = strchr(UTF8String, ':')) != NULL) {
			void *pool2;
			OFString *portString;

			*tmp2 = '\0';
			tmp2++;

			_host = [[OFString alloc]
			    initWithUTF8String: UTF8String];

			pool2 = objc_autoreleasePoolPush();
			portString = [OFString stringWithUTF8String: tmp2];

			if ([portString decimalValue] > 65535)
				@throw [OFInvalidFormatException exception];

			_port = [portString decimalValue];

			objc_autoreleasePoolPop(pool2);
		} else {
			_host = [[OFString alloc]
			    initWithUTF8String: UTF8String];

			if ([_scheme isEqual: @"http"])
				_port = 80;
			else if ([_scheme isEqual: @"https"])

Modified tests/OFArrayTests.m from [4017a0a9f1] to [ce6bbc2cf5].

350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428

	TEST(@"Detection of mutation during Fast Enumeration", ok)

	[m[0] removeLastObject];

#ifdef OF_HAVE_BLOCKS
	{
		__block bool ok = true;
		__block size_t count = 0;
		OFArray *cmp = a[0];
		OFMutableArray *a2;

		m[0] = [[a[0] mutableCopy] autorelease];
		[m[0] enumerateObjectsUsingBlock:
		    ^ (id obj, size_t idx, bool *stop) {
			    count++;
			    if (![obj isEqual: [cmp objectAtIndex: idx]])
				    ok = false;
		}];

		if (count != [cmp count])
			ok = false;

		TEST(@"Enumeration using blocks", ok)

		ok = false;
		a2 = m[0];
		@try {
			[a2 enumerateObjectsUsingBlock:
			    ^ (id obj, size_t idx, bool *stop) {
				[a2 removeObjectAtIndex: idx];
			}];
		} @catch (OFEnumerationMutationException *e) {
			ok = true;
		} @catch (OFOutOfRangeException *e) {
			/*
			 * Out of bounds access due to enumeration not being
			 * detected.
			 */
		}

		TEST(@"Detection of mutation during enumeration using blocks",
		    ok)
	}

	TEST(@"-[replaceObjectsUsingBlock:]",
	    R([m[0] replaceObjectsUsingBlock: ^ id (id obj, size_t idx) {
		switch (idx) {
		case 0:
			return @"foo";
		case 1:
			return @"bar";
		}

		return nil;
		}]) && [[m[0] description] isEqual: @"(\n\tfoo,\n\tbar\n)"])

	TEST(@"-[mappedArrayUsingBlock:]",
	    [[[m[0] mappedArrayUsingBlock: ^ id (id obj, size_t idx) {
		switch (idx) {
		case 0:
			return @"foobar";
		case 1:
			return @"qux";
		}

		return nil;
	    }] description] isEqual: @"(\n\tfoobar,\n\tqux\n)"])

	TEST(@"-[filteredArrayUsingBlock:]",
	   [[[m[0] filteredArrayUsingBlock: ^ bool (id obj, size_t idx) {
		return [obj isEqual: @"foo"];
	    }] description] isEqual: @"(\n\tfoo\n)"])

	TEST(@"-[foldUsingBlock:]",
	    [[arrayClass arrayWithObjects: [OFMutableString string], @"foo",
	    @"bar", @"baz", nil] foldUsingBlock: ^ id (id left, id right) {
		[left appendString: right];
		return left;







|






|

|
|



|

|

|



|



|








|



|











|











|
|







350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428

	TEST(@"Detection of mutation during Fast Enumeration", ok)

	[m[0] removeLastObject];

#ifdef OF_HAVE_BLOCKS
	{
		__block bool blockOk = true;
		__block size_t count = 0;
		OFArray *cmp = a[0];
		OFMutableArray *a2;

		m[0] = [[a[0] mutableCopy] autorelease];
		[m[0] enumerateObjectsUsingBlock:
		    ^ (id object, size_t idx, bool *stop) {
			    count++;
			    if (![object isEqual: [cmp objectAtIndex: idx]])
				    blockOk = false;
		}];

		if (count != [cmp count])
			blockOk = false;

		TEST(@"Enumeration using blocks", blockOk)

		blockOk = false;
		a2 = m[0];
		@try {
			[a2 enumerateObjectsUsingBlock:
			    ^ (id object, size_t idx, bool *stop) {
				[a2 removeObjectAtIndex: idx];
			}];
		} @catch (OFEnumerationMutationException *e) {
			blockOk = true;
		} @catch (OFOutOfRangeException *e) {
			/*
			 * Out of bounds access due to enumeration not being
			 * detected.
			 */
		}

		TEST(@"Detection of mutation during enumeration using blocks",
		    blockOk)
	}

	TEST(@"-[replaceObjectsUsingBlock:]",
	    R([m[0] replaceObjectsUsingBlock: ^ id (id object, size_t idx) {
		switch (idx) {
		case 0:
			return @"foo";
		case 1:
			return @"bar";
		}

		return nil;
		}]) && [[m[0] description] isEqual: @"(\n\tfoo,\n\tbar\n)"])

	TEST(@"-[mappedArrayUsingBlock:]",
	    [[[m[0] mappedArrayUsingBlock: ^ id (id object, size_t idx) {
		switch (idx) {
		case 0:
			return @"foobar";
		case 1:
			return @"qux";
		}

		return nil;
	    }] description] isEqual: @"(\n\tfoobar,\n\tqux\n)"])

	TEST(@"-[filteredArrayUsingBlock:]",
	    [[[m[0] filteredArrayUsingBlock: ^ bool (id object, size_t idx) {
		return [object isEqual: @"foo"];
	    }] description] isEqual: @"(\n\tfoo\n)"])

	TEST(@"-[foldUsingBlock:]",
	    [[arrayClass arrayWithObjects: [OFMutableString string], @"foo",
	    @"bar", @"baz", nil] foldUsingBlock: ^ id (id left, id right) {
		[left appendString: right];
		return left;

Modified tests/OFDictionaryTests.m from [76bc88ef2a] to [f2dd61fdb9].

264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328

329
330
331
332
333
334
335
	TEST(@"-[stringByURLEncoding]",
	    [[[OFDictionary dictionaryWithKeysAndObjects: @"foo", @"bar",
							  @"q&x", @"q=x", nil]
	    stringByURLEncoding] isEqual: @"q%26x=q%3Dx&foo=bar"])

#ifdef OF_HAVE_BLOCKS
	{
		__block size_t i = 0;
		__block bool ok = true;

		[mutDict enumerateKeysAndObjectsUsingBlock:
		    ^ (id key, id obj, bool *stop) {
			if (i > 1 || ![key isEqual: keys[i]]) {
				ok = false;
				*stop = true;
				return;
			}

			[mutDict setObject: [mutDict objectForKey: key]
				    forKey: key];
			i++;
		}];

		TEST(@"Enumeration using blocks", ok)

		ok = false;
		@try {
			[mutDict enumerateKeysAndObjectsUsingBlock:
			    ^ (id key, id obj, bool *stop) {
				[mutDict setObject: @""
					    forKey: @""];
			}];
		} @catch (OFEnumerationMutationException *e) {
			ok = true;
		}

		TEST(@"Detection of mutation during enumeration using blocks",
		    ok)

		[mutDict removeObjectForKey: @""];
	}

	TEST(@"-[replaceObjectsUsingBlock:]",
	    R([mutDict replaceObjectsUsingBlock: ^ id (id key, id obj) {
		if ([key isEqual: keys[0]])
			return @"value_1";
		if ([key isEqual: keys[1]])
			return @"value_2";

		return nil;
	    }]) && [[mutDict objectForKey: keys[0]] isEqual: @"value_1"] &&
	    [[mutDict objectForKey: keys[1]] isEqual: @"value_2"])

	TEST(@"-[mappedDictionaryUsingBlock:]",
	    [[[mutDict mappedDictionaryUsingBlock: ^ id (id key, id obj) {
		if ([key isEqual: keys[0]])
			return @"val1";
		if ([key isEqual: keys[1]])
			return @"val2";

		return nil;
	    }] description] isEqual: @"{\n\tkey1 = val1;\n\tkey2 = val2;\n}"])

	TEST(@"-[filteredDictionaryUsingBlock:]",
	    [[[mutDict filteredDictionaryUsingBlock: ^ bool (id key, id obj) {

		return [key isEqual: keys[0]];
	    }] description] isEqual: @"{\n\tkey1 = value_1;\n}"])
#endif

	TEST(@"-[count]", [mutDict count] == 2)

	TEST(@"+[dictionaryWithKeysAndObjects:]",







|
|


|
|
|






|


|

|


|




|



|





|










|









|
>







264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
	TEST(@"-[stringByURLEncoding]",
	    [[[OFDictionary dictionaryWithKeysAndObjects: @"foo", @"bar",
							  @"q&x", @"q=x", nil]
	    stringByURLEncoding] isEqual: @"q%26x=q%3Dx&foo=bar"])

#ifdef OF_HAVE_BLOCKS
	{
		__block size_t j = 0;
		__block bool blockOk = true;

		[mutDict enumerateKeysAndObjectsUsingBlock:
		    ^ (id key, id object, bool *stop) {
			if (j > 1 || ![key isEqual: keys[j]]) {
				blockOk = false;
				*stop = true;
				return;
			}

			[mutDict setObject: [mutDict objectForKey: key]
				    forKey: key];
			j++;
		}];

		TEST(@"Enumeration using blocks", blockOk)

		blockOk = false;
		@try {
			[mutDict enumerateKeysAndObjectsUsingBlock:
			    ^ (id key, id object, bool *stop) {
				[mutDict setObject: @""
					    forKey: @""];
			}];
		} @catch (OFEnumerationMutationException *e) {
			blockOk = true;
		}

		TEST(@"Detection of mutation during enumeration using blocks",
		    blockOk)

		[mutDict removeObjectForKey: @""];
	}

	TEST(@"-[replaceObjectsUsingBlock:]",
	    R([mutDict replaceObjectsUsingBlock: ^ id (id key, id object) {
		if ([key isEqual: keys[0]])
			return @"value_1";
		if ([key isEqual: keys[1]])
			return @"value_2";

		return nil;
	    }]) && [[mutDict objectForKey: keys[0]] isEqual: @"value_1"] &&
	    [[mutDict objectForKey: keys[1]] isEqual: @"value_2"])

	TEST(@"-[mappedDictionaryUsingBlock:]",
	    [[[mutDict mappedDictionaryUsingBlock: ^ id (id key, id object) {
		if ([key isEqual: keys[0]])
			return @"val1";
		if ([key isEqual: keys[1]])
			return @"val2";

		return nil;
	    }] description] isEqual: @"{\n\tkey1 = val1;\n\tkey2 = val2;\n}"])

	TEST(@"-[filteredDictionaryUsingBlock:]",
	    [[[mutDict filteredDictionaryUsingBlock:
	    ^ bool (id key, id object) {
		return [key isEqual: keys[0]];
	    }] description] isEqual: @"{\n\tkey1 = value_1;\n}"])
#endif

	TEST(@"-[count]", [mutDict count] == 2)

	TEST(@"+[dictionaryWithKeysAndObjects:]",

Modified tests/OFInvocationTests.m from [1bbbdf67b6] to [5d557debb9].

316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int i = 1; i <= 16; i++)
		[invocation setArgument: &i
				atIndex: i + 1];

	int intResult;
	TEST(@"-[invoke] #1", R([invocation invoke]) &&
	    R([invocation getReturnValue: &intResult]) && intResult == 8)

	/* -[invoke] #2 */
	selector = @selector(invocationTestMethod3::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int i = 1; i <= 16; i++) {
		double d = i;
		[invocation setArgument: &d
				atIndex: i + 1];
	}

	double doubleResult;
	TEST(@"-[invoke] #2", R([invocation invoke]) &&
	    R([invocation getReturnValue: &doubleResult]) &&
	    doubleResult == 8.5)

	/* -[invoke] #3 */
	selector = @selector(invocationTestMethod4::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int i = 1; i <= 16; i++) {
		float f = i;
		double d = i;

		if (i == 1 || i == 10)
			[invocation setArgument: &d
					atIndex: i + 1];
		else
			[invocation setArgument: &f
					atIndex: i + 1];
	}

	float floatResult;
	TEST(@"-[invoke] #3", R([invocation invoke]) &&
	    R([invocation getReturnValue: &floatResult]) && floatResult == 8.5)

	/* Only when encoding long doubles is supported */
	if (strcmp(@encode(double), @encode(long double)) != 0) {
		/* -[invoke] #4 */
		selector = @selector(invocationTestMethod5::::::::::::::::);
		invocation = [OFInvocation invocationWithMethodSignature:
		    [self methodSignatureForSelector: selector]];

		[invocation setArgument: &self
				atIndex: 0];
		[invocation setArgument: &selector
				atIndex: 1];

		for (int i = 1; i <= 16; i++) {
			long double d = i;
			[invocation setArgument: &d
					atIndex: i + 1];
		}

		long double longDoubleResult;
		TEST(@"-[invoke] #4", R([invocation invoke]) &&
		    R([invocation getReturnValue: &longDoubleResult]) &&
		    longDoubleResult == 8.5)
	}

# ifndef __STDC_NO_COMPLEX__
	/* -[invoke] #5 */
	selector = @selector(invocationTestMethod6::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int i = 1; i <= 16; i++) {
		complex float cf = i + 0.5 * i * I;
		complex double cd = i + 0.5 * i * I;

		if (i & 1)
			[invocation setArgument: &cf
					atIndex: i + 1];
		else
			[invocation setArgument: &cd
					atIndex: i + 1];
	}

	complex double complexDoubleResult;
	TEST(@"-[invoke] #5", R([invocation invoke]) &&
	    R([invocation getReturnValue: &complexDoubleResult]) &&
	    complexDoubleResult == 8.5 + 4.25 * I)

	/* Only when encoding complex long doubles is supported */
	if (strcmp(@encode(complex double),
	    @encode(complex long double)) != 0) {
		/* -[invoke] #6 */
		selector = @selector(invocationTestMethod7::::::::::::::::);
		invocation = [OFInvocation invocationWithMethodSignature:
		    [self methodSignatureForSelector: selector]];

		[invocation setArgument: &self
				atIndex: 0];
		[invocation setArgument: &selector
				atIndex: 1];

		for (int i = 1; i <= 16; i++) {
			complex double cd = i + 0.5 * i * I;
			complex float cf = i + 0.5 * i * I;
			complex long double cld = i + 0.5 * i * I;

			switch (i % 3) {
			case 0:
				[invocation setArgument: &cld
						atIndex: i + 1];
				break;
			case 1:
				[invocation setArgument: &cd
						atIndex: i + 1];
				break;
			case 2:
				[invocation setArgument: &cf
						atIndex: i + 1];
				break;
			}
		}

		complex long double complexLongDoubleResult;
		TEST(@"-[invoke] #6", R([invocation invoke]) &&
		    R([invocation getReturnValue: &complexLongDoubleResult]) &&







|
|
|















|
|

|

















|
|
|

|

|


|


















|
|

|



















|
|
|

|

|


|




















|
|
|
|

|


|



|



|







316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int j = 1; j <= 16; j++)
		[invocation setArgument: &j
				atIndex: j + 1];

	int intResult;
	TEST(@"-[invoke] #1", R([invocation invoke]) &&
	    R([invocation getReturnValue: &intResult]) && intResult == 8)

	/* -[invoke] #2 */
	selector = @selector(invocationTestMethod3::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int j = 1; j <= 16; j++) {
		double d = j;
		[invocation setArgument: &d
				atIndex: j + 1];
	}

	double doubleResult;
	TEST(@"-[invoke] #2", R([invocation invoke]) &&
	    R([invocation getReturnValue: &doubleResult]) &&
	    doubleResult == 8.5)

	/* -[invoke] #3 */
	selector = @selector(invocationTestMethod4::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int j = 1; j <= 16; j++) {
		float f = j;
		double d = j;

		if (j == 1 || j == 10)
			[invocation setArgument: &d
					atIndex: j + 1];
		else
			[invocation setArgument: &f
					atIndex: j + 1];
	}

	float floatResult;
	TEST(@"-[invoke] #3", R([invocation invoke]) &&
	    R([invocation getReturnValue: &floatResult]) && floatResult == 8.5)

	/* Only when encoding long doubles is supported */
	if (strcmp(@encode(double), @encode(long double)) != 0) {
		/* -[invoke] #4 */
		selector = @selector(invocationTestMethod5::::::::::::::::);
		invocation = [OFInvocation invocationWithMethodSignature:
		    [self methodSignatureForSelector: selector]];

		[invocation setArgument: &self
				atIndex: 0];
		[invocation setArgument: &selector
				atIndex: 1];

		for (int j = 1; j <= 16; j++) {
			long double d = j;
			[invocation setArgument: &d
					atIndex: j + 1];
		}

		long double longDoubleResult;
		TEST(@"-[invoke] #4", R([invocation invoke]) &&
		    R([invocation getReturnValue: &longDoubleResult]) &&
		    longDoubleResult == 8.5)
	}

# ifndef __STDC_NO_COMPLEX__
	/* -[invoke] #5 */
	selector = @selector(invocationTestMethod6::::::::::::::::);
	invocation = [OFInvocation invocationWithMethodSignature:
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int j = 1; j <= 16; j++) {
		complex float cf = j + 0.5 * j * I;
		complex double cd = j + 0.5 * j * I;

		if (j & 1)
			[invocation setArgument: &cf
					atIndex: j + 1];
		else
			[invocation setArgument: &cd
					atIndex: j + 1];
	}

	complex double complexDoubleResult;
	TEST(@"-[invoke] #5", R([invocation invoke]) &&
	    R([invocation getReturnValue: &complexDoubleResult]) &&
	    complexDoubleResult == 8.5 + 4.25 * I)

	/* Only when encoding complex long doubles is supported */
	if (strcmp(@encode(complex double),
	    @encode(complex long double)) != 0) {
		/* -[invoke] #6 */
		selector = @selector(invocationTestMethod7::::::::::::::::);
		invocation = [OFInvocation invocationWithMethodSignature:
		    [self methodSignatureForSelector: selector]];

		[invocation setArgument: &self
				atIndex: 0];
		[invocation setArgument: &selector
				atIndex: 1];

		for (int j = 1; j <= 16; j++) {
			complex double cd = j + 0.5 * j * I;
			complex float cf = j + 0.5 * j * I;
			complex long double cld = j + 0.5 * j * I;

			switch (j % 3) {
			case 0:
				[invocation setArgument: &cld
						atIndex: j + 1];
				break;
			case 1:
				[invocation setArgument: &cd
						atIndex: j + 1];
				break;
			case 2:
				[invocation setArgument: &cf
						atIndex: j + 1];
				break;
			}
		}

		complex long double complexLongDoubleResult;
		TEST(@"-[invoke] #6", R([invocation invoke]) &&
		    R([invocation getReturnValue: &complexLongDoubleResult]) &&
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int i = 1; i <= 16; i++) {
		__extension__ __int128 i128 = 0xFFFFFFFFFFFFFFFF;
		i128 <<= 64;
		i128 |= i;

		if (i == 1 || i == 5)
			[invocation setArgument: &i
					atIndex: i + 1];
		else
			[invocation setArgument: &i128
					atIndex: i + 1];
	}

	__extension__ __int128 int128Result;
	TEST(@"-[invoke] #7", R([invocation invoke]) &&
	    R([invocation getReturnValue: &int128Result]) &&
	    int128Result == __extension__ ((__int128)0xFFFFFFFFFFFFFFFF << 64) +
	    8)
# endif
#endif

	[pool drain];
}
@end







|


|

|
|
|


|













475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
	    [self methodSignatureForSelector: selector]];

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int j = 1; j <= 16; j++) {
		__extension__ __int128 i128 = 0xFFFFFFFFFFFFFFFF;
		i128 <<= 64;
		i128 |= j;

		if (j == 1 || j == 5)
			[invocation setArgument: &j
					atIndex: j + 1];
		else
			[invocation setArgument: &i128
					atIndex: j + 1];
	}

	__extension__ __int128 int128Result;
	TEST(@"-[invoke] #7", R([invocation invoke]) &&
	    R([invocation getReturnValue: &int128Result]) &&
	    int128Result == __extension__ ((__int128)0xFFFFFFFFFFFFFFFF << 64) +
	    8)
# endif
#endif

	[pool drain];
}
@end

Modified tests/OFListTests.m from [3c7e2e133b] to [9cc03e5fa4].

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158

	[list prependObject: strings[0]];

	loe = [list firstListObject];
	i = 0;
	ok = true;

	for (OFString *obj in list) {
		if (![obj isEqual: loe->object])
			ok = false;

		loe = loe->next;
		i++;
	}

	if ([list count] != i)
		ok = false;

	TEST(@"Fast Enumeration", ok)

	ok = false;
	@try {
		for (OFString *obj in list) {
			(void)obj;

			[list removeListObject: [list lastListObject]];
		}
	} @catch (OFEnumerationMutationException *e) {
		ok = true;
	}

	TEST(@"Detection of mutation during Fast Enumeration", ok)

	[pool drain];
}
@end







|
|













|
|












123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158

	[list prependObject: strings[0]];

	loe = [list firstListObject];
	i = 0;
	ok = true;

	for (OFString *object in list) {
		if (![object isEqual: loe->object])
			ok = false;

		loe = loe->next;
		i++;
	}

	if ([list count] != i)
		ok = false;

	TEST(@"Fast Enumeration", ok)

	ok = false;
	@try {
		for (OFString *object in list) {
			(void)object;

			[list removeListObject: [list lastListObject]];
		}
	} @catch (OFEnumerationMutationException *e) {
		ok = true;
	}

	TEST(@"Detection of mutation during Fast Enumeration", ok)

	[pool drain];
}
@end

Modified utils/ofhttp/OFHTTP.m from [94fff99697] to [19987f61b8].

759
760
761
762
763
764
765
766
767

768
769
770
771
772
773
774
775
776
		} else
			lengthString =
			    OF_LOCALIZED(@"size_unknown", @"unknown");

		if (_verbose) {
			void *pool = objc_autoreleasePoolPush();
			OFDictionary OF_GENERIC(OFString *, OFString *)
			    *headers = [response headers];
			OFEnumerator *keyEnumerator = [headers keyEnumerator];

			OFEnumerator *objectEnumerator =
			    [headers objectEnumerator];
			OFString *key, *object;

			[of_stdout writeString: @"  "];
			[of_stdout writeLine: OF_LOCALIZED(
			    @"info_name_unaligned",
			    @"Name: %[name]",
			    @"name", _currentFileName)];







|
|
>

|







759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
		} else
			lengthString =
			    OF_LOCALIZED(@"size_unknown", @"unknown");

		if (_verbose) {
			void *pool = objc_autoreleasePoolPush();
			OFDictionary OF_GENERIC(OFString *, OFString *)
			    *responseHeaders = [response headers];
			OFEnumerator *keyEnumerator =
			    [responseHeaders keyEnumerator];
			OFEnumerator *objectEnumerator =
			    [responseHeaders objectEnumerator];
			OFString *key, *object;

			[of_stdout writeString: @"  "];
			[of_stdout writeLine: OF_LOCALIZED(
			    @"info_name_unaligned",
			    @"Name: %[name]",
			    @"name", _currentFileName)];