ObjFW  Check-in [3d16a30f41]

Overview
Comment:Rework exceptions.

This mostly removes the argument for the class in which the exception
occurred. As backtraces were recently added for all platforms, the
passed class does not give any extra information on where the exception
occurred anymore.

This also removes a few other arguments which were not too helpful. In
the past, the idea was to pass as many arguments as possible so that it
is easier to find the origin of the exception. However, as backtraces
are a much better way to find the origin, those are not useful anymore
and just make the exception more cumbersome to use. The rule is now to
only pass arguments that might help in recovering from the exception or
provide information that is otherwise not easily accessible.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3d16a30f419ff35e6fa4bd4d2ae330fb85848aaa3f31955a6597297be3c45e07
User & Date: js on 2013-06-22 12:12:36
Other Links: manifest | tags
Context
2013-06-23
11:28
OFAlreadyConnectedException: Make socket optional. check-in: 71f54d7bb6 user: js tags: trunk
2013-06-22
12:12
Rework exceptions. check-in: 3d16a30f41 user: js tags: trunk
2013-06-20
08:13
Add support for MessagePack extensions. check-in: 5ec11e8b56 user: js tags: trunk
Changes

Modified src/OFArray.m from [3ddd9aa2f7] to [1b7e4a8b63].

179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195

	return [super init];
}

- initWithObject: (id)object
{
	if (object == nil) {
		Class c = [self class];
		[self release];
		@throw [OFInvalidArgumentException exceptionWithClass: c];
	}

	return [self initWithObjects: object, nil];
}

- initWithObjects: (id)firstObject, ...
{







<

|







179
180
181
182
183
184
185

186
187
188
189
190
191
192
193
194

	return [super init];
}

- initWithObject: (id)object
{
	if (object == nil) {

		[self release];
		@throw [OFInvalidArgumentException exception];
	}

	return [self initWithObjects: object, nil];
}

- initWithObjects: (id)firstObject, ...
{
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
- (OFArray*)objectsInRange: (of_range_t)range
{
	OFArray *ret;
	id *buffer;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length < [self count])
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (![self isKindOfClass: [OFMutableArray class]])
		return [OFArray_subarray arrayWithArray: self
						  range: range];

	buffer = [self allocMemoryWithSize: sizeof(*buffer)
				     count: range.length];







|







369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
- (OFArray*)objectsInRange: (of_range_t)range
{
	OFArray *ret;
	id *buffer;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length < [self count])
		@throw [OFOutOfRangeException exception];

	if (![self isKindOfClass: [OFMutableArray class]])
		return [OFArray_subarray arrayWithArray: self
						  range: range];

	buffer = [self allocMemoryWithSize: sizeof(*buffer)
				     count: range.length];
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
	void *pool;
	OFMutableString *ret;
	id *objects;
	size_t i, count;
	IMP append;

	if (separator == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	count = [self count];

	if (count == 0)
		return @"";
	if (count == 1)
		return [[self firstObject] performSelector: selector];







|
<







407
408
409
410
411
412
413
414

415
416
417
418
419
420
421
	void *pool;
	OFMutableString *ret;
	id *objects;
	size_t i, count;
	IMP append;

	if (separator == nil)
		@throw [OFInvalidArgumentException exception];


	count = [self count];

	if (count == 0)
		return @"";
	if (count == 1)
		return [[self firstObject] performSelector: selector];
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
		uint8_t type = 0xDC;
		uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)count);

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];
	} else
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	pool = objc_autoreleasePoolPush();

	i = 0;
	enumerator = [self objectEnumerator];
	while ((object = [enumerator nextObject]) != nil) {
		void *pool2 = objc_autoreleasePoolPush();







|







586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
		uint8_t type = 0xDC;
		uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)count);

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];
	} else
		@throw [OFOutOfRangeException exception];

	pool = objc_autoreleasePoolPush();

	i = 0;
	enumerator = [self objectEnumerator];
	while ((object = [enumerator nextObject]) != nil) {
		void *pool2 = objc_autoreleasePoolPush();
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count
{
	of_range_t range = of_range(state->state, count);

	if (range.length > SIZE_MAX - range.location)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (range.location + range.length > [self count])
		range.length = [self count] - range.location;

	[self getObjects: objects
		 inRange: range];








|







673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count
{
	of_range_t range = of_range(state->state, count);

	if (range.length > SIZE_MAX - range.location)
		@throw [OFOutOfRangeException exception];

	if (range.location + range.length > [self count])
		range.length = [self count] - range.location;

	[self getObjects: objects
		 inRange: range];

716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
#endif

- (OFArray*)arrayByAddingObject: (id)object
{
	OFMutableArray *ret;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	ret = [[self mutableCopy] autorelease];

	[ret addObject: object];
	[ret makeImmutable];

	return ret;







|
<







714
715
716
717
718
719
720
721

722
723
724
725
726
727
728
#endif

- (OFArray*)arrayByAddingObject: (id)object
{
	OFMutableArray *ret;

	if (object == nil)
		@throw [OFInvalidArgumentException exception];


	ret = [[self mutableCopy] autorelease];

	[ret addObject: object];
	[ret makeImmutable];

	return ret;
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
	[super dealloc];
}

- (id)nextObject
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: array];

	if (position < count)
		return [array objectAtIndex: position++];

	return nil;
}

- (void)reset
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: array];

	position = 0;
}
@end







<
|











<
|




849
850
851
852
853
854
855

856
857
858
859
860
861
862
863
864
865
866
867

868
869
870
871
872
	[super dealloc];
}

- (id)nextObject
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException

		    exceptionWithObject: array];

	if (position < count)
		return [array objectAtIndex: position++];

	return nil;
}

- (void)reset
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException

		    exceptionWithObject: array];

	position = 0;
}
@end

Modified src/OFArray_adjacent.m from [ad2d762abe] to [213aaaa47c].

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

- initWithObject: (id)object
{
	self = [self init];

	@try {
		if (object == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]];

		[_array addItem: &object];
		[object retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}







|
<







49
50
51
52
53
54
55
56

57
58
59
60
61
62
63

- initWithObject: (id)object
{
	self = [self init];

	@try {
		if (object == nil)
			@throw [OFInvalidArgumentException exception];


		[_array addItem: &object];
		[object retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
			if (objects[i] == nil)
				ok = false;

			[objects[i] retain];
		}

		if (!ok)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]];

		[_array addItems: objects
			   count: count];
	} @catch (id e) {
		size_t i;

		for (i = 0; i < count; i++)







|
<







143
144
145
146
147
148
149
150

151
152
153
154
155
156
157
			if (objects[i] == nil)
				ok = false;

			[objects[i] retain];
		}

		if (!ok)
			@throw [OFInvalidArgumentException exception];


		[_array addItems: objects
			   count: count];
	} @catch (id e) {
		size_t i;

		for (i = 0; i < count; i++)
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		OFXMLElement *child;

		if ((![[element name] isEqual: @"OFArray"] &&
		    ![[element name] isEqual: @"OFMutableArray"]) ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		enumerator = [[element elementsForNamespace:
		    OF_SERIALIZATION_NS] objectEnumerator];

		while ((child = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			id object;







|
<
<







172
173
174
175
176
177
178
179


180
181
182
183
184
185
186
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		OFXMLElement *child;

		if ((![[element name] isEqual: @"OFArray"] &&
		    ![[element name] isEqual: @"OFMutableArray"]) ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		enumerator = [[element elementsForNamespace:
		    OF_SERIALIZATION_NS] objectEnumerator];

		while ((child = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			id object;
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
254
255
256
257
258
259
- (id)objectAtIndex: (size_t)index
{
	id ret;

	@try {
		ret = *((id*)[_array itemAtIndex: index]);
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];
	}

	return ret;
}

- (id)objectAtIndexedSubscript: (size_t)index
{
	id ret;

	@try {
		ret = *((id*)[_array itemAtIndex: index]);
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];
	}

	return ret;
}

- (void)getObjects: (id*)buffer
	   inRange: (of_range_t)range
{
	id *objects = [_array items];
	size_t i, count = [_array count];

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > count)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	for (i = 0; i < range.length; i++)
		buffer[i] = objects[range.location + i];
}

- (size_t)indexOfObject: (id)object
{







|












|













|







214
215
216
217
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
254
255
- (id)objectAtIndex: (size_t)index
{
	id ret;

	@try {
		ret = *((id*)[_array itemAtIndex: index]);
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exception];
	}

	return ret;
}

- (id)objectAtIndexedSubscript: (size_t)index
{
	id ret;

	@try {
		ret = *((id*)[_array itemAtIndex: index]);
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exception];
	}

	return ret;
}

- (void)getObjects: (id*)buffer
	   inRange: (of_range_t)range
{
	id *objects = [_array items];
	size_t i, count = [_array count];

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > count)
		@throw [OFOutOfRangeException exception];

	for (i = 0; i < range.length; i++)
		buffer[i] = objects[range.location + i];
}

- (size_t)indexOfObject: (id)object
{
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
}


- (OFArray*)objectsInRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > [_array count])
		@throw [OFOutOfRangeException
		    exceptionWithClass: [self class]];

	if ([self isKindOfClass: [OFMutableArray class]])
		return [OFArray
		    arrayWithObjects: (id*)[_array items] + range.location
			       count: range.length];

	return [OFArray_adjacentSubarray arrayWithArray: self







|
<







288
289
290
291
292
293
294
295

296
297
298
299
300
301
302
}


- (OFArray*)objectsInRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > [_array count])
		@throw [OFOutOfRangeException exception];


	if ([self isKindOfClass: [OFMutableArray class]])
		return [OFArray
		    arrayWithObjects: (id*)[_array items] + range.location
			       count: range.length];

	return [OFArray_adjacentSubarray arrayWithArray: self

Modified src/OFArray_subarray.m from [4d0eadf9ff] to [83e4ee3b65].

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
	return _range.length;
}

- (id)objectAtIndex: (size_t)index
{
	if (index >= _range.length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	return [_array objectAtIndex: index + _range.location];
}

- (void)getObjects: (id*)buffer
	   inRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _range.length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	range.location += _range.location;

	return [_array getObjects: buffer
			  inRange: range];
}








|









|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
	return _range.length;
}

- (id)objectAtIndex: (size_t)index
{
	if (index >= _range.length)
		@throw [OFOutOfRangeException exception];

	return [_array objectAtIndex: index + _range.location];
}

- (void)getObjects: (id*)buffer
	   inRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _range.length)
		@throw [OFOutOfRangeException exception];

	range.location += _range.location;

	return [_array getObjects: buffer
			  inRange: range];
}

108
109
110
111
112
113
114
115
116
117
118
119
120
121
	return index;
}

- (OFArray*)objectsInRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _range.length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	range.location += _range.location;

	return [_array objectsInRange: range];
}
@end







|






108
109
110
111
112
113
114
115
116
117
118
119
120
121
	return index;
}

- (OFArray*)objectsInRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _range.length)
		@throw [OFOutOfRangeException exception];

	range.location += _range.location;

	return [_array objectsInRange: range];
}
@end

Modified src/OFCondition.m from [ece7460b2e] to [6bdb91bf4a].

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
}

- (void)dealloc
{
	if (_conditionInitialized)
		if (!of_condition_free(&_condition))
			@throw [OFConditionStillWaitingException
			    exceptionWithClass: [self class]
				     condition: self];

	[super dealloc];
}

- (void)wait
{
	if (!of_condition_wait(&_condition, &_mutex))
		@throw [OFConditionWaitFailedException
		    exceptionWithClass: [self class]
			     condition: self];
}

- (bool)waitForTimeInterval: (double)timeInterval
{
	return of_condition_timed_wait(&_condition, &_mutex, timeInterval);
}

- (bool)waitUntilDate: (OFDate*)date
{
	return of_condition_timed_wait(&_condition, &_mutex,
	    [date timeIntervalSinceNow]);
}

- (void)signal
{
	if (!of_condition_signal(&_condition))
		@throw [OFConditionSignalFailedException
		    exceptionWithClass: [self class]
			     condition: self];
}

- (void)broadcast
{
	if (!of_condition_broadcast(&_condition))
		@throw [OFConditionBroadcastFailedException
		    exceptionWithClass: [self class]
			     condition: self];
}
@end







<
|








<
|

















<
|






<
|


47
48
49
50
51
52
53

54
55
56
57
58
59
60
61
62

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

81
82
83
84
85
86
87

88
89
90
}

- (void)dealloc
{
	if (_conditionInitialized)
		if (!of_condition_free(&_condition))
			@throw [OFConditionStillWaitingException

			    exceptionWithCondition: self];

	[super dealloc];
}

- (void)wait
{
	if (!of_condition_wait(&_condition, &_mutex))
		@throw [OFConditionWaitFailedException

		    exceptionWithCondition: self];
}

- (bool)waitForTimeInterval: (double)timeInterval
{
	return of_condition_timed_wait(&_condition, &_mutex, timeInterval);
}

- (bool)waitUntilDate: (OFDate*)date
{
	return of_condition_timed_wait(&_condition, &_mutex,
	    [date timeIntervalSinceNow]);
}

- (void)signal
{
	if (!of_condition_signal(&_condition))
		@throw [OFConditionSignalFailedException

		    exceptionWithCondition: self];
}

- (void)broadcast
{
	if (!of_condition_broadcast(&_condition))
		@throw [OFConditionBroadcastFailedException

		    exceptionWithCondition: self];
}
@end

Modified src/OFConstantString.m from [8447dff468] to [7d49a47280].

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
		struct of_string_utf8_ivars *ivars;

		if (object_getClass(self) == [OFString_const class])
			return;

		if ((ivars = calloc(1, sizeof(*ivars))) == NULL)
			@throw [OFOutOfMemoryException
			    exceptionWithClass: [self class]
				 requestedSize: sizeof(*ivars)];

		ivars->cString = _cString;
		ivars->cStringLength = _cStringLength;

		switch (of_string_utf8_check(ivars->cString,
		    ivars->cStringLength,
			&ivars->length)) {
			case 1:
				ivars->isUTF8 = true;
				break;
			case -1:
				free(ivars);
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
		}

		_cString = (char*)ivars;
		object_setClass(self, [OFString_const class]);
	}
}








<
|












|
<







150
151
152
153
154
155
156

157
158
159
160
161
162
163
164
165
166
167
168
169
170

171
172
173
174
175
176
177
		struct of_string_utf8_ivars *ivars;

		if (object_getClass(self) == [OFString_const class])
			return;

		if ((ivars = calloc(1, sizeof(*ivars))) == NULL)
			@throw [OFOutOfMemoryException

			    exceptionWithRequestedSize: sizeof(*ivars)];

		ivars->cString = _cString;
		ivars->cStringLength = _cStringLength;

		switch (of_string_utf8_check(ivars->cString,
		    ivars->cStringLength,
			&ivars->length)) {
			case 1:
				ivars->isUTF8 = true;
				break;
			case -1:
				free(ivars);
				@throw [OFInvalidEncodingException exception];

		}

		_cString = (char*)ivars;
		object_setClass(self, [OFString_const class]);
	}
}

Modified src/OFCountedSet_hashtable.m from [ce18d3e849] to [4ab3538671].

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
171
172
173
174
		void *pool = objc_autoreleasePoolPush();
		OFArray *objects;
		OFEnumerator *enumerator;
		OFXMLElement *objectElement;

		if (![[element name] isEqual: @"OFCountedSet"] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		objects = [element elementsForName: @"object"
					 namespace: OF_SERIALIZATION_NS];

		enumerator = [objects objectEnumerator];
		while ((objectElement = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			OFXMLElement *object;
			OFXMLAttribute *count_;
			size_t count;

			object = [[objectElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];
			count_ = [objectElement attributeForName: @"count"];

			if (object == nil || count_ == nil)
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];

			count = (size_t)[[count_ stringValue] decimalValue];

			[_mapTable setValue: (void*)(uintptr_t)count
				     forKey: [object objectByDeserializing]];

			objc_autoreleasePoolPop(pool2);







|
<
<
















|
<







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
171
		void *pool = objc_autoreleasePoolPush();
		OFArray *objects;
		OFEnumerator *enumerator;
		OFXMLElement *objectElement;

		if (![[element name] isEqual: @"OFCountedSet"] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		objects = [element elementsForName: @"object"
					 namespace: OF_SERIALIZATION_NS];

		enumerator = [objects objectEnumerator];
		while ((objectElement = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			OFXMLElement *object;
			OFXMLAttribute *count_;
			size_t count;

			object = [[objectElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];
			count_ = [objectElement attributeForName: @"count"];

			if (object == nil || count_ == nil)
				@throw [OFInvalidFormatException exception];


			count = (size_t)[[count_ stringValue] decimalValue];

			[_mapTable setValue: (void*)(uintptr_t)count
				     forKey: [object objectByDeserializing]];

			objc_autoreleasePoolPop(pool2);
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
	@try {
		[_mapTable enumerateKeysAndValuesUsingBlock:
		    ^ (void *key, void *value, bool *stop) {
			block(key, (size_t)(uintptr_t)value, stop);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: self];
	}
}
#endif

- (void)addObject: (id)object
{
	size_t count = (size_t)(uintptr_t)[_mapTable valueForKey: object];

	if (SIZE_MAX - count < 1 || UINTPTR_MAX - count < 1)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	[_mapTable setValue: (void*)(uintptr_t)(count + 1)
		     forKey: object];
}

- (void)removeObject: (id)object
{







<
|









|







192
193
194
195
196
197
198

199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
	@try {
		[_mapTable enumerateKeysAndValuesUsingBlock:
		    ^ (void *key, void *value, bool *stop) {
			block(key, (size_t)(uintptr_t)value, stop);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException

		    exceptionWithObject: self];
	}
}
#endif

- (void)addObject: (id)object
{
	size_t count = (size_t)(uintptr_t)[_mapTable valueForKey: object];

	if (SIZE_MAX - count < 1 || UINTPTR_MAX - count < 1)
		@throw [OFOutOfRangeException exception];

	[_mapTable setValue: (void*)(uintptr_t)(count + 1)
		     forKey: object];
}

- (void)removeObject: (id)object
{

Modified src/OFDataArray+MessagePackValue.m from [b3b35d004c] to [d14fde3bb9].

564
565
566
567
568
569
570
571
572
573
574
575
576
- (id)messagePackValue
{
	size_t count = [self count];
	id object;

	if (parse_object([self items], count, &object) != count ||
	    object == nil)
		@throw [OFInvalidFormatException
		    exceptionWithClass: [self class]];

	return object;
}
@end







|
<




564
565
566
567
568
569
570
571

572
573
574
575
- (id)messagePackValue
{
	size_t count = [self count];
	id object;

	if (parse_object([self items], count, &object) != count ||
	    object == nil)
		@throw [OFInvalidFormatException exception];


	return object;
}
@end

Modified src/OFDataArray.m from [c782595990] to [d222b0db89].

118
119
120
121
122
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

- initWithItemSize: (size_t)itemSize
	  capacity: (size_t)capacity
{
	self = [super init];

	if (itemSize == 0) {
		Class c = [self class];
		[self release];
		@throw [OFInvalidArgumentException exceptionWithClass: c
							     selector: _cmd];
	}

	_items = [self allocMemoryWithSize: itemSize
				     count: capacity];

	_itemSize = itemSize;
	_capacity = capacity;

	return self;
}

- initWithContentsOfFile: (OFString*)path
{
	@try {
		OFFile *file = [[OFFile alloc] initWithPath: path
						       mode: @"rb"];
		off_t size = [OFFile sizeOfFileAtPath: path];

		if (size > SIZE_MAX)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		self = [self initWithItemSize: 1
				     capacity: (size_t)size];

		@try {
			size_t pageSize = [OFSystemInfo pageSize];
			char *buffer = [self allocMemoryWithSize: pageSize];







<

|
<



















|
<







118
119
120
121
122
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

- initWithItemSize: (size_t)itemSize
	  capacity: (size_t)capacity
{
	self = [super init];

	if (itemSize == 0) {

		[self release];
		@throw [OFInvalidArgumentException exception];

	}

	_items = [self allocMemoryWithSize: itemSize
				     count: capacity];

	_itemSize = itemSize;
	_capacity = capacity;

	return self;
}

- initWithContentsOfFile: (OFString*)path
{
	@try {
		OFFile *file = [[OFFile alloc] initWithPath: path
						       mode: @"rb"];
		off_t size = [OFFile sizeOfFileAtPath: path];

		if (size > SIZE_MAX)
			@throw [OFOutOfRangeException exception];


		self = [self initWithItemSize: 1
				     capacity: (size_t)size];

		@try {
			size_t pageSize = [OFSystemInfo pageSize];
			char *buffer = [self allocMemoryWithSize: pageSize];
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
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
254
255
256
257
258
259
260
261
262
263
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

	client = [OFHTTPClient client];
	request = [OFHTTPRequest requestWithURL: URL];
	reply = [client performRequest: request];

	if ([reply statusCode] != 200)
		@throw [OFHTTPRequestFailedException
		    exceptionWithClass: [request class]
			       request: request
				 reply: reply];

	/*
	 * TODO: This can be optimized by allocating a data array with the
	 * capacity from the Content-Length header.
	 */
	self = [[reply readDataArrayTillEndOfStream] retain];

	headers = [reply headers];
	if ((contentLength = [headers objectForKey: @"Content-Length"]) != nil)
		if ([self count] != (size_t)[contentLength decimalValue])
			@throw [OFTruncatedDataException
			    exceptionWithClass: [self class]];
#else
	@throw [OFUnsupportedProtocolException exceptionWithClass: c];
#endif

	objc_autoreleasePoolPop(pool);

	return self;
}

- initWithStringRepresentation: (OFString*)string
{
	self = [super init];

	@try {
		const char *cString;
		size_t i;

		_itemSize = 1;
		_count = [string
		    cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII];

		if (_count % 2 != 0)
			@throw [OFInvalidFormatException
			    exceptionWithClass: [self class]];

		_count /= 2;
		cString = [string
		    cStringWithEncoding: OF_STRING_ENCODING_ASCII];
		_items = [self allocMemoryWithSize: _count];

		for (i = 0; i < _count; i++) {
			uint8_t c1 = cString[2 * i];
			uint8_t c2 = cString[2 * i + 1];
			uint8_t byte;

			if (c1 >= '0' && c1 <= '9')
				byte = (c1 - '0') << 4;
			else if (c1 >= 'a' && c1 <= 'f')
				byte = (c1 - 'a' + 10) << 4;
			else if (c1 >= 'A' && c1 <= 'F')
				byte = (c1 - 'A' + 10) << 4;
			else
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];

			if (c2 >= '0' && c2 <= '9')
				byte |= c2 - '0';
			else if (c2 >= 'a' && c2 <= 'f')
				byte |= c2 - 'a' + 10;
			else if (c2 >= 'A' && c2 <= 'F')
				byte |= c2 - 'A' + 10;
			else
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];

			_items[i] = byte;
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithBase64EncodedString: (OFString*)string
{
	self = [self initWithItemSize: 1
			     capacity: [string length] / 3];

	@try {
		if (!of_base64_decode(self, [string cStringWithEncoding:
		    OF_STRING_ENCODING_ASCII], [string
		    cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII])) {
			Class c = [self class];
			[self release];
			@throw [OFInvalidFormatException exceptionWithClass: c];
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {
		void *pool = objc_autoreleasePoolPush();
		OFString *stringValue;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		stringValue = [element stringValue];

		self = [self initWithBase64EncodedString: stringValue];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {







<
|











|
<

|




















|
<


















|
<








|
<



















|
<
<
|
<
















|
<
<







199
200
201
202
203
204
205

206
207
208
209
210
211
212
213
214
215
216
217
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
254
255
256
257
258
259
260

261
262
263
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

	client = [OFHTTPClient client];
	request = [OFHTTPRequest requestWithURL: URL];
	reply = [client performRequest: request];

	if ([reply statusCode] != 200)
		@throw [OFHTTPRequestFailedException

		    exceptionWithRequest: request
				 reply: reply];

	/*
	 * TODO: This can be optimized by allocating a data array with the
	 * capacity from the Content-Length header.
	 */
	self = [[reply readDataArrayTillEndOfStream] retain];

	headers = [reply headers];
	if ((contentLength = [headers objectForKey: @"Content-Length"]) != nil)
		if ([self count] != (size_t)[contentLength decimalValue])
			@throw [OFTruncatedDataException exception];

#else
	@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
#endif

	objc_autoreleasePoolPop(pool);

	return self;
}

- initWithStringRepresentation: (OFString*)string
{
	self = [super init];

	@try {
		const char *cString;
		size_t i;

		_itemSize = 1;
		_count = [string
		    cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII];

		if (_count % 2 != 0)
			@throw [OFInvalidFormatException exception];


		_count /= 2;
		cString = [string
		    cStringWithEncoding: OF_STRING_ENCODING_ASCII];
		_items = [self allocMemoryWithSize: _count];

		for (i = 0; i < _count; i++) {
			uint8_t c1 = cString[2 * i];
			uint8_t c2 = cString[2 * i + 1];
			uint8_t byte;

			if (c1 >= '0' && c1 <= '9')
				byte = (c1 - '0') << 4;
			else if (c1 >= 'a' && c1 <= 'f')
				byte = (c1 - 'a' + 10) << 4;
			else if (c1 >= 'A' && c1 <= 'F')
				byte = (c1 - 'A' + 10) << 4;
			else
				@throw [OFInvalidFormatException exception];


			if (c2 >= '0' && c2 <= '9')
				byte |= c2 - '0';
			else if (c2 >= 'a' && c2 <= 'f')
				byte |= c2 - 'a' + 10;
			else if (c2 >= 'A' && c2 <= 'F')
				byte |= c2 - 'A' + 10;
			else
				@throw [OFInvalidFormatException exception];


			_items[i] = byte;
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithBase64EncodedString: (OFString*)string
{
	self = [self initWithItemSize: 1
			     capacity: [string length] / 3];

	@try {
		if (!of_base64_decode(self, [string cStringWithEncoding:
		    OF_STRING_ENCODING_ASCII], [string
		    cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII]))


			@throw [OFInvalidFormatException exception];

	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {
		void *pool = objc_autoreleasePoolPush();
		OFString *stringValue;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		stringValue = [element stringValue];

		self = [self initWithBase64EncodedString: stringValue];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
{
	return _items;
}

- (void*)itemAtIndex: (size_t)index
{
	if (index >= _count)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	return _items + index * _itemSize;
}

- (void*)firstItem
{
	if (_items == NULL || _count == 0)







|







333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
{
	return _items;
}

- (void*)itemAtIndex: (size_t)index
{
	if (index >= _count)
		@throw [OFOutOfRangeException exception];

	return _items + index * _itemSize;
}

- (void*)firstItem
{
	if (_items == NULL || _count == 0)
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384

	return _items + (_count - 1) * _itemSize;
}

- (void)addItem: (const void*)item
{
	if (SIZE_MAX - _count < 1)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (_count + 1 > _capacity) {
		_items = [self resizeMemory: _items
				       size: _itemSize
				      count: _count + 1];
		_capacity = _count + 1;
	}







|







357
358
359
360
361
362
363
364
365
366
367
368
369
370
371

	return _items + (_count - 1) * _itemSize;
}

- (void)addItem: (const void*)item
{
	if (SIZE_MAX - _count < 1)
		@throw [OFOutOfRangeException exception];

	if (_count + 1 > _capacity) {
		_items = [self resizeMemory: _items
				       size: _itemSize
				      count: _count + 1];
		_capacity = _count + 1;
	}
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
		    count: 1];
}

- (void)addItems: (const void*)items
	   count: (size_t)count
{
	if (count > SIZE_MAX - count)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (_count + count > _capacity) {
		_items = [self resizeMemory: _items
				       size: _itemSize
				      count: _count + count];
		_capacity = _count + count;
	}

	memcpy(_items + _count * _itemSize, items, count * _itemSize);
	_count += count;
}

- (void)insertItems: (const void*)items
	    atIndex: (size_t)index
	      count: (size_t)count
{
	if (count > SIZE_MAX - _count || index > _count)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (_count + count > _capacity) {
		_items = [self resizeMemory: _items
				       size: _itemSize
				      count: _count + count];
		_capacity = _count + count;
	}







|

















|







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
		    count: 1];
}

- (void)addItems: (const void*)items
	   count: (size_t)count
{
	if (count > SIZE_MAX - count)
		@throw [OFOutOfRangeException exception];

	if (_count + count > _capacity) {
		_items = [self resizeMemory: _items
				       size: _itemSize
				      count: _count + count];
		_capacity = _count + count;
	}

	memcpy(_items + _count * _itemSize, items, count * _itemSize);
	_count += count;
}

- (void)insertItems: (const void*)items
	    atIndex: (size_t)index
	      count: (size_t)count
{
	if (count > SIZE_MAX - _count || index > _count)
		@throw [OFOutOfRangeException exception];

	if (_count + count > _capacity) {
		_items = [self resizeMemory: _items
				       size: _itemSize
				      count: _count + count];
		_capacity = _count + count;
	}
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
	[self removeItemsInRange: of_range(index, 1)];
}

- (void)removeItemsInRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _count)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	memmove(_items + range.location * _itemSize,
	    _items + (range.location + range.length) * _itemSize,
	    (_count - range.location - range.length) * _itemSize);

	_count -= range.length;
	@try {







|







426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
	[self removeItemsInRange: of_range(index, 1)];
}

- (void)removeItemsInRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _count)
		@throw [OFOutOfRangeException exception];

	memmove(_items + range.location * _itemSize,
	    _items + (range.location + range.length) * _itemSize,
	    (_count - range.location - range.length) * _itemSize);

	_count -= range.length;
	@try {
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFDataArray *dataArray;
	int comparison;
	size_t count, minCount;

	if (![object isKindOfClass: [OFDataArray class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	dataArray = (OFDataArray*)object;

	if ([dataArray itemSize] != _itemSize)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	count = [dataArray count];
	minCount = (_count > count ? count : _count);

	if ((comparison = memcmp(_items, [dataArray items],
	    minCount * _itemSize)) == 0) {
		if (_count > count)







|
|
<



|
<
<







504
505
506
507
508
509
510
511
512

513
514
515
516


517
518
519
520
521
522
523
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFDataArray *dataArray;
	int comparison;
	size_t count, minCount;

	if (![object isKindOfClass: [OFDataArray class]])
		@throw [OFInvalidArgumentException exception];


	dataArray = (OFDataArray*)object;

	if ([dataArray itemSize] != _itemSize)
		@throw [OFInvalidArgumentException exception];



	count = [dataArray count];
	minCount = (_count > count ? count : _count);

	if ((comparison = memcmp(_items, [dataArray items],
	    minCount * _itemSize)) == 0) {
		if (_count > count)
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool;
	OFXMLElement *element;

	if (_itemSize != 1)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	pool = objc_autoreleasePoolPush();
	element = [OFXMLElement
	    elementWithName: [self className]
		  namespace: OF_SERIALIZATION_NS
		stringValue: of_base64_encode(_items, _count * _itemSize)];

	[element retain];

	objc_autoreleasePoolPop(pool);

	return [element autorelease];
}

- (OFDataArray*)messagePackRepresentation
{
	OFDataArray *data;

	if (_itemSize != 1)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	if (_count <= UINT8_MAX) {
		uint8_t type = 0xC4;
		uint8_t tmp = (uint8_t)_count;

		data = [OFDataArray dataArrayWithItemSize: 1
						 capacity: _count + 2];







|
<



















|
<
<







603
604
605
606
607
608
609
610

611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630


631
632
633
634
635
636
637

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool;
	OFXMLElement *element;

	if (_itemSize != 1)
		@throw [OFInvalidArgumentException exception];


	pool = objc_autoreleasePoolPush();
	element = [OFXMLElement
	    elementWithName: [self className]
		  namespace: OF_SERIALIZATION_NS
		stringValue: of_base64_encode(_items, _count * _itemSize)];

	[element retain];

	objc_autoreleasePoolPop(pool);

	return [element autorelease];
}

- (OFDataArray*)messagePackRepresentation
{
	OFDataArray *data;

	if (_itemSize != 1)
		@throw [OFInvalidArgumentException exception];



	if (_count <= UINT8_MAX) {
		uint8_t type = 0xC4;
		uint8_t tmp = (uint8_t)_count;

		data = [OFDataArray dataArrayWithItemSize: 1
						 capacity: _count + 2];
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
		data = [OFDataArray dataArrayWithItemSize: 1
						 capacity: _count + 5];

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];
	} else
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	[data addItems: _items
		 count: _count];

	return data;
}
@end







|







655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
		data = [OFDataArray dataArrayWithItemSize: 1
						 capacity: _count + 5];

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];
	} else
		@throw [OFOutOfRangeException exception];

	[data addItems: _items
		 count: _count];

	return data;
}
@end
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
}

- (void)addItem: (const void*)item
{
	size_t size, lastPageByte;

	if (SIZE_MAX - _count < 1 || _count + 1 > SIZE_MAX / _itemSize)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	lastPageByte = [OFSystemInfo pageSize] - 1;
	size = ((_count + 1) * _itemSize + lastPageByte) & ~lastPageByte;

	if (size > _capacity) {
		_items = [self resizeMemory: _items
				       size: size];







|







681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
}

- (void)addItem: (const void*)item
{
	size_t size, lastPageByte;

	if (SIZE_MAX - _count < 1 || _count + 1 > SIZE_MAX / _itemSize)
		@throw [OFOutOfRangeException exception];

	lastPageByte = [OFSystemInfo pageSize] - 1;
	size = ((_count + 1) * _itemSize + lastPageByte) & ~lastPageByte;

	if (size > _capacity) {
		_items = [self resizeMemory: _items
				       size: size];
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737

- (void)addItems: (const void*)items
	   count: (size_t)count
{
	size_t size, lastPageByte;

	if (count > SIZE_MAX - _count || _count + count > SIZE_MAX / _itemSize)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	lastPageByte = [OFSystemInfo pageSize] - 1;
	size = ((_count + count) * _itemSize + lastPageByte) & ~lastPageByte;

	if (size > _capacity) {
		_items = [self resizeMemory: _items
				       size: size];







|







704
705
706
707
708
709
710
711
712
713
714
715
716
717
718

- (void)addItems: (const void*)items
	   count: (size_t)count
{
	size_t size, lastPageByte;

	if (count > SIZE_MAX - _count || _count + count > SIZE_MAX / _itemSize)
		@throw [OFOutOfRangeException exception];

	lastPageByte = [OFSystemInfo pageSize] - 1;
	size = ((_count + count) * _itemSize + lastPageByte) & ~lastPageByte;

	if (size > _capacity) {
		_items = [self resizeMemory: _items
				       size: size];
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
	    atIndex: (size_t)index
	      count: (size_t)count
{
	size_t size, lastPageByte;

	if (count > SIZE_MAX - _count || index > _count ||
	    _count + count > SIZE_MAX / _itemSize)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	lastPageByte = [OFSystemInfo pageSize] - 1;
	size = ((_count + count) * _itemSize + lastPageByte) & ~lastPageByte;

	if (size > _capacity) {
		_items = [self resizeMemory: _items
				       size: size];







|







729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
	    atIndex: (size_t)index
	      count: (size_t)count
{
	size_t size, lastPageByte;

	if (count > SIZE_MAX - _count || index > _count ||
	    _count + count > SIZE_MAX / _itemSize)
		@throw [OFOutOfRangeException exception];

	lastPageByte = [OFSystemInfo pageSize] - 1;
	size = ((_count + count) * _itemSize + lastPageByte) & ~lastPageByte;

	if (size > _capacity) {
		_items = [self resizeMemory: _items
				       size: size];
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787

- (void)removeItemsInRange: (of_range_t)range
{
	size_t pageSize, size;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _count)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	memmove(_items + range.location * _itemSize,
	    _items + (range.location + range.length) * _itemSize,
	    (_count - range.location - range.length) * _itemSize);

	_count -= range.length;
	pageSize = [OFSystemInfo pageSize];







|







754
755
756
757
758
759
760
761
762
763
764
765
766
767
768

- (void)removeItemsInRange: (of_range_t)range
{
	size_t pageSize, size;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _count)
		@throw [OFOutOfRangeException exception];

	memmove(_items + range.location * _itemSize,
	    _items + (range.location + range.length) * _itemSize,
	    (_count - range.location - range.length) * _itemSize);

	_count -= range.length;
	pageSize = [OFSystemInfo pageSize];

Modified src/OFDate.m from [ce6ad02444] to [d90c31fbc5].

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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

#ifdef HAVE_GMTIME_R
# define GMTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException				\
		    exceptionWithClass: [self class]];			\
									\
	if (gmtime_r(&seconds, &tm) == NULL)				\
		@throw [OFOutOfRangeException				\
		    exceptionWithClass: [self class]];			\
									\
	return tm.field;
# define LOCALTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException				\
		    exceptionWithClass: [self class]];			\
									\
	if (localtime_r(&seconds, &tm) == NULL)				\
		@throw [OFOutOfRangeException				\
		    exceptionWithClass: [self class]];			\
									\
	return tm.field;
#else
# ifdef OF_HAVE_THREADS
#  define GMTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm *tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException				\
		    exceptionWithClass: [self class]];			\
									\
	[mutex lock];							\
									\
	@try {								\
		if ((tm = gmtime(&seconds)) == NULL)			\
			@throw [OFOutOfRangeException			\
			    exceptionWithClass: [self class]];		\
									\
		return tm->field;					\
	} @finally {							\
		[mutex unlock];						\
	}
#  define LOCALTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm *tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException				\
		    exceptionWithClass: [self class]];			\
									\
	[mutex lock];							\
									\
	@try {								\
		if ((tm = localtime(&seconds)) == NULL)			\
			@throw [OFOutOfRangeException			\
			    exceptionWithClass: [self class]];		\
									\
		return tm->field;					\
	} @finally {							\
		[mutex unlock];						\
	}
# else
#  define GMTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm *tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException				\
		    exceptionWithClass: [self class]];			\
									\
	if ((tm = gmtime(&seconds)) == NULL)				\
		@throw [OFOutOfRangeException				\
		    exceptionWithClass: [self class]];			\
									\
	return tm->field;
#  define LOCALTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm *tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException				\
		    exceptionWithClass: [self class]];			\
									\
	if ((tm = localtime(&seconds)) == NULL)				\
		@throw [OFOutOfRangeException				\
		    exceptionWithClass: [self class]];			\
									\
	return tm->field;
# endif
#endif

static int month_to_day_of_year[12] = {
	0,







|
<


|
<







|
<


|
<









|
<





|
<










|
<





|
<











|
<


|
<







|
<


|
<







50
51
52
53
54
55
56
57

58
59
60

61
62
63
64
65
66
67
68

69
70
71

72
73
74
75
76
77
78
79
80
81

82
83
84
85
86
87

88
89
90
91
92
93
94
95
96
97
98

99
100
101
102
103
104

105
106
107
108
109
110
111
112
113
114
115
116

117
118
119

120
121
122
123
124
125
126
127

128
129
130

131
132
133
134
135
136
137

#ifdef HAVE_GMTIME_R
# define GMTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException exception];		\

									\
	if (gmtime_r(&seconds, &tm) == NULL)				\
		@throw [OFOutOfRangeException exception];		\

									\
	return tm.field;
# define LOCALTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException exception];		\

									\
	if (localtime_r(&seconds, &tm) == NULL)				\
		@throw [OFOutOfRangeException exception];		\

									\
	return tm.field;
#else
# ifdef OF_HAVE_THREADS
#  define GMTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm *tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException exception];		\

									\
	[mutex lock];							\
									\
	@try {								\
		if ((tm = gmtime(&seconds)) == NULL)			\
			@throw [OFOutOfRangeException exception];	\

									\
		return tm->field;					\
	} @finally {							\
		[mutex unlock];						\
	}
#  define LOCALTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm *tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException exception];		\

									\
	[mutex lock];							\
									\
	@try {								\
		if ((tm = localtime(&seconds)) == NULL)			\
			@throw [OFOutOfRangeException exception];	\

									\
		return tm->field;					\
	} @finally {							\
		[mutex unlock];						\
	}
# else
#  define GMTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm *tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException exception];		\

									\
	if ((tm = gmtime(&seconds)) == NULL)				\
		@throw [OFOutOfRangeException exception];		\

									\
	return tm->field;
#  define LOCALTIME_RET(field)						\
	time_t seconds = (time_t)_seconds;				\
	struct tm *tm;							\
									\
	if (seconds != floor(_seconds))					\
		@throw [OFOutOfRangeException exception];		\

									\
	if ((tm = localtime(&seconds)) == NULL)				\
		@throw [OFOutOfRangeException exception];		\

									\
	return tm->field;
# endif
#endif

static int month_to_day_of_year[12] = {
	0,
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
	@try {
		struct tm tm = {};

		tm.tm_isdst = -1;

		if (of_strptime([string UTF8String], [format UTF8String],
		    &tm) == NULL)
			@throw [OFInvalidFormatException
			    exceptionWithClass: [self class]];

		/* Years */
		_seconds = (int64_t)(tm.tm_year - 70) * 31536000;
		/* Days of leap years, excluding the year to look at */
		_seconds += (((tm.tm_year + 1899) / 4) - 492) * 86400;
		_seconds -= (((tm.tm_year + 1899) / 100) - 19) * 86400;
		_seconds += (((tm.tm_year + 1899) / 400) - 4) * 86400;
		/* Leap day */
		if (tm.tm_mon >= 2 && (((tm.tm_year + 1900) % 4 == 0 &&
		    (tm.tm_year + 1900) % 100 != 0) ||
		    (tm.tm_year + 1900) % 400 == 0))
			_seconds += 86400;
		/* Months */
		if (tm.tm_mon < 0 || tm.tm_mon > 12)
			@throw [OFInvalidFormatException
			    exceptionWithClass: [self class]];
		_seconds += month_to_day_of_year[tm.tm_mon] * 86400;
		/* Days */
		_seconds += (tm.tm_mday - 1) * 86400;
		/* Hours */
		_seconds += tm.tm_hour * 3600;
		/* Minutes */
		_seconds += tm.tm_min * 60;







|
<














|
<







241
242
243
244
245
246
247
248

249
250
251
252
253
254
255
256
257
258
259
260
261
262
263

264
265
266
267
268
269
270
	@try {
		struct tm tm = {};

		tm.tm_isdst = -1;

		if (of_strptime([string UTF8String], [format UTF8String],
		    &tm) == NULL)
			@throw [OFInvalidFormatException exception];


		/* Years */
		_seconds = (int64_t)(tm.tm_year - 70) * 31536000;
		/* Days of leap years, excluding the year to look at */
		_seconds += (((tm.tm_year + 1899) / 4) - 492) * 86400;
		_seconds -= (((tm.tm_year + 1899) / 100) - 19) * 86400;
		_seconds += (((tm.tm_year + 1899) / 400) - 4) * 86400;
		/* Leap day */
		if (tm.tm_mon >= 2 && (((tm.tm_year + 1900) % 4 == 0 &&
		    (tm.tm_year + 1900) % 100 != 0) ||
		    (tm.tm_year + 1900) % 400 == 0))
			_seconds += 86400;
		/* Months */
		if (tm.tm_mon < 0 || tm.tm_mon > 12)
			@throw [OFInvalidFormatException exception];

		_seconds += month_to_day_of_year[tm.tm_mon] * 86400;
		/* Days */
		_seconds += (tm.tm_mday - 1) * 86400;
		/* Hours */
		_seconds += tm.tm_hour * 3600;
		/* Minutes */
		_seconds += tm.tm_min * 60;
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
	@try {
		struct tm tm = {};

		tm.tm_isdst = -1;

		if (of_strptime([string UTF8String], [format UTF8String],
		    &tm) == NULL)
			@throw [OFInvalidFormatException
			    exceptionWithClass: [self class]];

		if ((_seconds = mktime(&tm)) == -1)
			@throw [OFInvalidFormatException
			    exceptionWithClass: [self class]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







|
<


|
<







286
287
288
289
290
291
292
293

294
295
296

297
298
299
300
301
302
303
	@try {
		struct tm tm = {};

		tm.tm_isdst = -1;

		if (of_strptime([string UTF8String], [format UTF8String],
		    &tm) == NULL)
			@throw [OFInvalidFormatException exception];


		if ((_seconds = mktime(&tm)) == -1)
			@throw [OFInvalidFormatException exception];

	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
		union {
			double d;
			uint64_t u;
		} d;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		d.u = (uint64_t)[element hexadecimalValue];
		_seconds = d.d;

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];







|
<
<







311
312
313
314
315
316
317
318


319
320
321
322
323
324
325
		union {
			double d;
			uint64_t u;
		} d;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		d.u = (uint64_t)[element hexadecimalValue];
		_seconds = d.d;

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
}

- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFDate *otherDate;

	if (![object isKindOfClass: [OFDate class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	otherDate = (OFDate*)object;

	if (_seconds < otherDate->_seconds)
		return OF_ORDERED_ASCENDING;
	if (_seconds > otherDate->_seconds)
		return OF_ORDERED_DESCENDING;







|
<
<







371
372
373
374
375
376
377
378


379
380
381
382
383
384
385
}

- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFDate *otherDate;

	if (![object isKindOfClass: [OFDate class]])
		@throw [OFInvalidArgumentException exception];



	otherDate = (OFDate*)object;

	if (_seconds < otherDate->_seconds)
		return OF_ORDERED_ASCENDING;
	if (_seconds > otherDate->_seconds)
		return OF_ORDERED_DESCENDING;
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
	OFString *ret;
	time_t seconds = (time_t)_seconds;
	struct tm tm;
	size_t pageSize;
	char *buffer;

	if (seconds != floor(_seconds))
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

#ifdef HAVE_GMTIME_R
	if (gmtime_r(&seconds, &tm) == NULL)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];
#else
# ifdef OF_HAVE_THREADS
	[mutex lock];

	@try {
# endif
		struct tm *tmp;

		if ((tmp = gmtime(&seconds)) == NULL)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		tm = *tmp;
# ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
# endif
#endif

	pageSize = [OFSystemInfo pageSize];
	buffer = [self allocMemoryWithSize: pageSize];

	@try {
		if (!strftime(buffer, pageSize, [format UTF8String], &tm))
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		ret = [OFString stringWithUTF8String: buffer];
	} @finally {
		[self freeMemory: buffer];
	}

	return ret;
}

- (OFString*)localDateStringWithFormat: (OFConstantString*)format
{
	OFString *ret;
	time_t seconds = (time_t)_seconds;
	struct tm tm;
	size_t pageSize;
	char *buffer;

	if (seconds != floor(_seconds))
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

#ifdef HAVE_LOCALTIME_R
	if (localtime_r(&seconds, &tm) == NULL)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];
#else
# ifdef OF_HAVE_THREADS
	[mutex lock];

	@try {
# endif
		struct tm *tmp;

		if ((tmp = localtime(&seconds)) == NULL)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		tm = *tmp;
# ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
# endif
#endif

	pageSize = [OFSystemInfo pageSize];
	buffer = [self allocMemoryWithSize: pageSize];

	@try {
		if (!strftime(buffer, pageSize, [format UTF8String], &tm))
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		ret = [OFString stringWithUTF8String: buffer];
	} @finally {
		[self freeMemory: buffer];
	}

	return ret;







|



|









|
<














|
<


















|



|









|
<














|
<







495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516

517
518
519
520
521
522
523
524
525
526
527
528
529
530
531

532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564

565
566
567
568
569
570
571
572
573
574
575
576
577
578
579

580
581
582
583
584
585
586
	OFString *ret;
	time_t seconds = (time_t)_seconds;
	struct tm tm;
	size_t pageSize;
	char *buffer;

	if (seconds != floor(_seconds))
		@throw [OFOutOfRangeException exception];

#ifdef HAVE_GMTIME_R
	if (gmtime_r(&seconds, &tm) == NULL)
		@throw [OFOutOfRangeException exception];
#else
# ifdef OF_HAVE_THREADS
	[mutex lock];

	@try {
# endif
		struct tm *tmp;

		if ((tmp = gmtime(&seconds)) == NULL)
			@throw [OFOutOfRangeException exception];


		tm = *tmp;
# ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
# endif
#endif

	pageSize = [OFSystemInfo pageSize];
	buffer = [self allocMemoryWithSize: pageSize];

	@try {
		if (!strftime(buffer, pageSize, [format UTF8String], &tm))
			@throw [OFOutOfRangeException exception];


		ret = [OFString stringWithUTF8String: buffer];
	} @finally {
		[self freeMemory: buffer];
	}

	return ret;
}

- (OFString*)localDateStringWithFormat: (OFConstantString*)format
{
	OFString *ret;
	time_t seconds = (time_t)_seconds;
	struct tm tm;
	size_t pageSize;
	char *buffer;

	if (seconds != floor(_seconds))
		@throw [OFOutOfRangeException exception];

#ifdef HAVE_LOCALTIME_R
	if (localtime_r(&seconds, &tm) == NULL)
		@throw [OFOutOfRangeException exception];
#else
# ifdef OF_HAVE_THREADS
	[mutex lock];

	@try {
# endif
		struct tm *tmp;

		if ((tmp = localtime(&seconds)) == NULL)
			@throw [OFOutOfRangeException exception];


		tm = *tmp;
# ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
# endif
#endif

	pageSize = [OFSystemInfo pageSize];
	buffer = [self allocMemoryWithSize: pageSize];

	@try {
		if (!strftime(buffer, pageSize, [format UTF8String], &tm))
			@throw [OFOutOfRangeException exception];


		ret = [OFString stringWithUTF8String: buffer];
	} @finally {
		[self freeMemory: buffer];
	}

	return ret;

Modified src/OFDictionary.m from [903db74406] to [65bfd85485].

214
215
216
217
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
	abort();
}

- initWithObject: (id)object
	  forKey: (id)key
{
	if (key == nil || object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	return [self initWithKeysAndObjects: key, object, nil];
}

- initWithObjects: (OFArray*)objects_
	  forKeys: (OFArray*)keys_
{
	id *objects, *keys;
	size_t count;

	@try {
		count = [objects_ count];

		if (count != [keys_ count])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]];

		objects = [objects_ objects];
		keys = [keys_ objects];
	} @catch (id e) {
		[self release];
		@throw e;
	}







|
<














|
<







214
215
216
217
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
	abort();
}

- initWithObject: (id)object
	  forKey: (id)key
{
	if (key == nil || object == nil)
		@throw [OFInvalidArgumentException exception];


	return [self initWithKeysAndObjects: key, object, nil];
}

- initWithObjects: (OFArray*)objects_
	  forKeys: (OFArray*)keys_
{
	id *objects, *keys;
	size_t count;

	@try {
		count = [objects_ count];

		if (count != [keys_ count])
			@throw [OFInvalidArgumentException exception];


		objects = [objects_ objects];
		keys = [keys_ objects];
	} @catch (id e) {
		[self release];
		@throw e;
	}
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
		uint8_t type = 0xDF;
		uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)count);

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];
	} else
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	pool = objc_autoreleasePoolPush();

	i = 0;
	keyEnumerator = [self keyEnumerator];
	objectEnumerator = [self objectEnumerator];
	while ((key = [keyEnumerator nextObject]) != nil &&







|







669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
		uint8_t type = 0xDF;
		uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)count);

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];
	} else
		@throw [OFOutOfRangeException exception];

	pool = objc_autoreleasePoolPush();

	i = 0;
	keyEnumerator = [self keyEnumerator];
	objectEnumerator = [self objectEnumerator];
	while ((key = [keyEnumerator nextObject]) != nil &&

Modified src/OFDictionary_hashtable.m from [522c9d1fef] to [cf3019ae25].

196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
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
		va_list argumentsCopy;
		id key, object;
		size_t i, count;

		va_copy(argumentsCopy, arguments);

		if (firstKey == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		key = firstKey;

		if ((object = va_arg(arguments, id)) == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		count = 1;
		for (; va_arg(argumentsCopy, id) != nil; count++);

		if (count % 2 != 0)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		count /= 2;

		_mapTable = [[OFMapTable alloc]
		    initWithKeyFunctions: keyFunctions
			  valueFunctions: valueFunctions
				capacity: count];

		[_mapTable setValue: object
			     forKey: key];

		for (i = 1; i < count; i++) {
			key = va_arg(arguments, id);
			object = va_arg(arguments, id);

			if (key == nil || object == nil)
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]
					      selector: _cmd];

			[_mapTable setValue: object
				     forKey: key];
		}
	} @catch (id e) {
		[self release];
		@throw e;







|
<
<




|
<
<





|
<
<
















|
<
<







196
197
198
199
200
201
202
203


204
205
206
207
208


209
210
211
212
213
214


215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231


232
233
234
235
236
237
238
		va_list argumentsCopy;
		id key, object;
		size_t i, count;

		va_copy(argumentsCopy, arguments);

		if (firstKey == nil)
			@throw [OFInvalidArgumentException exception];



		key = firstKey;

		if ((object = va_arg(arguments, id)) == nil)
			@throw [OFInvalidArgumentException exception];



		count = 1;
		for (; va_arg(argumentsCopy, id) != nil; count++);

		if (count % 2 != 0)
			@throw [OFInvalidArgumentException exception];



		count /= 2;

		_mapTable = [[OFMapTable alloc]
		    initWithKeyFunctions: keyFunctions
			  valueFunctions: valueFunctions
				capacity: count];

		[_mapTable setValue: object
			     forKey: key];

		for (i = 1; i < count; i++) {
			key = va_arg(arguments, id);
			object = va_arg(arguments, id);

			if (key == nil || object == nil)
				@throw [OFInvalidArgumentException exception];



			[_mapTable setValue: object
				     forKey: key];
		}
	} @catch (id e) {
		[self release];
		@throw e;
261
262
263
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

		keys = [element elementsForName: @"key"
				      namespace: OF_SERIALIZATION_NS];
		objects = [element elementsForName: @"object"
					 namespace: OF_SERIALIZATION_NS];

		if ([keys count] != [objects count])
			@throw [OFInvalidFormatException
			    exceptionWithClass: [self class]];

		_mapTable = [[OFMapTable alloc]
		    initWithKeyFunctions: keyFunctions
			  valueFunctions: valueFunctions
				capacity: [keys count]];

		keyEnumerator = [keys objectEnumerator];
		objectEnumerator = [objects objectEnumerator];
		while ((keyElement = [keyEnumerator nextObject]) != nil &&
		    (objectElement = [objectEnumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			OFXMLElement *key, *object;

			key = [[keyElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];
			object = [[objectElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];

			if (key == nil || object == nil)
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];

			[_mapTable setValue: [object objectByDeserializing]
				     forKey: [key objectByDeserializing]];

			objc_autoreleasePoolPop(pool2);
		}








|
<



















|
<







253
254
255
256
257
258
259
260

261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280

281
282
283
284
285
286
287

		keys = [element elementsForName: @"key"
				      namespace: OF_SERIALIZATION_NS];
		objects = [element elementsForName: @"object"
					 namespace: OF_SERIALIZATION_NS];

		if ([keys count] != [objects count])
			@throw [OFInvalidFormatException exception];


		_mapTable = [[OFMapTable alloc]
		    initWithKeyFunctions: keyFunctions
			  valueFunctions: valueFunctions
				capacity: [keys count]];

		keyEnumerator = [keys objectEnumerator];
		objectEnumerator = [objects objectEnumerator];
		while ((keyElement = [keyEnumerator nextObject]) != nil &&
		    (objectElement = [objectEnumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			OFXMLElement *key, *object;

			key = [[keyElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];
			object = [[objectElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];

			if (key == nil || object == nil)
				@throw [OFInvalidFormatException exception];


			[_mapTable setValue: [object objectByDeserializing]
				     forKey: [key objectByDeserializing]];

			objc_autoreleasePoolPop(pool2);
		}

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
	[_mapTable dealloc];

	[super dealloc];
}

- (id)objectForKey: (id)key
{
	id ret;

	@try {
		ret = [_mapTable valueForKey: key];
	} @catch (OFInvalidArgumentException *e) {
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}

	return ret;
}

- (size_t)count
{
	return [_mapTable count];
}








<
<
<
|
<
<
<
<
<
<
<







299
300
301
302
303
304
305



306







307
308
309
310
311
312
313
	[_mapTable dealloc];

	[super dealloc];
}

- (id)objectForKey: (id)key
{



	return [_mapTable valueForKey: key];







}

- (size_t)count
{
	return [_mapTable count];
}

454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
	@try {
		[_mapTable enumerateKeysAndValuesUsingBlock:
		    ^ (void *key, void *value, bool *stop) {
			block(key, value, stop);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: self];
	}
}
#endif

- (uint32_t)hash
{
	return [_mapTable hash];
}
@end







<
|









434
435
436
437
438
439
440

441
442
443
444
445
446
447
448
449
450
	@try {
		[_mapTable enumerateKeysAndValuesUsingBlock:
		    ^ (void *key, void *value, bool *stop) {
			block(key, value, stop);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException

		    exceptionWithObject: self];
	}
}
#endif

- (uint32_t)hash
{
	return [_mapTable hash];
}
@end

Modified src/OFFile.m from [c7437b1fa1] to [d114dfb10e].

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
		    exceptionWithClass: self];
#endif
}

+ (instancetype)fileWithPath: (OFString*)path
			mode: (OFString*)mode
{
	return [[[self alloc] initWithPath: path
				      mode: mode] autorelease];
}

+ (instancetype)fileWithFileDescriptor: (int)filedescriptor
{
	return [[[self alloc]
	    initWithFileDescriptor: filedescriptor] autorelease];







|







156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
		    exceptionWithClass: self];
#endif
}

+ (instancetype)fileWithPath: (OFString*)path
			mode: (OFString*)mode
{
	return [[(OFFile*)[self alloc] initWithPath: path
				      mode: mode] autorelease];
}

+ (instancetype)fileWithFileDescriptor: (int)filedescriptor
{
	return [[[self alloc]
	    initWithFileDescriptor: filedescriptor] autorelease];
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#ifndef _WIN32
	if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    DIR_MODE))
#else
	if (_wmkdir([path UTF16String]))
#endif
		@throw [OFCreateDirectoryFailedException
		    exceptionWithClass: self
				  path: path];
}

+ (void)createDirectoryAtPath: (OFString*)path
		createParents: (bool)createParents
{
	void *pool;
	OFArray *pathComponents;







|
<







240
241
242
243
244
245
246
247

248
249
250
251
252
253
254
#ifndef _WIN32
	if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    DIR_MODE))
#else
	if (_wmkdir([path UTF16String]))
#endif
		@throw [OFCreateDirectoryFailedException
		    exceptionWithPath: path];

}

+ (void)createDirectoryAtPath: (OFString*)path
		createParents: (bool)createParents
{
	void *pool;
	OFArray *pathComponents;
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309

#ifndef _WIN32
	DIR *dir;
	struct dirent *dirent;

	if ((dir = opendir([path cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) == NULL)
		@throw [OFOpenFileFailedException exceptionWithClass: self
								path: path
								mode: @"r"];

	@try {
		while ((dirent = readdir(dir)) != NULL) {
			void *pool = objc_autoreleasePoolPush();
			OFString *file;








|
<







293
294
295
296
297
298
299
300

301
302
303
304
305
306
307

#ifndef _WIN32
	DIR *dir;
	struct dirent *dirent;

	if ((dir = opendir([path cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) == NULL)
		@throw [OFOpenFileFailedException exceptionWithPath: path

								mode: @"r"];

	@try {
		while ((dirent = readdir(dir)) != NULL) {
			void *pool = objc_autoreleasePoolPush();
			OFString *file;

326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
	HANDLE handle;
	WIN32_FIND_DATAW fd;

	path = [path stringByAppendingString: @"\\*"];

	if ((handle = FindFirstFileW([path UTF16String],
	    &fd)) == INVALID_HANDLE_VALUE)
		@throw [OFOpenFileFailedException exceptionWithClass: self
								path: path
								mode: @"r"];

	@try {
		do {
			void *pool2 = objc_autoreleasePoolPush();
			OFString *file;








|
<







324
325
326
327
328
329
330
331

332
333
334
335
336
337
338
	HANDLE handle;
	WIN32_FIND_DATAW fd;

	path = [path stringByAppendingString: @"\\*"];

	if ((handle = FindFirstFileW([path UTF16String],
	    &fd)) == INVALID_HANDLE_VALUE)
		@throw [OFOpenFileFailedException exceptionWithPath: path

								mode: @"r"];

	@try {
		do {
			void *pool2 = objc_autoreleasePoolPush();
			OFString *file;

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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
{
#ifndef _WIN32
	if (chdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wchdir([path UTF16String]))
#endif
		@throw [OFChangeDirectoryFailedException
		    exceptionWithClass: self
				  path: path];
}

#ifdef OF_HAVE_CHMOD
+ (void)changeModeOfFileAtPath: (OFString*)path
			  mode: (mode_t)mode
{
# ifndef _WIN32
	if (chmod([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], mode))
# else
	if (_wchmod([path UTF16String], mode))
# endif
		@throw [OFChangeFileModeFailedException
		    exceptionWithClass: self
				  path: path
				  mode: mode];
}
#endif

+ (off_t)sizeOfFileAtPath: (OFString*)path
{
#ifndef _WIN32
	struct stat s;

	if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    &s) == -1)
#else
	struct _stat s;

	if (_wstat([path UTF16String], &s) == -1)
#endif
		/* FIXME: Maybe use another exception? */
		@throw [OFOpenFileFailedException exceptionWithClass: self
								path: path
								mode: @"r"];

	return s.st_size;
}

+ (OFDate*)modificationDateOfFileAtPath: (OFString*)path
{
#ifndef _WIN32
	struct stat s;

	if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    &s) == -1)
#else
	struct _stat s;

	if (_wstat([path UTF16String], &s) == -1)
#endif
		/* FIXME: Maybe use another exception? */
		@throw [OFOpenFileFailedException exceptionWithClass: self
								path: path
								mode: @"r"];

	/* FIXME: We could be more precise on some OSes */
	return [OFDate dateWithTimeIntervalSince1970: s.st_mtime];
}

#ifdef OF_HAVE_CHOWN
+ (void)changeOwnerOfFileAtPath: (OFString*)path
			  owner: (OFString*)owner
			  group: (OFString*)group
{
	uid_t uid = -1;
	gid_t gid = -1;

	if (owner == nil && group == nil)
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

# ifdef OF_HAVE_THREADS
	if (!of_mutex_lock(&mutex))
		@throw [OFLockFailedException exceptionWithClass: self];

	@try {
# endif
		if (owner != nil) {
			struct passwd *passwd;

			if ((passwd = getpwnam([owner cStringWithEncoding:
			    OF_STRING_ENCODING_NATIVE])) == NULL)
				@throw [OFChangeFileOwnerFailedException
				    exceptionWithClass: self
						  path: path
						 owner: owner
						 group: group];

			uid = passwd->pw_uid;
		}

		if (group != nil) {
			struct group *group_;

			if ((group_ = getgrnam([group cStringWithEncoding:
			    OF_STRING_ENCODING_NATIVE])) == NULL)
				@throw [OFChangeFileOwnerFailedException
				    exceptionWithClass: self
						  path: path
						 owner: owner
						 group: group];

			gid = group_->gr_gid;
		}
# ifdef OF_HAVE_THREADS
	} @finally {
		if (!of_mutex_unlock(&mutex))
			@throw [OFUnlockFailedException
			    exceptionWithClass: self];
	}
# endif

	if (chown([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    uid, gid))
		@throw [OFChangeFileOwnerFailedException
		    exceptionWithClass: self
				  path: path
				 owner: owner
				 group: group];
}
#endif

+ (void)copyFileAtPath: (OFString*)source
		toPath: (OFString*)destination







|
<












|
<

















|
<


















|
<















|
<



|









|
<












|
<








|
<






|
<







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
467
468
469
470

471
472
473
474
475
476
477

478
479
480
481
482
483
484
{
#ifndef _WIN32
	if (chdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wchdir([path UTF16String]))
#endif
		@throw [OFChangeDirectoryFailedException
		    exceptionWithPath: path];

}

#ifdef OF_HAVE_CHMOD
+ (void)changeModeOfFileAtPath: (OFString*)path
			  mode: (mode_t)mode
{
# ifndef _WIN32
	if (chmod([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], mode))
# else
	if (_wchmod([path UTF16String], mode))
# endif
		@throw [OFChangeFileModeFailedException
		    exceptionWithPath: path

				  mode: mode];
}
#endif

+ (off_t)sizeOfFileAtPath: (OFString*)path
{
#ifndef _WIN32
	struct stat s;

	if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    &s) == -1)
#else
	struct _stat s;

	if (_wstat([path UTF16String], &s) == -1)
#endif
		/* FIXME: Maybe use another exception? */
		@throw [OFOpenFileFailedException exceptionWithPath: path

								mode: @"r"];

	return s.st_size;
}

+ (OFDate*)modificationDateOfFileAtPath: (OFString*)path
{
#ifndef _WIN32
	struct stat s;

	if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    &s) == -1)
#else
	struct _stat s;

	if (_wstat([path UTF16String], &s) == -1)
#endif
		/* FIXME: Maybe use another exception? */
		@throw [OFOpenFileFailedException exceptionWithPath: path

								mode: @"r"];

	/* FIXME: We could be more precise on some OSes */
	return [OFDate dateWithTimeIntervalSince1970: s.st_mtime];
}

#ifdef OF_HAVE_CHOWN
+ (void)changeOwnerOfFileAtPath: (OFString*)path
			  owner: (OFString*)owner
			  group: (OFString*)group
{
	uid_t uid = -1;
	gid_t gid = -1;

	if (owner == nil && group == nil)
		@throw [OFInvalidArgumentException exception];


# ifdef OF_HAVE_THREADS
	if (!of_mutex_lock(&mutex))
		@throw [OFLockFailedException exception];

	@try {
# endif
		if (owner != nil) {
			struct passwd *passwd;

			if ((passwd = getpwnam([owner cStringWithEncoding:
			    OF_STRING_ENCODING_NATIVE])) == NULL)
				@throw [OFChangeFileOwnerFailedException
				    exceptionWithPath: path

						 owner: owner
						 group: group];

			uid = passwd->pw_uid;
		}

		if (group != nil) {
			struct group *group_;

			if ((group_ = getgrnam([group cStringWithEncoding:
			    OF_STRING_ENCODING_NATIVE])) == NULL)
				@throw [OFChangeFileOwnerFailedException
				    exceptionWithPath: path

						 owner: owner
						 group: group];

			gid = group_->gr_gid;
		}
# ifdef OF_HAVE_THREADS
	} @finally {
		if (!of_mutex_unlock(&mutex))
			@throw [OFUnlockFailedException exception];

	}
# endif

	if (chown([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    uid, gid))
		@throw [OFChangeFileOwnerFailedException
		    exceptionWithPath: path

				 owner: owner
				 group: group];
}
#endif

+ (void)copyFileAtPath: (OFString*)source
		toPath: (OFString*)destination
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
							nil];
	}

	override = [self fileExistsAtPath: destination];
	pageSize = [OFSystemInfo pageSize];

	if ((buffer = malloc(pageSize)) == NULL)
		@throw [OFOutOfMemoryException exceptionWithClass: self
						    requestedSize: pageSize];

	@try {
		sourceFile = [OFFile fileWithPath: source
					     mode: @"rb"];
		destinationFile = [OFFile fileWithPath: destination
						  mode: @"wb"];








|
|







496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
							nil];
	}

	override = [self fileExistsAtPath: destination];
	pageSize = [OFSystemInfo pageSize];

	if ((buffer = malloc(pageSize)) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: pageSize];

	@try {
		sourceFile = [OFFile fileWithPath: source
					     mode: @"rb"];
		destinationFile = [OFFile fileWithPath: destination
						  mode: @"wb"];

564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
#ifndef _WIN32
	if (rename([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wrename([source UTF16String], [destination UTF16String]))
#endif
		@throw [OFRenameFileFailedException
		    exceptionWithClass: self
			    sourcePath: source
		       destinationPath: destination];

	objc_autoreleasePoolPop(pool);
}

+ (void)deleteFileAtPath: (OFString*)path
{
#ifndef _WIN32
	if (unlink([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wunlink([path UTF16String]))
#endif
		@throw [OFDeleteFileFailedException exceptionWithClass: self
								  path: path];
}

+ (void)deleteDirectoryAtPath: (OFString*)path
{
#ifndef _WIN32
	if (rmdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wrmdir([path UTF16String]))
#endif
		@throw [OFDeleteDirectoryFailedException
		    exceptionWithClass: self
				  path: path];
}

#ifdef OF_HAVE_LINK
+ (void)linkFileAtPath: (OFString*)source
		toPath: (OFString*)destination
{
	void *pool = objc_autoreleasePoolPush();

	if ([self directoryExistsAtPath: destination]) {
		OFString *filename = [source lastPathComponent];
		destination = [OFString stringWithPath: destination, filename,
							nil];
	}

	if (link([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
		@throw [OFLinkFailedException exceptionWithClass: self
						      sourcePath: source
						 destinationPath: destination];

	objc_autoreleasePoolPop(pool);
}
#endif

#ifdef OF_HAVE_SYMLINK







|
<












|
<










|
<
















|
|







552
553
554
555
556
557
558
559

560
561
562
563
564
565
566
567
568
569
570
571
572

573
574
575
576
577
578
579
580
581
582
583

584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
#ifndef _WIN32
	if (rename([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wrename([source UTF16String], [destination UTF16String]))
#endif
		@throw [OFRenameFileFailedException
		    exceptionWithSourcePath: source

		       destinationPath: destination];

	objc_autoreleasePoolPop(pool);
}

+ (void)deleteFileAtPath: (OFString*)path
{
#ifndef _WIN32
	if (unlink([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wunlink([path UTF16String]))
#endif
		@throw [OFDeleteFileFailedException exceptionWithPath: path];

}

+ (void)deleteDirectoryAtPath: (OFString*)path
{
#ifndef _WIN32
	if (rmdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wrmdir([path UTF16String]))
#endif
		@throw [OFDeleteDirectoryFailedException
		    exceptionWithPath: path];

}

#ifdef OF_HAVE_LINK
+ (void)linkFileAtPath: (OFString*)source
		toPath: (OFString*)destination
{
	void *pool = objc_autoreleasePoolPush();

	if ([self directoryExistsAtPath: destination]) {
		OFString *filename = [source lastPathComponent];
		destination = [OFString stringWithPath: destination, filename,
							nil];
	}

	if (link([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
		@throw [OFLinkFailedException
		    exceptionWithSourcePath: source
						 destinationPath: destination];

	objc_autoreleasePoolPop(pool);
}
#endif

#ifdef OF_HAVE_SYMLINK
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
		destination = [OFString stringWithPath: destination, filename,
							nil];
	}

	if (symlink([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
		@throw [OFSymlinkFailedException
		    exceptionWithClass: self
			    sourcePath: source
		       destinationPath: destination];

	objc_autoreleasePoolPop(pool);
}
#endif

- init







|
<







616
617
618
619
620
621
622
623

624
625
626
627
628
629
630
		destination = [OFString stringWithPath: destination, filename,
							nil];
	}

	if (symlink([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
		@throw [OFSymlinkFailedException
		    exceptionWithSourcePath: source

		       destinationPath: destination];

	objc_autoreleasePoolPop(pool);
}
#endif

- init
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
{
	self = [super init];

	@try {
		int flags;

		if ((flags = parse_mode([mode UTF8String])) == -1)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

#ifndef _WIN32
		if ((_fd = open([path cStringWithEncoding:
		    OF_STRING_ENCODING_NATIVE], flags, DEFAULT_MODE)) == -1)
#else
		if ((_fd = _wopen([path UTF16String], flags,
		    DEFAULT_MODE)) == -1)
#endif
			@throw [OFOpenFileFailedException
			    exceptionWithClass: [self class]
					  path: path
					  mode: mode];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;







|
<
<









|
<







644
645
646
647
648
649
650
651


652
653
654
655
656
657
658
659
660
661

662
663
664
665
666
667
668
{
	self = [super init];

	@try {
		int flags;

		if ((flags = parse_mode([mode UTF8String])) == -1)
			@throw [OFInvalidArgumentException exception];



#ifndef _WIN32
		if ((_fd = open([path cStringWithEncoding:
		    OF_STRING_ENCODING_NATIVE], flags, DEFAULT_MODE)) == -1)
#else
		if ((_fd = _wopen([path UTF16String], flags,
		    DEFAULT_MODE)) == -1)
#endif
			@throw [OFOpenFileFailedException
			    exceptionWithPath: path

					  mode: mode];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
- (size_t)lowlevelReadIntoBuffer: (void*)buffer
			  length: (size_t)length
{
	ssize_t ret;

	if (_fd == -1 || _atEndOfStream ||
	    (ret = read(_fd, buffer, length)) < 0)
		@throw [OFReadFailedException exceptionWithClass: [self class]
							  stream: self
						 requestedLength: length];

	if (ret == 0)
		_atEndOfStream = true;

	return ret;
}

- (void)lowlevelWriteBuffer: (const void*)buffer
		     length: (size_t)length
{
	if (_fd == -1 || _atEndOfStream || write(_fd, buffer, length) < length)
		@throw [OFWriteFailedException exceptionWithClass: [self class]
							   stream: self
						  requestedLength: length];
}

- (void)lowlevelSeekToOffset: (off_t)offset
		      whence: (int)whence
{
	if (lseek(_fd, offset, whence) == -1)
		@throw [OFSeekFailedException exceptionWithClass: [self class]
							  stream: self
							  offset: offset
							  whence: whence];
}

- (int)fileDescriptorForReading
{
	return _fd;







|
<












|
<







|
<







688
689
690
691
692
693
694
695

696
697
698
699
700
701
702
703
704
705
706
707
708

709
710
711
712
713
714
715
716

717
718
719
720
721
722
723
- (size_t)lowlevelReadIntoBuffer: (void*)buffer
			  length: (size_t)length
{
	ssize_t ret;

	if (_fd == -1 || _atEndOfStream ||
	    (ret = read(_fd, buffer, length)) < 0)
		@throw [OFReadFailedException exceptionWithStream: self

						 requestedLength: length];

	if (ret == 0)
		_atEndOfStream = true;

	return ret;
}

- (void)lowlevelWriteBuffer: (const void*)buffer
		     length: (size_t)length
{
	if (_fd == -1 || _atEndOfStream || write(_fd, buffer, length) < length)
		@throw [OFWriteFailedException exceptionWithStream: self

						  requestedLength: length];
}

- (void)lowlevelSeekToOffset: (off_t)offset
		      whence: (int)whence
{
	if (lseek(_fd, offset, whence) == -1)
		@throw [OFSeekFailedException exceptionWithStream: self

							  offset: offset
							  whence: whence];
}

- (int)fileDescriptorForReading
{
	return _fd;

Modified src/OFHTTPClient.m from [821496c01f] to [fa59054e17].

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
	contentLength = [headers objectForKey: @"Content-Length"];
	if (contentLength != nil) {
		_hasContentLength = true;

		@try {
			_toRead = (size_t)[contentLength decimalValue];
		} @catch (OFInvalidFormatException *e) {
			@throw [OFInvalidServerReplyException
			    exceptionWithClass: [self class]];
		}
	}
}

- (size_t)lowlevelReadIntoBuffer: (void*)buffer
			  length: (size_t)length
{
	if (_atEndOfStream) {
		OFReadFailedException *e;

		e = [OFReadFailedException exceptionWithClass: [self class]
						       stream: self
					      requestedLength: length];

#ifndef _WIN32
		e->_errNo = ENOTCONN;
#else
		e->_errNo = WSAENOTCONN;
#endif







|
<










|
<







111
112
113
114
115
116
117
118

119
120
121
122
123
124
125
126
127
128
129

130
131
132
133
134
135
136
	contentLength = [headers objectForKey: @"Content-Length"];
	if (contentLength != nil) {
		_hasContentLength = true;

		@try {
			_toRead = (size_t)[contentLength decimalValue];
		} @catch (OFInvalidFormatException *e) {
			@throw [OFInvalidServerReplyException exception];

		}
	}
}

- (size_t)lowlevelReadIntoBuffer: (void*)buffer
			  length: (size_t)length
{
	if (_atEndOfStream) {
		OFReadFailedException *e;

		e = [OFReadFailedException exceptionWithStream: self

					      requestedLength: length];

#ifndef _WIN32
		e->_errNo = ENOTCONN;
#else
		e->_errNo = WSAENOTCONN;
#endif
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
					  length: length];

		_toRead -= length;

		if (_toRead == 0)
			if ([[_socket readLine] length] > 0)
				@throw [OFInvalidServerReplyException
				    exceptionWithClass: [self class]];

		return length;
	} else {
		void *pool = objc_autoreleasePoolPush();
		OFString *line;
		of_range_t range;

		@try {
			line = [_socket readLine];
		} @catch (OFInvalidEncodingException *e) {
			@throw [OFInvalidServerReplyException
			    exceptionWithClass: [self class]];
		}

		range = [line rangeOfString: @";"];
		if (range.location != OF_NOT_FOUND)
			line = [line substringWithRange:
			    of_range(0, range.location)];

		@try {
			_toRead =
			    (size_t)[line hexadecimalValue];
		} @catch (OFInvalidFormatException *e) {
			@throw [OFInvalidServerReplyException
			    exceptionWithClass: [self class]];
		}

		if (_toRead == 0) {
			_atEndOfStream = true;

			if (_keepAlive) {
				@try {
					line = [_socket readLine];
				} @catch (OFInvalidEncodingException *e) {
					@throw [OFInvalidServerReplyException
					    exceptionWithClass: [self class]];
				}

				if ([line length] > 0)
					@throw [OFInvalidServerReplyException
					    exceptionWithClass: [self class]];
			} else
				[_socket close];
		}

		objc_autoreleasePoolPop(pool);

		return 0;







|










|
<











|
<










|




|







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194

195
196
197
198
199
200
201
202
203
204
205
206

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
					  length: length];

		_toRead -= length;

		if (_toRead == 0)
			if ([[_socket readLine] length] > 0)
				@throw [OFInvalidServerReplyException
				    exception];

		return length;
	} else {
		void *pool = objc_autoreleasePoolPush();
		OFString *line;
		of_range_t range;

		@try {
			line = [_socket readLine];
		} @catch (OFInvalidEncodingException *e) {
			@throw [OFInvalidServerReplyException exception];

		}

		range = [line rangeOfString: @";"];
		if (range.location != OF_NOT_FOUND)
			line = [line substringWithRange:
			    of_range(0, range.location)];

		@try {
			_toRead =
			    (size_t)[line hexadecimalValue];
		} @catch (OFInvalidFormatException *e) {
			@throw [OFInvalidServerReplyException exception];

		}

		if (_toRead == 0) {
			_atEndOfStream = true;

			if (_keepAlive) {
				@try {
					line = [_socket readLine];
				} @catch (OFInvalidEncodingException *e) {
					@throw [OFInvalidServerReplyException
					    exception];
				}

				if ([line length] > 0)
					@throw [OFInvalidServerReplyException
					    exception];
			} else
				[_socket close];
		}

		objc_autoreleasePoolPop(pool);

		return 0;
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
	OFTCPSocket *socket;

	[self close];

	if ([[URL scheme] isEqual: @"https"]) {
		if (of_tls_socket_class == Nil)
			@throw [OFUnsupportedProtocolException
			    exceptionWithClass: [self class]
					   URL: URL];

		socket = [[[of_tls_socket_class alloc] init]
		    autorelease];
	} else
		socket = [OFTCPSocket socket];

	if ([_delegate respondsToSelector:







|
<







300
301
302
303
304
305
306
307

308
309
310
311
312
313
314
	OFTCPSocket *socket;

	[self close];

	if ([[URL scheme] isEqual: @"https"]) {
		if (of_tls_socket_class == Nil)
			@throw [OFUnsupportedProtocolException
			    exceptionWithURL: URL];


		socket = [[[of_tls_socket_class alloc] init]
		    autorelease];
	} else
		socket = [OFTCPSocket socket];

	if ([_delegate respondsToSelector:
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
	OFMutableDictionary *serverHeaders;
	OFEnumerator *keyEnumerator, *objectEnumerator;
	OFString *key, *object;
	int status;
	const char *type = NULL;

	if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"])
		@throw [OFUnsupportedProtocolException
		    exceptionWithClass: [self class]
				   URL: URL];

	/* Can we reuse the socket? */
	if (_socket != nil && [[_lastURL scheme] isEqual: [URL scheme]] &&
	    [[_lastURL host] isEqual: [URL host]] &&
	    [_lastURL port] == [URL port]) {
		/*
		 * Set _socket to nil, so that in case of an error it won't be







|
<
<







339
340
341
342
343
344
345
346


347
348
349
350
351
352
353
	OFMutableDictionary *serverHeaders;
	OFEnumerator *keyEnumerator, *objectEnumerator;
	OFString *key, *object;
	int status;
	const char *type = NULL;

	if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"])
		@throw [OFUnsupportedProtocolException exceptionWithURL: URL];



	/* Can we reuse the socket? */
	if (_socket != nil && [[_lastURL scheme] isEqual: [URL scheme]] &&
	    [[_lastURL host] isEqual: [URL host]] &&
	    [_lastURL port] == [URL port]) {
		/*
		 * Set _socket to nil, so that in case of an error it won't be
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
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
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
	if (requestType == OF_HTTP_REQUEST_TYPE_POST)
		[socket writeBuffer: [POSTData items]
			     length: [POSTData count] * [POSTData itemSize]];

	@try {
		line = [socket readLine];
	} @catch (OFInvalidEncodingException *e) {
		@throw [OFInvalidServerReplyException
		    exceptionWithClass: [self class]];
	}

	/*
	 * It's possible that the write succeeds on a connection that is
	 * keep-alive, but the connection has already been closed by the remote
	 * end due to a timeout. In this case, we need to reconnect.
	 */
	if (line == nil) {
		socket = [self OF_createSocketForRequest: request];
		[socket writeString: requestString];

		if (requestType == OF_HTTP_REQUEST_TYPE_POST)
			[socket writeBuffer: [POSTData items]
				     length: [POSTData count] *
					     [POSTData itemSize]];

		@try {
			line = [socket readLine];
		} @catch (OFInvalidEncodingException *e) {
			@throw [OFInvalidServerReplyException
			    exceptionWithClass: [self class]];
		}
	}

	if (![line hasPrefix: @"HTTP/"] || [line characterAtIndex: 8] != ' ')
		@throw [OFInvalidServerReplyException
		    exceptionWithClass: [self class]];

	version = [line substringWithRange: of_range(5, 3)];
	if (![version isEqual: @"1.0"] && ![version isEqual: @"1.1"])
		@throw [OFUnsupportedVersionException
		    exceptionWithClass: [self class]
			       version: version];

	status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];

	serverHeaders = [OFMutableDictionary dictionary];

	for (;;) {
		OFString *key, *value;
		const char *lineC, *tmp;
		char *keyC;

		@try {
			line = [socket readLine];
		} @catch (OFInvalidEncodingException *e) {
			@throw [OFInvalidServerReplyException
			    exceptionWithClass: [self class]];
		}

		if (line == nil)
			@throw [OFInvalidServerReplyException
			    exceptionWithClass: [self class]];

		if ([line length] == 0)
			break;

		lineC = [line UTF8String];

		if ((tmp = strchr(lineC, ':')) == NULL)
			@throw [OFInvalidServerReplyException
			    exceptionWithClass: [self class]];

		if ((keyC = malloc(tmp - lineC + 1)) == NULL)
			@throw [OFOutOfMemoryException
			    exceptionWithClass: [self class]
				 requestedSize: tmp - lineC + 1];

		memcpy(keyC, lineC, tmp - lineC);
		keyC[tmp - lineC] = '\0';
		normalize_key(keyC);

		@try {
			key = [OFString stringWithUTF8StringNoCopy: keyC







|
<



















|
<




|
<




<
|













|
<



|
<







|
<



<
|







449
450
451
452
453
454
455
456

457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
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
506
507
508
509
510
511
512

513
514
515

516
517
518
519
520
521
522
523
	if (requestType == OF_HTTP_REQUEST_TYPE_POST)
		[socket writeBuffer: [POSTData items]
			     length: [POSTData count] * [POSTData itemSize]];

	@try {
		line = [socket readLine];
	} @catch (OFInvalidEncodingException *e) {
		@throw [OFInvalidServerReplyException exception];

	}

	/*
	 * It's possible that the write succeeds on a connection that is
	 * keep-alive, but the connection has already been closed by the remote
	 * end due to a timeout. In this case, we need to reconnect.
	 */
	if (line == nil) {
		socket = [self OF_createSocketForRequest: request];
		[socket writeString: requestString];

		if (requestType == OF_HTTP_REQUEST_TYPE_POST)
			[socket writeBuffer: [POSTData items]
				     length: [POSTData count] *
					     [POSTData itemSize]];

		@try {
			line = [socket readLine];
		} @catch (OFInvalidEncodingException *e) {
			@throw [OFInvalidServerReplyException exception];

		}
	}

	if (![line hasPrefix: @"HTTP/"] || [line characterAtIndex: 8] != ' ')
		@throw [OFInvalidServerReplyException exception];


	version = [line substringWithRange: of_range(5, 3)];
	if (![version isEqual: @"1.0"] && ![version isEqual: @"1.1"])
		@throw [OFUnsupportedVersionException

		    exceptionWithVersion: version];

	status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];

	serverHeaders = [OFMutableDictionary dictionary];

	for (;;) {
		OFString *key, *value;
		const char *lineC, *tmp;
		char *keyC;

		@try {
			line = [socket readLine];
		} @catch (OFInvalidEncodingException *e) {
			@throw [OFInvalidServerReplyException exception];

		}

		if (line == nil)
			@throw [OFInvalidServerReplyException exception];


		if ([line length] == 0)
			break;

		lineC = [line UTF8String];

		if ((tmp = strchr(lineC, ':')) == NULL)
			@throw [OFInvalidServerReplyException exception];


		if ((keyC = malloc(tmp - lineC + 1)) == NULL)
			@throw [OFOutOfMemoryException

			    exceptionWithRequestedSize: tmp - lineC + 1];

		memcpy(keyC, lineC, tmp - lineC);
		keyC[tmp - lineC] = '\0';
		normalize_key(keyC);

		@try {
			key = [OFString stringWithUTF8StringNoCopy: keyC
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636

	[reply retain];
	objc_autoreleasePoolPop(pool);
	[reply autorelease];

	if (status / 100 != 2)
		@throw [OFHTTPRequestFailedException
		    exceptionWithClass: [self class]
			       request: request
				 reply: reply];

	return reply;
}

- (void)close
{







<
|







606
607
608
609
610
611
612

613
614
615
616
617
618
619
620

	[reply retain];
	objc_autoreleasePoolPop(pool);
	[reply autorelease];

	if (status / 100 != 2)
		@throw [OFHTTPRequestFailedException

		    exceptionWithRequest: request
				 reply: reply];

	return reply;
}

- (void)close
{

Modified src/OFHTTPRequest.m from [24712e6afd] to [a21b81861e].

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
	return _requestType;
}

- (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion
{
	if (protocolVersion.major != 1 || protocolVersion.minor > 1)
		@throw [OFUnsupportedVersionException
		    exceptionWithClass: [self class]
			       version: [OFString stringWithFormat: @"%u.%u",
					    protocolVersion.major,
					    protocolVersion.minor]];

	_protocolVersion = protocolVersion;
}

- (of_http_request_protocol_version_t)protocolVersion
{
	return _protocolVersion;
}

- (void)setProtocolVersionFromString: (OFString*)string
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *components = [string componentsSeparatedByString: @"."];
	intmax_t major, minor;
	of_http_request_protocol_version_t protocolVersion;

	if ([components count] != 2)
		@throw [OFInvalidFormatException
		    exceptionWithClass: [self class]];

	major = [[components firstObject] decimalValue];
	minor = [[components lastObject] decimalValue];

	if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	protocolVersion.major = (uint8_t)major;
	protocolVersion.minor = (uint8_t)minor;

	[self setProtocolVersion: protocolVersion];

	objc_autoreleasePoolPop(pool);







<
|



















|
<





|







97
98
99
100
101
102
103

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
132
133
134
135
136
137
	return _requestType;
}

- (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion
{
	if (protocolVersion.major != 1 || protocolVersion.minor > 1)
		@throw [OFUnsupportedVersionException

		    exceptionWithVersion: [OFString stringWithFormat: @"%u.%u",
					    protocolVersion.major,
					    protocolVersion.minor]];

	_protocolVersion = protocolVersion;
}

- (of_http_request_protocol_version_t)protocolVersion
{
	return _protocolVersion;
}

- (void)setProtocolVersionFromString: (OFString*)string
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *components = [string componentsSeparatedByString: @"."];
	intmax_t major, minor;
	of_http_request_protocol_version_t protocolVersion;

	if ([components count] != 2)
		@throw [OFInvalidFormatException exception];


	major = [[components firstObject] decimalValue];
	minor = [[components lastObject] decimalValue];

	if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX)
		@throw [OFOutOfRangeException exception];

	protocolVersion.major = (uint8_t)major;
	protocolVersion.minor = (uint8_t)minor;

	[self setProtocolVersion: protocolVersion];

	objc_autoreleasePoolPop(pool);

Modified src/OFHTTPRequestReply.m from [96daca57e6] to [db55a6ac9c].

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
	[super dealloc];
}

- (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion
{
	if (protocolVersion.major != 1 || protocolVersion.minor > 1)
		@throw [OFUnsupportedVersionException
		    exceptionWithClass: [self class]
			       version: [OFString stringWithFormat: @"%u.%u",
					    protocolVersion.major,
					    protocolVersion.minor]];

	_protocolVersion = protocolVersion;
}

- (of_http_request_protocol_version_t)protocolVersion
{
	return _protocolVersion;
}

- (void)setProtocolVersionFromString: (OFString*)string
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *components = [string componentsSeparatedByString: @"."];
	intmax_t major, minor;
	of_http_request_protocol_version_t protocolVersion;

	if ([components count] != 2)
		@throw [OFInvalidFormatException
		    exceptionWithClass: [self class]];

	major = [[components firstObject] decimalValue];
	minor = [[components lastObject] decimalValue];

	if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	protocolVersion.major = (uint8_t)major;
	protocolVersion.minor = (uint8_t)minor;

	[self setProtocolVersion: protocolVersion];

	objc_autoreleasePoolPop(pool);







<
|



















|
<





|







48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

76
77
78
79
80
81
82
83
84
85
86
87
88
	[super dealloc];
}

- (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion
{
	if (protocolVersion.major != 1 || protocolVersion.minor > 1)
		@throw [OFUnsupportedVersionException

		    exceptionWithVersion: [OFString stringWithFormat: @"%u.%u",
					    protocolVersion.major,
					    protocolVersion.minor]];

	_protocolVersion = protocolVersion;
}

- (of_http_request_protocol_version_t)protocolVersion
{
	return _protocolVersion;
}

- (void)setProtocolVersionFromString: (OFString*)string
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *components = [string componentsSeparatedByString: @"."];
	intmax_t major, minor;
	of_http_request_protocol_version_t protocolVersion;

	if ([components count] != 2)
		@throw [OFInvalidFormatException exception];


	major = [[components firstObject] decimalValue];
	minor = [[components lastObject] decimalValue];

	if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX)
		@throw [OFOutOfRangeException exception];

	protocolVersion.major = (uint8_t)major;
	protocolVersion.minor = (uint8_t)minor;

	[self setProtocolVersion: protocolVersion];

	objc_autoreleasePoolPop(pool);
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
	if (encoding == OF_STRING_ENCODING_AUTODETECT)
		encoding = OF_STRING_ENCODING_UTF_8;

	data = [self readDataArrayTillEndOfStream];

	if ((contentLength = [_headers objectForKey: @"Content-Length"]) != nil)
		if ([data count] != (size_t)[contentLength decimalValue])
			@throw [OFTruncatedDataException
			    exceptionWithClass: [self class]];

	ret = [[OFString alloc] initWithCString: (char*)[data items]
				       encoding: encoding
					 length: [data count]];

	objc_autoreleasePoolPop(pool);








|
<







142
143
144
145
146
147
148
149

150
151
152
153
154
155
156
	if (encoding == OF_STRING_ENCODING_AUTODETECT)
		encoding = OF_STRING_ENCODING_UTF_8;

	data = [self readDataArrayTillEndOfStream];

	if ((contentLength = [_headers objectForKey: @"Content-Length"]) != nil)
		if ([data count] != (size_t)[contentLength decimalValue])
			@throw [OFTruncatedDataException exception];


	ret = [[OFString alloc] initWithCString: (char*)[data items]
				       encoding: encoding
					 length: [data count]];

	objc_autoreleasePoolPop(pool);

Modified src/OFHTTPServer.m from [0c9c549df6] to [0971f78b90].

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
{
	char *cString = strdup([key UTF8String]);
	uint8_t *tmp = (uint8_t*)cString;
	bool firstLetter = true;

	if (cString == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithClass: nil
			 requestedSize: strlen([key UTF8String])];

	while (*tmp != '\0') {
		if (!isalnum(*tmp)) {
			firstLetter = true;
			tmp++;
			continue;
		}







<
|







141
142
143
144
145
146
147

148
149
150
151
152
153
154
155
{
	char *cString = strdup([key UTF8String]);
	uint8_t *tmp = (uint8_t*)cString;
	bool firstLetter = true;

	if (cString == NULL)
		@throw [OFOutOfMemoryException

		    exceptionWithRequestedSize: strlen([key UTF8String])];

	while (*tmp != '\0') {
		if (!isalnum(*tmp)) {
			firstLetter = true;
			tmp++;
			continue;
		}
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
{
	OF_GETTER(_name, true)
}

- (void)start
{
	if (_host == nil || _port == 0)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	if (_listeningSocket != nil)
		@throw [OFAlreadyConnectedException
		    exceptionWithClass: [self class]
				socket: _listeningSocket];

	_listeningSocket = [[OFTCPSocket alloc] init];
	[_listeningSocket bindToHost: _host
				port: _port];
	[_listeningSocket listen];

	[_listeningSocket asyncAcceptWithTarget: self







|
<
<


|
<
<







685
686
687
688
689
690
691
692


693
694
695


696
697
698
699
700
701
702
{
	OF_GETTER(_name, true)
}

- (void)start
{
	if (_host == nil || _port == 0)
		@throw [OFInvalidArgumentException exception];



	if (_listeningSocket != nil)
		@throw [OFAlreadyConnectedException exception];



	_listeningSocket = [[OFTCPSocket alloc] init];
	[_listeningSocket bindToHost: _host
				port: _port];
	[_listeningSocket listen];

	[_listeningSocket asyncAcceptWithTarget: self

Modified src/OFList.m from [0d2e63e3da] to [e54c914e15].

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
	@try {
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		OFXMLElement *child;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		enumerator = [[element elementsForNamespace:
		    OF_SERIALIZATION_NS] objectEnumerator];
		while ((child = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();

			[self appendObject: [child objectByDeserializing]];







|
<
<







42
43
44
45
46
47
48
49


50
51
52
53
54
55
56
	@try {
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		OFXMLElement *child;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		enumerator = [[element elementsForNamespace:
		    OF_SERIALIZATION_NS] objectEnumerator];
		while ((child = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();

			[self appendObject: [child objectByDeserializing]];
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
467
468

- (id)nextObject
{
	id ret;

	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: _list];

	if (_current == NULL)
		return nil;

	ret = _current->object;
	_current = _current->next;

	return ret;
}

- (void)reset
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: _list];

	_current = [_list firstListObject];
}
@end







<
|














<
|




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

- (id)nextObject
{
	id ret;

	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException

		    exceptionWithObject: _list];

	if (_current == NULL)
		return nil;

	ret = _current->object;
	_current = _current->next;

	return ret;
}

- (void)reset
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException

		    exceptionWithObject: _list];

	_current = [_list firstListObject];
}
@end

Modified src/OFMD5Hash.m from [621cd607df] to [ae6cec6554].

166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
	const char *buffer = buffer_;

	if (length == 0)
		return;

	if (_calculated)
		@throw [OFHashAlreadyCalculatedException
		    exceptionWithClass: [self class]
				  hash: self];

	/* Update bitcount */
	t = _bits[0];
	if ((_bits[0] = t + ((uint32_t)length << 3)) < t)
		/* Carry from low to high */
		_bits[1]++;
	_bits[1] += (uint32_t)length >> 29;







|
<







166
167
168
169
170
171
172
173

174
175
176
177
178
179
180
	const char *buffer = buffer_;

	if (length == 0)
		return;

	if (_calculated)
		@throw [OFHashAlreadyCalculatedException
		    exceptionWithHash: self];


	/* Update bitcount */
	t = _bits[0];
	if ((_bits[0] = t + ((uint32_t)length << 3)) < t)
		/* Carry from low to high */
		_bits[1]++;
	_bits[1] += (uint32_t)length >> 29;

Modified src/OFMapTable.m from [e861c4b211] to [40dcf1c644].

133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
		SET_DEFAULT(_valueFunctions.equal, default_equal);

#undef SET_DEFAULT

		if (capacity > UINT32_MAX ||
		    capacity > UINT32_MAX / sizeof(*_buckets) ||
		    capacity > UINT32_MAX / 8)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		for (_capacity = 1; _capacity < capacity; _capacity *= 2);
		if (capacity * 8 / _capacity >= 6)
			_capacity *= 2;

		if (_capacity < MIN_CAPACITY)
			_capacity = MIN_CAPACITY;







|
<







133
134
135
136
137
138
139
140

141
142
143
144
145
146
147
		SET_DEFAULT(_valueFunctions.equal, default_equal);

#undef SET_DEFAULT

		if (capacity > UINT32_MAX ||
		    capacity > UINT32_MAX / sizeof(*_buckets) ||
		    capacity > UINT32_MAX / 8)
			@throw [OFOutOfRangeException exception];


		for (_capacity = 1; _capacity < capacity; _capacity *= 2);
		if (capacity * 8 / _capacity >= 6)
			_capacity *= 2;

		if (_capacity < MIN_CAPACITY)
			_capacity = MIN_CAPACITY;
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
}

- (void*)valueForKey: (void*)key
{
	uint32_t i, hash, last;

	if (key == NULL)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	hash = OF_ROL(_keyFunctions.hash(key), _rotate);
	last = _capacity;

	for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) {
		if (_buckets[i] == &deleted)
			continue;







|
<
<







252
253
254
255
256
257
258
259


260
261
262
263
264
265
266
}

- (void*)valueForKey: (void*)key
{
	uint32_t i, hash, last;

	if (key == NULL)
		@throw [OFInvalidArgumentException exception];



	hash = OF_ROL(_keyFunctions.hash(key), _rotate);
	last = _capacity;

	for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) {
		if (_buckets[i] == &deleted)
			continue;
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
- (void)OF_resizeForCount: (uint32_t)count
{
	uint32_t i, fullness, capacity;
	struct of_map_table_bucket **buckets;

	if (count > UINT32_MAX || count > UINT32_MAX / sizeof(*_buckets) ||
	    count > UINT32_MAX / 8)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	fullness = count * 8 / _capacity;

	if (fullness >= 6)
		capacity = _capacity * 2;
	else if (fullness <= 1)
		capacity = _capacity / 2;







|







289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
- (void)OF_resizeForCount: (uint32_t)count
{
	uint32_t i, fullness, capacity;
	struct of_map_table_bucket **buckets;

	if (count > UINT32_MAX || count > UINT32_MAX / sizeof(*_buckets) ||
	    count > UINT32_MAX / 8)
		@throw [OFOutOfRangeException exception];

	fullness = count * 8 / _capacity;

	if (fullness >= 6)
		capacity = _capacity * 2;
	else if (fullness <= 1)
		capacity = _capacity / 2;
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
	     forKey: (void*)key
	       hash: (uint32_t)hash
{
	uint32_t i, last;
	void *old;

	if (key == NULL || value == NULL)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	hash = OF_ROL(hash, _rotate);
	last = _capacity;

	for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) {
		if (_buckets[i] == &deleted)
			continue;







|
<
<







348
349
350
351
352
353
354
355


356
357
358
359
360
361
362
	     forKey: (void*)key
	       hash: (uint32_t)hash
{
	uint32_t i, last;
	void *old;

	if (key == NULL || value == NULL)
		@throw [OFInvalidArgumentException exception];



	hash = OF_ROL(hash, _rotate);
	last = _capacity;

	for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) {
		if (_buckets[i] == &deleted)
			continue;
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
			last = hash & (_capacity - 1);

			for (i = 0; i < last && _buckets[i] != NULL &&
			    _buckets[i] != &deleted; i++);
		}

		if (i >= last)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		bucket = [self allocMemoryWithSize: sizeof(*bucket)];

		@try {
			bucket->key = _keyFunctions.retain(key);
		} @catch (id e) {
			[self freeMemory: bucket];







|
<







396
397
398
399
400
401
402
403

404
405
406
407
408
409
410
			last = hash & (_capacity - 1);

			for (i = 0; i < last && _buckets[i] != NULL &&
			    _buckets[i] != &deleted; i++);
		}

		if (i >= last)
			@throw [OFOutOfRangeException exception];


		bucket = [self allocMemoryWithSize: sizeof(*bucket)];

		@try {
			bucket->key = _keyFunctions.retain(key);
		} @catch (id e) {
			[self freeMemory: bucket];
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
}

- (void)removeValueForKey: (void*)key
{
	uint32_t i, hash, last;

	if (key == NULL)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	hash = OF_ROL(_keyFunctions.hash(key), _rotate);
	last = _capacity;

	for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) {
		if (_buckets[i] == &deleted)
			continue;







|
<
<







441
442
443
444
445
446
447
448


449
450
451
452
453
454
455
}

- (void)removeValueForKey: (void*)key
{
	uint32_t i, hash, last;

	if (key == NULL)
		@throw [OFInvalidArgumentException exception];



	hash = OF_ROL(_keyFunctions.hash(key), _rotate);
	last = _capacity;

	for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) {
		if (_buckets[i] == &deleted)
			continue;
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
	size_t i;
	bool stop = false;
	unsigned long mutations = _mutations;

	for (i = 0; i < _capacity && !stop; i++) {
		if (_mutations != mutations)
			@throw [OFEnumerationMutationException
			    exceptionWithClass: [self class]
					object: self];

		if (_buckets[i] != NULL && _buckets[i] != &deleted)
			block(_buckets[i]->key, _buckets[i]->value, &stop);
	}
}

- (void)replaceValuesUsingBlock: (of_map_table_replace_block_t)block
{
	size_t i;
	unsigned long mutations = _mutations;

	for (i = 0; i < _capacity; i++) {
		if (_mutations != mutations)
			@throw [OFEnumerationMutationException
			    exceptionWithClass: [self class]
					object: self];

		if (_buckets[i] != NULL && _buckets[i] != &deleted) {
			void *new;

			new = block(_buckets[i]->key, _buckets[i]->value);
			if (new == NULL)
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]
					      selector: _cmd];

			if (new != _buckets[i]->value) {
				_valueFunctions.release(_buckets[i]->value);
				_buckets[i]->value =
				    _valueFunctions.retain(new);
			}
		}







<
|














<
|






|
<
<







575
576
577
578
579
580
581

582
583
584
585
586
587
588
589
590
591
592
593
594
595
596

597
598
599
600
601
602
603
604


605
606
607
608
609
610
611
	size_t i;
	bool stop = false;
	unsigned long mutations = _mutations;

	for (i = 0; i < _capacity && !stop; i++) {
		if (_mutations != mutations)
			@throw [OFEnumerationMutationException

			    exceptionWithObject: self];

		if (_buckets[i] != NULL && _buckets[i] != &deleted)
			block(_buckets[i]->key, _buckets[i]->value, &stop);
	}
}

- (void)replaceValuesUsingBlock: (of_map_table_replace_block_t)block
{
	size_t i;
	unsigned long mutations = _mutations;

	for (i = 0; i < _capacity; i++) {
		if (_mutations != mutations)
			@throw [OFEnumerationMutationException

			    exceptionWithObject: self];

		if (_buckets[i] != NULL && _buckets[i] != &deleted) {
			void *new;

			new = block(_buckets[i]->key, _buckets[i]->value);
			if (new == NULL)
				@throw [OFInvalidArgumentException exception];



			if (new != _buckets[i]->value) {
				_valueFunctions.release(_buckets[i]->value);
				_buckets[i]->value =
				    _valueFunctions.retain(new);
			}
		}
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
	abort();
}

- (void)reset
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [_mapTable class]
				object: _mapTable];

	_position = 0;
}
@end

@implementation OFMapTableKeyEnumerator
- (void*)nextValue
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [_mapTable class]
				object: _mapTable];

	for (; _position < _capacity && (_buckets[_position] == NULL ||
	    _buckets[_position] == &deleted); _position++);

	if (_position < _capacity)
		return _buckets[_position++]->key;
	else
		return NULL;
}
@end

@implementation OFMapTableValueEnumerator
- (void*)nextValue
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [_mapTable class]
				object: _mapTable];

	for (; _position < _capacity && (_buckets[_position] == NULL ||
	    _buckets[_position] == &deleted); _position++);

	if (_position < _capacity)
		return _buckets[_position++]->value;
	else







<
|










<
|
















<
|







666
667
668
669
670
671
672

673
674
675
676
677
678
679
680
681
682
683

684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700

701
702
703
704
705
706
707
708
	abort();
}

- (void)reset
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException

		    exceptionWithObject: _mapTable];

	_position = 0;
}
@end

@implementation OFMapTableKeyEnumerator
- (void*)nextValue
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException

		    exceptionWithObject: _mapTable];

	for (; _position < _capacity && (_buckets[_position] == NULL ||
	    _buckets[_position] == &deleted); _position++);

	if (_position < _capacity)
		return _buckets[_position++]->key;
	else
		return NULL;
}
@end

@implementation OFMapTableValueEnumerator
- (void*)nextValue
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException

		    exceptionWithObject: _mapTable];

	for (; _position < _capacity && (_buckets[_position] == NULL ||
	    _buckets[_position] == &deleted); _position++);

	if (_position < _capacity)
		return _buckets[_position++]->value;
	else
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
{
	id ret;

	@try {
		ret = [_enumerator nextValue];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [_object class]
				object: _object];
	}

	return ret;
}

- (void)reset
{
	@try {
		[_enumerator reset];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [_object class]
				object: _object];
	}
}
@end







<
|











<
|



734
735
736
737
738
739
740

741
742
743
744
745
746
747
748
749
750
751
752

753
754
755
756
{
	id ret;

	@try {
		ret = [_enumerator nextValue];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException

		    exceptionWithObject: _object];
	}

	return ret;
}

- (void)reset
{
	@try {
		[_enumerator reset];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException

		    exceptionWithObject: _object];
	}
}
@end

Modified src/OFMessagePackExtension.m from [5710c5d5b2] to [015dabf7d7].

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- initWithType: (int8_t)type
	  data: (OFDataArray*)data
{
	self = [super init];

	@try {
		if (data == nil || [data itemSize] != 1)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		_type = type;
		_data = [data retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}







|
<
<







49
50
51
52
53
54
55
56


57
58
59
60
61
62
63
- initWithType: (int8_t)type
	  data: (OFDataArray*)data
{
	self = [super init];

	@try {
		if (data == nil || [data itemSize] != 1)
			@throw [OFInvalidArgumentException exception];



		_type = type;
		_data = [data retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

Modified src/OFMutableArray.m from [f511e7126a] to [20e48ccd57].

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

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
{
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	count = [self count];

	for (i = 0; i < count; i++) {
		if ([[self objectAtIndex: i] isEqual: oldObject]) {
			[self replaceObjectAtIndex: i
					withObject: newObject];
			return;
		}
	}
}

- (void)replaceObjectIdenticalTo: (id)oldObject
		      withObject: (id)newObject
{
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	count = [self count];

	for (i = 0; i < count; i++) {
		if ([self objectAtIndex: i] == oldObject) {
			[self replaceObjectAtIndex: i
					withObject: newObject];







|
<


















|
<







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

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
{
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException exception];


	count = [self count];

	for (i = 0; i < count; i++) {
		if ([[self objectAtIndex: i] isEqual: oldObject]) {
			[self replaceObjectAtIndex: i
					withObject: newObject];
			return;
		}
	}
}

- (void)replaceObjectIdenticalTo: (id)oldObject
		      withObject: (id)newObject
{
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException exception];


	count = [self count];

	for (i = 0; i < count; i++) {
		if ([self objectAtIndex: i] == oldObject) {
			[self replaceObjectAtIndex: i
					withObject: newObject];
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
337
338
339
340
341
342
343
344
345
}

- (void)removeObject: (id)object
{
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	count = [self count];

	for (i = 0; i < count; i++) {
		if ([[self objectAtIndex: i] isEqual: object]) {
			[self removeObjectAtIndex: i];

			return;
		}
	}
}

- (void)removeObjectIdenticalTo: (id)object
{
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	count = [self count];

	for (i = 0; i < count; i++) {
		if ([self objectAtIndex: i] == object) {
			[self removeObjectAtIndex: i];








|
<

















|
<







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
337
338
339
340
341
}

- (void)removeObject: (id)object
{
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException exception];


	count = [self count];

	for (i = 0; i < count; i++) {
		if ([[self objectAtIndex: i] isEqual: object]) {
			[self removeObjectAtIndex: i];

			return;
		}
	}
}

- (void)removeObjectIdenticalTo: (id)object
{
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException exception];


	count = [self count];

	for (i = 0; i < count; i++) {
		if ([self objectAtIndex: i] == object) {
			[self removeObjectAtIndex: i];

Modified src/OFMutableArray_adjacent.m from [4bdaba029a] to [190fb95780].

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

	return self;
}

- (void)addObject: (id)object
{
	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	[_array addItem: &object];
	[object retain];

	_mutations++;
}

- (void)insertObject: (id)object
	     atIndex: (size_t)index
{
	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	@try {
		[_array insertItem: &object
			   atIndex: index];
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];
	}
	[object retain];

	_mutations++;
}

- (void)insertObjectsFromArray: (OFArray*)array
		       atIndex: (size_t)index
{
	id *objects = [array objects];
	size_t i, count = [array count];

	@try {
		[_array insertItems: objects
			    atIndex: index
			      count: count];
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];
	}

	for (i = 0; i < count; i++)
		[objects[i] retain];

	_mutations++;
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
{
	id *objects;
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [_array items];
	count = [_array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: oldObject]) {
			[newObject retain];







|
<











|
<





|

















|















|
<







47
48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
63
64
65
66

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113

	return self;
}

- (void)addObject: (id)object
{
	if (object == nil)
		@throw [OFInvalidArgumentException exception];


	[_array addItem: &object];
	[object retain];

	_mutations++;
}

- (void)insertObject: (id)object
	     atIndex: (size_t)index
{
	if (object == nil)
		@throw [OFInvalidArgumentException exception];


	@try {
		[_array insertItem: &object
			   atIndex: index];
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exception];
	}
	[object retain];

	_mutations++;
}

- (void)insertObjectsFromArray: (OFArray*)array
		       atIndex: (size_t)index
{
	id *objects = [array objects];
	size_t i, count = [array count];

	@try {
		[_array insertItems: objects
			    atIndex: index
			      count: count];
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exception];
	}

	for (i = 0; i < count; i++)
		[objects[i] retain];

	_mutations++;
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
{
	id *objects;
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException exception];


	objects = [_array items];
	count = [_array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: oldObject]) {
			[newObject retain];
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
- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (id)object
{
	id *objects;
	id oldObject;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [_array items];

	if (index >= [_array count])
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	oldObject = objects[index];
	objects[index] = [object retain];
	[oldObject release];
}

- (void)replaceObjectIdenticalTo: (id)oldObject
		      withObject: (id)newObject
{
	id *objects;
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [_array items];
	count = [_array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == oldObject) {
			[newObject retain];







|
<




|













|
<







122
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
- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (id)object
{
	id *objects;
	id oldObject;

	if (object == nil)
		@throw [OFInvalidArgumentException exception];


	objects = [_array items];

	if (index >= [_array count])
		@throw [OFOutOfRangeException exception];

	oldObject = objects[index];
	objects[index] = [object retain];
	[oldObject release];
}

- (void)replaceObjectIdenticalTo: (id)oldObject
		      withObject: (id)newObject
{
	id *objects;
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException exception];


	objects = [_array items];
	count = [_array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == oldObject) {
			[newObject retain];
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

- (void)removeObject: (id)object
{
	id *objects;
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [_array items];
	count = [_array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: object]) {
			object = objects[i];







|
<







163
164
165
166
167
168
169
170

171
172
173
174
175
176
177

- (void)removeObject: (id)object
{
	id *objects;
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException exception];


	objects = [_array items];
	count = [_array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: object]) {
			object = objects[i];
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209

- (void)removeObjectIdenticalTo: (id)object
{
	id *objects;
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [_array items];
	count = [_array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == object) {
			[_array removeItemAtIndex: i];







|
<







188
189
190
191
192
193
194
195

196
197
198
199
200
201
202

- (void)removeObjectIdenticalTo: (id)object
{
	id *objects;
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException exception];


	objects = [_array items];
	count = [_array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == object) {
			[_array removeItemAtIndex: i];
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
- (void)removeObjectsInRange: (of_range_t)range
{
	id *objects = [_array items], *copy;
	size_t i, count = [_array count];

	if (range.length > SIZE_MAX - range.location ||
	    range.length > count - range.location)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	copy = [self allocMemoryWithSize: sizeof(*copy)
				   count: range.length];
	memcpy(copy, objects + range.location, range.length * sizeof(id));

	@try {
		[_array removeItemsInRange: range];







|







232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
- (void)removeObjectsInRange: (of_range_t)range
{
	id *objects = [_array items], *copy;
	size_t i, count = [_array count];

	if (range.length > SIZE_MAX - range.location ||
	    range.length > count - range.location)
		@throw [OFOutOfRangeException exception];

	copy = [self allocMemoryWithSize: sizeof(*copy)
				   count: range.length];
	memcpy(copy, objects + range.location, range.length * sizeof(id));

	@try {
		[_array removeItemsInRange: range];
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
	    withObjectAtIndex: (size_t)index2
{
	id *objects = [_array items];
	size_t count = [_array count];
	id tmp;

	if (index1 >= count || index2 >= count)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	tmp = objects[index1];
	objects[index1] = objects[index2];
	objects[index2] = tmp;
}

- (void)reverse







|







272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
	    withObjectAtIndex: (size_t)index2
{
	id *objects = [_array items];
	size_t count = [_array count];
	id tmp;

	if (index1 >= count || index2 >= count)
		@throw [OFOutOfRangeException exception];

	tmp = objects[index1];
	objects[index1] = objects[index2];
	objects[index2] = tmp;
}

- (void)reverse
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
	size_t i, count = [_array count];
	bool stop = false;
	unsigned long mutations = _mutations;

	for (i = 0; i < count && !stop; i++) {
		if (_mutations != mutations)
			@throw [OFEnumerationMutationException
			    exceptionWithClass: [self class]
					object: self];

		block(objects[i], i, &stop);
	}
}

- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	id *objects = [_array items];
	size_t i, count = [_array count];
	unsigned long mutations = _mutations;

	for (i = 0; i < count; i++) {
		id new;

		if (_mutations != mutations)
			@throw [OFEnumerationMutationException
			    exceptionWithClass: [self class]
					object: self];

		new = block(objects[i], i);

		if (new == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		if (new != objects[i]) {
			[objects[i] release];
			objects[i] = [new retain];
		}
	}
}







<
|
















<
|




|
<
<







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
	size_t i, count = [_array count];
	bool stop = false;
	unsigned long mutations = _mutations;

	for (i = 0; i < count && !stop; i++) {
		if (_mutations != mutations)
			@throw [OFEnumerationMutationException

			    exceptionWithObject: self];

		block(objects[i], i, &stop);
	}
}

- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	id *objects = [_array items];
	size_t i, count = [_array count];
	unsigned long mutations = _mutations;

	for (i = 0; i < count; i++) {
		id new;

		if (_mutations != mutations)
			@throw [OFEnumerationMutationException

			    exceptionWithObject: self];

		new = block(objects[i], i);

		if (new == nil)
			@throw [OFInvalidArgumentException exception];



		if (new != objects[i]) {
			[objects[i] release];
			objects[i] = [new retain];
		}
	}
}

Modified src/OFMutableDictionary_hashtable.m from [e4b0cd098c] to [697582eaa4].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <string.h>

#import "OFMutableDictionary_hashtable.h"
#import "OFDictionary_hashtable.h"
#import "OFMapTable.h"

#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"

#import "macros.h"

@implementation OFMutableDictionary_hashtable
+ (void)initialize
{
	if (self == [OFMutableDictionary_hashtable class])
		[self inheritMethodsFromClass: [OFDictionary_hashtable class]];
}

- (void)setObject: (id)object
	   forKey: (id)key
{
	@try {
		[_mapTable setValue: object
			     forKey: key];
	} @catch (OFInvalidArgumentException *e) {
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}
}

- (void)removeObjectForKey: (id)key
{
	@try {
		[_mapTable removeValueForKey: key];
	} @catch (OFInvalidArgumentException *e) {
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}
}

#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
	@try {
		[_mapTable replaceValuesUsingBlock:
		    ^ void* (void *key, void *value) {
			return block(key, value);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: self];
	}
}
#endif

- (void)makeImmutable
{
	object_setClass(self, [OFDictionary_hashtable class]);
}
@end







<














<


<
<
<
<
<




<

<
<
<
<
<












<
|









19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
34
35
36
37
38
39

40
41





42
43
44
45

46





47
48
49
50
51
52
53
54
55
56
57
58

59
60
61
62
63
64
65
66
67
68
#include <string.h>

#import "OFMutableDictionary_hashtable.h"
#import "OFDictionary_hashtable.h"
#import "OFMapTable.h"

#import "OFEnumerationMutationException.h"

#import "OFOutOfRangeException.h"

#import "macros.h"

@implementation OFMutableDictionary_hashtable
+ (void)initialize
{
	if (self == [OFMutableDictionary_hashtable class])
		[self inheritMethodsFromClass: [OFDictionary_hashtable class]];
}

- (void)setObject: (id)object
	   forKey: (id)key
{

		[_mapTable setValue: object
			     forKey: key];





}

- (void)removeObjectForKey: (id)key
{

		[_mapTable removeValueForKey: key];





}

#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
	@try {
		[_mapTable replaceValuesUsingBlock:
		    ^ void* (void *key, void *value) {
			return block(key, value);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException

		    exceptionWithObject: self];
	}
}
#endif

- (void)makeImmutable
{
	object_setClass(self, [OFDictionary_hashtable class]);
}
@end

Modified src/OFMutableString.m from [ab8d403b2b] to [8d0822912d].

394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
- (void)appendFormat: (OFConstantString*)format
	   arguments: (va_list)arguments
{
	char *UTF8String;
	int UTF8StringLength;

	if (format == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String],
	    arguments)) == -1)
		@throw [OFInvalidFormatException
		    exceptionWithClass: [self class]];

	@try {
		[self appendUTF8String: UTF8String
				length: UTF8StringLength];
	} @finally {
		free(UTF8String);
	}







|
<
<



|
<







394
395
396
397
398
399
400
401


402
403
404
405

406
407
408
409
410
411
412
- (void)appendFormat: (OFConstantString*)format
	   arguments: (va_list)arguments
{
	char *UTF8String;
	int UTF8StringLength;

	if (format == nil)
		@throw [OFInvalidArgumentException exception];



	if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String],
	    arguments)) == -1)
		@throw [OFInvalidFormatException exception];


	@try {
		[self appendUTF8String: UTF8String
				length: UTF8StringLength];
	} @finally {
		free(UTF8String);
	}
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
	const of_unichar_t *searchCharacters = [string characters];
	size_t searchLength = [string length];
	size_t replacementLength = [replacement length];
	size_t i;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > [self length])
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (searchLength > range.length) {
		objc_autoreleasePoolPop(pool);
		return;
	}

	pool2 = objc_autoreleasePoolPush();







|







494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
	const of_unichar_t *searchCharacters = [string characters];
	size_t searchLength = [string length];
	size_t replacementLength = [replacement length];
	size_t i;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > [self length])
		@throw [OFOutOfRangeException exception];

	if (searchLength > range.length) {
		objc_autoreleasePoolPop(pool);
		return;
	}

	pool2 = objc_autoreleasePoolPush();

Modified src/OFMutableString_UTF8.m from [50da202bb8] to [7fb8de4d28].

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
		}

		cLen = of_string_utf8_decode(_s->cString + i,
		    _s->cStringLength - i, &c);

		if (cLen == 0 || c > 0x10FFFF) {
			[self freeMemory: unicodeString];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];
		}

		switch (c) {
		case ' ':
		case '\t':
		case '\n':
		case '\r':







|
<







123
124
125
126
127
128
129
130

131
132
133
134
135
136
137
		}

		cLen = of_string_utf8_decode(_s->cString + i,
		    _s->cStringLength - i, &c);

		if (cLen == 0 || c > 0x10FFFF) {
			[self freeMemory: unicodeString];
			@throw [OFInvalidEncodingException exception];

		}

		switch (c) {
		case ' ':
		case '\t':
		case '\n':
		case '\r':
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
			newCStringLength += 2;
		else if (c < 0x10000)
			newCStringLength += 3;
		else if (c < 0x110000)
			newCStringLength += 4;
		else {
			[self freeMemory: unicodeString];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];
		}

		i += cLen;
	}

	@try {
		newCString = [self allocMemoryWithSize: newCStringLength + 1];







|
<







156
157
158
159
160
161
162
163

164
165
166
167
168
169
170
			newCStringLength += 2;
		else if (c < 0x10000)
			newCStringLength += 3;
		else if (c < 0x110000)
			newCStringLength += 4;
		else {
			[self freeMemory: unicodeString];
			@throw [OFInvalidEncodingException exception];

		}

		i += cLen;
	}

	@try {
		newCString = [self allocMemoryWithSize: newCStringLength + 1];
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
	for (i = 0; i < unicodeLen; i++) {
		size_t d;

		if ((d = of_string_utf8_encode(unicodeString[i],
		    newCString + j)) == 0) {
			[self freeMemory: unicodeString];
			[self freeMemory: newCString];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];
		}
		j += d;
	}

	assert(j == newCStringLength);
	newCString[j] = 0;
	[self freeMemory: unicodeString];







|
<







178
179
180
181
182
183
184
185

186
187
188
189
190
191
192
	for (i = 0; i < unicodeLen; i++) {
		size_t d;

		if ((d = of_string_utf8_encode(unicodeString[i],
		    newCString + j)) == 0) {
			[self freeMemory: unicodeString];
			[self freeMemory: newCString];
			@throw [OFInvalidEncodingException exception];

		}
		j += d;
	}

	assert(j == newCStringLength);
	newCString[j] = 0;
	[self freeMemory: unicodeString];
213
214
215
216
217
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
	size_t lenNew, lenOld;

	if (_s->isUTF8)
		index = of_string_utf8_get_position(_s->cString, index,
		    _s->cStringLength);

	if (index > _s->cStringLength)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	/* Shortcut if old and new character both are ASCII */
	if (!(character & 0x80) && !(_s->cString[index] & 0x80)) {
		_s->hashed = false;
		_s->cString[index] = character;
		return;
	}

	if ((lenNew = of_string_utf8_encode(character, buffer)) == 0)
		@throw [OFInvalidEncodingException
		    exceptionWithClass: [self class]];

	if ((lenOld = of_string_utf8_decode(_s->cString + index,
	    _s->cStringLength - index, &c)) == 0)
		@throw [OFInvalidEncodingException
		    exceptionWithClass: [self class]];

	_s->hashed = false;

	if (lenNew == lenOld)
		memcpy(_s->cString + index, buffer, lenNew);
	else if (lenNew > lenOld) {
		_s->cString = [self resizeMemory: _s->cString







|









|
<



|
<







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227

228
229
230
231

232
233
234
235
236
237
238
	size_t lenNew, lenOld;

	if (_s->isUTF8)
		index = of_string_utf8_get_position(_s->cString, index,
		    _s->cStringLength);

	if (index > _s->cStringLength)
		@throw [OFOutOfRangeException exception];

	/* Shortcut if old and new character both are ASCII */
	if (!(character & 0x80) && !(_s->cString[index] & 0x80)) {
		_s->hashed = false;
		_s->cString[index] = character;
		return;
	}

	if ((lenNew = of_string_utf8_encode(character, buffer)) == 0)
		@throw [OFInvalidEncodingException exception];


	if ((lenOld = of_string_utf8_decode(_s->cString + index,
	    _s->cStringLength - index, &c)) == 0)
		@throw [OFInvalidEncodingException exception];


	_s->hashed = false;

	if (lenNew == lenOld)
		memcpy(_s->cString + index, buffer, lenNew);
	else if (lenNew > lenOld) {
		_s->cString = [self resizeMemory: _s->cString
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
	}

	switch (of_string_utf8_check(UTF8String, UTF8StringLength, &length)) {
	case 1:
		_s->isUTF8 = true;
		break;
	case -1:
		@throw [OFInvalidEncodingException
		    exceptionWithClass: [self class]];
	}

	_s->hashed = false;
	_s->cString = [self resizeMemory: _s->cString
				    size: _s->cStringLength +
					  UTF8StringLength + 1];
	memcpy(_s->cString + _s->cStringLength, UTF8String,







|
<







282
283
284
285
286
287
288
289

290
291
292
293
294
295
296
	}

	switch (of_string_utf8_check(UTF8String, UTF8StringLength, &length)) {
	case 1:
		_s->isUTF8 = true;
		break;
	case -1:
		@throw [OFInvalidEncodingException exception];

	}

	_s->hashed = false;
	_s->cString = [self resizeMemory: _s->cString
				    size: _s->cStringLength +
					  UTF8StringLength + 1];
	memcpy(_s->cString + _s->cStringLength, UTF8String,
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
	}

	switch (of_string_utf8_check(UTF8String, UTF8StringLength, &length)) {
	case 1:
		_s->isUTF8 = true;
		break;
	case -1:
		@throw [OFInvalidEncodingException
		    exceptionWithClass: [self class]];
	}

	_s->hashed = false;
	_s->cString = [self resizeMemory: _s->cString
				    size: _s->cStringLength +
					  UTF8StringLength + 1];
	memcpy(_s->cString + _s->cStringLength, UTF8String, UTF8StringLength);







|
<







311
312
313
314
315
316
317
318

319
320
321
322
323
324
325
	}

	switch (of_string_utf8_check(UTF8String, UTF8StringLength, &length)) {
	case 1:
		_s->isUTF8 = true;
		break;
	case -1:
		@throw [OFInvalidEncodingException exception];

	}

	_s->hashed = false;
	_s->cString = [self resizeMemory: _s->cString
				    size: _s->cStringLength +
					  UTF8StringLength + 1];
	memcpy(_s->cString + _s->cStringLength, UTF8String, UTF8StringLength);
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
}

- (void)appendString: (OFString*)string
{
	size_t UTF8StringLength;

	if (string == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	UTF8StringLength = [string UTF8StringLength];

	_s->hashed = false;
	_s->cString = [self resizeMemory: _s->cString
				    size: _s->cStringLength +
					  UTF8StringLength + 1];







|
<
<







356
357
358
359
360
361
362
363


364
365
366
367
368
369
370
}

- (void)appendString: (OFString*)string
{
	size_t UTF8StringLength;

	if (string == nil)
		@throw [OFInvalidArgumentException exception];



	UTF8StringLength = [string UTF8StringLength];

	_s->hashed = false;
	_s->cString = [self resizeMemory: _s->cString
				    size: _s->cStringLength +
					  UTF8StringLength + 1];
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
				isUTF8 = true;

				memcpy(tmp + j, buffer, 4);
				j += 4;

				break;
			default:
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
			}
		}

		tmp[j] = '\0';

		_s->hashed = false;
		_s->cString = [self resizeMemory: _s->cString







|
<







419
420
421
422
423
424
425
426

427
428
429
430
431
432
433
				isUTF8 = true;

				memcpy(tmp + j, buffer, 4);
				j += 4;

				break;
			default:
				@throw [OFInvalidEncodingException exception];

			}
		}

		tmp[j] = '\0';

		_s->hashed = false;
		_s->cString = [self resizeMemory: _s->cString
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
- (void)appendFormat: (OFConstantString*)format
	   arguments: (va_list)arguments
{
	char *UTF8String;
	int UTF8StringLength;

	if (format == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String],
	    arguments)) == -1)
		@throw [OFInvalidFormatException
		    exceptionWithClass: [self class]];

	@try {
		[self appendUTF8String: UTF8String
				length: UTF8StringLength];
	} @finally {
		free(UTF8String);
	}







|
<
<



|
<







447
448
449
450
451
452
453
454


455
456
457
458

459
460
461
462
463
464
465
- (void)appendFormat: (OFConstantString*)format
	   arguments: (va_list)arguments
{
	char *UTF8String;
	int UTF8StringLength;

	if (format == nil)
		@throw [OFInvalidArgumentException exception];



	if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String],
	    arguments)) == -1)
		@throw [OFInvalidFormatException exception];


	@try {
		[self appendUTF8String: UTF8String
				length: UTF8StringLength];
	} @finally {
		free(UTF8String);
	}
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
	for (i = 0; i < _s->cStringLength; i++) {
		/* ASCII */
		if OF_LIKELY (!(_s->cString[i] & 0x80))
			continue;

		/* A start byte can't happen first as we reversed everything */
		if OF_UNLIKELY (_s->cString[i] & 0x40)
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];

		/* Next byte must not be ASCII */
		if OF_UNLIKELY (_s->cStringLength < i + 1 ||
		    !(_s->cString[i + 1] & 0x80))
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];

		/* Next byte is the start byte */
		if OF_LIKELY (_s->cString[i + 1] & 0x40) {
			_s->cString[i] ^= _s->cString[i + 1];
			_s->cString[i + 1] ^= _s->cString[i];
			_s->cString[i] ^= _s->cString[i + 1];

			i++;
			continue;
		}

		/* Second next byte must not be ASCII */
		if OF_UNLIKELY (_s->cStringLength < i + 2 ||
		    !(_s->cString[i + 2] & 0x80))
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];

		/* Second next byte is the start byte */
		if OF_LIKELY (_s->cString[i + 2] & 0x40) {
			_s->cString[i] ^= _s->cString[i + 2];
			_s->cString[i + 2] ^= _s->cString[i];
			_s->cString[i] ^= _s->cString[i + 2];

			i += 2;
			continue;
		}

		/* Third next byte must not be ASCII */
		if OF_UNLIKELY (_s->cStringLength < i + 3 ||
		    !(_s->cString[i + 3] & 0x80))
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];

		/* Third next byte is the start byte */
		if OF_LIKELY (_s->cString[i + 3] & 0x40) {
			_s->cString[i] ^= _s->cString[i + 3];
			_s->cString[i + 3] ^= _s->cString[i];
			_s->cString[i] ^= _s->cString[i + 3];

			_s->cString[i + 1] ^= _s->cString[i + 2];
			_s->cString[i + 2] ^= _s->cString[i + 1];
			_s->cString[i + 1] ^= _s->cString[i + 2];

			i += 3;
			continue;
		}

		/* UTF-8 does not allow more than 4 bytes per character */
		@throw [OFInvalidEncodingException
		    exceptionWithClass: [self class]];
	}
}

- (void)insertString: (OFString*)string
	     atIndex: (size_t)index
{
	size_t newCStringLength;

	if (index > _s->length)
		@throw [OFOutOfRangeException
		    exceptionWithClass: [self class]];

	if (_s->isUTF8)
		index = of_string_utf8_get_position(_s->cString, index,
		    _s->cStringLength);

	newCStringLength = _s->cStringLength + [string UTF8StringLength];
	_s->hashed = false;







|
<




|
<














|
<














|
<
















|
<









|
<







485
486
487
488
489
490
491
492

493
494
495
496
497

498
499
500
501
502
503
504
505
506
507
508
509
510
511
512

513
514
515
516
517
518
519
520
521
522
523
524
525
526
527

528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544

545
546
547
548
549
550
551
552
553
554

555
556
557
558
559
560
561
	for (i = 0; i < _s->cStringLength; i++) {
		/* ASCII */
		if OF_LIKELY (!(_s->cString[i] & 0x80))
			continue;

		/* A start byte can't happen first as we reversed everything */
		if OF_UNLIKELY (_s->cString[i] & 0x40)
			@throw [OFInvalidEncodingException exception];


		/* Next byte must not be ASCII */
		if OF_UNLIKELY (_s->cStringLength < i + 1 ||
		    !(_s->cString[i + 1] & 0x80))
			@throw [OFInvalidEncodingException exception];


		/* Next byte is the start byte */
		if OF_LIKELY (_s->cString[i + 1] & 0x40) {
			_s->cString[i] ^= _s->cString[i + 1];
			_s->cString[i + 1] ^= _s->cString[i];
			_s->cString[i] ^= _s->cString[i + 1];

			i++;
			continue;
		}

		/* Second next byte must not be ASCII */
		if OF_UNLIKELY (_s->cStringLength < i + 2 ||
		    !(_s->cString[i + 2] & 0x80))
			@throw [OFInvalidEncodingException exception];


		/* Second next byte is the start byte */
		if OF_LIKELY (_s->cString[i + 2] & 0x40) {
			_s->cString[i] ^= _s->cString[i + 2];
			_s->cString[i + 2] ^= _s->cString[i];
			_s->cString[i] ^= _s->cString[i + 2];

			i += 2;
			continue;
		}

		/* Third next byte must not be ASCII */
		if OF_UNLIKELY (_s->cStringLength < i + 3 ||
		    !(_s->cString[i + 3] & 0x80))
			@throw [OFInvalidEncodingException exception];


		/* Third next byte is the start byte */
		if OF_LIKELY (_s->cString[i + 3] & 0x40) {
			_s->cString[i] ^= _s->cString[i + 3];
			_s->cString[i + 3] ^= _s->cString[i];
			_s->cString[i] ^= _s->cString[i + 3];

			_s->cString[i + 1] ^= _s->cString[i + 2];
			_s->cString[i + 2] ^= _s->cString[i + 1];
			_s->cString[i + 1] ^= _s->cString[i + 2];

			i += 3;
			continue;
		}

		/* UTF-8 does not allow more than 4 bytes per character */
		@throw [OFInvalidEncodingException exception];

	}
}

- (void)insertString: (OFString*)string
	     atIndex: (size_t)index
{
	size_t newCStringLength;

	if (index > _s->length)
		@throw [OFOutOfRangeException exception];


	if (_s->isUTF8)
		index = of_string_utf8_get_position(_s->cString, index,
		    _s->cStringLength);

	newCStringLength = _s->cStringLength + [string UTF8StringLength];
	_s->hashed = false;
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614

- (void)deleteCharactersInRange: (of_range_t)range
{
	size_t start = range.location;
	size_t end = range.location + range.length;

	if (range.length > SIZE_MAX - range.location || end > _s->length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (_s->isUTF8) {
		start = of_string_utf8_get_position(_s->cString, start,
		    _s->cStringLength);
		end = of_string_utf8_get_position(_s->cString, end,
		    _s->cStringLength);
	}







|







581
582
583
584
585
586
587
588
589
590
591
592
593
594
595

- (void)deleteCharactersInRange: (of_range_t)range
{
	size_t start = range.location;
	size_t end = range.location + range.length;

	if (range.length > SIZE_MAX - range.location || end > _s->length)
		@throw [OFOutOfRangeException exception];

	if (_s->isUTF8) {
		start = of_string_utf8_get_position(_s->cString, start,
		    _s->cStringLength);
		end = of_string_utf8_get_position(_s->cString, end,
		    _s->cStringLength);
	}
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
		      withString: (OFString*)replacement
{
	size_t start = range.location;
	size_t end = range.location + range.length;
	size_t newCStringLength, newLength;

	if (range.length > SIZE_MAX - range.location || end > _s->length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	newLength = _s->length - range.length + [replacement length];

	if (_s->isUTF8) {
		start = of_string_utf8_get_position(_s->cString, start,
		    _s->cStringLength);
		end = of_string_utf8_get_position(_s->cString, end,







|







613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
		      withString: (OFString*)replacement
{
	size_t start = range.location;
	size_t end = range.location + range.length;
	size_t newCStringLength, newLength;

	if (range.length > SIZE_MAX - range.location || end > _s->length)
		@throw [OFOutOfRangeException exception];

	newLength = _s->length - range.length + [replacement length];

	if (_s->isUTF8) {
		start = of_string_utf8_get_position(_s->cString, start,
		    _s->cStringLength);
		end = of_string_utf8_get_position(_s->cString, end,
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
	size_t searchLength = [string UTF8StringLength];
	size_t replacementLength = [replacement UTF8StringLength];
	size_t i, last, newCStringLength, newLength;
	char *newCString;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > [self length])
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (_s->isUTF8) {
		range.location = of_string_utf8_get_position(_s->cString,
		    range.location, _s->cStringLength);
		range.length = of_string_utf8_get_position(
		    _s->cString + range.location, range.length,
		    _s->cStringLength - range.location);







|







654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
	size_t searchLength = [string UTF8StringLength];
	size_t replacementLength = [replacement UTF8StringLength];
	size_t i, last, newCStringLength, newLength;
	char *newCString;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > [self length])
		@throw [OFOutOfRangeException exception];

	if (_s->isUTF8) {
		range.location = of_string_utf8_get_position(_s->cString,
		    range.location, _s->cStringLength);
		range.length = of_string_utf8_get_position(
		    _s->cString + range.location, range.length,
		    _s->cStringLength - range.location);

Modified src/OFMutex.m from [c030ce7087] to [8d97287034].

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

	return self;
}

- (void)lock
{
	if (!of_mutex_lock(&_mutex))
		@throw [OFLockFailedException exceptionWithClass: [self class]
							    lock: self];
}

- (bool)tryLock
{
	return of_mutex_trylock(&_mutex);
}

- (void)unlock
{
	if (!of_mutex_unlock(&_mutex))
		@throw [OFUnlockFailedException exceptionWithClass: [self class]
							      lock: self];
}

- (void)setName: (OFString*)name
{
	OF_SETTER(_name, name, true, 1)
}








|
<










|
<







46
47
48
49
50
51
52
53

54
55
56
57
58
59
60
61
62
63
64

65
66
67
68
69
70
71

	return self;
}

- (void)lock
{
	if (!of_mutex_lock(&_mutex))
		@throw [OFLockFailedException exceptionWithLock: self];

}

- (bool)tryLock
{
	return of_mutex_trylock(&_mutex);
}

- (void)unlock
{
	if (!of_mutex_unlock(&_mutex))
		@throw [OFUnlockFailedException exceptionWithLock: self];

}

- (void)setName: (OFString*)name
{
	OF_SETTER(_name, name, true, 1)
}

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
					   [self className], _name];
}

- (void)dealloc
{
	if (_initialized)
		if (!of_mutex_free(&_mutex))
			@throw [OFStillLockedException
			    exceptionWithClass: [self class]
					  lock: self];

	[_name release];

	[super dealloc];
}
@end







|
<
<






83
84
85
86
87
88
89
90


91
92
93
94
95
96
					   [self className], _name];
}

- (void)dealloc
{
	if (_initialized)
		if (!of_mutex_free(&_mutex))
			@throw [OFStillLockedException exceptionWithLock: self];



	[_name release];

	[super dealloc];
}
@end

Modified src/OFNull.m from [13afae3773] to [10a564f1a5].

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

	[self release];

	pool = objc_autoreleasePoolPush();

	if (![[element name] isEqual: [self className]] ||
	    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	objc_autoreleasePoolPop(pool);

	return [OFNull null];
}

- (OFString*)description







|
<
<







46
47
48
49
50
51
52
53


54
55
56
57
58
59
60

	[self release];

	pool = objc_autoreleasePoolPush();

	if (![[element name] isEqual: [self className]] ||
	    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
		@throw [OFInvalidArgumentException exception];



	objc_autoreleasePoolPop(pool);

	return [OFNull null];
}

- (OFString*)description

Modified src/OFNumber.m from [bc121f7ad1] to [779309786a].

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
	case OF_NUMBER_UINTPTR:						\
		return (t)_value.uintptr;				\
	case OF_NUMBER_FLOAT:						\
		return (t)_value.float_;				\
	case OF_NUMBER_DOUBLE:						\
		return (t)_value.double_;				\
	default:							\
		@throw [OFInvalidFormatException			\
		    exceptionWithClass: [self class]];			\
	}
#define CALCULATE(o, n)							\
	switch (_type) {						\
	case OF_NUMBER_BOOL:						\
		return [OFNumber numberWithBool:			\
		    _value.bool_ o [n boolValue]];			\
	case OF_NUMBER_CHAR:						\







|
<







88
89
90
91
92
93
94
95

96
97
98
99
100
101
102
	case OF_NUMBER_UINTPTR:						\
		return (t)_value.uintptr;				\
	case OF_NUMBER_FLOAT:						\
		return (t)_value.float_;				\
	case OF_NUMBER_DOUBLE:						\
		return (t)_value.double_;				\
	default:							\
		@throw [OFInvalidFormatException exception];		\

	}
#define CALCULATE(o, n)							\
	switch (_type) {						\
	case OF_NUMBER_BOOL:						\
		return [OFNumber numberWithBool:			\
		    _value.bool_ o [n boolValue]];			\
	case OF_NUMBER_CHAR:						\
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
	case OF_NUMBER_FLOAT:						\
		return [OFNumber numberWithFloat:			\
		    _value.float_ o [n floatValue]];			\
	case OF_NUMBER_DOUBLE:						\
		return [OFNumber numberWithDouble:			\
		    _value.double_ o [n doubleValue]];			\
	default:							\
		@throw [OFInvalidFormatException			\
		    exceptionWithClass: [self class]];			\
	}
#define CALCULATE2(o, n)						\
	switch (_type) {						\
	case OF_NUMBER_BOOL:						\
		return [OFNumber numberWithBool:			\
		    _value.bool_ o [n boolValue]];			\
	case OF_NUMBER_CHAR:						\







|
<







177
178
179
180
181
182
183
184

185
186
187
188
189
190
191
	case OF_NUMBER_FLOAT:						\
		return [OFNumber numberWithFloat:			\
		    _value.float_ o [n floatValue]];			\
	case OF_NUMBER_DOUBLE:						\
		return [OFNumber numberWithDouble:			\
		    _value.double_ o [n doubleValue]];			\
	default:							\
		@throw [OFInvalidFormatException exception];		\

	}
#define CALCULATE2(o, n)						\
	switch (_type) {						\
	case OF_NUMBER_BOOL:						\
		return [OFNumber numberWithBool:			\
		    _value.bool_ o [n boolValue]];			\
	case OF_NUMBER_CHAR:						\
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
		return [OFNumber numberWithIntPtr:			\
		    _value.intptr o [n intPtrValue]];			\
	case OF_NUMBER_UINTPTR:						\
		return [OFNumber numberWithUIntPtr:			\
		    _value.uintptr o [n uIntPtrValue]];			\
	case OF_NUMBER_FLOAT:						\
	case OF_NUMBER_DOUBLE:						\
		@throw [OFInvalidArgumentException			\
		    exceptionWithClass: [self class]			\
			      selector: _cmd];				\
	default:							\
		@throw [OFInvalidFormatException			\
		    exceptionWithClass: [self class]];			\
	}
#define CALCULATE3(o)							\
	switch (_type) {						\
	case OF_NUMBER_BOOL:						\
		return [OFNumber numberWithBool: _value.bool_ o];	\
	case OF_NUMBER_CHAR:						\
		return [OFNumber numberWithChar: _value.schar o];	\







|
<
<

|
<







261
262
263
264
265
266
267
268


269
270

271
272
273
274
275
276
277
		return [OFNumber numberWithIntPtr:			\
		    _value.intptr o [n intPtrValue]];			\
	case OF_NUMBER_UINTPTR:						\
		return [OFNumber numberWithUIntPtr:			\
		    _value.uintptr o [n uIntPtrValue]];			\
	case OF_NUMBER_FLOAT:						\
	case OF_NUMBER_DOUBLE:						\
		@throw [OFInvalidArgumentException exception];		\


	default:							\
		@throw [OFInvalidFormatException exception];		\

	}
#define CALCULATE3(o)							\
	switch (_type) {						\
	case OF_NUMBER_BOOL:						\
		return [OFNumber numberWithBool: _value.bool_ o];	\
	case OF_NUMBER_CHAR:						\
		return [OFNumber numberWithChar: _value.schar o];	\
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
	case OF_NUMBER_UINTPTR:						\
		return [OFNumber numberWithUIntPtr: _value.uintptr o];	\
	case OF_NUMBER_FLOAT:						\
		return [OFNumber numberWithFloat: _value.float_ o];	\
	case OF_NUMBER_DOUBLE:						\
		return [OFNumber numberWithDouble: _value.double_ o];	\
	default:							\
		@throw [OFInvalidFormatException			\
		    exceptionWithClass: [self class]];			\
	}

@implementation OFNumber
+ (instancetype)numberWithBool: (bool)bool_
{
	return [[[self alloc] initWithBool: bool_] autorelease];
}







|
<







329
330
331
332
333
334
335
336

337
338
339
340
341
342
343
	case OF_NUMBER_UINTPTR:						\
		return [OFNumber numberWithUIntPtr: _value.uintptr o];	\
	case OF_NUMBER_FLOAT:						\
		return [OFNumber numberWithFloat: _value.float_ o];	\
	case OF_NUMBER_DOUBLE:						\
		return [OFNumber numberWithDouble: _value.double_ o];	\
	default:							\
		@throw [OFInvalidFormatException exception];		\

	}

@implementation OFNumber
+ (instancetype)numberWithBool: (bool)bool_
{
	return [[[self alloc] initWithBool: bool_] autorelease];
}
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFString *typeString;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		typeString = [[element attributeForName: @"type"] stringValue];

		if ([typeString isEqual: @"boolean"]) {
			_type = OF_NUMBER_BOOL;

			if ([[element stringValue] isEqual: @"true"])
				_value.bool_ = true;
			else if ([[element stringValue] isEqual: @"false"])
				_value.bool_ = false;
			else
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]
					      selector: _cmd];
		} else if ([typeString isEqual: @"unsigned"]) {
			/*
			 * FIXME: This will fail if the value is bigger than
			 *	  INTMAX_MAX!
			 */
			_type = OF_NUMBER_UINTMAX;
			_value.uintmax = [element decimalValue];







|
<
<











|
<
<







775
776
777
778
779
780
781
782


783
784
785
786
787
788
789
790
791
792
793
794


795
796
797
798
799
800
801

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFString *typeString;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		typeString = [[element attributeForName: @"type"] stringValue];

		if ([typeString isEqual: @"boolean"]) {
			_type = OF_NUMBER_BOOL;

			if ([[element stringValue] isEqual: @"true"])
				_value.bool_ = true;
			else if ([[element stringValue] isEqual: @"false"])
				_value.bool_ = false;
			else
				@throw [OFInvalidArgumentException exception];


		} else if ([typeString isEqual: @"unsigned"]) {
			/*
			 * FIXME: This will fail if the value is bigger than
			 *	  INTMAX_MAX!
			 */
			_type = OF_NUMBER_UINTMAX;
			_value.uintmax = [element decimalValue];
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
			} d;

			d.u = (uint64_t)[element hexadecimalValue];

			_type = OF_NUMBER_DOUBLE;
			_value.double_ = d.d;
		} else
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}








|
<
<







819
820
821
822
823
824
825
826


827
828
829
830
831
832
833
			} d;

			d.u = (uint64_t)[element hexadecimalValue];

			_type = OF_NUMBER_DOUBLE;
			_value.double_ = d.d;
		} else
			@throw [OFInvalidArgumentException exception];



		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}

1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
}

- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFNumber *number;

	if (![object isKindOfClass: [OFNumber class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	number = (OFNumber*)object;

	if (_type & OF_NUMBER_FLOAT || number->_type & OF_NUMBER_FLOAT) {
		double double1 = [self doubleValue];
		double double2 = [number doubleValue];








|
<
<







998
999
1000
1001
1002
1003
1004
1005


1006
1007
1008
1009
1010
1011
1012
}

- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFNumber *number;

	if (![object isKindOfClass: [OFNumber class]])
		@throw [OFInvalidArgumentException exception];



	number = (OFNumber*)object;

	if (_type & OF_NUMBER_FLOAT || number->_type & OF_NUMBER_FLOAT) {
		double double1 = [self doubleValue];
		double double2 = [number doubleValue];

1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
	case OF_NUMBER_FLOAT:
		return [OFNumber numberWithFloat:
		    fmodf(_value.float_, [number floatValue])];
	case OF_NUMBER_DOUBLE:
		return [OFNumber numberWithDouble:
		    fmod(_value.double_, [number doubleValue])];
	default:
		@throw [OFInvalidFormatException
		    exceptionWithClass: [self class]];
	}
}

- copy
{
	return [self retain];
}







|
<







1239
1240
1241
1242
1243
1244
1245
1246

1247
1248
1249
1250
1251
1252
1253
	case OF_NUMBER_FLOAT:
		return [OFNumber numberWithFloat:
		    fmodf(_value.float_, [number floatValue])];
	case OF_NUMBER_DOUBLE:
		return [OFNumber numberWithDouble:
		    fmod(_value.double_, [number doubleValue])];
	default:
		@throw [OFInvalidFormatException exception];

	}
}

- copy
{
	return [self retain];
}
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
		if (![ret containsString: @"."])
			[ret appendString: @".0"];

		[ret makeImmutable];

		return ret;
	default:
		@throw [OFInvalidFormatException
		    exceptionWithClass: [self class]];
	}
}

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool = objc_autoreleasePoolPush();
	OFXMLElement *element;







|
<







1302
1303
1304
1305
1306
1307
1308
1309

1310
1311
1312
1313
1314
1315
1316
		if (![ret containsString: @"."])
			[ret appendString: @".0"];

		[ret makeImmutable];

		return ret;
	default:
		@throw [OFInvalidFormatException exception];

	}
}

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool = objc_autoreleasePoolPush();
	OFXMLElement *element;
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
		[element addAttributeWithName: @"type"
				  stringValue: @"double"];
		[element setStringValue:
		    [OFString stringWithFormat: @"%016" PRIx64, d.u]];

		break;
	default:
		@throw [OFInvalidFormatException
		    exceptionWithClass: [self class]];
	}

	[element retain];

	objc_autoreleasePoolPop(pool);

	return [element autorelease];







|
<







1380
1381
1382
1383
1384
1385
1386
1387

1388
1389
1390
1391
1392
1393
1394
		[element addAttributeWithName: @"type"
				  stringValue: @"double"];
		[element setStringValue:
		    [OFString stringWithFormat: @"%016" PRIx64, d.u]];

		break;
	default:
		@throw [OFInvalidFormatException exception];

	}

	[element retain];

	objc_autoreleasePoolPop(pool);

	return [element autorelease];
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
			data = [OFDataArray dataArrayWithItemSize: 1
							 capacity: 9];

			[data addItem: &type];
			[data addItems: &tmp
				 count: sizeof(tmp)];
		} else
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];
	} else {
		uintmax_t value = [self uIntMaxValue];

		if (value <= 127) {
			uint8_t tmp = ((uint8_t)value & 0x7F);

			data = [OFDataArray dataArrayWithItemSize: 1







|
<







1494
1495
1496
1497
1498
1499
1500
1501

1502
1503
1504
1505
1506
1507
1508
			data = [OFDataArray dataArrayWithItemSize: 1
							 capacity: 9];

			[data addItem: &type];
			[data addItems: &tmp
				 count: sizeof(tmp)];
		} else
			@throw [OFOutOfRangeException exception];

	} else {
		uintmax_t value = [self uIntMaxValue];

		if (value <= 127) {
			uint8_t tmp = ((uint8_t)value & 0x7F);

			data = [OFDataArray dataArrayWithItemSize: 1
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
			data = [OFDataArray dataArrayWithItemSize: 1
							 capacity: 9];

			[data addItem: &type];
			[data addItems: &tmp
				 count: sizeof(tmp)];
		} else
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];
	}

	return data;
}
@end







|
<





1545
1546
1547
1548
1549
1550
1551
1552

1553
1554
1555
1556
1557
			data = [OFDataArray dataArrayWithItemSize: 1
							 capacity: 9];

			[data addItem: &type];
			[data addItems: &tmp
				 count: sizeof(tmp)];
		} else
			@throw [OFOutOfRangeException exception];

	}

	return data;
}
@end

Modified src/OFObject.m from [22ddb06ede] to [87e58e39d7].

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
	abort();
}
#endif

static void
enumeration_mutation_handler(id object)
{
	@throw [OFEnumerationMutationException
	    exceptionWithClass: [object class]
			object: object];
}

void
of_method_not_found(id obj, SEL sel)
{
	[obj doesNotRecognizeSelector: sel];








|
<
<







125
126
127
128
129
130
131
132


133
134
135
136
137
138
139
	abort();
}
#endif

static void
enumeration_mutation_handler(id object)
{
	@throw [OFEnumerationMutationException exceptionWithObject: object];


}

void
of_method_not_found(id obj, SEL sel)
{
	[obj doesNotRecognizeSelector: sel];

870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
	void *pointer;
	struct pre_mem *preMem;

	if OF_UNLIKELY (size == 0)
		return NULL;

	if OF_UNLIKELY (size > SIZE_MAX - PRE_IVARS_ALIGN)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if OF_UNLIKELY ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL)
		@throw [OFOutOfMemoryException exceptionWithClass: [self class]
						    requestedSize: size];
	preMem = pointer;

	preMem->owner = self;
	preMem->prev = PRE_IVARS->lastMem;
	preMem->next = NULL;

	if OF_LIKELY (PRE_IVARS->lastMem != NULL)
		PRE_IVARS->lastMem->next = preMem;

	if OF_UNLIKELY (PRE_IVARS->firstMem == NULL)
		PRE_IVARS->firstMem = preMem;
	PRE_IVARS->lastMem = preMem;

	return (char*)pointer + PRE_MEM_ALIGN;
}

- (void*)allocMemoryWithSize: (size_t)size
		       count: (size_t)count
{
	if OF_UNLIKELY (count > SIZE_MAX / size)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	return [self allocMemoryWithSize: size * count];
}

- (void*)resizeMemory: (void*)pointer
		 size: (size_t)size
{
	void *new;
	struct pre_mem *preMem;

	if OF_UNLIKELY (pointer == NULL)
		return [self allocMemoryWithSize: size];

	if OF_UNLIKELY (size == 0) {
		[self freeMemory: pointer];
		return NULL;
	}

	if OF_UNLIKELY (PRE_MEM(pointer)->owner != self)
		@throw [OFMemoryNotPartOfObjectException
		    exceptionWithClass: [self class]
			       pointer: pointer];

	if OF_UNLIKELY ((new = realloc(PRE_MEM(pointer),
	    PRE_MEM_ALIGN + size)) == NULL)
		@throw [OFOutOfMemoryException exceptionWithClass: [self class]
						    requestedSize: size];
	preMem = new;

	if OF_UNLIKELY (preMem != PRE_MEM(pointer)) {
		if OF_LIKELY (preMem->prev != NULL)
			preMem->prev->next = preMem;
		if OF_LIKELY (preMem->next != NULL)
			preMem->next->prev = preMem;







|


|
|




















|




















|
|



|
|







868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
	void *pointer;
	struct pre_mem *preMem;

	if OF_UNLIKELY (size == 0)
		return NULL;

	if OF_UNLIKELY (size > SIZE_MAX - PRE_IVARS_ALIGN)
		@throw [OFOutOfRangeException exception];

	if OF_UNLIKELY ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: size];
	preMem = pointer;

	preMem->owner = self;
	preMem->prev = PRE_IVARS->lastMem;
	preMem->next = NULL;

	if OF_LIKELY (PRE_IVARS->lastMem != NULL)
		PRE_IVARS->lastMem->next = preMem;

	if OF_UNLIKELY (PRE_IVARS->firstMem == NULL)
		PRE_IVARS->firstMem = preMem;
	PRE_IVARS->lastMem = preMem;

	return (char*)pointer + PRE_MEM_ALIGN;
}

- (void*)allocMemoryWithSize: (size_t)size
		       count: (size_t)count
{
	if OF_UNLIKELY (count > SIZE_MAX / size)
		@throw [OFOutOfRangeException exception];

	return [self allocMemoryWithSize: size * count];
}

- (void*)resizeMemory: (void*)pointer
		 size: (size_t)size
{
	void *new;
	struct pre_mem *preMem;

	if OF_UNLIKELY (pointer == NULL)
		return [self allocMemoryWithSize: size];

	if OF_UNLIKELY (size == 0) {
		[self freeMemory: pointer];
		return NULL;
	}

	if OF_UNLIKELY (PRE_MEM(pointer)->owner != self)
		@throw [OFMemoryNotPartOfObjectException
		    exceptionWithPointer: pointer
				  object: self];

	if OF_UNLIKELY ((new = realloc(PRE_MEM(pointer),
	    PRE_MEM_ALIGN + size)) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: size];
	preMem = new;

	if OF_UNLIKELY (preMem != PRE_MEM(pointer)) {
		if OF_LIKELY (preMem->prev != NULL)
			preMem->prev->next = preMem;
		if OF_LIKELY (preMem->next != NULL)
			preMem->next->prev = preMem;
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982

	if OF_UNLIKELY (size == 0 || count == 0) {
		[self freeMemory: pointer];
		return NULL;
	}

	if OF_UNLIKELY (count > SIZE_MAX / size)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	return [self resizeMemory: pointer
			     size: size * count];
}

- (void)freeMemory: (void*)pointer
{
	if OF_UNLIKELY (pointer == NULL)
		return;

	if OF_UNLIKELY (PRE_MEM(pointer)->owner != self)
		@throw [OFMemoryNotPartOfObjectException
		    exceptionWithClass: [self class]
			       pointer: pointer];

	if OF_LIKELY (PRE_MEM(pointer)->prev != NULL)
		PRE_MEM(pointer)->prev->next = PRE_MEM(pointer)->next;
	if OF_LIKELY (PRE_MEM(pointer)->next != NULL)
		PRE_MEM(pointer)->next->prev = PRE_MEM(pointer)->prev;

	if OF_UNLIKELY (PRE_IVARS->firstMem == PRE_MEM(pointer))







|












|
|







952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980

	if OF_UNLIKELY (size == 0 || count == 0) {
		[self freeMemory: pointer];
		return NULL;
	}

	if OF_UNLIKELY (count > SIZE_MAX / size)
		@throw [OFOutOfRangeException exception];

	return [self resizeMemory: pointer
			     size: size * count];
}

- (void)freeMemory: (void*)pointer
{
	if OF_UNLIKELY (pointer == NULL)
		return;

	if OF_UNLIKELY (PRE_MEM(pointer)->owner != self)
		@throw [OFMemoryNotPartOfObjectException
		    exceptionWithPointer: pointer
				  object: self];

	if OF_LIKELY (PRE_MEM(pointer)->prev != NULL)
		PRE_MEM(pointer)->prev->next = PRE_MEM(pointer)->next;
	if OF_LIKELY (PRE_MEM(pointer)->next != NULL)
		PRE_MEM(pointer)->next->prev = PRE_MEM(pointer)->prev;

	if OF_UNLIKELY (PRE_IVARS->firstMem == PRE_MEM(pointer))
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
- (id)forwardingTargetForSelector: (SEL)selector
{
	return nil;
}

- (void)doesNotRecognizeSelector: (SEL)selector
{
	@throw [OFNotImplementedException exceptionWithClass: [self class]
						    selector: selector];
}

- retain
{
#if defined(OF_HAVE_ATOMIC_OPS)
	of_atomic_inc_32(&PRE_IVARS->retainCount);
#else







|
|







991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
- (id)forwardingTargetForSelector: (SEL)selector
{
	return nil;
}

- (void)doesNotRecognizeSelector: (SEL)selector
{
	@throw [OFNotImplementedException exceptionWithSelector: selector
							 object: self];
}

- retain
{
#if defined(OF_HAVE_ATOMIC_OPS)
	of_atomic_inc_32(&PRE_IVARS->retainCount);
#else

Modified src/OFProcess.m from [499c5dab3d] to [6a59691f03].

388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
	    !ReadFile(_readPipe[0], buffer, length, &ret, NULL)) {
		if (GetLastError() == ERROR_BROKEN_PIPE) {
			_atEndOfStream = true;
			return 0;
		}

#endif
		@throw [OFReadFailedException exceptionWithClass: [self class]
							  stream: self
						 requestedLength: length];
	}

	if (ret == 0)
		_atEndOfStream = true;

	return ret;







|
<







388
389
390
391
392
393
394
395

396
397
398
399
400
401
402
	    !ReadFile(_readPipe[0], buffer, length, &ret, NULL)) {
		if (GetLastError() == ERROR_BROKEN_PIPE) {
			_atEndOfStream = true;
			return 0;
		}

#endif
		@throw [OFReadFailedException exceptionWithStream: self

						 requestedLength: length];
	}

	if (ret == 0)
		_atEndOfStream = true;

	return ret;
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
#else
	DWORD ret;

	if (_writePipe[1] == NULL || _atEndOfStream ||
	    !WriteFile(_writePipe[1], buffer, length, &ret, NULL) ||
	    ret < length)
#endif
		@throw [OFWriteFailedException exceptionWithClass: [self class]
							   stream: self
						  requestedLength: length];
}

- (int)fileDescriptorForReading
{
#ifndef _WIN32
	return _readPipe[0];







|
<







411
412
413
414
415
416
417
418

419
420
421
422
423
424
425
#else
	DWORD ret;

	if (_writePipe[1] == NULL || _atEndOfStream ||
	    !WriteFile(_writePipe[1], buffer, length, &ret, NULL) ||
	    ret < length)
#endif
		@throw [OFWriteFailedException exceptionWithStream: self

						  requestedLength: length];
}

- (int)fileDescriptorForReading
{
#ifndef _WIN32
	return _readPipe[0];

Modified src/OFRecursiveMutex.m from [f580a06287] to [e917c62920].

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

	return self;
}

- (void)lock
{
	if (!of_rmutex_lock(&_rmutex))
		@throw [OFLockFailedException exceptionWithClass: [self class]
							    lock: self];
}

- (bool)tryLock
{
	return of_rmutex_trylock(&_rmutex);
}

- (void)unlock
{
	if (!of_rmutex_unlock(&_rmutex))
		@throw [OFUnlockFailedException exceptionWithClass: [self class]
							      lock: self];
}

- (void)setName: (OFString*)name
{
	OF_SETTER(_name, name, true, 1)
}








|
<










|
<







46
47
48
49
50
51
52
53

54
55
56
57
58
59
60
61
62
63
64

65
66
67
68
69
70
71

	return self;
}

- (void)lock
{
	if (!of_rmutex_lock(&_rmutex))
		@throw [OFLockFailedException exceptionWithLock: self];

}

- (bool)tryLock
{
	return of_rmutex_trylock(&_rmutex);
}

- (void)unlock
{
	if (!of_rmutex_unlock(&_rmutex))
		@throw [OFUnlockFailedException exceptionWithLock: self];

}

- (void)setName: (OFString*)name
{
	OF_SETTER(_name, name, true, 1)
}

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
					   [self className], _name];
}

- (void)dealloc
{
	if (_initialized)
		if (!of_rmutex_free(&_rmutex))
			@throw [OFStillLockedException
			    exceptionWithClass: [self class]
					  lock: self];

	[_name release];

	[super dealloc];
}
@end







|
<
<






83
84
85
86
87
88
89
90


91
92
93
94
95
96
					   [self className], _name];
}

- (void)dealloc
{
	if (_initialized)
		if (!of_rmutex_free(&_rmutex))
			@throw [OFStillLockedException exceptionWithLock: self];



	[_name release];

	[super dealloc];
}
@end

Modified src/OFSHA1Hash.m from [fbdf78c69a] to [0b7be48688].

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
		  length: (size_t)length
{
	if (length == 0)
		return;

	if (_calculated)
		@throw [OFHashAlreadyCalculatedException
		    exceptionWithClass: [self class]
				  hash: self];

	sha1_update(_state, &_count, _buffer, buffer, length);
}

- (uint8_t*)digest
{
	size_t i;







|
<







161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
		  length: (size_t)length
{
	if (length == 0)
		return;

	if (_calculated)
		@throw [OFHashAlreadyCalculatedException
		    exceptionWithHash: self];


	sha1_update(_state, &_count, _buffer, buffer, length);
}

- (uint8_t*)digest
{
	size_t i;

Modified src/OFSet_hashtable.m from [953bd32ef3] to [d36729b45c].

214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		OFXMLElement *child;

		if ((![[element name] isEqual: @"OFSet"] &&
		    ![[element name] isEqual: @"OFMutableSet"]) ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		enumerator = [[element elementsForNamespace:
		    OF_SERIALIZATION_NS] objectEnumerator];
		while ((child = [enumerator nextObject]) != nil) {
			void *pool2  = objc_autoreleasePoolPush();

			[_mapTable setValue: (void*)1







|
<
<







214
215
216
217
218
219
220
221


222
223
224
225
226
227
228
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		OFXMLElement *child;

		if ((![[element name] isEqual: @"OFSet"] &&
		    ![[element name] isEqual: @"OFMutableSet"]) ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		enumerator = [[element elementsForNamespace:
		    OF_SERIALIZATION_NS] objectEnumerator];
		while ((child = [enumerator nextObject]) != nil) {
			void *pool2  = objc_autoreleasePoolPush();

			[_mapTable setValue: (void*)1
311
312
313
314
315
316
317
318
319
320
321
322
323
	@try {
		[_mapTable enumerateKeysAndValuesUsingBlock:
		    ^ (void *key, void *value, bool *stop) {
			block(key, stop);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: self];
	}
}
#endif
@end







<
|




309
310
311
312
313
314
315

316
317
318
319
320
	@try {
		[_mapTable enumerateKeysAndValuesUsingBlock:
		    ^ (void *key, void *value, bool *stop) {
			block(key, stop);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException

		    exceptionWithObject: self];
	}
}
#endif
@end

Modified src/OFStdIOStream.m from [f5689e7f1a] to [0fb850ba21].

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
- (size_t)lowlevelReadIntoBuffer: (void*)buffer
			  length: (size_t)length
{
	ssize_t ret;

	if (_fd == -1 || _atEndOfStream ||
	    (ret = read(_fd, buffer, length)) < 0)
		@throw [OFReadFailedException exceptionWithClass: [self class]
							  stream: self
						 requestedLength: length];

	if (ret == 0)
		_atEndOfStream = true;

	return ret;
}

- (void)lowlevelWriteBuffer: (const void*)buffer
		     length: (size_t)length
{
	if (_fd == -1 || _atEndOfStream || write(_fd, buffer, length) < length)
		@throw [OFWriteFailedException exceptionWithClass: [self class]
							   stream: self
						  requestedLength: length];
}

- (int)fileDescriptorForReading
{
	return _fd;
}







|
<












|
<







95
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110
111
112
113
114
115

116
117
118
119
120
121
122
- (size_t)lowlevelReadIntoBuffer: (void*)buffer
			  length: (size_t)length
{
	ssize_t ret;

	if (_fd == -1 || _atEndOfStream ||
	    (ret = read(_fd, buffer, length)) < 0)
		@throw [OFReadFailedException exceptionWithStream: self

						 requestedLength: length];

	if (ret == 0)
		_atEndOfStream = true;

	return ret;
}

- (void)lowlevelWriteBuffer: (const void*)buffer
		     length: (size_t)length
{
	if (_fd == -1 || _atEndOfStream || write(_fd, buffer, length) < length)
		@throw [OFWriteFailedException exceptionWithStream: self

						  requestedLength: length];
}

- (int)fileDescriptorForReading
{
	return _fd;
}

Modified src/OFStream.m from [2d4bdd05bf] to [cfbf6fbabe].

785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
	OFString *ret;

	delimiterCString = [delimiter cStringWithEncoding: encoding];
	delimiterLength = [delimiter cStringLengthWithEncoding: encoding];
	j = 0;

	if (delimiterLength == 0)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	/* Look if there's something in our buffer */
	if (!_waitingForDelimiter && _readBuffer != NULL) {
		for (i = 0; i < _readBufferLength; i++) {
			if (_readBuffer[i] != delimiterCString[j++])
				j = 0;








|
<
<







785
786
787
788
789
790
791
792


793
794
795
796
797
798
799
	OFString *ret;

	delimiterCString = [delimiter cStringWithEncoding: encoding];
	delimiterLength = [delimiter cStringLengthWithEncoding: encoding];
	j = 0;

	if (delimiterLength == 0)
		@throw [OFInvalidArgumentException exception];



	/* Look if there's something in our buffer */
	if (!_waitingForDelimiter && _readBuffer != NULL) {
		for (i = 0; i < _readBufferLength; i++) {
			if (_readBuffer[i] != delimiterCString[j++])
				j = 0;

1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
- (size_t)writeFormat: (OFConstantString*)format
	    arguments: (va_list)arguments
{
	char *UTF8String;
	int length;

	if (format == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	if ((length = of_vasprintf(&UTF8String, [format UTF8String],
	    arguments)) == -1)
		@throw [OFInvalidFormatException
		    exceptionWithClass: [self class]];

	@try {
		[self writeBuffer: UTF8String
			   length: length];
	} @finally {
		free(UTF8String);
	}







|
<
<



|
<







1443
1444
1445
1446
1447
1448
1449
1450


1451
1452
1453
1454

1455
1456
1457
1458
1459
1460
1461
- (size_t)writeFormat: (OFConstantString*)format
	    arguments: (va_list)arguments
{
	char *UTF8String;
	int length;

	if (format == nil)
		@throw [OFInvalidArgumentException exception];



	if ((length = of_vasprintf(&UTF8String, [format UTF8String],
	    arguments)) == -1)
		@throw [OFInvalidFormatException exception];


	@try {
		[self writeBuffer: UTF8String
			   length: length];
	} @finally {
		free(UTF8String);
	}
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546

		readFlags = fcntl([self fileDescriptorForReading], F_GETFL);

		readImplemented = true;

		if (readFlags == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithClass: [self class]
					stream: self];

		if (enable)
			readFlags &= ~O_NONBLOCK;
		else
			readFlags |= O_NONBLOCK;

		if (fcntl([self fileDescriptorForReading], F_SETFL,
		    readFlags) == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithClass: [self class]
					stream: self];
	} @catch (OFNotImplementedException *e) {
	}

	@try {
		int writeFlags;

		writeFlags = fcntl([self fileDescriptorForWriting], F_GETFL);

		writeImplemented = true;

		if (writeFlags == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithClass: [self class]
					stream: self];

		if (enable)
			writeFlags &= ~O_NONBLOCK;
		else
			writeFlags |= O_NONBLOCK;

		if (fcntl([self fileDescriptorForWriting], F_SETFL,
		    writeFlags) == -1)
			@throw [OFSetOptionFailedException
			    exceptionWithClass: [self class]
					stream: self];
	} @catch (OFNotImplementedException *e) {
	}

	if (!readImplemented && !writeImplemented)
		@throw [OFNotImplementedException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	_blocking = enable;
#else
	[self doesNotRecognizeSelector: _cmd];
	abort();
#endif
}







<
|









<
|












<
|









<
|




|
<
|







1483
1484
1485
1486
1487
1488
1489

1490
1491
1492
1493
1494
1495
1496
1497
1498
1499

1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512

1513
1514
1515
1516
1517
1518
1519
1520
1521
1522

1523
1524
1525
1526
1527
1528

1529
1530
1531
1532
1533
1534
1535
1536

		readFlags = fcntl([self fileDescriptorForReading], F_GETFL);

		readImplemented = true;

		if (readFlags == -1)
			@throw [OFSetOptionFailedException

			    exceptionWithStream: self];

		if (enable)
			readFlags &= ~O_NONBLOCK;
		else
			readFlags |= O_NONBLOCK;

		if (fcntl([self fileDescriptorForReading], F_SETFL,
		    readFlags) == -1)
			@throw [OFSetOptionFailedException

			    exceptionWithStream: self];
	} @catch (OFNotImplementedException *e) {
	}

	@try {
		int writeFlags;

		writeFlags = fcntl([self fileDescriptorForWriting], F_GETFL);

		writeImplemented = true;

		if (writeFlags == -1)
			@throw [OFSetOptionFailedException

			    exceptionWithStream: self];

		if (enable)
			writeFlags &= ~O_NONBLOCK;
		else
			writeFlags |= O_NONBLOCK;

		if (fcntl([self fileDescriptorForWriting], F_SETFL,
		    writeFlags) == -1)
			@throw [OFSetOptionFailedException

			    exceptionWithStream: self];
	} @catch (OFNotImplementedException *e) {
	}

	if (!readImplemented && !writeImplemented)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd

								 object: self];

	_blocking = enable;
#else
	[self doesNotRecognizeSelector: _cmd];
	abort();
#endif
}

Modified src/OFStreamObserver_kqueue.m from [0df0a2e4f0] to [49f47f6ab0].

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
}

- (void)OF_addFileDescriptorForReading: (int)fd
{
	struct kevent event;

	if ([_changeList count] >= INT_MAX)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	EV_SET(&event, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
	[_changeList addItem: &event];
}

- (void)OF_addFileDescriptorForWriting: (int)fd
{
	struct kevent event;

	if ([_changeList count] >= INT_MAX)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	EV_SET(&event, fd, EVFILT_WRITE, EV_ADD, 0, 0, 0);
	[_changeList addItem: &event];
}

- (void)OF_removeFileDescriptorForReading: (int)fd
{







|










|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
}

- (void)OF_addFileDescriptorForReading: (int)fd
{
	struct kevent event;

	if ([_changeList count] >= INT_MAX)
		@throw [OFOutOfRangeException exception];

	EV_SET(&event, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
	[_changeList addItem: &event];
}

- (void)OF_addFileDescriptorForWriting: (int)fd
{
	struct kevent event;

	if ([_changeList count] >= INT_MAX)
		@throw [OFOutOfRangeException exception];

	EV_SET(&event, fd, EVFILT_WRITE, EV_ADD, 0, 0, 0);
	[_changeList addItem: &event];
}

- (void)OF_removeFileDescriptorForReading: (int)fd
{

Modified src/OFStreamObserver_poll.m from [a45ade6207] to [45fcb749cc].

149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
	objc_autoreleasePoolPop(pool);

	FDs = [_FDs items];
	nFDs = [_FDs count];

#ifdef OPEN_MAX
	if (nFDs > OPEN_MAX)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];
#endif

	if (poll(FDs, (nfds_t)nFDs,
	    (int)(timeInterval != -1 ? timeInterval * 1000 : -1)) < 1)
		return false;

	for (i = 0; i < nFDs; i++) {







|







149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
	objc_autoreleasePoolPop(pool);

	FDs = [_FDs items];
	nFDs = [_FDs count];

#ifdef OPEN_MAX
	if (nFDs > OPEN_MAX)
		@throw [OFOutOfRangeException exception];
#endif

	if (poll(FDs, (nfds_t)nFDs,
	    (int)(timeInterval != -1 ? timeInterval * 1000 : -1)) < 1)
		return false;

	for (i = 0; i < nFDs; i++) {

Modified src/OFStreamSocket.m from [10e23bfd72] to [252939c90a].

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

- (size_t)lowlevelReadIntoBuffer: (void*)buffer
			  length: (size_t)length
{
	ssize_t ret;

	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithClass: [self class]
							    socket: self];

	if (_atEndOfStream) {
		OFReadFailedException *e;

		e = [OFReadFailedException exceptionWithClass: [self class]
						       stream: self
					      requestedLength: length];
#ifndef _WIN32
		e->_errNo = ENOTCONN;
#else
		e->_errNo = WSAENOTCONN;
#endif

		@throw e;
	}

	if ((ret = recv(_socket, buffer, length, 0)) < 0)
		@throw [OFReadFailedException exceptionWithClass: [self class]
							  stream: self
						 requestedLength: length];

	if (ret == 0)
		_atEndOfStream = true;

	return ret;
}

- (void)lowlevelWriteBuffer: (const void*)buffer
		     length: (size_t)length
{
	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithClass: [self class]
							    socket: self];

	if (_atEndOfStream) {
		OFWriteFailedException *e;

		e = [OFWriteFailedException exceptionWithClass: [self class]
							stream: self
					       requestedLength: length];
#ifndef _WIN32
		e->_errNo = ENOTCONN;
#else
		e->_errNo = WSAENOTCONN;
#endif

		@throw e;
	}

	if (send(_socket, buffer, length, 0) < length)
		@throw [OFWriteFailedException exceptionWithClass: [self class]
							   stream: self
						  requestedLength: length];
}

#ifdef _WIN32
- (void)setBlocking: (bool)enable
{
	u_long v = enable;
	_blocking = enable;

	if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR)
		@throw [OFSetOptionFailedException
		    exceptionWithClass: [self class]
				stream: self];
}
#endif

- (int)fileDescriptorForReading
{
	return _socket;
}

- (int)fileDescriptorForWriting
{
	return _socket;
}

- (void)close
{
	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithClass: [self class]
							    socket: self];

	close(_socket);
	_socket = INVALID_SOCKET;

	_atEndOfStream = false;
}








|
<




|
<











|
<












|
<




|
<











|
<










|
<
<
















|
<







86
87
88
89
90
91
92
93

94
95
96
97
98

99
100
101
102
103
104
105
106
107
108
109
110

111
112
113
114
115
116
117
118
119
120
121
122
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
159
160
161
162
163
164
165
166
167
168

169
170
171
172
173
174
175

- (size_t)lowlevelReadIntoBuffer: (void*)buffer
			  length: (size_t)length
{
	ssize_t ret;

	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithSocket: self];


	if (_atEndOfStream) {
		OFReadFailedException *e;

		e = [OFReadFailedException exceptionWithStream: self

					      requestedLength: length];
#ifndef _WIN32
		e->_errNo = ENOTCONN;
#else
		e->_errNo = WSAENOTCONN;
#endif

		@throw e;
	}

	if ((ret = recv(_socket, buffer, length, 0)) < 0)
		@throw [OFReadFailedException exceptionWithStream: self

						 requestedLength: length];

	if (ret == 0)
		_atEndOfStream = true;

	return ret;
}

- (void)lowlevelWriteBuffer: (const void*)buffer
		     length: (size_t)length
{
	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithSocket: self];


	if (_atEndOfStream) {
		OFWriteFailedException *e;

		e = [OFWriteFailedException exceptionWithStream: self

					       requestedLength: length];
#ifndef _WIN32
		e->_errNo = ENOTCONN;
#else
		e->_errNo = WSAENOTCONN;
#endif

		@throw e;
	}

	if (send(_socket, buffer, length, 0) < length)
		@throw [OFWriteFailedException exceptionWithStream: self

						  requestedLength: length];
}

#ifdef _WIN32
- (void)setBlocking: (bool)enable
{
	u_long v = enable;
	_blocking = enable;

	if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR)
		@throw [OFSetOptionFailedException exceptionWithStream: self];


}
#endif

- (int)fileDescriptorForReading
{
	return _socket;
}

- (int)fileDescriptorForWriting
{
	return _socket;
}

- (void)close
{
	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithSocket: self];


	close(_socket);
	_socket = INVALID_SOCKET;

	_atEndOfStream = false;
}

Modified src/OFString+JSONValue.m from [a402664fc6] to [c7c766a996].

661
662
663
664
665
666
667
668
669
670
671
672
673
	id object;
	size_t line = 1;

	object = nextObject(&pointer, stop, &line, 0, depthLimit);
	skipWhitespacesAndComments(&pointer, stop, &line);

	if (pointer < stop || object == nil)
		@throw [OFInvalidJSONException exceptionWithClass: [self class]
							     line: line];

	return object;
}
@end







|





661
662
663
664
665
666
667
668
669
670
671
672
673
	id object;
	size_t line = 1;

	object = nextObject(&pointer, stop, &line, 0, depthLimit);
	skipWhitespacesAndComments(&pointer, stop, &line);

	if (pointer < stop || object == nil)
		@throw [OFInvalidJSONException exceptionWithString: self
							     line: line];

	return object;
}
@end

Modified src/OFString+Serialization.m from [2cf8d059db] to [d4f8416b9e].

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
	OFString *version;
	OFArray *elements;
	id object;

	@try {
		root = [OFXMLElement elementWithXMLString: self];
	} @catch (OFMalformedXMLException *e) {
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	} @catch (OFUnboundNamespaceException *e) {
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}

	version = [[root attributeForName: @"version"] stringValue];
	if (version == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	if ([version decimalValue] != 1)
		@throw [OFUnsupportedVersionException
		    exceptionWithClass: [self class]
			       version: version];

	elements = [root elementsForNamespace: OF_SERIALIZATION_NS];

	if ([elements count] != 1)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	object = [[[elements firstObject] objectByDeserializing] retain];

	objc_autoreleasePoolPop(pool);

	return [object autorelease];
}
@end







|
<
<

|
<
<




|
<
<



<
|




|
<
<








40
41
42
43
44
45
46
47


48
49


50
51
52
53
54


55
56
57

58
59
60
61
62
63


64
65
66
67
68
69
70
71
	OFString *version;
	OFArray *elements;
	id object;

	@try {
		root = [OFXMLElement elementWithXMLString: self];
	} @catch (OFMalformedXMLException *e) {
		@throw [OFInvalidArgumentException exception];


	} @catch (OFUnboundNamespaceException *e) {
		@throw [OFInvalidArgumentException exception];


	}

	version = [[root attributeForName: @"version"] stringValue];
	if (version == nil)
		@throw [OFInvalidArgumentException exception];



	if ([version decimalValue] != 1)
		@throw [OFUnsupportedVersionException

		    exceptionWithVersion: version];

	elements = [root elementsForNamespace: OF_SERIALIZATION_NS];

	if ([elements count] != 1)
		@throw [OFInvalidArgumentException exception];



	object = [[[elements firstObject] objectByDeserializing] retain];

	objc_autoreleasePoolPop(pool);

	return [object autorelease];
}
@end

Modified src/OFString+URLEncoding.m from [285804da91] to [5d54dc5328].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#import "OFString+URLEncoding.h"

#import "OFInvalidEncodingException.h"
#import "OFOutOfMemoryException.h"

/* Reference for static linking */
int _OFString_URLEncoding_reference;

@implementation OFString (URLEncoding)
- (OFString*)stringByURLEncoding
{
	const char *string = [self UTF8String];
	char *retCString;
	size_t i;
	OFString *ret;

	/*
	 * Worst case: 3 times longer than before.
	 * Oh, and we can't use [self allocWithSize:] here as self might be a
	 * @"" literal.
	 */
	if ((retCString = malloc(([self UTF8StringLength] * 3) + 1)) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithClass: [self class]
			 requestedSize: ([self UTF8StringLength] * 3) + 1];

	for (i = 0; *string != '\0'; string++) {
		if (isalnum((int)*string) || *string == '-' || *string == '_' ||
		    *string == '.' || *string == '~')
			retCString[i++] = *string;
		else {
			uint8_t high, low;







|



















|
<
|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53

#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#import "OFString+URLEncoding.h"

#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"

/* Reference for static linking */
int _OFString_URLEncoding_reference;

@implementation OFString (URLEncoding)
- (OFString*)stringByURLEncoding
{
	const char *string = [self UTF8String];
	char *retCString;
	size_t i;
	OFString *ret;

	/*
	 * Worst case: 3 times longer than before.
	 * Oh, and we can't use [self allocWithSize:] here as self might be a
	 * @"" literal.
	 */
	if ((retCString = malloc(([self UTF8StringLength] * 3) + 1)) == NULL)
		@throw [OFOutOfMemoryException exceptionWithRequestedSize:

		    ([self UTF8StringLength] * 3) + 1];

	for (i = 0; *string != '\0'; string++) {
		if (isalnum((int)*string) || *string == '-' || *string == '_' ||
		    *string == '.' || *string == '~')
			retCString[i++] = *string;
		else {
			uint8_t high, low;
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
	char *retCString;
	char byte = 0;
	int state = 0;
	size_t i;

	if ((retCString = malloc([self UTF8StringLength] + 1)) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithClass: [self class]
			 requestedSize: [self UTF8StringLength] + 1];

	for (i = 0; *string; string++) {
		switch (state) {
		case 0:
			if (*string == '%')
				state = 1;
			else if (*string == '+')







<
|







80
81
82
83
84
85
86

87
88
89
90
91
92
93
94
	char *retCString;
	char byte = 0;
	int state = 0;
	size_t i;

	if ((retCString = malloc([self UTF8StringLength] + 1)) == NULL)
		@throw [OFOutOfMemoryException

		    exceptionWithRequestedSize: [self UTF8StringLength] + 1];

	for (i = 0; *string; string++) {
		switch (state) {
		case 0:
			if (*string == '%')
				state = 1;
			else if (*string == '+')
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
				byte += (*string - '0') << shift;
			else if (*string >= 'A' && *string <= 'F')
				byte += (*string - 'A' + 10) << shift;
			else if (*string >= 'a' && *string <= 'f')
				byte += (*string - 'a' + 10) << shift;
			else {
				free(retCString);
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
			}

			if (++state == 3) {
				retCString[i++] = byte;
				state = 0;
				byte = 0;
			}

			break;
		}
	}
	retCString[i] = '\0';

	if (state != 0) {
		free(retCString);
		@throw [OFInvalidEncodingException
		    exceptionWithClass: [self class]];
	}

	@try {
		ret = [OFString stringWithUTF8String: retCString
					      length: i];
	} @finally {
		free(retCString);
	}
	return ret;
}
@end







|
<















|
<











104
105
106
107
108
109
110
111

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

128
129
130
131
132
133
134
135
136
137
138
				byte += (*string - '0') << shift;
			else if (*string >= 'A' && *string <= 'F')
				byte += (*string - 'A' + 10) << shift;
			else if (*string >= 'a' && *string <= 'f')
				byte += (*string - 'a' + 10) << shift;
			else {
				free(retCString);
				@throw [OFInvalidFormatException exception];

			}

			if (++state == 3) {
				retCString[i++] = byte;
				state = 0;
				byte = 0;
			}

			break;
		}
	}
	retCString[i] = '\0';

	if (state != 0) {
		free(retCString);
		@throw [OFInvalidFormatException exception];

	}

	@try {
		ret = [OFString stringWithUTF8String: retCString
					      length: i];
	} @finally {
		free(retCString);
	}
	return ret;
}
@end

Modified src/OFString+XMLEscaping.m from [5265ca0446] to [08aa8faea7].

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
	j = 0;
	retLength = length;

	/*
	 * We can't use allocMemoryWithSize: here as it might be a @"" literal
	 */
	if ((retCString = malloc(retLength)) == NULL)
		@throw [OFOutOfMemoryException exceptionWithClass: [self class]
						    requestedSize: retLength];

	for (i = 0; i < length; i++) {
		switch (string[i]) {
			case '<':
				append = "&lt;";
				appendLen = 4;
				break;







|
|







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
	j = 0;
	retLength = length;

	/*
	 * We can't use allocMemoryWithSize: here as it might be a @"" literal
	 */
	if ((retCString = malloc(retLength)) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: retLength];

	for (i = 0; i < length; i++) {
		switch (string[i]) {
			case '<':
				append = "&lt;";
				appendLen = 4;
				break;
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
		if (append != NULL) {
			char *newRetCString;

			if ((newRetCString = realloc(retCString,
			    retLength + appendLen)) == NULL) {
				free(retCString);
				@throw [OFOutOfMemoryException
				     exceptionWithClass: [self class]
					  requestedSize: retLength + appendLen];
			}
			retCString = newRetCString;
			retLength += appendLen - 1;

			memcpy(retCString + j, append, appendLen);
			j += appendLen;
		} else







|
|







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
		if (append != NULL) {
			char *newRetCString;

			if ((newRetCString = realloc(retCString,
			    retLength + appendLen)) == NULL) {
				free(retCString);
				@throw [OFOutOfMemoryException
				     exceptionWithRequestedSize: retLength +
								 appendLen];
			}
			retCString = newRetCString;
			retLength += appendLen - 1;

			memcpy(retCString + j, append, appendLen);
			j += appendLen;
		} else

Modified src/OFString+XMLUnescaping.m from [baacfe9bd9] to [1dff93e5a9].

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

#include "config.h"

#include <string.h>

#import "OFString.h"

#import "OFInvalidEncodingException.h"

#import "autorelease.h"
#import "macros.h"

int _OFString_XMLUnescaping_reference;

static OF_INLINE OFString*







|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

#include "config.h"

#include <string.h>

#import "OFString.h"

#import "OFInvalidFormatException.h"

#import "autorelease.h"
#import "macros.h"

int _OFString_XMLUnescaping_reference;

static OF_INLINE OFString*
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
171
172
173
174
175
176
177
178
179
180
181
182
183
				OFString *tmp;

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

				if (tmp == nil)
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];

				[ret appendString: tmp];
				objc_autoreleasePoolPop(pool);
			} else if (delegate != nil) {
				void *pool;
				OFString *n, *tmp;

				pool = objc_autoreleasePoolPush();

				n = [OFString
				    stringWithUTF8String: entity
						  length: entityLength];
				tmp =	  [delegate string: self
				containsUnknownEntityNamed: n];

				if (tmp == nil)
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];

				[ret appendString: tmp];
				objc_autoreleasePoolPop(pool);
			} else
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];

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

	if (inEntity)
		@throw [OFInvalidEncodingException
		    exceptionWithClass: [self class]];

	[ret appendUTF8String: string + last
		       length: i - last];

	[ret makeImmutable];

	return ret;







|
|
















|
|




|
<







|
<







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
171
172
173
174

175
176
177
178
179
180
181
				OFString *tmp;

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

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

				[ret appendString: tmp];
				objc_autoreleasePoolPop(pool);
			} else if (delegate != nil) {
				void *pool;
				OFString *n, *tmp;

				pool = objc_autoreleasePoolPush();

				n = [OFString
				    stringWithUTF8String: entity
						  length: entityLength];
				tmp =	  [delegate string: self
				containsUnknownEntityNamed: n];

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

				[ret appendString: tmp];
				objc_autoreleasePoolPop(pool);
			} else
				@throw [OFInvalidFormatException exception];


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

	if (inEntity)
		@throw [OFInvalidFormatException exception];


	[ret appendUTF8String: string + last
		       length: i - last];

	[ret makeImmutable];

	return ret;
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
				OFString *tmp;

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

				if (tmp == nil)
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];

				[ret appendString: tmp];
				objc_autoreleasePoolPop(pool);
			} else {
				void *pool;
				OFString *entityString, *tmp;

				pool = objc_autoreleasePoolPush();

				entityString = [OFString
				    stringWithUTF8String: entity
						  length: entityLength];
				tmp = block(self, entityString);

				if (tmp == nil)
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];

				[ret appendString: tmp];
				objc_autoreleasePoolPop(pool);
			}

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

	if (inEntity)
		@throw [OFInvalidEncodingException
		    exceptionWithClass: [self class]];

	[ret appendUTF8String: string + last
		       length: i - last];

	[ret makeImmutable];

	return ret;
}
#endif
@end







|
|















|
|











|
<










236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273

274
275
276
277
278
279
280
281
282
283
				OFString *tmp;

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

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

				[ret appendString: tmp];
				objc_autoreleasePoolPop(pool);
			} else {
				void *pool;
				OFString *entityString, *tmp;

				pool = objc_autoreleasePoolPush();

				entityString = [OFString
				    stringWithUTF8String: entity
						  length: entityLength];
				tmp = block(self, entityString);

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

				[ret appendString: tmp];
				objc_autoreleasePoolPop(pool);
			}

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

	if (inEntity)
		@throw [OFInvalidFormatException exception];


	[ret appendUTF8String: string + last
		       length: i - last];

	[ret makeImmutable];

	return ret;
}
#endif
@end

Modified src/OFString.m from [b10086fe78] to [dc3e1b10e9].

882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902

	@try {
		OFFile *file;

		if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
		    &st) == -1)
			@throw [OFOpenFileFailedException
			    exceptionWithClass: [self class]
					  path: path
					  mode: @"rb"];

		if (st.st_size > SIZE_MAX)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		file = [[OFFile alloc] initWithPath: path
					       mode: @"rb"];

		@try {
			tmp = [self allocMemoryWithSize: (size_t)st.st_size];








|
<



|
<







882
883
884
885
886
887
888
889

890
891
892
893

894
895
896
897
898
899
900

	@try {
		OFFile *file;

		if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
		    &st) == -1)
			@throw [OFOpenFileFailedException
			    exceptionWithPath: path

					  mode: @"rb"];

		if (st.st_size > SIZE_MAX)
			@throw [OFOutOfRangeException exception];


		file = [[OFFile alloc] initWithPath: path
					       mode: @"rb"];

		@try {
			tmp = [self allocMemoryWithSize: (size_t)st.st_size];

956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
#ifdef OF_HAVE_SOCKETS
	client = [OFHTTPClient client];
	request = [OFHTTPRequest requestWithURL: URL];
	reply = [client performRequest: request];

	if ([reply statusCode] != 200)
		@throw [OFHTTPRequestFailedException
		    exceptionWithClass: [request class]
			       request: request
				 reply: reply];

	headers = [reply headers];

	if (encoding == OF_STRING_ENCODING_AUTODETECT &&
	    (contentType = [headers objectForKey: @"Content-Type"]) != nil) {
		contentType = [contentType lowercaseString];







<
|







954
955
956
957
958
959
960

961
962
963
964
965
966
967
968
#ifdef OF_HAVE_SOCKETS
	client = [OFHTTPClient client];
	request = [OFHTTPRequest requestWithURL: URL];
	reply = [client performRequest: request];

	if ([reply statusCode] != 200)
		@throw [OFHTTPRequestFailedException

		    exceptionWithRequest: request
				 reply: reply];

	headers = [reply headers];

	if (encoding == OF_STRING_ENCODING_AUTODETECT &&
	    (contentType = [headers objectForKey: @"Content-Type"]) != nil) {
		contentType = [contentType lowercaseString];
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
	if (encoding == OF_STRING_ENCODING_AUTODETECT)
		encoding = OF_STRING_ENCODING_UTF_8;

	data = [reply readDataArrayTillEndOfStream];

	if ((contentLength = [headers objectForKey: @"Content-Length"]) != nil)
		if ([data count] != (size_t)[contentLength decimalValue])
			@throw [OFTruncatedDataException
			    exceptionWithClass: [self class]];

	self = [[c alloc] initWithCString: (char*)[data items]
				 encoding: encoding
				   length: [data count]];
#else
	@throw [OFUnsupportedProtocolException exceptionWithClass: c];
#endif

	objc_autoreleasePoolPop(pool);

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		if ([self isKindOfClass: [OFMutableString class]]) {
			if (![[element name] isEqual: @"OFMutableString"])
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]
					      selector: _cmd];
		} else {
			if (![[element name] isEqual: @"OFString"])
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]
					      selector: _cmd];
		}

		self = [self initWithString: [element stringValue]];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];







|
<





|













|
<
<



|
<
<


|
<
<







980
981
982
983
984
985
986
987

988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007


1008
1009
1010
1011


1012
1013
1014


1015
1016
1017
1018
1019
1020
1021
	if (encoding == OF_STRING_ENCODING_AUTODETECT)
		encoding = OF_STRING_ENCODING_UTF_8;

	data = [reply readDataArrayTillEndOfStream];

	if ((contentLength = [headers objectForKey: @"Content-Length"]) != nil)
		if ([data count] != (size_t)[contentLength decimalValue])
			@throw [OFTruncatedDataException exception];


	self = [[c alloc] initWithCString: (char*)[data items]
				 encoding: encoding
				   length: [data count]];
#else
	@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
#endif

	objc_autoreleasePoolPop(pool);

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		if ([self isKindOfClass: [OFMutableString class]]) {
			if (![[element name] isEqual: @"OFMutableString"])
				@throw [OFInvalidArgumentException exception];


		} else {
			if (![[element name] isEqual: @"OFString"])
				@throw [OFInvalidArgumentException exception];


		}

		self = [self initWithString: [element stringValue]];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
			    buffer);

			/*
			 * Check for one more than the current index, as we
			 * need one for the terminating zero.
			 */
			if (j + len >= maxLength)
				@throw [OFOutOfRangeException
				    exceptionWithClass: [self class]];

			switch (len) {
			case 1:
				cString[j++] = buffer[0];

				break;
			case 2:
			case 3:
			case 4:
				memcpy(cString + j, buffer, len);
				j += len;

				break;
			default:
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
			}
		}

		cString[j] = '\0';

		return j;
	case OF_STRING_ENCODING_ASCII:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		for (i = 0; i < length; i++) {
			if OF_UNLIKELY (characters[i] > 0x80)
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];

			cString[i] = (char)characters[i];
		}

		cString[i] = '\0';

		return length;
	case OF_STRING_ENCODING_ISO_8859_1:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		for (i = 0; i < length; i++) {
			if OF_UNLIKELY (characters[i] > 0xFF)
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];

			cString[i] = (uint8_t)characters[i];
		}

		cString[i] = '\0';

		return length;
	case OF_STRING_ENCODING_ISO_8859_15:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		for (i = 0; i < length; i++) {
			of_unichar_t c = characters[i];

			switch (c) {
			case 0xA4:
			case 0xA6:
			case 0xA8:
			case 0xB4:
			case 0xB8:
			case 0xBC:
			case 0xBD:
			case 0xBE:
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
			}

			if OF_UNLIKELY (c > 0xFF) {
				switch (c) {
				case 0x20AC:
					cString[i] = 0xA4;
					break;







|
<














|
<








|
<



|
<









|
<



|
<









|
<













|
<







1042
1043
1044
1045
1046
1047
1048
1049

1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064

1065
1066
1067
1068
1069
1070
1071
1072
1073

1074
1075
1076
1077

1078
1079
1080
1081
1082
1083
1084
1085
1086
1087

1088
1089
1090
1091

1092
1093
1094
1095
1096
1097
1098
1099
1100
1101

1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115

1116
1117
1118
1119
1120
1121
1122
			    buffer);

			/*
			 * Check for one more than the current index, as we
			 * need one for the terminating zero.
			 */
			if (j + len >= maxLength)
				@throw [OFOutOfRangeException exception];


			switch (len) {
			case 1:
				cString[j++] = buffer[0];

				break;
			case 2:
			case 3:
			case 4:
				memcpy(cString + j, buffer, len);
				j += len;

				break;
			default:
				@throw [OFInvalidEncodingException exception];

			}
		}

		cString[j] = '\0';

		return j;
	case OF_STRING_ENCODING_ASCII:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException exception];


		for (i = 0; i < length; i++) {
			if OF_UNLIKELY (characters[i] > 0x80)
				@throw [OFInvalidEncodingException exception];


			cString[i] = (char)characters[i];
		}

		cString[i] = '\0';

		return length;
	case OF_STRING_ENCODING_ISO_8859_1:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException exception];


		for (i = 0; i < length; i++) {
			if OF_UNLIKELY (characters[i] > 0xFF)
				@throw [OFInvalidEncodingException exception];


			cString[i] = (uint8_t)characters[i];
		}

		cString[i] = '\0';

		return length;
	case OF_STRING_ENCODING_ISO_8859_15:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException exception];


		for (i = 0; i < length; i++) {
			of_unichar_t c = characters[i];

			switch (c) {
			case 0xA4:
			case 0xA6:
			case 0xA8:
			case 0xB4:
			case 0xB8:
			case 0xBC:
			case 0xBD:
			case 0xBE:
				@throw [OFInvalidEncodingException exception];

			}

			if OF_UNLIKELY (c > 0xFF) {
				switch (c) {
				case 0x20AC:
					cString[i] = 0xA4;
					break;
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
					cString[i] = 0xBD;
					break;
				case 0x178:
					cString[i] = 0xBE;
					break;
				default:
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];
				}
			} else
				cString[i] = (uint8_t)c;
		}

		cString[i] = '\0';

		return length;
	case OF_STRING_ENCODING_WINDOWS_1252:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		for (i = 0; i < length; i++) {
			of_unichar_t c = characters[i];

			if OF_UNLIKELY (c >= 0x80 && c <= 0x9F)
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];

			if OF_UNLIKELY (c > 0xFF) {
				switch (c) {
				case 0x20AC:
					cString[i] = 0x80;
					break;
				case 0x201A:







|










|
<





|
<







1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157

1158
1159
1160
1161
1162
1163

1164
1165
1166
1167
1168
1169
1170
					cString[i] = 0xBD;
					break;
				case 0x178:
					cString[i] = 0xBE;
					break;
				default:
					@throw [OFInvalidEncodingException
					    exception];
				}
			} else
				cString[i] = (uint8_t)c;
		}

		cString[i] = '\0';

		return length;
	case OF_STRING_ENCODING_WINDOWS_1252:
		if (length + 1 > maxLength)
			@throw [OFOutOfRangeException exception];


		for (i = 0; i < length; i++) {
			of_unichar_t c = characters[i];

			if OF_UNLIKELY (c >= 0x80 && c <= 0x9F)
				@throw [OFInvalidEncodingException exception];


			if OF_UNLIKELY (c > 0xFF) {
				switch (c) {
				case 0x20AC:
					cString[i] = 0x80;
					break;
				case 0x201A:
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
					cString[i] = 0x9E;
					break;
				case 0x178:
					cString[i] = 0x9F;
					break;
				default:
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];
				}
			} else
				cString[i] = (uint8_t)c;
		}

		cString[i] = '\0';

		return length;
	default:
		@throw [OFNotImplementedException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}
}

- (const char*)cStringWithEncoding: (of_string_encoding_t)encoding
{
	OFObject *object = [[[OFObject alloc] init] autorelease];
	size_t length = [self length];







|









|
<
|







1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260

1261
1262
1263
1264
1265
1266
1267
1268
					cString[i] = 0x9E;
					break;
				case 0x178:
					cString[i] = 0x9F;
					break;
				default:
					@throw [OFInvalidEncodingException
					    exception];
				}
			} else
				cString[i] = (uint8_t)c;
		}

		cString[i] = '\0';

		return length;
	default:
		@throw [OFNotImplementedException exceptionWithSelector: _cmd

								 object: self];
	}
}

- (const char*)cStringWithEncoding: (of_string_encoding_t)encoding
{
	OFObject *object = [[[OFObject alloc] init] autorelease];
	size_t length = [self length];
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331

		[self getCString: cString
		       maxLength: length + 1
			encoding: encoding];

		break;
	default:
		@throw [OFNotImplementedException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}

	return cString;
}

- (const char*)UTF8String
{







|
<
|







1294
1295
1296
1297
1298
1299
1300
1301

1302
1303
1304
1305
1306
1307
1308
1309

		[self getCString: cString
		       maxLength: length + 1
			encoding: encoding];

		break;
	default:
		@throw [OFNotImplementedException exceptionWithSelector: _cmd

								 object: self];
	}

	return cString;
}

- (const char*)UTF8String
{
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379

		for (i = 0; i < length; i++) {
			char buffer[4];
			size_t len = of_string_utf8_encode(characters[i],
			    buffer);

			if (len == 0)
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];

			UTF8StringLength += len;
		}

		return UTF8StringLength;
	case OF_STRING_ENCODING_ASCII:
	case OF_STRING_ENCODING_ISO_8859_1:
	case OF_STRING_ENCODING_ISO_8859_15:
	case OF_STRING_ENCODING_WINDOWS_1252:
		return [self length];
	default:
		@throw [OFNotImplementedException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}
}

- (size_t)UTF8StringLength
{
	return [self cStringLengthWithEncoding: OF_STRING_ENCODING_UTF_8];
}







|
<











|
<
|







1328
1329
1330
1331
1332
1333
1334
1335

1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347

1348
1349
1350
1351
1352
1353
1354
1355

		for (i = 0; i < length; i++) {
			char buffer[4];
			size_t len = of_string_utf8_encode(characters[i],
			    buffer);

			if (len == 0)
				@throw [OFInvalidEncodingException exception];


			UTF8StringLength += len;
		}

		return UTF8StringLength;
	case OF_STRING_ENCODING_ASCII:
	case OF_STRING_ENCODING_ISO_8859_1:
	case OF_STRING_ENCODING_ISO_8859_15:
	case OF_STRING_ENCODING_WINDOWS_1252:
		return [self length];
	default:
		@throw [OFNotImplementedException exceptionWithSelector: _cmd

								 object: self];
	}
}

- (size_t)UTF8StringLength
{
	return [self cStringLengthWithEncoding: OF_STRING_ENCODING_UTF_8];
}
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
	const of_unichar_t *characters, *otherCharacters;
	size_t i, minimumLength;

	if (object == self)
		return OF_ORDERED_SAME;

	if (![object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	otherString = (OFString*)object;
	minimumLength = ([self length] > [otherString length]
	    ? [otherString length] : [self length]);

	pool = objc_autoreleasePoolPush();








|
<
<







1421
1422
1423
1424
1425
1426
1427
1428


1429
1430
1431
1432
1433
1434
1435
	const of_unichar_t *characters, *otherCharacters;
	size_t i, minimumLength;

	if (object == self)
		return OF_ORDERED_SAME;

	if (![object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exception];



	otherString = (OFString*)object;
	minimumLength = ([self length] > [otherString length]
	    ? [otherString length] : [self length]);

	pool = objc_autoreleasePoolPush();

1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
		data = [OFDataArray dataArrayWithItemSize: 1
						 capacity: length + 5];

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];
	} else
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	[data addItems: [self UTF8String]
		 count: length];

	return data;
}








|







1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
		data = [OFDataArray dataArrayWithItemSize: 1
						 capacity: length + 5];

		[data addItem: &type];
		[data addItems: &tmp
			 count: sizeof(tmp)];
	} else
		@throw [OFOutOfRangeException exception];

	[data addItems: [self UTF8String]
		 count: length];

	return data;
}

1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
	if ((searchLength = [string length]) == 0)
		return of_range(0, 0);

	if (searchLength > range.length)
		return of_range(OF_NOT_FOUND, 0);

	if (range.length > SIZE_MAX / sizeof(of_unichar_t))
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	pool = objc_autoreleasePoolPush();

	searchCharacters = [string characters];
	characters = malloc(range.length * sizeof(of_unichar_t));

	if (characters == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithClass: [self class]
			 requestedSize: range.length * sizeof(of_unichar_t)];

	@try {
		[self getCharacters: characters
			    inRange: range];

		if (options & OF_STRING_SEARCH_BACKWARDS) {
			for (i = range.length - searchLength;; i--) {







|







|
<
|







1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684

1685
1686
1687
1688
1689
1690
1691
1692
	if ((searchLength = [string length]) == 0)
		return of_range(0, 0);

	if (searchLength > range.length)
		return of_range(OF_NOT_FOUND, 0);

	if (range.length > SIZE_MAX / sizeof(of_unichar_t))
		@throw [OFOutOfRangeException exception];

	pool = objc_autoreleasePoolPush();

	searchCharacters = [string characters];
	characters = malloc(range.length * sizeof(of_unichar_t));

	if (characters == NULL)
		@throw [OFOutOfMemoryException exceptionWithRequestedSize:

		    range.length * sizeof(of_unichar_t)];

	@try {
		[self getCharacters: characters
			    inRange: range];

		if (options & OF_STRING_SEARCH_BACKWARDS) {
			for (i = range.length - searchLength;; i--) {
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
- (OFString*)substringWithRange: (of_range_t)range
{
	void *pool;
	OFString *ret;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > [self length])
		@throw [OFOutOfRangeException
		    exceptionWithClass: [self class]];

	pool = objc_autoreleasePoolPush();
	ret = [[OFString alloc]
	    initWithCharacters: [self characters] + range.location
			length: range.length];
	objc_autoreleasePoolPop(pool);








|
<







1753
1754
1755
1756
1757
1758
1759
1760

1761
1762
1763
1764
1765
1766
1767
- (OFString*)substringWithRange: (of_range_t)range
{
	void *pool;
	OFString *ret;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > [self length])
		@throw [OFOutOfRangeException exception];


	pool = objc_autoreleasePoolPush();
	ret = [[OFString alloc]
	    initWithCharacters: [self characters] + range.location
			length: range.length];
	objc_autoreleasePoolPop(pool);

2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
		i++;

	for (; i < length; i++) {
		if (expectWhitespace) {
			if (characters[i] != ' ' && characters[i] != '\t' &&
			    characters[i] != '\n' && characters[i] != '\r' &&
			    characters[i] != '\f')
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];
			continue;
		}

		if (characters[i] >= '0' && characters[i] <= '9') {
			if (INTMAX_MAX / 10 < value ||
			    INTMAX_MAX - value * 10 < characters[i] - '0')
				@throw [OFOutOfRangeException
				    exceptionWithClass: [self class]];

			value = (value * 10) + (characters[i] - '0');
		} else if (characters[i] == ' ' || characters[i] == '\t' ||
		    characters[i] == '\n' || characters[i] == '\r' ||
		    characters[i] == '\f')
			expectWhitespace = true;
		else
			@throw [OFInvalidFormatException
			    exceptionWithClass: [self class]];
	}

	if (characters[0] == '-')
		value *= -1;

	objc_autoreleasePoolPop(pool);








|
<






|
<







|
<







2214
2215
2216
2217
2218
2219
2220
2221

2222
2223
2224
2225
2226
2227
2228

2229
2230
2231
2232
2233
2234
2235
2236

2237
2238
2239
2240
2241
2242
2243
		i++;

	for (; i < length; i++) {
		if (expectWhitespace) {
			if (characters[i] != ' ' && characters[i] != '\t' &&
			    characters[i] != '\n' && characters[i] != '\r' &&
			    characters[i] != '\f')
				@throw [OFInvalidFormatException exception];

			continue;
		}

		if (characters[i] >= '0' && characters[i] <= '9') {
			if (INTMAX_MAX / 10 < value ||
			    INTMAX_MAX - value * 10 < characters[i] - '0')
				@throw [OFOutOfRangeException exception];


			value = (value * 10) + (characters[i] - '0');
		} else if (characters[i] == ' ' || characters[i] == '\t' ||
		    characters[i] == '\n' || characters[i] == '\r' ||
		    characters[i] == '\f')
			expectWhitespace = true;
		else
			@throw [OFInvalidFormatException exception];

	}

	if (characters[0] == '-')
		value *= -1;

	objc_autoreleasePoolPop(pool);

2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
	for (; i < length; i++) {
		uintmax_t newValue;

		if (expectWhitespace) {
			if (characters[i] != ' ' && characters[i] != '\t' &&
			    characters[i] != '\n' && characters[i] != '\r' &&
			    characters[i] != '\f')
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];
			continue;
		}

		if (characters[i] >= '0' && characters[i] <= '9') {
			newValue = (value << 4) | (characters[i] - '0');
			foundValue = true;
		} else if (characters[i] >= 'A' && characters[i] <= 'F') {
			newValue = (value << 4) | (characters[i] - 'A' + 10);
			foundValue = true;
		} else if (characters[i] >= 'a' && characters[i] <= 'f') {
			newValue = (value << 4) | (characters[i] - 'a' + 10);
			foundValue = true;
		} else if (characters[i] == 'h' || characters[i] == ' ' ||
		    characters[i] == '\t' || characters[i] == '\n' ||
		    characters[i] == '\r' || characters[i] == '\f') {
			expectWhitespace = true;
			continue;
		} else
			@throw [OFInvalidFormatException
			    exceptionWithClass: [self class]];

		if (newValue < value)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		value = newValue;
	}

	if (!foundValue)
		@throw [OFInvalidFormatException
		    exceptionWithClass: [self class]];

	objc_autoreleasePoolPop(pool);

	return value;
}

- (float)floatValue







|
<


















|
<


|
<





|
<







2273
2274
2275
2276
2277
2278
2279
2280

2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299

2300
2301
2302

2303
2304
2305
2306
2307
2308

2309
2310
2311
2312
2313
2314
2315
	for (; i < length; i++) {
		uintmax_t newValue;

		if (expectWhitespace) {
			if (characters[i] != ' ' && characters[i] != '\t' &&
			    characters[i] != '\n' && characters[i] != '\r' &&
			    characters[i] != '\f')
				@throw [OFInvalidFormatException exception];

			continue;
		}

		if (characters[i] >= '0' && characters[i] <= '9') {
			newValue = (value << 4) | (characters[i] - '0');
			foundValue = true;
		} else if (characters[i] >= 'A' && characters[i] <= 'F') {
			newValue = (value << 4) | (characters[i] - 'A' + 10);
			foundValue = true;
		} else if (characters[i] >= 'a' && characters[i] <= 'f') {
			newValue = (value << 4) | (characters[i] - 'a' + 10);
			foundValue = true;
		} else if (characters[i] == 'h' || characters[i] == ' ' ||
		    characters[i] == '\t' || characters[i] == '\n' ||
		    characters[i] == '\r' || characters[i] == '\f') {
			expectWhitespace = true;
			continue;
		} else
			@throw [OFInvalidFormatException exception];


		if (newValue < value)
			@throw [OFOutOfRangeException exception];


		value = newValue;
	}

	if (!foundValue)
		@throw [OFInvalidFormatException exception];


	objc_autoreleasePoolPop(pool);

	return value;
}

- (float)floatValue
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377

	/* Check if there are any invalid chars left */
	if (endPointer != NULL)
		for (; *endPointer != '\0'; endPointer++)
			if (*endPointer != ' ' && *endPointer != '\t' &&
			    *endPointer != '\n' && *endPointer != '\r' &&
			    *endPointer != '\f')
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];

	objc_autoreleasePoolPop(pool);

	return value;
}

- (double)doubleValue







|
<







2327
2328
2329
2330
2331
2332
2333
2334

2335
2336
2337
2338
2339
2340
2341

	/* Check if there are any invalid chars left */
	if (endPointer != NULL)
		for (; *endPointer != '\0'; endPointer++)
			if (*endPointer != ' ' && *endPointer != '\t' &&
			    *endPointer != '\n' && *endPointer != '\r' &&
			    *endPointer != '\f')
				@throw [OFInvalidFormatException exception];


	objc_autoreleasePoolPop(pool);

	return value;
}

- (double)doubleValue
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404

	/* Check if there are any invalid chars left */
	if (endPointer != NULL)
		for (; *endPointer != '\0'; endPointer++)
			if (*endPointer != ' ' && *endPointer != '\t' &&
			    *endPointer != '\n' && *endPointer != '\r' &&
			    *endPointer != '\f')
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];

	objc_autoreleasePoolPop(pool);

	return value;
}

- (const of_unichar_t*)characters







|
<







2353
2354
2355
2356
2357
2358
2359
2360

2361
2362
2363
2364
2365
2366
2367

	/* Check if there are any invalid chars left */
	if (endPointer != NULL)
		for (; *endPointer != '\0'; endPointer++)
			if (*endPointer != ' ' && *endPointer != '\t' &&
			    *endPointer != '\n' && *endPointer != '\r' &&
			    *endPointer != '\f')
				@throw [OFInvalidFormatException exception];


	objc_autoreleasePoolPop(pool);

	return value;
}

- (const of_unichar_t*)characters
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451

	j = 0;

	for (i = 0; i < length; i++) {
		of_unichar_t c = characters[i];

		if (c > 0x10FFFF)
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];

		if (swap) {
			if (c > 0xFFFF) {
				c -= 0x10000;
				ret[j++] = OF_BSWAP16(0xD800 | (c >> 10));
				ret[j++] = OF_BSWAP16(0xDC00 | (c & 0x3FF));
			} else







|
<







2399
2400
2401
2402
2403
2404
2405
2406

2407
2408
2409
2410
2411
2412
2413

	j = 0;

	for (i = 0; i < length; i++) {
		of_unichar_t c = characters[i];

		if (c > 0x10FFFF)
			@throw [OFInvalidEncodingException exception];


		if (swap) {
			if (c > 0xFFFF) {
				c -= 0x10000;
				ret[j++] = OF_BSWAP16(0xD800 | (c >> 10));
				ret[j++] = OF_BSWAP16(0xDC00 | (c & 0x3FF));
			} else

Modified src/OFString_UTF8.m from [3ce37a1895] to [3a479b89af].

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202

		switch (of_string_utf8_check(UTF8String, UTF8StringLength,
		    &_s->length)) {
		case 1:
			_s->isUTF8 = true;
			break;
		case -1:
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];
		}

		memcpy(_s->cString, UTF8String, UTF8StringLength);
		_s->cString[UTF8StringLength] = 0;
	} @catch (id e) {
		[self release];
		@throw e;







|
<







187
188
189
190
191
192
193
194

195
196
197
198
199
200
201

		switch (of_string_utf8_check(UTF8String, UTF8StringLength,
		    &_s->length)) {
		case 1:
			_s->isUTF8 = true;
			break;
		case -1:
			@throw [OFInvalidEncodingException exception];

		}

		memcpy(_s->cString, UTF8String, UTF8StringLength);
		_s->cString[UTF8StringLength] = 0;
	} @catch (id e) {
		[self release];
		@throw e;
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
		if (encoding == OF_STRING_ENCODING_UTF_8 ||
		    encoding == OF_STRING_ENCODING_ASCII) {
			switch (of_string_utf8_check(cString, cStringLength,
			    &_s->length)) {
			case 1:
				if (encoding == OF_STRING_ENCODING_ASCII)
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];

				_s->isUTF8 = true;
				break;
			case -1:
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
			}

			memcpy(_s->cString, cString, cStringLength);
			_s->cString[cStringLength] = 0;

			return self;
		}







|




|
<







228
229
230
231
232
233
234
235
236
237
238
239
240

241
242
243
244
245
246
247
		if (encoding == OF_STRING_ENCODING_UTF_8 ||
		    encoding == OF_STRING_ENCODING_ASCII) {
			switch (of_string_utf8_check(cString, cStringLength,
			    &_s->length)) {
			case 1:
				if (encoding == OF_STRING_ENCODING_ASCII)
					@throw [OFInvalidEncodingException
					    exception];

				_s->isUTF8 = true;
				break;
			case -1:
				@throw [OFInvalidEncodingException exception];

			}

			memcpy(_s->cString, cString, cStringLength);
			_s->cString[cStringLength] = 0;

			return self;
		}
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277

				_s->isUTF8 = true;
				bytes = of_string_utf8_encode(
				    (uint8_t)cString[i], buffer);

				if (bytes == 0)
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];

				_s->cStringLength += bytes - 1;
				_s->cString = [self
				    resizeMemory: _s->cString
					    size: _s->cStringLength + 1];

				memcpy(_s->cString + j, buffer, bytes);







|







261
262
263
264
265
266
267
268
269
270
271
272
273
274
275

				_s->isUTF8 = true;
				bytes = of_string_utf8_encode(
				    (uint8_t)cString[i], buffer);

				if (bytes == 0)
					@throw [OFInvalidEncodingException
					    exception];

				_s->cStringLength += bytes - 1;
				_s->cString = [self
				    resizeMemory: _s->cString
					    size: _s->cStringLength + 1];

				memcpy(_s->cString + j, buffer, bytes);
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
		case OF_STRING_ENCODING_ISO_8859_15:
			table = of_iso_8859_15;
			break;
		case OF_STRING_ENCODING_WINDOWS_1252:
			table = of_windows_1252;
			break;
		default:
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];
		}

		for (i = j = 0; i < cStringLength; i++) {
			char buffer[4];
			of_unichar_t character;
			size_t characterBytes;

			if (!(cString[i] & 0x80)) {
				_s->cString[j++] = cString[i];
				continue;
			}

			character = table[(uint8_t)cString[i]];

			if (character == 0xFFFD)
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];

			_s->isUTF8 = true;
			characterBytes = of_string_utf8_encode(character,
			    buffer);

			if (characterBytes == 0)
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];

			_s->cStringLength += characterBytes - 1;
			_s->cString = [self
			    resizeMemory: _s->cString
				    size: _s->cStringLength + 1];

			memcpy(_s->cString + j, buffer, characterBytes);







|
<















|
<






|
<







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
		case OF_STRING_ENCODING_ISO_8859_15:
			table = of_iso_8859_15;
			break;
		case OF_STRING_ENCODING_WINDOWS_1252:
			table = of_windows_1252;
			break;
		default:
			@throw [OFInvalidEncodingException exception];

		}

		for (i = j = 0; i < cStringLength; i++) {
			char buffer[4];
			of_unichar_t character;
			size_t characterBytes;

			if (!(cString[i] & 0x80)) {
				_s->cString[j++] = cString[i];
				continue;
			}

			character = table[(uint8_t)cString[i]];

			if (character == 0xFFFD)
				@throw [OFInvalidEncodingException exception];


			_s->isUTF8 = true;
			characterBytes = of_string_utf8_encode(character,
			    buffer);

			if (characterBytes == 0)
				@throw [OFInvalidEncodingException exception];


			_s->cStringLength += characterBytes - 1;
			_s->cString = [self
			    resizeMemory: _s->cString
				    size: _s->cStringLength + 1];

			memcpy(_s->cString + j, buffer, characterBytes);
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376

		switch (of_string_utf8_check(UTF8String, UTF8StringLength,
		    &_s->length)) {
		case 1:
			_s->isUTF8 = true;
			break;
		case -1:
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;







|
<







356
357
358
359
360
361
362
363

364
365
366
367
368
369
370

		switch (of_string_utf8_check(UTF8String, UTF8StringLength,
		    &_s->length)) {
		case 1:
			_s->isUTF8 = true;
			break;
		case -1:
			@throw [OFInvalidEncodingException exception];

		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
				_s->isUTF8 = true;

				memcpy(_s->cString + j, buffer, len);
				j += len;

				break;
			default:
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
			}
		}

		_s->cString[j] = '\0';
		_s->cStringLength = j;

		@try {







|
<







425
426
427
428
429
430
431
432

433
434
435
436
437
438
439
				_s->isUTF8 = true;

				memcpy(_s->cString + j, buffer, len);
				j += len;

				break;
			default:
				@throw [OFInvalidEncodingException exception];

			}
		}

		_s->cString[j] = '\0';
		_s->cStringLength = j;

		@try {
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
			char buffer[4];
			of_unichar_t character =
			    (swap ? OF_BSWAP16(string[i]) : string[i]);
			size_t len;

			/* Missing high surrogate */
			if ((character & 0xFC00) == 0xDC00)
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];

			if ((character & 0xFC00) == 0xD800) {
				of_char16_t nextCharacter;

				if (length <= i + 1)
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];

				nextCharacter = (swap
				    ? OF_BSWAP16(string[i + 1])
				    : string[i + 1]);

				if ((nextCharacter & 0xFC00) != 0xDC00)
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];

				character = (((character & 0x3FF) << 10) |
				    (nextCharacter & 0x3FF)) + 0x10000;

				i++;
				_s->length--;
			}







|
<






|







|







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
506
507
508
			char buffer[4];
			of_unichar_t character =
			    (swap ? OF_BSWAP16(string[i]) : string[i]);
			size_t len;

			/* Missing high surrogate */
			if ((character & 0xFC00) == 0xDC00)
				@throw [OFInvalidEncodingException exception];


			if ((character & 0xFC00) == 0xD800) {
				of_char16_t nextCharacter;

				if (length <= i + 1)
					@throw [OFInvalidEncodingException
					    exception];

				nextCharacter = (swap
				    ? OF_BSWAP16(string[i + 1])
				    : string[i + 1]);

				if ((nextCharacter & 0xFC00) != 0xDC00)
					@throw [OFInvalidEncodingException
					    exception];

				character = (((character & 0x3FF) << 10) |
				    (nextCharacter & 0x3FF)) + 0x10000;

				i++;
				_s->length--;
			}
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
				_s->isUTF8 = true;

				memcpy(_s->cString + j, buffer, len);
				j += len;

				break;
			default:
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
			}
		}

		_s->cString[j] = '\0';
		_s->cStringLength = j;

		@try {







|
<







519
520
521
522
523
524
525
526

527
528
529
530
531
532
533
				_s->isUTF8 = true;

				memcpy(_s->cString + j, buffer, len);
				j += len;

				break;
			default:
				@throw [OFInvalidEncodingException exception];

			}
		}

		_s->cString[j] = '\0';
		_s->cStringLength = j;

		@try {
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
				_s->isUTF8 = true;

				memcpy(_s->cString + j, buffer, len);
				j += len;

				break;
			default:
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
			}
		}

		_s->cString[j] = '\0';
		_s->cStringLength = j;

		@try {







|
<







585
586
587
588
589
590
591
592

593
594
595
596
597
598
599
				_s->isUTF8 = true;

				memcpy(_s->cString + j, buffer, len);
				j += len;

				break;
			default:
				@throw [OFInvalidEncodingException exception];

			}
		}

		_s->cString[j] = '\0';
		_s->cStringLength = j;

		@try {
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
	self = [super init];

	@try {
		char *tmp;
		int cStringLength;

		if (format == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		_s = &_storage;

		if ((cStringLength = of_vasprintf(&tmp, [format UTF8String],
		    arguments)) == -1)
			@throw [OFInvalidFormatException
			    exceptionWithClass: [self class]];

		_s->cStringLength = cStringLength;

		@try {
			switch (of_string_utf8_check(tmp, cStringLength,
			    &_s->length)) {
			case 1:
				_s->isUTF8 = true;
				break;
			case -1:
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
			}

			_s->cString = [self
			    allocMemoryWithSize: cStringLength + 1];
			memcpy(_s->cString, tmp, cStringLength + 1);
		} @finally {
			free(tmp);







|
<
<





|
<










|
<







616
617
618
619
620
621
622
623


624
625
626
627
628
629

630
631
632
633
634
635
636
637
638
639
640

641
642
643
644
645
646
647
	self = [super init];

	@try {
		char *tmp;
		int cStringLength;

		if (format == nil)
			@throw [OFInvalidArgumentException exception];



		_s = &_storage;

		if ((cStringLength = of_vasprintf(&tmp, [format UTF8String],
		    arguments)) == -1)
			@throw [OFInvalidFormatException exception];


		_s->cStringLength = cStringLength;

		@try {
			switch (of_string_utf8_check(tmp, cStringLength,
			    &_s->length)) {
			case 1:
				_s->isUTF8 = true;
				break;
			case -1:
				@throw [OFInvalidEncodingException exception];

			}

			_s->cString = [self
			    allocMemoryWithSize: cStringLength + 1];
			memcpy(_s->cString, tmp, cStringLength + 1);
		} @finally {
			free(tmp);
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
- (size_t)getCString: (char*)cString
	   maxLength: (size_t)maxLength
	    encoding: (of_string_encoding_t)encoding
{
	switch (encoding) {
	case OF_STRING_ENCODING_ASCII:
		if (_s->isUTF8)
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];
		/* intentional fall-through */
	case OF_STRING_ENCODING_UTF_8:
		if (_s->cStringLength + 1 > maxLength)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		memcpy(cString, _s->cString, _s->cStringLength + 1);

		return _s->cStringLength;
	default:
		return [super getCString: cString
			       maxLength: maxLength
				encoding: encoding];
	}
}

- (const char*)cStringWithEncoding: (of_string_encoding_t)encoding
{
	switch (encoding) {
	case OF_STRING_ENCODING_ASCII:
		if (_s->isUTF8)
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];
		/* intentional fall-through */
	case OF_STRING_ENCODING_UTF_8:
		return _s->cString;
	default:
		return [super cStringWithEncoding: encoding];
	}
}







|
<



|
<
















|
<







729
730
731
732
733
734
735
736

737
738
739
740

741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757

758
759
760
761
762
763
764
- (size_t)getCString: (char*)cString
	   maxLength: (size_t)maxLength
	    encoding: (of_string_encoding_t)encoding
{
	switch (encoding) {
	case OF_STRING_ENCODING_ASCII:
		if (_s->isUTF8)
			@throw [OFInvalidEncodingException exception];

		/* intentional fall-through */
	case OF_STRING_ENCODING_UTF_8:
		if (_s->cStringLength + 1 > maxLength)
			@throw [OFOutOfRangeException exception];


		memcpy(cString, _s->cString, _s->cStringLength + 1);

		return _s->cStringLength;
	default:
		return [super getCString: cString
			       maxLength: maxLength
				encoding: encoding];
	}
}

- (const char*)cStringWithEncoding: (of_string_encoding_t)encoding
{
	switch (encoding) {
	case OF_STRING_ENCODING_ASCII:
		if (_s->isUTF8)
			@throw [OFInvalidEncodingException exception];

		/* intentional fall-through */
	case OF_STRING_ENCODING_UTF_8:
		return _s->cString;
	default:
		return [super cStringWithEncoding: encoding];
	}
}
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
	size_t otherCStringLength, minimumCStringLength;
	int compare;

	if (object == self)
		return OF_ORDERED_SAME;

	if (![object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	otherString = (OFString*)object;
	otherCStringLength = [otherString UTF8StringLength];
	minimumCStringLength = (_s->cStringLength > otherCStringLength
	    ? otherCStringLength : _s->cStringLength);

	if ((compare = memcmp(_s->cString, [otherString UTF8String],







|
<
<







823
824
825
826
827
828
829
830


831
832
833
834
835
836
837
	size_t otherCStringLength, minimumCStringLength;
	int compare;

	if (object == self)
		return OF_ORDERED_SAME;

	if (![object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exception];



	otherString = (OFString*)object;
	otherCStringLength = [otherString UTF8StringLength];
	minimumCStringLength = (_s->cStringLength > otherCStringLength
	    ? otherCStringLength : _s->cStringLength);

	if ((compare = memcmp(_s->cString, [otherString UTF8String],
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
	size_t i, j, otherCStringLength, minimumCStringLength;
	int compare;

	if (otherString == self)
		return OF_ORDERED_SAME;

	if (![otherString isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	otherCString = [otherString UTF8String];
	otherCStringLength = [otherString UTF8StringLength];

	if (!_s->isUTF8) {
		minimumCStringLength = (_s->cStringLength > otherCStringLength
		    ? otherCStringLength : _s->cStringLength);







|
<
<







855
856
857
858
859
860
861
862


863
864
865
866
867
868
869
	size_t i, j, otherCStringLength, minimumCStringLength;
	int compare;

	if (otherString == self)
		return OF_ORDERED_SAME;

	if (![otherString isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exception];



	otherCString = [otherString UTF8String];
	otherCStringLength = [otherString UTF8StringLength];

	if (!_s->isUTF8) {
		minimumCStringLength = (_s->cStringLength > otherCStringLength
		    ? otherCStringLength : _s->cStringLength);
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927

		l1 = of_string_utf8_decode(_s->cString + i,
		    _s->cStringLength - i, &c1);
		l2 = of_string_utf8_decode(otherCString + j,
		    otherCStringLength - j, &c2);

		if (l1 == 0 || l2 == 0 || c1 > 0x10FFFF || c2 > 0x10FFFF)
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];

		if (c1 >> 8 < OF_UNICODE_CASEFOLDING_TABLE_SIZE) {
			of_unichar_t tc =
			    of_unicode_casefolding_table[c1 >> 8][c1 & 0xFF];

			if (tc)
				c1 = tc;







|
<







891
892
893
894
895
896
897
898

899
900
901
902
903
904
905

		l1 = of_string_utf8_decode(_s->cString + i,
		    _s->cStringLength - i, &c1);
		l2 = of_string_utf8_decode(otherCString + j,
		    otherCStringLength - j, &c2);

		if (l1 == 0 || l2 == 0 || c1 > 0x10FFFF || c2 > 0x10FFFF)
			@throw [OFInvalidEncodingException exception];


		if (c1 >> 8 < OF_UNICODE_CASEFOLDING_TABLE_SIZE) {
			of_unichar_t tc =
			    of_unicode_casefolding_table[c1 >> 8][c1 & 0xFF];

			if (tc)
				c1 = tc;
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979

	for (i = 0; i < _s->cStringLength; i++) {
		of_unichar_t c;
		size_t length;

		if ((length = of_string_utf8_decode(_s->cString + i,
		    _s->cStringLength - i, &c)) == 0)
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];

		OF_HASH_ADD(hash, (c & 0xFF0000) >> 16);
		OF_HASH_ADD(hash, (c & 0x00FF00) >>  8);
		OF_HASH_ADD(hash,  c & 0x0000FF);

		i += length - 1;
	}







|
<







942
943
944
945
946
947
948
949

950
951
952
953
954
955
956

	for (i = 0; i < _s->cStringLength; i++) {
		of_unichar_t c;
		size_t length;

		if ((length = of_string_utf8_decode(_s->cString + i,
		    _s->cStringLength - i, &c)) == 0)
			@throw [OFInvalidEncodingException exception];


		OF_HASH_ADD(hash, (c & 0xFF0000) >> 16);
		OF_HASH_ADD(hash, (c & 0x00FF00) >>  8);
		OF_HASH_ADD(hash,  c & 0x0000FF);

		i += length - 1;
	}
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
}

- (of_unichar_t)characterAtIndex: (size_t)index
{
	of_unichar_t character;

	if (index >= _s->length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (!_s->isUTF8)
		return _s->cString[index];

	index = of_string_utf8_get_position(_s->cString, index,
	    _s->cStringLength);

	if (!of_string_utf8_decode(_s->cString + index,
	    _s->cStringLength - index, &character))
		@throw [OFInvalidEncodingException
		    exceptionWithClass: [self class]];

	return character;
}

- (void)getCharacters: (of_unichar_t*)buffer
	      inRange: (of_range_t)range
{
	/* TODO: Could be slightly optimized */
	void *pool = objc_autoreleasePoolPush();
	const of_unichar_t *characters = [self characters];

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _s->length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	memcpy(buffer, characters + range.location,
	    range.length * sizeof(of_unichar_t));

	objc_autoreleasePoolPop(pool);
}

- (of_range_t)rangeOfString: (OFString*)string
		    options: (int)options
		      range: (of_range_t)range
{
	const char *cString = [string UTF8String];
	size_t i, cStringLength = [string UTF8StringLength];
	size_t rangeLocation, rangeLength;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _s->length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (_s->isUTF8) {
		rangeLocation = of_string_utf8_get_position(
		    _s->cString, range.location, _s->cStringLength);
		rangeLength = of_string_utf8_get_position(
		    _s->cString + rangeLocation, range.length,
		    _s->cStringLength - rangeLocation);







|









|
<













|

















|







964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981

982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
}

- (of_unichar_t)characterAtIndex: (size_t)index
{
	of_unichar_t character;

	if (index >= _s->length)
		@throw [OFOutOfRangeException exception];

	if (!_s->isUTF8)
		return _s->cString[index];

	index = of_string_utf8_get_position(_s->cString, index,
	    _s->cStringLength);

	if (!of_string_utf8_decode(_s->cString + index,
	    _s->cStringLength - index, &character))
		@throw [OFInvalidEncodingException exception];


	return character;
}

- (void)getCharacters: (of_unichar_t*)buffer
	      inRange: (of_range_t)range
{
	/* TODO: Could be slightly optimized */
	void *pool = objc_autoreleasePoolPush();
	const of_unichar_t *characters = [self characters];

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _s->length)
		@throw [OFOutOfRangeException exception];

	memcpy(buffer, characters + range.location,
	    range.length * sizeof(of_unichar_t));

	objc_autoreleasePoolPop(pool);
}

- (of_range_t)rangeOfString: (OFString*)string
		    options: (int)options
		      range: (of_range_t)range
{
	const char *cString = [string UTF8String];
	size_t i, cStringLength = [string UTF8StringLength];
	size_t rangeLocation, rangeLength;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _s->length)
		@throw [OFOutOfRangeException exception];

	if (_s->isUTF8) {
		rangeLocation = of_string_utf8_get_position(
		    _s->cString, range.location, _s->cStringLength);
		rangeLength = of_string_utf8_get_position(
		    _s->cString + rangeLocation, range.length,
		    _s->cStringLength - rangeLocation);
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118

- (OFString*)substringWithRange: (of_range_t)range
{
	size_t start = range.location;
	size_t end = range.location + range.length;

	if (range.length > SIZE_MAX - range.location || end > _s->length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (_s->isUTF8) {
		start = of_string_utf8_get_position(_s->cString, start,
		    _s->cStringLength);
		end = of_string_utf8_get_position(_s->cString, end,
		    _s->cStringLength);
	}







|







1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094

- (OFString*)substringWithRange: (of_range_t)range
{
	size_t start = range.location;
	size_t end = range.location + range.length;

	if (range.length > SIZE_MAX - range.location || end > _s->length)
		@throw [OFOutOfRangeException exception];

	if (_s->isUTF8) {
		start = of_string_utf8_get_position(_s->cString, start,
		    _s->cStringLength);
		end = of_string_utf8_get_position(_s->cString, end,
		    _s->cStringLength);
	}
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
		of_unichar_t c;
		size_t cLen;

		cLen = of_string_utf8_decode(_s->cString + i,
		    _s->cStringLength - i, &c);

		if (cLen == 0 || c > 0x10FFFF)
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];

		ret[j++] = c;
		i += cLen;
	}

	return ret;
}







|
<







1298
1299
1300
1301
1302
1303
1304
1305

1306
1307
1308
1309
1310
1311
1312
		of_unichar_t c;
		size_t cLen;

		cLen = of_string_utf8_decode(_s->cString + i,
		    _s->cStringLength - i, &c);

		if (cLen == 0 || c > 0x10FFFF)
			@throw [OFInvalidEncodingException exception];


		ret[j++] = c;
		i += cLen;
	}

	return ret;
}
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
		of_unichar_t c;
		size_t cLen;

		cLen = of_string_utf8_decode(_s->cString + i,
		    _s->cStringLength - i, &c);

		if (cLen == 0 || c > 0x10FFFF)
			@throw [OFInvalidEncodingException
			    exceptionWithClass: [self class]];

		if (byteOrder != OF_BYTE_ORDER_NATIVE)
			ret[j++] = OF_BSWAP32(c);
		else
			ret[j++] = c;

		i += cLen;







|
<







1326
1327
1328
1329
1330
1331
1332
1333

1334
1335
1336
1337
1338
1339
1340
		of_unichar_t c;
		size_t cLen;

		cLen = of_string_utf8_decode(_s->cString + i,
		    _s->cStringLength - i, &c);

		if (cLen == 0 || c > 0x10FFFF)
			@throw [OFInvalidEncodingException exception];


		if (byteOrder != OF_BYTE_ORDER_NATIVE)
			ret[j++] = OF_BSWAP32(c);
		else
			ret[j++] = c;

		i += cLen;

Modified src/OFTCPSocket+SOCKS5.m from [76d38f9e30] to [8d47abae82].

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
		   length: 3];

	[self readIntoBuffer: reply
		 exactLength: 2];

	if (reply[0] != 5 || reply[1] != 0) {
		[self close];
		@throw [OFConnectionFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host
				  port: port];
	}

	wasWriteBufferEnabled = [self isWriteBufferEnabled];
	[self setWriteBufferEnabled: true];

	/* CONNECT request */
	[self writeBuffer: request







|
|
|
<
<







36
37
38
39
40
41
42
43
44
45


46
47
48
49
50
51
52
		   length: 3];

	[self readIntoBuffer: reply
		 exactLength: 2];

	if (reply[0] != 5 || reply[1] != 0) {
		[self close];
		@throw [OFConnectionFailedException exceptionWithHost: host
								 port: port
							       socket: self];


	}

	wasWriteBufferEnabled = [self isWriteBufferEnabled];
	[self setWriteBufferEnabled: true];

	/* CONNECT request */
	[self writeBuffer: request
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
	[self setWriteBufferEnabled: wasWriteBufferEnabled];

	[self readIntoBuffer: reply
		 exactLength: 4];

	if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) {
		[self close];
		@throw [OFConnectionFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host
				  port: port];
	}

	/* Skip the rest of the reply */
	switch (reply[3]) {
	case 1: /* IPv4 */
		[self readIntoBuffer: reply
			 exactLength: 4];
		break;
	case 3: /* Domainname */
		[self readIntoBuffer: reply
			 exactLength: [self readInt8]];
		break;
	case 4: /* IPv6 */
		[self readIntoBuffer: reply
			 exactLength: 16];
		break;
	default:
		[self close];
		@throw [OFConnectionFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host
				  port: port];
	}

	[self readBigEndianInt16];
}
@end







|
|
|
<
<


















|
|
|
<
<





60
61
62
63
64
65
66
67
68
69


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90


91
92
93
94
95
	[self setWriteBufferEnabled: wasWriteBufferEnabled];

	[self readIntoBuffer: reply
		 exactLength: 4];

	if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) {
		[self close];
		@throw [OFConnectionFailedException exceptionWithHost: host
								 port: port
							       socket: self];


	}

	/* Skip the rest of the reply */
	switch (reply[3]) {
	case 1: /* IPv4 */
		[self readIntoBuffer: reply
			 exactLength: 4];
		break;
	case 3: /* Domainname */
		[self readIntoBuffer: reply
			 exactLength: [self readInt8]];
		break;
	case 4: /* IPv6 */
		[self readIntoBuffer: reply
			 exactLength: 16];
		break;
	default:
		[self close];
		@throw [OFConnectionFailedException exceptionWithHost: host
								 port: port
							       socket: self];


	}

	[self readBigEndianInt16];
}
@end

Modified src/OFTCPSocket.m from [b00741c4c9] to [3305aefb9e].

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
- (void)connectToHost: (OFString*)host
		 port: (uint16_t)port
{
	OFString *destinationHost = host;
	uint16_t destinationPort = port;

	if (_socket != INVALID_SOCKET)
		@throw [OFAlreadyConnectedException
		    exceptionWithClass: [self class]
				socket: self];

	if (_SOCKS5Host != nil) {
		/* Connect to the SOCKS5 proxy instead */
		host = _SOCKS5Host;
		port = _SOCKS5Port;
	}

#ifdef HAVE_THREADSAFE_GETADDRINFO
	struct addrinfo hints, *res, *res0;
	char portCString[7];

	memset(&hints, 0, sizeof(struct addrinfo));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_flags = AI_NUMERICSERV;
	snprintf(portCString, 7, "%" PRIu16, port);

	if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    portCString, &hints, &res0))
		@throw [OFAddressTranslationFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host];

	for (res = res0; res != NULL; res = res->ai_next) {
		if ((_socket = socket(res->ai_family, res->ai_socktype,
		    res->ai_protocol)) == INVALID_SOCKET)
			continue;

		if (connect(_socket, res->ai_addr, res->ai_addrlen) == -1) {







|
<
<




















|
|
<







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
- (void)connectToHost: (OFString*)host
		 port: (uint16_t)port
{
	OFString *destinationHost = host;
	uint16_t destinationPort = port;

	if (_socket != INVALID_SOCKET)
		@throw [OFAlreadyConnectedException exceptionWithSocket: self];



	if (_SOCKS5Host != nil) {
		/* Connect to the SOCKS5 proxy instead */
		host = _SOCKS5Host;
		port = _SOCKS5Port;
	}

#ifdef HAVE_THREADSAFE_GETADDRINFO
	struct addrinfo hints, *res, *res0;
	char portCString[7];

	memset(&hints, 0, sizeof(struct addrinfo));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_flags = AI_NUMERICSERV;
	snprintf(portCString, 7, "%" PRIu16, port);

	if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    portCString, &hints, &res0))
		@throw [OFAddressTranslationFailedException
		    exceptionWithHost: host
			       socket: self];


	for (res = res0; res != NULL; res = res->ai_next) {
		if ((_socket = socket(res->ai_family, res->ai_socktype,
		    res->ai_protocol)) == INVALID_SOCKET)
			continue;

		if (connect(_socket, res->ai_addr, res->ai_addrlen) == -1) {
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
	addr.sin_port = OF_BSWAP16_IF_LE(port);

	if ((addr.sin_addr.s_addr = inet_addr([host cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) != (in_addr_t)(-1)) {
		if ((_socket = socket(AF_INET, SOCK_STREAM,
		    0)) == INVALID_SOCKET) {
			@throw [OFConnectionFailedException
			    exceptionWithClass: [self class]

					socket: self
					  host: host
					  port: port];
		}

		if (connect(_socket, (struct sockaddr*)&addr,
		    sizeof(addr)) == -1) {
			close(_socket);
			_socket = INVALID_SOCKET;
			@throw [OFConnectionFailedException
			    exceptionWithClass: [self class]

					socket: self
					  host: host
					  port: port];
		}

		if (_SOCKS5Host != nil)
			[self OF_SOCKS5ConnectToHost: destinationHost
						port: destinationPort];

		return;







|
>
|
<
<







|
>
|
<
<







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
	addr.sin_port = OF_BSWAP16_IF_LE(port);

	if ((addr.sin_addr.s_addr = inet_addr([host cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) != (in_addr_t)(-1)) {
		if ((_socket = socket(AF_INET, SOCK_STREAM,
		    0)) == INVALID_SOCKET) {
			@throw [OFConnectionFailedException
			    exceptionWithHost: host
					 port: port
				       socket: self];


		}

		if (connect(_socket, (struct sockaddr*)&addr,
		    sizeof(addr)) == -1) {
			close(_socket);
			_socket = INVALID_SOCKET;
			@throw [OFConnectionFailedException
			    exceptionWithHost: host
					 port: port
				       socket: self];


		}

		if (_SOCKS5Host != nil)
			[self OF_SOCKS5ConnectToHost: destinationHost
						port: destinationPort];

		return;
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
	if ((he = gethostbyname([host cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_HAVE_THREADS
		[addrlist release];
		[mutex unlock];
# endif
		@throw [OFAddressTranslationFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host];
	}

	if (he->h_addrtype != AF_INET ||
	    (_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
# ifdef OF_HAVE_THREADS
		[addrlist release];
		[mutex unlock];
# endif
		@throw [OFConnectionFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host
				  port: port];
	}

# ifdef OF_HAVE_THREADS
	@try {
		for (ip = he->h_addr_list; *ip != NULL; ip++)
			[addrlist addItem: ip];








|
|
<








|
|
|
<
<







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
	if ((he = gethostbyname([host cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_HAVE_THREADS
		[addrlist release];
		[mutex unlock];
# endif
		@throw [OFAddressTranslationFailedException
		    exceptionWithHost: host
			       socket: self];

	}

	if (he->h_addrtype != AF_INET ||
	    (_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
# ifdef OF_HAVE_THREADS
		[addrlist release];
		[mutex unlock];
# endif
		@throw [OFConnectionFailedException exceptionWithHost: host
								 port: port
							       socket: self];


	}

# ifdef OF_HAVE_THREADS
	@try {
		for (ip = he->h_addr_list; *ip != NULL; ip++)
			[addrlist addItem: ip];

483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
	if (!connected) {
		close(_socket);
		_socket = INVALID_SOCKET;
	}
#endif

	if (_socket == INVALID_SOCKET)
		@throw [OFConnectionFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host
				  port: port];

	if (_SOCKS5Host != nil)
		[self OF_SOCKS5ConnectToHost: destinationHost
					port: destinationPort];
}

#ifdef OF_HAVE_THREADS







|
|
|
<
<







475
476
477
478
479
480
481
482
483
484


485
486
487
488
489
490
491
	if (!connected) {
		close(_socket);
		_socket = INVALID_SOCKET;
	}
#endif

	if (_socket == INVALID_SOCKET)
		@throw [OFConnectionFailedException exceptionWithHost: host
								 port: port
							       socket: self];



	if (_SOCKS5Host != nil)
		[self OF_SOCKS5ConnectToHost: destinationHost
					port: destinationPort];
}

#ifdef OF_HAVE_THREADS
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588

589
590
591
592
593
594
595
596
597
598
599
600
601
602
603

604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648

649
650
651
652
653
654
655
656
657
658
659
660
661
662

663
664
665
666
667
668
669
670
671
672
673
674
675
676
677

678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693

694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
#endif
	} addr;
#ifndef __wii__
	socklen_t addrLen;
#endif

	if (_socket != INVALID_SOCKET)
		@throw [OFAlreadyConnectedException
		    exceptionWithClass: [self class]
				socket: self];

	if (_SOCKS5Host != nil)
		@throw [OFNotImplementedException
		    exceptionWithClass: [self class]
			      selector: _cmd];

#ifdef __wii__
	if (port == 0)
		port = freePort--;
#endif

#ifdef HAVE_THREADSAFE_GETADDRINFO
	struct addrinfo hints, *res;
	char portCString[7];

	memset(&hints, 0, sizeof(struct addrinfo));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_flags = AI_NUMERICSERV | AI_PASSIVE;
	snprintf(portCString, 7, "%" PRIu16, port);

	if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    portCString, &hints, &res))
		@throw [OFAddressTranslationFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host];

	if ((_socket = socket(res->ai_family, SOCK_STREAM,
	    0)) == INVALID_SOCKET)
		@throw [OFBindFailedException exceptionWithClass: [self class]

							  socket: self
							    host: host
							    port: port];

	if (setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one,
	    sizeof(one)))
		@throw [OFSetOptionFailedException
		    exceptionWithClass: [self class]
				stream: self];

	if (bind(_socket, res->ai_addr, res->ai_addrlen) == -1) {
		freeaddrinfo(res);
		close(_socket);
		_socket = INVALID_SOCKET;
		@throw [OFBindFailedException exceptionWithClass: [self class]

							  socket: self
							    host: host
							    port: port];
	}

	freeaddrinfo(res);
#else
	memset(&addr, 0, sizeof(addr));
	addr.in.sin_family = AF_INET;
	addr.in.sin_port = OF_BSWAP16_IF_LE(port);

	if ((addr.in.sin_addr.s_addr = inet_addr([host cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) == (in_addr_t)(-1)) {
# ifdef OF_HAVE_THREADS
		[mutex lock];
		@try {
# endif
			struct hostent *he;

			if ((he = gethostbyname([host cStringWithEncoding:
			    OF_STRING_ENCODING_NATIVE])) == NULL)
				@throw [OFAddressTranslationFailedException
				    exceptionWithClass: [self class]
						socket: self
						  host: host];

			if (he->h_addrtype != AF_INET ||
			    he->h_addr_list[0] == NULL) {
				@throw [OFAddressTranslationFailedException
				    exceptionWithClass: [self class]
						socket: self
						  host: host];
			}

			memcpy(&addr.in.sin_addr.s_addr, he->h_addr_list[0],
			    he->h_length);
# ifdef OF_HAVE_THREADS
		} @finally {
			[mutex unlock];
		}
# endif
	}

	if ((_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
		@throw [OFBindFailedException exceptionWithClass: [self class]

							  socket: self
							    host: host
							    port: port];

	if (setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one,
	    sizeof(one)))
		@throw [OFSetOptionFailedException
		    exceptionWithClass: [self class]
				stream: self];

	if (bind(_socket, (struct sockaddr*)&addr.in, sizeof(addr.in)) == -1) {
		close(_socket);
		_socket = INVALID_SOCKET;
		@throw [OFBindFailedException exceptionWithClass: [self class]

							  socket: self
							    host: host
							    port: port];
	}
#endif

	if (port > 0)
		return port;

#ifndef __wii__
	addrLen = sizeof(addr.storage);
	if (getsockname(_socket, (struct sockaddr*)&addr, &addrLen)) {
		close(_socket);
		_socket = INVALID_SOCKET;
		@throw [OFBindFailedException exceptionWithClass: [self class]

							  socket: self
							    host: host
							    port: port];
	}

	if (addr.storage.ss_family == AF_INET)
		return OF_BSWAP16_IF_LE(addr.in.sin_port);
# ifdef AF_INET6
	if (addr.storage.ss_family == AF_INET6)
		return OF_BSWAP16_IF_LE(addr.in6.sin6_port);
# endif
#endif

	close(_socket);
	_socket = INVALID_SOCKET;
	@throw [OFBindFailedException exceptionWithClass: [self class]

						  socket: self
						    host: host
						    port: port];
}

- (void)listenWithBackLog: (int)backLog
{
	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithClass: [self class]
							    socket: self];

	if (listen(_socket, backLog) == -1)
		@throw [OFListenFailedException exceptionWithClass: [self class]
							    socket: self
							   backLog: backLog];

	_listening = true;
}

- (void)listen
{







|
<
<


|
<
|



















|
|
<



|
>
|
<
<



|
<
<





|
>
|
<
<



















|
|
<




|
|
<












|
>
|
<
<



|
<
<




|
>
|
<
<











|
>
|
<
<












|
>
|
<
<





|
<


|
<







538
539
540
541
542
543
544
545


546
547
548

549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570

571
572
573
574
575
576


577
578
579
580


581
582
583
584
585
586
587
588


589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609

610
611
612
613
614
615

616
617
618
619
620
621
622
623
624
625
626
627
628
629
630


631
632
633
634


635
636
637
638
639
640
641


642
643
644
645
646
647
648
649
650
651
652
653
654
655


656
657
658
659
660
661
662
663
664
665
666
667
668
669
670


671
672
673
674
675
676

677
678
679

680
681
682
683
684
685
686
#endif
	} addr;
#ifndef __wii__
	socklen_t addrLen;
#endif

	if (_socket != INVALID_SOCKET)
		@throw [OFAlreadyConnectedException exceptionWithSocket: self];



	if (_SOCKS5Host != nil)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd

								 object: self];

#ifdef __wii__
	if (port == 0)
		port = freePort--;
#endif

#ifdef HAVE_THREADSAFE_GETADDRINFO
	struct addrinfo hints, *res;
	char portCString[7];

	memset(&hints, 0, sizeof(struct addrinfo));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_flags = AI_NUMERICSERV | AI_PASSIVE;
	snprintf(portCString, 7, "%" PRIu16, port);

	if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    portCString, &hints, &res))
		@throw [OFAddressTranslationFailedException
		    exceptionWithHost: host
			       socket: self];


	if ((_socket = socket(res->ai_family, SOCK_STREAM,
	    0)) == INVALID_SOCKET)
		@throw [OFBindFailedException exceptionWithHost: host
							   port: port
							 socket: self];



	if (setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one,
	    sizeof(one)))
		@throw [OFSetOptionFailedException exceptionWithStream: self];



	if (bind(_socket, res->ai_addr, res->ai_addrlen) == -1) {
		freeaddrinfo(res);
		close(_socket);
		_socket = INVALID_SOCKET;
		@throw [OFBindFailedException exceptionWithHost: host
							   port: port
							 socket: self];


	}

	freeaddrinfo(res);
#else
	memset(&addr, 0, sizeof(addr));
	addr.in.sin_family = AF_INET;
	addr.in.sin_port = OF_BSWAP16_IF_LE(port);

	if ((addr.in.sin_addr.s_addr = inet_addr([host cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) == (in_addr_t)(-1)) {
# ifdef OF_HAVE_THREADS
		[mutex lock];
		@try {
# endif
			struct hostent *he;

			if ((he = gethostbyname([host cStringWithEncoding:
			    OF_STRING_ENCODING_NATIVE])) == NULL)
				@throw [OFAddressTranslationFailedException
				    exceptionWithHost: host
					       socket: self];


			if (he->h_addrtype != AF_INET ||
			    he->h_addr_list[0] == NULL) {
				@throw [OFAddressTranslationFailedException
				    exceptionWithHost: host
					       socket: self];

			}

			memcpy(&addr.in.sin_addr.s_addr, he->h_addr_list[0],
			    he->h_length);
# ifdef OF_HAVE_THREADS
		} @finally {
			[mutex unlock];
		}
# endif
	}

	if ((_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
		@throw [OFBindFailedException exceptionWithHost: host
							   port: port
							 socket: self];



	if (setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one,
	    sizeof(one)))
		@throw [OFSetOptionFailedException exceptionWithStream: self];



	if (bind(_socket, (struct sockaddr*)&addr.in, sizeof(addr.in)) == -1) {
		close(_socket);
		_socket = INVALID_SOCKET;
		@throw [OFBindFailedException exceptionWithHost: host
							   port: port
							 socket: self];


	}
#endif

	if (port > 0)
		return port;

#ifndef __wii__
	addrLen = sizeof(addr.storage);
	if (getsockname(_socket, (struct sockaddr*)&addr, &addrLen)) {
		close(_socket);
		_socket = INVALID_SOCKET;
		@throw [OFBindFailedException exceptionWithHost: host
							   port: port
							 socket: self];


	}

	if (addr.storage.ss_family == AF_INET)
		return OF_BSWAP16_IF_LE(addr.in.sin_port);
# ifdef AF_INET6
	if (addr.storage.ss_family == AF_INET6)
		return OF_BSWAP16_IF_LE(addr.in6.sin6_port);
# endif
#endif

	close(_socket);
	_socket = INVALID_SOCKET;
	@throw [OFBindFailedException exceptionWithHost: host
						   port: port
						 socket: self];


}

- (void)listenWithBackLog: (int)backLog
{
	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithSocket: self];


	if (listen(_socket, backLog) == -1)
		@throw [OFListenFailedException exceptionWithSocket: self

							   backLog: backLog];

	_listening = true;
}

- (void)listen
{
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739

	client = [[[[self class] alloc] init] autorelease];
	addrLen = sizeof(*addr);
	addr = [client allocMemoryWithSize: addrLen];

	if ((socket = accept(_socket, (struct sockaddr*)addr,
	    &addrLen)) == INVALID_SOCKET)
		@throw [OFAcceptFailedException exceptionWithClass: [self class]
							    socket: self];

	client->_socket = socket;
	client->_sockAddr = addr;
	client->_sockAddrLen = addrLen;

	return client;
}







|
<







696
697
698
699
700
701
702
703

704
705
706
707
708
709
710

	client = [[[[self class] alloc] init] autorelease];
	addrLen = sizeof(*addr);
	addr = [client allocMemoryWithSize: addrLen];

	if ((socket = accept(_socket, (struct sockaddr*)addr,
	    &addrLen)) == INVALID_SOCKET)
		@throw [OFAcceptFailedException exceptionWithSocket: self];


	client->_socket = socket;
	client->_sockAddr = addr;
	client->_sockAddrLen = addrLen;

	return client;
}
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
#endif

- (void)setKeepAlivesEnabled: (bool)enable
{
	int v = enable;

	if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, sizeof(v)))
		@throw [OFSetOptionFailedException
		    exceptionWithClass: [self class]
				stream: self];
}

- (OFString*)remoteAddress
{
	char *host;

	if (_sockAddr == NULL || _sockAddrLen == 0)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

#ifdef HAVE_THREADSAFE_GETADDRINFO
	host = [self allocMemoryWithSize: NI_MAXHOST];

	@try {
		if (getnameinfo((struct sockaddr*)_sockAddr, _sockAddrLen, host,
		    NI_MAXHOST, NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV))
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: [self class]];

		return [OFString stringWithCString: host
					  encoding: OF_STRING_ENCODING_NATIVE];
	} @finally {
		[self freeMemory: host];
	}
#else
# ifdef OF_HAVE_THREADS
	[mutex lock];

	@try {
# endif
		host = inet_ntoa(((struct sockaddr_in*)_sockAddr)->sin_addr);

		if (host == NULL)
			@throw [OFAddressTranslationFailedException
			    exceptionWithClass: [self class]];

		return [OFString stringWithCString: host
					  encoding: OF_STRING_ENCODING_NATIVE];
# ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}







|
<
<







<
|
<








|
















|







726
727
728
729
730
731
732
733


734
735
736
737
738
739
740

741

742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
#endif

- (void)setKeepAlivesEnabled: (bool)enable
{
	int v = enable;

	if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, sizeof(v)))
		@throw [OFSetOptionFailedException exceptionWithStream: self];


}

- (OFString*)remoteAddress
{
	char *host;

	if (_sockAddr == NULL || _sockAddrLen == 0)

		@throw [OFNotConnectedException exceptionWithSocket: self];


#ifdef HAVE_THREADSAFE_GETADDRINFO
	host = [self allocMemoryWithSize: NI_MAXHOST];

	@try {
		if (getnameinfo((struct sockaddr*)_sockAddr, _sockAddrLen, host,
		    NI_MAXHOST, NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV))
			@throw [OFAddressTranslationFailedException
			    exceptionWithSocket: self];

		return [OFString stringWithCString: host
					  encoding: OF_STRING_ENCODING_NATIVE];
	} @finally {
		[self freeMemory: host];
	}
#else
# ifdef OF_HAVE_THREADS
	[mutex lock];

	@try {
# endif
		host = inet_ntoa(((struct sockaddr_in*)_sockAddr)->sin_addr);

		if (host == NULL)
			@throw [OFAddressTranslationFailedException
			    exceptionWithSocket: self];

		return [OFString stringWithCString: host
					  encoding: OF_STRING_ENCODING_NATIVE];
# ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}

Modified src/OFThread.m from [cdfc8ccff6] to [6bf58b8f5f].

155
156
157
158
159
160
161

162
163
164
165
166
167
168
169
170

+ (void)setObject: (id)object
	forTLSKey: (OFTLSKey*)key
{
	id oldObject = of_tlskey_get(key->_key);

	if (!of_tlskey_set(key->_key, [object retain]))

		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

	[oldObject release];
}

+ (id)objectForTLSKey: (OFTLSKey*)key
{
	return [[(id)of_tlskey_get(key->_key) retain] autorelease];







>
|
<







155
156
157
158
159
160
161
162
163

164
165
166
167
168
169
170

+ (void)setObject: (id)object
	forTLSKey: (OFTLSKey*)key
{
	id oldObject = of_tlskey_get(key->_key);

	if (!of_tlskey_set(key->_key, [object retain]))
		/* FIXME: Find a better exception */
		@throw [OFInvalidArgumentException exception];


	[oldObject release];
}

+ (id)objectForTLSKey: (OFTLSKey*)key
{
	return [[(id)of_tlskey_get(key->_key) retain] autorelease];
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
	return mainThread;
}
#endif

+ (void)sleepForTimeInterval: (double)seconds
{
	if (seconds < 0)
		@throw [OFOutOfRangeException exceptionWithClass: self];

#if defined(HAVE_NANOSLEEP)
	struct timespec rqtp;

	rqtp.tv_sec = (time_t)seconds;
	rqtp.tv_nsec = lrint((seconds - rqtp.tv_sec) * 1000000000);

	if (rqtp.tv_sec != floor(seconds))
		@throw [OFOutOfRangeException exceptionWithClass: self];

	nanosleep(&rqtp, NULL);
#elif !defined(_WIN32)
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException exceptionWithClass: self];

	sleep((unsigned int)seconds);
	usleep((useconds_t)lrint((seconds - floor(seconds)) * 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException exceptionWithClass: self];

	Sleep((unsigned int)(seconds * 1000));
#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{







|








|




|





|







180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
	return mainThread;
}
#endif

+ (void)sleepForTimeInterval: (double)seconds
{
	if (seconds < 0)
		@throw [OFOutOfRangeException exception];

#if defined(HAVE_NANOSLEEP)
	struct timespec rqtp;

	rqtp.tv_sec = (time_t)seconds;
	rqtp.tv_nsec = lrint((seconds - rqtp.tv_sec) * 1000000000);

	if (rqtp.tv_sec != floor(seconds))
		@throw [OFOutOfRangeException exception];

	nanosleep(&rqtp, NULL);
#elif !defined(_WIN32)
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	sleep((unsigned int)seconds);
	usleep((useconds_t)lrint((seconds - floor(seconds)) * 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	Sleep((unsigned int)(seconds * 1000));
#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
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
337
338
	[oldRunLoop release];
}

- (void)start
{
	if (_running == OF_THREAD_RUNNING)
		@throw [OFThreadStillRunningException
		    exceptionWithClass: [self class]
				thread: self];

	if (_running == OF_THREAD_WAITING_FOR_JOIN) {
		of_thread_detach(_thread);
		[_returnValue release];
	}

	[self retain];

	_running = OF_THREAD_RUNNING;

	if (!of_thread_new(&_thread, call_main, self)) {
		[self release];
		@throw [OFThreadStartFailedException
		    exceptionWithClass: [self class]
				thread: self];
	}

	set_thread_name(self);
}

- (id)join
{
	if (_running == OF_THREAD_NOT_RUNNING || !of_thread_join(_thread))
		@throw [OFThreadJoinFailedException
		    exceptionWithClass: [self class]
				thread: self];

	_running = OF_THREAD_NOT_RUNNING;

	return _returnValue;
}

- copy







<
|












|
<
<








|
<
<







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
	[oldRunLoop release];
}

- (void)start
{
	if (_running == OF_THREAD_RUNNING)
		@throw [OFThreadStillRunningException

		    exceptionWithThread: self];

	if (_running == OF_THREAD_WAITING_FOR_JOIN) {
		of_thread_detach(_thread);
		[_returnValue release];
	}

	[self retain];

	_running = OF_THREAD_RUNNING;

	if (!of_thread_new(&_thread, call_main, self)) {
		[self release];
		@throw [OFThreadStartFailedException exceptionWithThread: self];


	}

	set_thread_name(self);
}

- (id)join
{
	if (_running == OF_THREAD_NOT_RUNNING || !of_thread_join(_thread))
		@throw [OFThreadJoinFailedException exceptionWithThread: self];



	_running = OF_THREAD_NOT_RUNNING;

	return _returnValue;
}

- copy
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
		set_thread_name(self);
}

- (void)dealloc
{
	if (_running == OF_THREAD_RUNNING)
		@throw [OFThreadStillRunningException
		    exceptionWithClass: [self class]
				thread: self];

	/*
	 * We should not be running anymore, but call detach in order to free
	 * the resources.
	 */
	if (_running == OF_THREAD_WAITING_FOR_JOIN)
		of_thread_detach(_thread);







<
|







367
368
369
370
371
372
373

374
375
376
377
378
379
380
381
		set_thread_name(self);
}

- (void)dealloc
{
	if (_running == OF_THREAD_RUNNING)
		@throw [OFThreadStillRunningException

		    exceptionWithThread: self];

	/*
	 * We should not be running anymore, but call detach in order to free
	 * the resources.
	 */
	if (_running == OF_THREAD_WAITING_FOR_JOIN)
		of_thread_detach(_thread);

Modified src/OFTimer.m from [a9cca4ec95] to [2cd75597b2].

349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
}

- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFTimer *timer;

	if (![object isKindOfClass: [OFTimer class]])
		@throw[OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	timer = (OFTimer*)object;

	return [_fireDate compare: timer->_fireDate];
}

- (void)fire







|
<
<







349
350
351
352
353
354
355
356


357
358
359
360
361
362
363
}

- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	OFTimer *timer;

	if (![object isKindOfClass: [OFTimer class]])
		@throw [OFInvalidArgumentException exception];



	timer = (OFTimer*)object;

	return [_fireDate compare: timer->_fireDate];
}

- (void)fire

Modified src/OFURL.m from [269af2cde7] to [a580a39551].

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
	self = [super init];

	@try {
		char *tmp, *tmp2;

		if ((UTF8String2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     exceptionWithClass: [self class]
				  requestedSize: [string UTF8StringLength]];

		UTF8String = UTF8String2;

		if (!strncmp(UTF8String, "file://", 7)) {
			_scheme = @"file";
			_path = [[OFString alloc]
			    initWithUTF8String: UTF8String + 7];
			return self;
		} else if (!strncmp(UTF8String, "http://", 7)) {
			_scheme = @"http";
			UTF8String += 7;
		} else if (!strncmp(UTF8String, "https://", 8)) {
			_scheme = @"https";
			UTF8String += 8;
		} else
			@throw [OFInvalidFormatException
			    exceptionWithClass: [self class]];

		if ((tmp = strchr(UTF8String, '/')) != NULL) {
			*tmp = '\0';
			tmp++;
		}

		if ((tmp2 = strchr(UTF8String, '@')) != NULL) {







|
|















|
<







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

82
83
84
85
86
87
88
	self = [super init];

	@try {
		char *tmp, *tmp2;

		if ((UTF8String2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     exceptionWithRequestedSize: [string
							     UTF8StringLength]];

		UTF8String = UTF8String2;

		if (!strncmp(UTF8String, "file://", 7)) {
			_scheme = @"file";
			_path = [[OFString alloc]
			    initWithUTF8String: UTF8String + 7];
			return self;
		} else if (!strncmp(UTF8String, "http://", 7)) {
			_scheme = @"http";
			UTF8String += 7;
		} else if (!strncmp(UTF8String, "https://", 8)) {
			_scheme = @"https";
			UTF8String += 8;
		} else
			@throw [OFInvalidFormatException exception];


		if ((tmp = strchr(UTF8String, '/')) != NULL) {
			*tmp = '\0';
			tmp++;
		}

		if ((tmp2 = strchr(UTF8String, '@')) != NULL) {
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
			_host = [[OFString alloc]
			    initWithUTF8String: UTF8String];

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

			if ([portString decimalValue] > 65535)
				@throw [OFInvalidFormatException
				    exceptionWithClass: [self class]];

			_port = [portString decimalValue];

			if (_port == 0)
				_port = 80;

			objc_autoreleasePoolPop(pool);







|
<







116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
			_host = [[OFString alloc]
			    initWithUTF8String: UTF8String];

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

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


			_port = [portString decimalValue];

			if (_port == 0)
				_port = 80;

			objc_autoreleasePoolPop(pool);
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
		_host = [URL->_host copy];
		_port = URL->_port;
		_user = [URL->_user copy];
		_password = [URL->_password copy];

		if ((UTF8String2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     exceptionWithClass: [self class]
				  requestedSize: [string UTF8StringLength]];

		UTF8String = UTF8String2;

		if ((tmp = strchr(UTF8String, '#')) != NULL) {
			*tmp = '\0';
			_fragment = [[OFString alloc]
			    initWithUTF8String: tmp + 1];







|
|







193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
		_host = [URL->_host copy];
		_port = URL->_port;
		_user = [URL->_user copy];
		_password = [URL->_password copy];

		if ((UTF8String2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     exceptionWithRequestedSize:
			     [string UTF8StringLength]];

		UTF8String = UTF8String2;

		if ((tmp = strchr(UTF8String, '#')) != NULL) {
			*tmp = '\0';
			_fragment = [[OFString alloc]
			    initWithUTF8String: tmp + 1];
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
- initWithSerialization: (OFXMLElement*)element
{
	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		self = [self initWithString: [element stringValue]];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;







|
<
<







254
255
256
257
258
259
260
261


262
263
264
265
266
267
268
- initWithSerialization: (OFXMLElement*)element
{
	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		self = [self initWithString: [element stringValue]];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
{
	OF_GETTER(_scheme, true)
}

- (void)setScheme: (OFString*)scheme
{
	if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	OF_SETTER(_scheme, scheme, true, 1)
}

- (OFString*)host
{
	OF_GETTER(_host, true)







|
<
<







368
369
370
371
372
373
374
375


376
377
378
379
380
381
382
{
	OF_GETTER(_scheme, true)
}

- (void)setScheme: (OFString*)scheme
{
	if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"])
		@throw [OFInvalidArgumentException exception];



	OF_SETTER(_scheme, scheme, true, 1)
}

- (OFString*)host
{
	OF_GETTER(_host, true)
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
	OF_GETTER(_path, true)
}

- (void)setPath: (OFString*)path
{
	if (([_scheme isEqual: @"http"] || [_scheme isEqual: @"https"]) &&
	    ![path hasPrefix: @"/"])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	OF_SETTER(_path, path, true, 1)
}

- (OFString*)parameters
{
	OF_GETTER(_parameters, true)







|
<
<







422
423
424
425
426
427
428
429


430
431
432
433
434
435
436
	OF_GETTER(_path, true)
}

- (void)setPath: (OFString*)path
{
	if (([_scheme isEqual: @"http"] || [_scheme isEqual: @"https"]) &&
	    ![path hasPrefix: @"/"])
		@throw [OFInvalidArgumentException exception];



	OF_SETTER(_path, path, true, 1)
}

- (OFString*)parameters
{
	OF_GETTER(_parameters, true)

Modified src/OFXMLAttribute.m from [7c243af737] to [476d95eb23].

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		_name = [[[element attributeForName: @"name"]
		    stringValue] copy];
		_namespace = [[[element attributeForName: @"namespace"]
		    stringValue] copy];
		_stringValue = [[[element attributeForName: @"stringValue"]
		    stringValue] copy];







|
<
<







74
75
76
77
78
79
80
81


82
83
84
85
86
87
88
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		_name = [[[element attributeForName: @"name"]
		    stringValue] copy];
		_namespace = [[[element attributeForName: @"namespace"]
		    stringValue] copy];
		_stringValue = [[[element attributeForName: @"stringValue"]
		    stringValue] copy];

Modified src/OFXMLCDATA.m from [6d4e644cb2] to [364dfac913].

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		_CDATA = [[element stringValue] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;







|
<
<







49
50
51
52
53
54
55
56


57
58
59
60
61
62
63
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		_CDATA = [[element stringValue] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;

Modified src/OFXMLCharacters.m from [046d0816e6] to [34ed4f268b].

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		_characters = [[element stringValue] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;







|
<
<







49
50
51
52
53
54
55
56


57
58
59
60
61
62
63
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		_characters = [[element stringValue] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;

Modified src/OFXMLComment.m from [8300178d58] to [345af0db6d].

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		_comment = [[element stringValue] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;







|
<
<







51
52
53
54
55
56
57
58


59
60
61
62
63
64
65
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		_comment = [[element stringValue] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;

Modified src/OFXMLElement+Serialization.m from [4b7b970c65] to [6b31560ec3].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
	void *pool = objc_autoreleasePoolPush();
	Class class;
	id object;

	if ((class = objc_getClass([_name cStringWithEncoding:
	    OF_STRING_ENCODING_ASCII])) == Nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	if (![class conformsToProtocol: @protocol(OFSerialization)])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	object = [[class alloc] initWithSerialization: self];

	objc_autoreleasePoolPop(pool);

	return [object autorelease];
}
@end







|
<


|
<








33
34
35
36
37
38
39
40

41
42
43

44
45
46
47
48
49
50
51
{
	void *pool = objc_autoreleasePoolPush();
	Class class;
	id object;

	if ((class = objc_getClass([_name cStringWithEncoding:
	    OF_STRING_ENCODING_ASCII])) == Nil)
		@throw [OFInvalidArgumentException exception];


	if (![class conformsToProtocol: @protocol(OFSerialization)])
		@throw [OFInvalidArgumentException exception];


	object = [[class alloc] initWithSerialization: self];

	objc_autoreleasePoolPop(pool);

	return [object autorelease];
}
@end

Modified src/OFXMLElement.m from [5660c1a7c6] to [29fe39b5ac].

163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
     namespace: (OFString*)namespace
   stringValue: (OFString*)stringValue
{
	self = [super init];

	@try {
		if (name == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		_name = [name copy];
		_namespace = [namespace copy];

		_namespaces = [[OFMutableDictionary alloc]
		    initWithKeysAndObjects:
		    @"http://www.w3.org/XML/1998/namespace", @"xml",







|
<
<







163
164
165
166
167
168
169
170


171
172
173
174
175
176
177
     namespace: (OFString*)namespace
   stringValue: (OFString*)stringValue
{
	self = [super init];

	@try {
		if (name == nil)
			@throw [OFInvalidArgumentException exception];



		_name = [name copy];
		_namespace = [namespace copy];

		_namespaces = [[OFMutableDictionary alloc]
		    initWithKeysAndObjects:
		    @"http://www.w3.org/XML/1998/namespace", @"xml",
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207

- initWithElement: (OFXMLElement*)element
{
	self = [super init];

	@try {
		if (element == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		_name = [element->_name copy];
		_namespace = [element->_namespace copy];
		_defaultNamespace = [element->_defaultNamespace copy];
		_attributes = [element->_attributes mutableCopy];
		_namespaces = [element->_namespaces mutableCopy];
		_children = [element->_children mutableCopy];







|
<
<







189
190
191
192
193
194
195
196


197
198
199
200
201
202
203

- initWithElement: (OFXMLElement*)element
{
	self = [super init];

	@try {
		if (element == nil)
			@throw [OFInvalidArgumentException exception];



		_name = [element->_name copy];
		_namespace = [element->_namespace copy];
		_defaultNamespace = [element->_defaultNamespace copy];
		_attributes = [element->_attributes mutableCopy];
		_namespaces = [element->_namespaces mutableCopy];
		_children = [element->_children mutableCopy];
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
	OFXMLElement_OFXMLElementBuilderDelegate *delegate;
	Class c;

	c = [self class];
	[self release];

	if (string == nil)
		@throw [OFInvalidArgumentException exceptionWithClass: c
							     selector: _cmd];

	pool = objc_autoreleasePoolPush();

	parser = [OFXMLParser parser];
	builder = [OFXMLElementBuilder elementBuilder];
	delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
	    autorelease];

	[parser setDelegate: builder];
	[builder setDelegate: delegate];

	[parser parseString: string];

	if (![parser finishedParsing])
		@throw [OFMalformedXMLException exceptionWithClass: c
							    parser: parser];

	self = [delegate->_element retain];

	objc_autoreleasePoolPop(pool);

	return self;
}







|
<














|
<







217
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
	OFXMLElement_OFXMLElementBuilderDelegate *delegate;
	Class c;

	c = [self class];
	[self release];

	if (string == nil)
		@throw [OFInvalidArgumentException exception];


	pool = objc_autoreleasePoolPush();

	parser = [OFXMLParser parser];
	builder = [OFXMLElementBuilder elementBuilder];
	delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
	    autorelease];

	[parser setDelegate: builder];
	[builder setDelegate: delegate];

	[parser parseString: string];

	if (![parser finishedParsing])
		@throw [OFMalformedXMLException exceptionWithParser: parser];


	self = [delegate->_element retain];

	objc_autoreleasePoolPop(pool);

	return self;
}
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286

	[parser setDelegate: builder];
	[builder setDelegate: delegate];

	[parser parseFile: path];

	if (![parser finishedParsing])
		@throw [OFMalformedXMLException exceptionWithClass: c
							    parser: parser];

	self = [delegate->_element retain];

	objc_autoreleasePoolPop(pool);

	return self;
}







|
<







265
266
267
268
269
270
271
272

273
274
275
276
277
278
279

	[parser setDelegate: builder];
	[builder setDelegate: delegate];

	[parser parseFile: path];

	if (![parser finishedParsing])
		@throw [OFMalformedXMLException exceptionWithParser: parser];


	self = [delegate->_element retain];

	objc_autoreleasePoolPop(pool);

	return self;
}
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
		OFXMLElement *attributesElement, *namespacesElement;
		OFXMLElement *childrenElement;
		OFEnumerator *keyEnumerator, *objectEnumerator;
		id key, object;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		_name = [[[element attributeForName: @"name"]
		    stringValue] copy];
		_namespace = [[[element attributeForName: @"namespace"]
		    stringValue] copy];
		_defaultNamespace = [[[element attributeForName:
		    @"defaultNamespace"] stringValue] copy];







|
<
<







287
288
289
290
291
292
293
294


295
296
297
298
299
300
301
		OFXMLElement *attributesElement, *namespacesElement;
		OFXMLElement *childrenElement;
		OFEnumerator *keyEnumerator, *objectEnumerator;
		id key, object;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		_name = [[[element attributeForName: @"name"]
		    stringValue] copy];
		_namespace = [[[element attributeForName: @"namespace"]
		    stringValue] copy];
		_defaultNamespace = [[[element attributeForName:
		    @"defaultNamespace"] stringValue] copy];
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

		/* Sanity checks */
		if ((_attributes != nil && ![_attributes isKindOfClass:
		    [OFMutableArray class]]) || (_namespaces != nil &&
		    ![_namespaces isKindOfClass:
		    [OFMutableDictionary class]]) || (_children != nil &&
		    ![_children isKindOfClass: [OFMutableArray class]]))
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		objectEnumerator = [_attributes objectEnumerator];
		while ((object = [objectEnumerator nextObject]) != nil)
			if (![object isKindOfClass: [OFXMLAttribute class]])
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]
					      selector: _cmd];

		keyEnumerator = [_namespaces keyEnumerator];
		objectEnumerator = [_namespaces objectEnumerator];
		while ((key = [keyEnumerator nextObject]) != nil &&
		    (object = [objectEnumerator nextObject]) != nil)
			if (![key isKindOfClass: [OFString class]] ||
			    ![object isKindOfClass: [OFString class]])
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]
					      selector: _cmd];

		objectEnumerator = [_children objectEnumerator];
		while ((object = [objectEnumerator nextObject]) != nil)
			if (![object isKindOfClass: [OFXMLNode class]])
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]
					      selector: _cmd];

		if (_namespaces == nil)
			_namespaces = [[OFMutableDictionary alloc] init];

		[_namespaces
		    setObject: @"xml"
		       forKey: @"http://www.w3.org/XML/1998/namespace"];
		[_namespaces setObject: @"xmlns"
				forKey: @"http://www.w3.org/2000/xmlns/"];

		if (_name == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}








|
<
<




|
<
<







|
<
<




|
<
<











|
<
<







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

		/* Sanity checks */
		if ((_attributes != nil && ![_attributes isKindOfClass:
		    [OFMutableArray class]]) || (_namespaces != nil &&
		    ![_namespaces isKindOfClass:
		    [OFMutableDictionary class]]) || (_children != nil &&
		    ![_children isKindOfClass: [OFMutableArray class]]))
			@throw [OFInvalidArgumentException exception];



		objectEnumerator = [_attributes objectEnumerator];
		while ((object = [objectEnumerator nextObject]) != nil)
			if (![object isKindOfClass: [OFXMLAttribute class]])
				@throw [OFInvalidArgumentException exception];



		keyEnumerator = [_namespaces keyEnumerator];
		objectEnumerator = [_namespaces objectEnumerator];
		while ((key = [keyEnumerator nextObject]) != nil &&
		    (object = [objectEnumerator nextObject]) != nil)
			if (![key isKindOfClass: [OFString class]] ||
			    ![object isKindOfClass: [OFString class]])
				@throw [OFInvalidArgumentException exception];



		objectEnumerator = [_children objectEnumerator];
		while ((object = [objectEnumerator nextObject]) != nil)
			if (![object isKindOfClass: [OFXMLNode class]])
				@throw [OFInvalidArgumentException exception];



		if (_namespaces == nil)
			_namespaces = [[OFMutableDictionary alloc] init];

		[_namespaces
		    setObject: @"xml"
		       forKey: @"http://www.w3.org/XML/1998/namespace"];
		[_namespaces setObject: @"xmlns"
				forKey: @"http://www.w3.org/2000/xmlns/"];

		if (_name == nil)
			@throw [OFInvalidArgumentException exception];



		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}

397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413

	[super dealloc];
}

- (void)setName: (OFString*)name
{
	if (name == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	OF_SETTER(_name, name, true, 1)
}

- (OFString*)name
{
	OF_GETTER(_name, true)







|
<
<







378
379
380
381
382
383
384
385


386
387
388
389
390
391
392

	[super dealloc];
}

- (void)setName: (OFString*)name
{
	if (name == nil)
		@throw [OFInvalidArgumentException exception];



	OF_SETTER(_name, name, true, 1)
}

- (OFString*)name
{
	OF_GETTER(_name, true)
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
		OFString *tmp =
		    [[attributesObjects[j] stringValue] stringByXMLEscaping];

		if ([attributesObjects[j] namespace] != nil &&
		    (attributePrefix = [allNamespaces objectForKey:
		    [attributesObjects[j] namespace]]) == nil)
			@throw [OFUnboundNamespaceException
			    exceptionWithClass: [self class]
				     namespace: [attributesObjects[j]
						    namespace]
				       element: self];

		length += [attributeName UTF8StringLength] +
		    (attributePrefix != nil ?
		    [attributePrefix UTF8StringLength] + 1 : 0) +
		    [tmp UTF8StringLength] + 4;







<
|







560
561
562
563
564
565
566

567
568
569
570
571
572
573
574
		OFString *tmp =
		    [[attributesObjects[j] stringValue] stringByXMLEscaping];

		if ([attributesObjects[j] namespace] != nil &&
		    (attributePrefix = [allNamespaces objectForKey:
		    [attributesObjects[j] namespace]]) == nil)
			@throw [OFUnboundNamespaceException

			    exceptionWithNamespace: [attributesObjects[j]
						    namespace]
				       element: self];

		length += [attributeName UTF8StringLength] +
		    (attributePrefix != nil ?
		    [attributePrefix UTF8StringLength] + 1 : 0) +
		    [tmp UTF8StringLength] + 4;
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
	}
}

- (void)setPrefix: (OFString*)prefix
     forNamespace: (OFString*)namespace
{
	if ([prefix length] == 0)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	if (namespace == nil)
		namespace = @"";

	[_namespaces setObject: prefix
			forKey: namespace];
}








|
<
<







897
898
899
900
901
902
903
904


905
906
907
908
909
910
911
	}
}

- (void)setPrefix: (OFString*)prefix
     forNamespace: (OFString*)namespace
{
	if ([prefix length] == 0)
		@throw [OFInvalidArgumentException exception];


	if (namespace == nil)
		namespace = @"";

	[_namespaces setObject: prefix
			forKey: namespace];
}

952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
{
	OF_SETTER(_defaultNamespace, defaultNamespace, true, 1)
}

- (void)addChild: (OFXMLNode*)child
{
	if ([child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	if (_children == nil)
		_children = [[OFMutableArray alloc] init];

	[_children addObject: child];
}

- (void)insertChild: (OFXMLNode*)child
	    atIndex: (size_t)index
{
	if ([child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	if (_children == nil)
		_children = [[OFMutableArray alloc] init];

	[_children insertObject: child
			atIndex: index];
}

- (void)insertChildren: (OFArray*)children
	       atIndex: (size_t)index
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [children objectEnumerator];
	OFXMLNode *node;

	while ((node = [enumerator nextObject]) != nil)
		if ([node isKindOfClass: [OFXMLAttribute class]])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

	[_children insertObjectsFromArray: children
				  atIndex: index];

	objc_autoreleasePoolPop(pool);
}

- (void)removeChild: (OFXMLNode*)child
{
	if ([child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	[_children removeObject: child];
}

- (void)removeChildAtIndex: (size_t)index
{
	[_children removeObjectAtIndex: index];
}

- (void)replaceChild: (OFXMLNode*)child
	    withNode: (OFXMLNode*)node
{
	if ([node isKindOfClass: [OFXMLAttribute class]] ||
	    [child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	[_children replaceObject: child
		      withObject: node];
}

- (void)replaceChildAtIndex: (size_t)index
		   withNode: (OFXMLNode*)node
{
	if ([node isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	[_children replaceObjectAtIndex: index
			     withObject: node];
}

- (OFXMLElement*)elementForName: (OFString*)elementName
{







|
<
<











|
<
<

















|
<
<










|
<
<














|
<
<









|
<
<







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
957
958
959
960
961
962
963
964
965


966
967
968
969
970
971
972
973
974
975
976


977
978
979
980
981
982
983
984
985
986
987
988
989
990
991


992
993
994
995
996
997
998
999
1000
1001


1002
1003
1004
1005
1006
1007
1008
{
	OF_SETTER(_defaultNamespace, defaultNamespace, true, 1)
}

- (void)addChild: (OFXMLNode*)child
{
	if ([child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException exception];



	if (_children == nil)
		_children = [[OFMutableArray alloc] init];

	[_children addObject: child];
}

- (void)insertChild: (OFXMLNode*)child
	    atIndex: (size_t)index
{
	if ([child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException exception];



	if (_children == nil)
		_children = [[OFMutableArray alloc] init];

	[_children insertObject: child
			atIndex: index];
}

- (void)insertChildren: (OFArray*)children
	       atIndex: (size_t)index
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [children objectEnumerator];
	OFXMLNode *node;

	while ((node = [enumerator nextObject]) != nil)
		if ([node isKindOfClass: [OFXMLAttribute class]])
			@throw [OFInvalidArgumentException exception];



	[_children insertObjectsFromArray: children
				  atIndex: index];

	objc_autoreleasePoolPop(pool);
}

- (void)removeChild: (OFXMLNode*)child
{
	if ([child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException exception];



	[_children removeObject: child];
}

- (void)removeChildAtIndex: (size_t)index
{
	[_children removeObjectAtIndex: index];
}

- (void)replaceChild: (OFXMLNode*)child
	    withNode: (OFXMLNode*)node
{
	if ([node isKindOfClass: [OFXMLAttribute class]] ||
	    [child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException exception];



	[_children replaceObject: child
		      withObject: node];
}

- (void)replaceChildAtIndex: (size_t)index
		   withNode: (OFXMLNode*)node
{
	if ([node isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException exception];



	[_children replaceObjectAtIndex: index
			     withObject: node];
}

- (OFXMLElement*)elementForName: (OFString*)elementName
{

Modified src/OFXMLElementBuilder.m from [13da6c9002] to [c7b5dfc686].

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
		if ([_delegate respondsToSelector: @selector(elementBuilder:
		    didNotExpectCloseTag:prefix:namespace:)])
			[_delegate elementBuilder: self
			     didNotExpectCloseTag: name
					   prefix: prefix
					namespace: namespace];
		else
			@throw [OFMalformedXMLException
			    exceptionWithClass: [self class]];

		return;
	case 1:
		[_delegate elementBuilder: self
			  didBuildElement: [_stack firstObject]];
		break;
	}







|
<







125
126
127
128
129
130
131
132

133
134
135
136
137
138
139
		if ([_delegate respondsToSelector: @selector(elementBuilder:
		    didNotExpectCloseTag:prefix:namespace:)])
			[_delegate elementBuilder: self
			     didNotExpectCloseTag: name
					   prefix: prefix
					namespace: namespace];
		else
			@throw [OFMalformedXMLException exception];


		return;
	case 1:
		[_delegate elementBuilder: self
			  didBuildElement: [_stack firstObject]];
		break;
	}

Modified src/OFXMLParser.m from [12e7c5b831] to [c5cbe08edf].

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
	if (attributePrefix == nil)
		return;

	attributeNS = namespace_for_prefix(attributePrefix, namespaces);

	if ((attributePrefix != nil && attributeNS == nil))
		@throw [OFUnboundPrefixException
		    exceptionWithClass: [self class]
				prefix: attributePrefix
				parser: self];

	[attribute->_namespace release];
	attribute->_namespace = [attributeNS retain];
}

@implementation OFXMLParser







<
|







123
124
125
126
127
128
129

130
131
132
133
134
135
136
137
	if (attributePrefix == nil)
		return;

	attributeNS = namespace_for_prefix(attributePrefix, namespaces);

	if ((attributePrefix != nil && attributeNS == nil))
		@throw [OFUnboundPrefixException

		    exceptionWithPrefix: attributePrefix
				parser: self];

	[attribute->_namespace release];
	attribute->_namespace = [attributeNS retain];
}

@implementation OFXMLParser
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
	if (_data[_i] != "\xEF\xBB\xBF"[_level]) {
		if (_level == 0) {
			_state = OF_XMLPARSER_OUTSIDE_TAG;
			_i--;
			return;
		}

		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];
	}

	if (_level++ == 2)
		_state = OF_XMLPARSER_OUTSIDE_TAG;

	_last = _i + 1;
}

/* Not in a tag */
- (void)OF_outsideTagState
{
	size_t length;

	if ((_finishedParsing || [_previous count] < 1) && _data[_i] != ' ' &&
	    _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r' &&
	    _data[_i] != '<')
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];

	if (_data[_i] != '<')
		return;

	if ((length = _i - _last) > 0)
		buffer_append(_buffer, _data + _last, _encoding, length);








|
<
















|
<







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
	if (_data[_i] != "\xEF\xBB\xBF"[_level]) {
		if (_level == 0) {
			_state = OF_XMLPARSER_OUTSIDE_TAG;
			_i--;
			return;
		}

		@throw [OFMalformedXMLException exceptionWithParser: self];

	}

	if (_level++ == 2)
		_state = OF_XMLPARSER_OUTSIDE_TAG;

	_last = _i + 1;
}

/* Not in a tag */
- (void)OF_outsideTagState
{
	size_t length;

	if ((_finishedParsing || [_previous count] < 1) && _data[_i] != ' ' &&
	    _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r' &&
	    _data[_i] != '<')
		@throw [OFMalformedXMLException exceptionWithParser: self];


	if (_data[_i] != '<')
		return;

	if ((length = _i - _last) > 0)
		buffer_append(_buffer, _data + _last, _encoding, length);

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
	_state = OF_XMLPARSER_TAG_OPENED;
}

/* Tag was just opened */
- (void)OF_tagOpenedState
{
	if (_finishedParsing && _data[_i] != '!' && _data[_i] != '?')
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];

	switch (_data[_i]) {
	case '?':
		_last = _i + 1;
		_state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS;
		_level = 0;
		break;
	case '/':
		_last = _i + 1;
		_state = OF_XMLPARSER_IN_CLOSE_TAG_NAME;
		_acceptProlog = false;
		break;
	case '!':
		_last = _i + 1;
		_state = OF_XMLPARSER_IN_EXCLAMATIONMARK;
		_acceptProlog = false;
		break;
	default:
		if (_depthLimit > 0 && [_previous count] >= _depthLimit)
			@throw [OFMalformedXMLException
			    exceptionWithClass: [self class]
					parser: self];

		_state = OF_XMLPARSER_IN_TAG_NAME;
		_acceptProlog = false;
		_i--;
		break;
	}
}







|
<




















<
|







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
	_state = OF_XMLPARSER_TAG_OPENED;
}

/* Tag was just opened */
- (void)OF_tagOpenedState
{
	if (_finishedParsing && _data[_i] != '!' && _data[_i] != '?')
		@throw [OFMalformedXMLException exceptionWithParser: self];


	switch (_data[_i]) {
	case '?':
		_last = _i + 1;
		_state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS;
		_level = 0;
		break;
	case '/':
		_last = _i + 1;
		_state = OF_XMLPARSER_IN_CLOSE_TAG_NAME;
		_acceptProlog = false;
		break;
	case '!':
		_last = _i + 1;
		_state = OF_XMLPARSER_IN_EXCLAMATIONMARK;
		_acceptProlog = false;
		break;
	default:
		if (_depthLimit > 0 && [_previous count] >= _depthLimit)
			@throw [OFMalformedXMLException

			    exceptionWithParser: self];

		_state = OF_XMLPARSER_IN_TAG_NAME;
		_acceptProlog = false;
		_i--;
		break;
	}
}
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
		PI = transform_string(_buffer, 1, false, nil);

		if ([PI isEqual: @"xml"] || [PI hasPrefix: @"xml "] ||
		    [PI hasPrefix: @"xml\t"] || [PI hasPrefix: @"xml\r"] ||
		    [PI hasPrefix: @"xml\n"])
			if (![self OF_parseXMLProcessingInstructions: PI])
				@throw [OFMalformedXMLException
				    exceptionWithClass: [self class]
						parser: self];

		if ([_delegate respondsToSelector:
		    @selector(parser:foundProcessingInstructions:)])
			[_delegate		 parser: self
			    foundProcessingInstructions: PI];

		objc_autoreleasePoolPop(pool);







<
|







515
516
517
518
519
520
521

522
523
524
525
526
527
528
529
		PI = transform_string(_buffer, 1, false, nil);

		if ([PI isEqual: @"xml"] || [PI hasPrefix: @"xml "] ||
		    [PI hasPrefix: @"xml\t"] || [PI hasPrefix: @"xml\r"] ||
		    [PI hasPrefix: @"xml\n"])
			if (![self OF_parseXMLProcessingInstructions: PI])
				@throw [OFMalformedXMLException

				    exceptionWithParser: self];

		if ([_delegate respondsToSelector:
		    @selector(parser:foundProcessingInstructions:)])
			[_delegate		 parser: self
			    foundProcessingInstructions: PI];

		objc_autoreleasePoolPop(pool);
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
	if (_data[_i] == '>' || _data[_i] == '/') {
		OFString *namespace;

		namespace = namespace_for_prefix(_prefix, _namespaces);

		if (_prefix != nil && namespace == nil)
			@throw [OFUnboundPrefixException
			    exceptionWithClass: [self class]
					prefix: _prefix
					parser: self];

		if ([_delegate respondsToSelector: @selector(parser:
		    didStartElement:prefix:namespace:attributes:)])
			[_delegate parser: self
			  didStartElement: _name
				   prefix: _prefix







<
|







574
575
576
577
578
579
580

581
582
583
584
585
586
587
588
	if (_data[_i] == '>' || _data[_i] == '/') {
		OFString *namespace;

		namespace = namespace_for_prefix(_prefix, _namespaces);

		if (_prefix != nil && namespace == nil)
			@throw [OFUnboundPrefixException

			    exceptionWithPrefix: _prefix
					parser: self];

		if ([_delegate respondsToSelector: @selector(parser:
		    didStartElement:prefix:namespace:attributes:)])
			[_delegate parser: self
			  didStartElement: _name
				   prefix: _prefix
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
				length: tmp - bufferCString];
	} else {
		_name = [bufferString copy];
		_prefix = nil;
	}

	if (![[_previous lastObject] isEqual: bufferString])
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];

	[_previous removeLastObject];

	[_buffer removeAllItems];

	namespace = namespace_for_prefix(_prefix, _namespaces);
	if (_prefix != nil && namespace == nil)
		@throw [OFUnboundPrefixException
		    exceptionWithClass: [self class]
				prefix: _prefix
				parser: self];

	if ([_delegate respondsToSelector:
	    @selector(parser:didEndElement:prefix:namespace:)])
		[_delegate parser: self
		    didEndElement: _name
			   prefix: _prefix







|
<







|
<
<







653
654
655
656
657
658
659
660

661
662
663
664
665
666
667
668


669
670
671
672
673
674
675
				length: tmp - bufferCString];
	} else {
		_name = [bufferString copy];
		_prefix = nil;
	}

	if (![[_previous lastObject] isEqual: bufferString])
		@throw [OFMalformedXMLException exceptionWithParser: self];


	[_previous removeLastObject];

	[_buffer removeAllItems];

	namespace = namespace_for_prefix(_prefix, _namespaces);
	if (_prefix != nil && namespace == nil)
		@throw [OFUnboundPrefixException exceptionWithPrefix: _prefix


				parser: self];

	if ([_delegate respondsToSelector:
	    @selector(parser:didEndElement:prefix:namespace:)])
		[_delegate parser: self
		    didEndElement: _name
			   prefix: _prefix
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738

	attributesObjects = [_attributes objects];
	attributesCount = [_attributes count];

	namespace = namespace_for_prefix(_prefix, _namespaces);

	if (_prefix != nil && namespace == nil)
		@throw [OFUnboundPrefixException
		    exceptionWithClass: [self class]
				prefix: _prefix
				parser: self];

	for (j = 0; j < attributesCount; j++)
		resolve_attribute_namespace(attributesObjects[j], _namespaces,
		    self);

	pool = objc_autoreleasePoolPush();







|
<
<







712
713
714
715
716
717
718
719


720
721
722
723
724
725
726

	attributesObjects = [_attributes objects];
	attributesCount = [_attributes count];

	namespace = namespace_for_prefix(_prefix, _namespaces);

	if (_prefix != nil && namespace == nil)
		@throw [OFUnboundPrefixException exceptionWithPrefix: _prefix


				parser: self];

	for (j = 0; j < attributesCount; j++)
		resolve_attribute_namespace(attributesObjects[j], _namespaces,
		    self);

	pool = objc_autoreleasePoolPush();
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
	_last = _i + 1;

	if (_data[_i] == ' ' || _data[_i] == '\t' || _data[_i] == '\n' ||
	    _data[_i] == '\r')
		return;

	if (_data[_i] != '\'' && _data[_i] != '"')
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];

	_delimiter = _data[_i];
	_state = OF_XMLPARSER_IN_ATTR_VALUE;
}

/* Looking for attribute value */
- (void)OF_inAttributeValueState







|
<







817
818
819
820
821
822
823
824

825
826
827
828
829
830
831
	_last = _i + 1;

	if (_data[_i] == ' ' || _data[_i] == '\t' || _data[_i] == '\n' ||
	    _data[_i] == '\r')
		return;

	if (_data[_i] != '\'' && _data[_i] != '"')
		@throw [OFMalformedXMLException exceptionWithParser: self];


	_delimiter = _data[_i];
	_state = OF_XMLPARSER_IN_ATTR_VALUE;
}

/* Looking for attribute value */
- (void)OF_inAttributeValueState
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
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
/* Expecting closing '>' */
- (void)OF_expectCloseState
{
	if (_data[_i] == '>') {
		_last = _i + 1;
		_state = OF_XMLPARSER_OUTSIDE_TAG;
	} else
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];
}

/* Expecting closing '>' or space */
- (void)OF_expectSpaceOrCloseState
{
	if (_data[_i] == '>') {
		_last = _i + 1;
		_state = OF_XMLPARSER_OUTSIDE_TAG;
	} else if (_data[_i] != ' ' && _data[_i] != '\t' &&
	    _data[_i] != '\n' && _data[_i] != '\r')
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];
}

/* In <! */
- (void)OF_inExclamationMarkState
{
	if (_finishedParsing && _data[_i] != '-')
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];

	if (_data[_i] == '-')
		_state = OF_XMLPARSER_IN_COMMENT_OPENING;
	else if (_data[_i] == '[') {
		_state = OF_XMLPARSER_IN_CDATA_OPENING;
		_level = 0;
	} else if (_data[_i] == 'D') {
		_state = OF_XMLPARSER_IN_DOCTYPE;
		_level = 0;
	} else
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];

	_last = _i + 1;
}

/* CDATA */
- (void)OF_inCDATAOpeningState
{
	if (_data[_i] != "CDATA["[_level])
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];

	if (++_level == 6) {
		_state = OF_XMLPARSER_IN_CDATA_1;
		_level = 0;
	}

	_last = _i + 1;







|
<










|
<






|
<










|
<








|
<







869
870
871
872
873
874
875
876

877
878
879
880
881
882
883
884
885
886
887

888
889
890
891
892
893
894

895
896
897
898
899
900
901
902
903
904
905

906
907
908
909
910
911
912
913
914

915
916
917
918
919
920
921
/* Expecting closing '>' */
- (void)OF_expectCloseState
{
	if (_data[_i] == '>') {
		_last = _i + 1;
		_state = OF_XMLPARSER_OUTSIDE_TAG;
	} else
		@throw [OFMalformedXMLException exceptionWithParser: self];

}

/* Expecting closing '>' or space */
- (void)OF_expectSpaceOrCloseState
{
	if (_data[_i] == '>') {
		_last = _i + 1;
		_state = OF_XMLPARSER_OUTSIDE_TAG;
	} else if (_data[_i] != ' ' && _data[_i] != '\t' &&
	    _data[_i] != '\n' && _data[_i] != '\r')
		@throw [OFMalformedXMLException exceptionWithParser: self];

}

/* In <! */
- (void)OF_inExclamationMarkState
{
	if (_finishedParsing && _data[_i] != '-')
		@throw [OFMalformedXMLException exceptionWithParser: self];


	if (_data[_i] == '-')
		_state = OF_XMLPARSER_IN_COMMENT_OPENING;
	else if (_data[_i] == '[') {
		_state = OF_XMLPARSER_IN_CDATA_OPENING;
		_level = 0;
	} else if (_data[_i] == 'D') {
		_state = OF_XMLPARSER_IN_DOCTYPE;
		_level = 0;
	} else
		@throw [OFMalformedXMLException exceptionWithParser: self];


	_last = _i + 1;
}

/* CDATA */
- (void)OF_inCDATAOpeningState
{
	if (_data[_i] != "CDATA["[_level])
		@throw [OFMalformedXMLException exceptionWithParser: self];


	if (++_level == 6) {
		_state = OF_XMLPARSER_IN_CDATA_1;
		_level = 0;
	}

	_last = _i + 1;
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
	_state = OF_XMLPARSER_OUTSIDE_TAG;
}

/* Comment */
- (void)OF_inCommentOpeningState
{
	if (_data[_i] != '-')
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];

	_last = _i + 1;
	_state = OF_XMLPARSER_IN_COMMENT_1;
	_level = 0;
}

- (void)OF_inCommentState1







|
<







961
962
963
964
965
966
967
968

969
970
971
972
973
974
975
	_state = OF_XMLPARSER_OUTSIDE_TAG;
}

/* Comment */
- (void)OF_inCommentOpeningState
{
	if (_data[_i] != '-')
		@throw [OFMalformedXMLException exceptionWithParser: self];


	_last = _i + 1;
	_state = OF_XMLPARSER_IN_COMMENT_1;
	_level = 0;
}

- (void)OF_inCommentState1
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019

- (void)OF_inCommentState2
{
	void *pool;
	OFString *comment;

	if (_data[_i] != '>')
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];

	pool = objc_autoreleasePoolPush();

	buffer_append(_buffer, _data + _last, _encoding, _i - _last);
	comment = transform_string(_buffer, 2, false, nil);

	if ([_delegate respondsToSelector: @selector(parser:foundComment:)])







|
<







985
986
987
988
989
990
991
992

993
994
995
996
997
998
999

- (void)OF_inCommentState2
{
	void *pool;
	OFString *comment;

	if (_data[_i] != '>')
		@throw [OFMalformedXMLException exceptionWithParser: self];


	pool = objc_autoreleasePoolPush();

	buffer_append(_buffer, _data + _last, _encoding, _i - _last);
	comment = transform_string(_buffer, 2, false, nil);

	if ([_delegate respondsToSelector: @selector(parser:foundComment:)])
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045

/* In <!DOCTYPE ...> */
- (void)OF_inDOCTYPEState
{
	if ((_level < 6 && _data[_i] != "OCTYPE"[_level]) ||
	    (_level == 6 && _data[_i] != ' ' && _data[_i] != '\t' &&
	    _data[_i] != '\n' && _data[_i] != '\r'))
		@throw [OFMalformedXMLException exceptionWithClass: [self class]
							    parser: self];

	_level++;

	if (_level > 6 && _data[_i] == '>')
		_state = OF_XMLPARSER_OUTSIDE_TAG;

	_last = _i + 1;







|
<







1010
1011
1012
1013
1014
1015
1016
1017

1018
1019
1020
1021
1022
1023
1024

/* In <!DOCTYPE ...> */
- (void)OF_inDOCTYPEState
{
	if ((_level < 6 && _data[_i] != "OCTYPE"[_level]) ||
	    (_level == 6 && _data[_i] != ' ' && _data[_i] != '\t' &&
	    _data[_i] != '\n' && _data[_i] != '\r'))
		@throw [OFMalformedXMLException exceptionWithParser: self];


	_level++;

	if (_level > 6 && _data[_i] == '>')
		_state = OF_XMLPARSER_OUTSIDE_TAG;

	_last = _i + 1;

Modified src/OFXMLProcessingInstructions.m from [36610c4045] to [bd61df5cc4].

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		_processingInstructions = [[element stringValue] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;







|
<
<







51
52
53
54
55
56
57
58


59
60
61
62
63
64
65
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];



		_processingInstructions = [[element stringValue] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;

Modified src/bridge/NSArray_OFArray.m from [fcfeb7640b] to [59dab118dc].

45
46
47
48
49
50
51
52
53
54
55
56
}

- (NSUInteger)count
{
	size_t count = [_array count];

	if (count > NSUIntegerMax)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	return (NSUInteger)count;
}
@end







|




45
46
47
48
49
50
51
52
53
54
55
56
}

- (NSUInteger)count
{
	size_t count = [_array count];

	if (count > NSUIntegerMax)
		@throw [OFOutOfRangeException exception];

	return (NSUInteger)count;
}
@end

Modified src/bridge/NSDictionary_OFDictionary.m from [5fb2d6b00a] to [d7e3af47a2].

52
53
54
55
56
57
58
59
60
61
62
63
}

- (NSUInteger)count
{
	size_t count = [_dictionary count];

	if (count > NSUIntegerMax)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	return (NSUInteger)count;
}
@end







|




52
53
54
55
56
57
58
59
60
61
62
63
}

- (NSUInteger)count
{
	size_t count = [_dictionary count];

	if (count > NSUIntegerMax)
		@throw [OFOutOfRangeException exception];

	return (NSUInteger)count;
}
@end

Modified src/bridge/OFArray_NSArray.m from [0b7f7cf63f] to [ede4fb38a1].

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
}

- (id)objectAtIndex: (size_t)index
{
	id object;

	if (index > NSUIntegerMax)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	object = [_array objectAtIndex: index];

	if ([(NSObject*)object conformsToProtocol: @protocol(NSBridging)])
		return [object OFObject];

	return object;







|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
}

- (id)objectAtIndex: (size_t)index
{
	id object;

	if (index > NSUIntegerMax)
		@throw [OFOutOfRangeException exception];

	object = [_array objectAtIndex: index];

	if ([(NSObject*)object conformsToProtocol: @protocol(NSBridging)])
		return [object OFObject];

	return object;

Modified src/exceptions/OFAcceptFailedException.h from [ede346dfd9] to [503d7340b3].

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@property (readonly, retain, nonatomic) OFTCPSocket *socket;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased accept failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which could not accept a connection
 * @return A new, autoreleased accept failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    socket: (OFTCPSocket*)socket;

/*!
 * @brief Initializes an already allocated accept failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which could not accept a connection
 * @return An initialized accept failed exception
 */
- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket;

/*!
 * @brief Returns the socket which could not accept a connection.
 *
 * @return The socket which could not accept a connection
 */
- (OFTCPSocket*)socket;







<



|
<




<



<
|







35
36
37
38
39
40
41

42
43
44
45

46
47
48
49

50
51
52

53
54
55
56
57
58
59
60
@property (readonly, retain, nonatomic) OFTCPSocket *socket;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased accept failed exception.
 *

 * @param socket The socket which could not accept a connection
 * @return A new, autoreleased accept failed exception
 */
+ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket;


/*!
 * @brief Initializes an already allocated accept failed exception.
 *

 * @param socket The socket which could not accept a connection
 * @return An initialized accept failed exception
 */

- initWithSocket: (OFTCPSocket*)socket;

/*!
 * @brief Returns the socket which could not accept a connection.
 *
 * @return The socket which could not accept a connection
 */
- (OFTCPSocket*)socket;

Modified src/exceptions/OFAcceptFailedException.m from [27f8f634eb] to [1d660443ac].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#import "OFAcceptFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFAcceptFailedException
+ (instancetype)exceptionWithClass: (Class)class
			    socket: (OFTCPSocket*)socket
{
	return [[[self alloc] initWithClass: class
				     socket: socket] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 socket: (OFTCPSocket*)socket
{
	self = [super initWithClass: class];

	_socket = [socket retain];
	_errNo = GET_SOCK_ERRNO;

	return self;
}

- (void)dealloc
{
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to accept connection in socket of type %@! " ERRFMT,
	    _inClass, ERRPARAM];
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}

- (int)errNo
{
	return _errNo;
}
@end







|
<

|
<


|











<
|

|

















|
|












21
22
23
24
25
26
27
28

29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#import "OFAcceptFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFAcceptFailedException
+ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket

{
	return [[[self alloc] initWithSocket: socket] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithSocket: (OFTCPSocket*)socket
{
	self = [super init];

	_socket = [socket retain];
	_errNo = GET_SOCK_ERRNO;

	return self;
}

- (void)dealloc
{
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to accept connection in socket of class %@! " ERRFMT,
	    [_socket class], ERRPARAM];
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}

- (int)errNo
{
	return _errNo;
}
@end

Modified src/exceptions/OFAddressTranslationFailedException.h from [1027254cc2] to [59a41d896a].

29
30
31
32
33
34
35
36
37

38
39
40
41
42
43
44
45







46

47
48
49
50
51







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78







79
80
81
82
83
84
85
{
	OFTCPSocket *_socket;
	OFString    *_host;
	int	    _errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFTCPSocket *socket;
@property (readonly, copy, nonatomic) OFString *host;

@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased address translation failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which could not translate the address







 * @param host The host for which translation was requested

 * @return A new, autoreleased address translation failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    socket: (OFTCPSocket*)socket
			      host: (OFString*)host;








/*!
 * @brief Initializes an already allocated address translation failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which could not translate the address
 * @param host The host for which translation was requested
 * @return An initialized address translation failed exception
 */
- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket
	   host: (OFString*)host;

/*!
 * @brief Returns the socket which could not translate the address.
 *
 * @return The socket which could not translate the address
 */
- (OFTCPSocket*)socket;

/*!
 * @brief Returns the host for which the address translation was requested.
 *
 * @return The host for which the address translation was requested
 */
- (OFString*)host;








/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end







<

>






<

>
>
>
>
>
>
>

>


|
|
|
>
>
>
>
>
>
>




|

<


<
<
|
<
<
<
<
<
<
|








>
>
>
>
>
>
>







29
30
31
32
33
34
35

36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

72
73


74






75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
	OFTCPSocket *_socket;
	OFString    *_host;
	int	    _errNo;
}

#ifdef OF_HAVE_PROPERTIES

@property (readonly, copy, nonatomic) OFString *host;
@property (readonly, retain, nonatomic) OFTCPSocket *socket;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased address translation failed exception.
 *

 * @param socket The socket which could not translate the address
 * @return A new, autoreleased address translation failed exception
 */
+ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket;

/*!
 * @brief Creates a new, autoreleased address translation failed exception.
 *
 * @param host The host for which translation was requested
 * @param socket The socket which could not translate the address
 * @return A new, autoreleased address translation failed exception
 */
+ (instancetype)exceptionWithHost: (OFString*)host
			   socket: (OFTCPSocket*)socket;

/*!
 * @brief Initializes an already allocated address translation failed exception.
 *
 * @param socket The socket which could not translate the address
 * @return An initialized address translation failed exception
 */
- initWithSocket: (OFTCPSocket*)socket;

/*!
 * @brief Initializes an already allocated address translation failed exception.
 *
 * @param host The host for which translation was requested
 * @param socket The socket which could not translate the address

 * @return An initialized address translation failed exception
 */


- initWithHost: (OFString*)host






	socket: (OFTCPSocket*)socket;

/*!
 * @brief Returns the host for which the address translation was requested.
 *
 * @return The host for which the address translation was requested
 */
- (OFString*)host;

/*!
 * @brief Returns the socket which could not translate the address.
 *
 * @return The socket which could not translate the address
 */
- (OFTCPSocket*)socket;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/exceptions/OFAddressTranslationFailedException.m from [2191f51302] to [d737be39ca].

19
20
21
22
23
24
25





26
27
28
29
30
31







32

33
34


35

36
37
38


39




40
41
42
43
44
45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

79
80

81
82





83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#import "OFAddressTranslationFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFAddressTranslationFailedException





+ (instancetype)exceptionWithClass: (Class)class
			    socket: (OFTCPSocket*)socket
			      host: (OFString*)host
{
	return [[[self alloc] initWithClass: class
				     socket: socket







				       host: host] autorelease];

}



- initWithClass: (Class)class

{
	self = [super initWithClass: class];



	_errNo = GET_AT_ERRNO;





	return self;
}

- initWithClass: (Class)class
	 socket: (OFTCPSocket*)socket
	   host: (OFString*)host
{
	self = [super initWithClass: class];

	@try {
		_socket = [socket retain];
		_host   = [host copy];

		_errNo  = GET_AT_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_socket release];
	[_host release];

	[super dealloc];
}

- (OFString*)description
{
	if (_host != nil)
		return [OFString stringWithFormat:
		    @"The host %@ could not be translated to an address in "
		    @"class %@. This means that either the host was not found, "
		    @"there was a problem with the name server, there was a "
		    @"problem with your network connection or you specified an "
		    @"invalid host. " ERRFMT, _host, _inClass, AT_ERRPARAM];

	else
		return [OFString stringWithFormat:

		    @"An address translation failed in class %@! " ERRFMT,
		    _inClass, AT_ERRPARAM];





}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}

- (OFString*)host
{
	OF_GETTER(_host, false)
}

- (int)errNo
{
	return _errNo;
}
@end







>
>
>
>
>
|

<

|
|
>
>
>
>
>
>
>
|
>


>
>
|
>

|

>
>

>
>
>
>




|

<

|


<

>











|
|








|
|
|
|
|
>


>
|
|
>
>
>
>
>







<
<
<
<
<





19
20
21
22
23
24
25
26
27
28
29
30
31
32

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

67
68
69
70

71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116





117
118
119
120
121
#import "OFAddressTranslationFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFAddressTranslationFailedException
+ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket
{
	return [[[self alloc] initWithSocket: socket] autorelease];
}

+ (instancetype)exceptionWithHost: (OFString*)host
			    socket: (OFTCPSocket*)socket

{
	return [[[self alloc] initWithHost: host
				    socket: socket] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
}

	abort();
}

- initWithSocket: (OFTCPSocket*)socket
{
	self = [super init];

	@try {
		_socket = [socket retain];
	_errNo = GET_AT_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithHost: (OFString*)host
	 socket: (OFTCPSocket*)socket

{
	self = [super init];

	@try {

		_host   = [host copy];
		_socket = [socket retain];
		_errNo  = GET_AT_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_host release];
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	if (_host != nil)
		return [OFString stringWithFormat:
		    @"The host %@ could not be translated to an address for a "
		    @"socket of type %@. This means that either the host was "
		    @"not found, there was a problem with the name server, "
		    @"there was a problem with your network connection or you "
		    @"specified an invalid host. " ERRFMT, _host,
		    [_socket class], AT_ERRPARAM];
	else
		return [OFString stringWithFormat:
		    @"An address could not be translated translation for a "
		    @"socket of type %@! " ERRFMT, [_socket class],
		    AT_ERRPARAM];
}

- (OFString*)host
{
	OF_GETTER(_host, false)
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}






- (int)errNo
{
	return _errNo;
}
@end

Modified src/exceptions/OFAlreadyConnectedException.h from [a1bbdc5954] to [04eb25813d].

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFTCPSocket *socket;
#endif

/*!
 * @brief Creates a new, autoreleased already connected exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which is already connected
 * @return A new, autoreleased already connected exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    socket: (OFTCPSocket*)socket;

/*!
 * @brief Initializes an already allocated already connected exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which is already connected
 * @return An initialized already connected exception
 */
- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket;

/*!
 * @brief Returns the socket which is already connected.
 *
 * @return The socket which is already connected
 */
- (OFTCPSocket*)socket;
@end







<



|
<




<



<
|








34
35
36
37
38
39
40

41
42
43
44

45
46
47
48

49
50
51

52
53
54
55
56
57
58
59
60
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFTCPSocket *socket;
#endif

/*!
 * @brief Creates a new, autoreleased already connected exception.
 *

 * @param socket The socket which is already connected
 * @return A new, autoreleased already connected exception
 */
+ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket;


/*!
 * @brief Initializes an already allocated already connected exception.
 *

 * @param socket The socket which is already connected
 * @return An initialized already connected exception
 */

- initWithSocket: (OFTCPSocket*)socket;

/*!
 * @brief Returns the socket which is already connected.
 *
 * @return The socket which is already connected
 */
- (OFTCPSocket*)socket;
@end

Modified src/exceptions/OFAlreadyConnectedException.m from [599e14bfbf] to [c3c77169a0].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#import "OFAlreadyConnectedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFAlreadyConnectedException
+ (instancetype)exceptionWithClass: (Class)class
			    socket: (OFTCPSocket*)socket
{
	return [[[self alloc] initWithClass: class
				     socket: socket] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 socket: (OFTCPSocket*)socket
{
	self = [super initWithClass: class];

	_socket = [socket retain];

	return self;
}

- (void)dealloc
{
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The socket of type %@ is already connected or bound and thus "
	    @"can't be connected or bound again!", _inClass];
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}
@end







|
<

|
<


|











<
|

|

















|







21
22
23
24
25
26
27
28

29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#import "OFAlreadyConnectedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFAlreadyConnectedException
+ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket

{
	return [[[self alloc] initWithSocket: socket] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithSocket: (OFTCPSocket*)socket
{
	self = [super init];

	_socket = [socket retain];

	return self;
}

- (void)dealloc
{
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The socket of type %@ is already connected or bound and thus "
	    @"can't be connected or bound again!", [_socket class]];
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}
@end

Modified src/exceptions/OFBindFailedException.h from [08e07c93e0] to [8e4f2bb116].

30
31
32
33
34
35
36
37
38
39

40
41
42
43
44
45
46
47
48
49

50
51
52
53
54
55

56
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91







92
93
94
95
96
97
98
	OFTCPSocket *_socket;
	OFString    *_host;
	uint16_t    _port;
	int	    _errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFTCPSocket *socket;
@property (readonly, copy, nonatomic) OFString *host;
@property (readonly) uint16_t port;

@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased bind failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which could not be bound
 * @param host The host on which binding failed
 * @param port The port on which binding failed

 * @return A new, autoreleased bind failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    socket: (OFTCPSocket*)socket
			      host: (OFString*)host
			      port: (uint16_t)port;


/*!
 * @brief Initializes an already allocated bind failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which could not be bound
 * @param host The host on which binding failed
 * @param port The port on which binding failed

 * @return An initialized bind failed exception
 */
- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket
	   host: (OFString*)host
	   port: (uint16_t)port;

/*!
 * @brief Returns the socket which could not be bound.
 *
 * @return The socket which could not be bound
 */
- (OFTCPSocket*)socket;

/*!
 * @brief Returns the host on which binding failed.
 *
 * @return The host on which binding failed
 */
- (OFString*)host;

/*!
 * @brief Return the port on which binding failed.
 *
 * @return The port on which binding failed
 */
- (uint16_t)port;








/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end







<


>






<
<


>


|
<
<
|
>




<
<


>


<
<
|
|
<
<
<
<
<
<
|















>
>
>
>
>
>
>







30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
45


46
47
48
49
50
51


52
53
54
55
56
57


58
59
60
61
62


63
64






65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
	OFTCPSocket *_socket;
	OFString    *_host;
	uint16_t    _port;
	int	    _errNo;
}

#ifdef OF_HAVE_PROPERTIES

@property (readonly, copy, nonatomic) OFString *host;
@property (readonly) uint16_t port;
@property (readonly, retain, nonatomic) OFTCPSocket *socket;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased bind failed exception.
 *


 * @param host The host on which binding failed
 * @param port The port on which binding failed
 * @param socket The socket which could not be bound
 * @return A new, autoreleased bind failed exception
 */
+ (instancetype)exceptionWithHost: (OFString*)host


			     port: (uint16_t)port
			   socket: (OFTCPSocket*)socket;

/*!
 * @brief Initializes an already allocated bind failed exception.
 *


 * @param host The host on which binding failed
 * @param port The port on which binding failed
 * @param socket The socket which could not be bound
 * @return An initialized bind failed exception
 */


- initWithHost: (OFString*)host
	  port: (uint16_t)port






	socket: (OFTCPSocket*)socket;

/*!
 * @brief Returns the host on which binding failed.
 *
 * @return The host on which binding failed
 */
- (OFString*)host;

/*!
 * @brief Return the port on which binding failed.
 *
 * @return The port on which binding failed
 */
- (uint16_t)port;

/*!
 * @brief Returns the socket which could not be bound.
 *
 * @return The socket which could not be bound
 */
- (OFTCPSocket*)socket;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/exceptions/OFBindFailedException.m from [857a2f6180] to [e9a7fb70cc].

21
22
23
24
25
26
27
28
29
30
31

32
33

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60
61

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99





100
101
102
103
104
105
#import "OFBindFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFBindFailedException
+ (instancetype)exceptionWithClass: (Class)class
			    socket: (OFTCPSocket*)socket
			      host: (OFString*)host
			      port: (uint16_t)port

{
	return [[[self alloc] initWithClass: class

				     socket: socket
				       host: host
				       port: port] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 socket: (OFTCPSocket*)socket
	   host: (OFString*)host
	   port: (uint16_t)port

{
	self = [super initWithClass: class];

	@try {
		_socket = [socket retain];
		_host   = [host copy];
		_port   = port;

		_errNo  = GET_SOCK_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_socket release];
	[_host release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Binding to port %" @PRIu16 @" on host %@ failed in class %@! "
	    ERRFMT, _port, _host, _inClass, ERRPARAM];
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}

- (OFString*)host
{
	OF_GETTER(_host, false)
}

- (uint16_t)port
{
	return _port;
}






- (int)errNo
{
	return _errNo;
}
@end







|
<
<

>

|
>
|
<
<


|











<
<
|

>

|


<


>











|
|







|
|
<
<
<
<
<











>
>
>
>
>






21
22
23
24
25
26
27
28


29
30
31
32
33
34


35
36
37
38
39
40
41
42
43
44
45
46
47
48


49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80





81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#import "OFBindFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFBindFailedException
+ (instancetype)exceptionWithHost: (OFString*)host


			      port: (uint16_t)port
			   socket: (OFTCPSocket*)socket
{
	return [[[self alloc] initWithHost: host
				      port: port
				    socket: socket] autorelease];


}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}



- initWithHost: (OFString*)host
	   port: (uint16_t)port
	socket: (OFTCPSocket*)socket
{
	self = [super init];

	@try {

		_host   = [host copy];
		_port   = port;
		_socket = [socket retain];
		_errNo  = GET_SOCK_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_host release];
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Binding to port %" @PRIu16 @" on host %@ failed in socket of "
	    @"type %@! " ERRFMT, _port, _host, [_socket class], ERRPARAM];





}

- (OFString*)host
{
	OF_GETTER(_host, false)
}

- (uint16_t)port
{
	return _port;
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}

- (int)errNo
{
	return _errNo;
}
@end

Modified src/exceptions/OFChangeDirectoryFailedException.h from [4e7164768a] to [263d921551].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

52





53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased change directory failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path A string with the path of the directory to which couldn't be
 *	       changed
 * @return A new, autoreleased change directory failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      path: (OFString*)path;

/*!
 * @brief Initializes an already allocated change directory failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path A string with the path of the directory to which couldn't be
 *	       changed
 * @return An initialized change directory failed exception
 */

- initWithClass: (Class)class_





	   path: (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns the path to which changing failed.
 *
 * @return The path to which changing failed
 */
- (OFString*)path;
@end







<




|
<




<




>
|
>
>
>
>
>
|







<
<
<
<
<
<
<

29
30
31
32
33
34
35

36
37
38
39
40

41
42
43
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63







64
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased change directory failed exception.
 *

 * @param path A string with the path of the directory to which couldn't be
 *	       changed
 * @return A new, autoreleased change directory failed exception
 */
+ (instancetype)exceptionWithPath: (OFString*)path;


/*!
 * @brief Initializes an already allocated change directory failed exception.
 *

 * @param path A string with the path of the directory to which couldn't be
 *	       changed
 * @return An initialized change directory failed exception
 */
- initWithPath: (OFString*)path;

/*!
 * @brief Returns the path to which changing failed.
 *
 * @return The path to which changing failed
 */
- (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;







@end

Modified src/exceptions/OFChangeDirectoryFailedException.m from [d55c526118] to [f29258b4ad].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

#import "OFChangeDirectoryFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFChangeDirectoryFailedException
+ (instancetype)exceptionWithClass: (Class)class
			      path: (OFString*)path
{
	return [[[self alloc] initWithClass: class
				       path: path] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	   path: (OFString*)path
{
	self = [super initWithClass: class];

	@try {
		_path  = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;







|
<

|
<


|











<
|

|







20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53

#import "OFChangeDirectoryFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFChangeDirectoryFailedException
+ (instancetype)exceptionWithPath: (OFString*)path

{
	return [[[self alloc] initWithPath: path] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithPath: (OFString*)path
{
	self = [super init];

	@try {
		_path  = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
65
66
67
68
69
70
71
72

73



74
75
76
77
78
79
80
81
82
83
84
85

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to change to directory %@ in class %@! " ERRFMT, _path,

	    _inClass, ERRPARAM];



}

- (int)errNo
{
	return _errNo;
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}
@end







|
>
|
>
>
>






<
<
<
<
<

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80





81

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to change to directory %@! " ERRFMT, _path, ERRPARAM];
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}

- (int)errNo
{
	return _errNo;
}





@end

Modified src/exceptions/OFChangeFileModeFailedException.h from [ff2f6d8da0] to [c4f537c584].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80







81
@property (readonly) mode_t mode;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased change file mode failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path The path of the file
 * @param mode The new mode for the file
 * @return A new, autoreleased change file mode failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      path: (OFString*)path
			      mode: (mode_t)mode;

/*!
 * @brief Initializes an already allocated change file mode failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path The path of the file
 * @param mode The new mode for the file
 * @return An initialized change file mode failed exception
 */
- initWithClass: (Class)class_
	   path: (OFString*)path
	   mode: (mode_t)mode;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns the path of the file.
 *
 * @return The path of the file
 */
- (OFString*)path;

/*!
 * @brief Returns the new mode for the file.
 *
 * @return The new mode for the file
 */
- (mode_t)mode;







@end







<




|
<





<




<
|


<
<
<
<
<
<
<













>
>
>
>
>
>
>

33
34
35
36
37
38
39

40
41
42
43
44

45
46
47
48
49

50
51
52
53

54
55
56







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@property (readonly) mode_t mode;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased change file mode failed exception.
 *

 * @param path The path of the file
 * @param mode The new mode for the file
 * @return A new, autoreleased change file mode failed exception
 */
+ (instancetype)exceptionWithPath: (OFString*)path

			      mode: (mode_t)mode;

/*!
 * @brief Initializes an already allocated change file mode failed exception.
 *

 * @param path The path of the file
 * @param mode The new mode for the file
 * @return An initialized change file mode failed exception
 */

- initWithPath: (OFString*)path
	   mode: (mode_t)mode;








/*!
 * @brief Returns the path of the file.
 *
 * @return The path of the file
 */
- (OFString*)path;

/*!
 * @brief Returns the new mode for the file.
 *
 * @return The new mode for the file
 */
- (mode_t)mode;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/exceptions/OFChangeFileModeFailedException.m from [b8c50ad165] to [eccae35bc7].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

#import "OFChangeFileModeFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFChangeFileModeFailedException
+ (instancetype)exceptionWithClass: (Class)class
			      path: (OFString*)path
			      mode: (mode_t)mode
{
	return [[[self alloc] initWithClass: class
				       path: path
				       mode: mode] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	   path: (OFString*)path
	   mode: (mode_t)mode
{
	self = [super initWithClass: class];

	@try {
		_path  = [path copy];
		_mode  = mode;
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];







|
<


|
<



|











<
|


|







20
21
22
23
24
25
26
27

28
29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56

#import "OFChangeFileModeFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFChangeFileModeFailedException
+ (instancetype)exceptionWithPath: (OFString*)path

			      mode: (mode_t)mode
{
	return [[[self alloc] initWithPath: path

				       mode: mode] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithPath: (OFString*)path
	   mode: (mode_t)mode
{
	self = [super init];

	@try {
		_path  = [path copy];
		_mode  = mode;
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93





94

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to change mode for file %@ to %d in class %@! " ERRFMT,
	    _path, _mode, _inClass, ERRPARAM];
}

- (int)errNo
{
	return _errNo;
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}

- (mode_t)mode
{
	return _mode;
}





@end







|
|
<
<
<
<
<











>
>
>
>
>

66
67
68
69
70
71
72
73
74





75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to change mode for file %@ to %d! " ERRFMT, _path, _mode,
	    ERRPARAM];





}

- (OFString*)path
{
	OF_GETTER(_path, false)
}

- (mode_t)mode
{
	return _mode;
}

- (int)errNo
{
	return _errNo;
}
@end

Modified src/exceptions/OFChangeFileOwnerFailedException.h from [c53d35405c] to [480da76a9c].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88







89
90
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

#ifndef _WIN32
/*!
 * @brief An exception indicating that changing the owner of a file failed.
 */
@interface OFChangeFileOwnerFailedException: OFException
{
	OFString *_path, *_owner, *_group;
	int _errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *path, *owner, *group;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased change file owner failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path The path of the file
 * @param owner The new owner for the file
 * @param group The new group for the file
 * @return A new, autoreleased change file owner failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      path: (OFString*)path
			     owner: (OFString*)owner
			     group: (OFString*)group;

/*!
 * @brief Initializes an already allocated change file owner failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path The path of the file
 * @param owner The new owner for the file
 * @param group The new group for the file
 * @return An initialized change file owner failed exception
 */
- initWithClass: (Class)class_
	   path: (OFString*)path
	  owner: (OFString*)owner
	  group: (OFString*)group;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns the path of the file.
 *
 * @return The path of the file
 */
- (OFString*)path;

/*!
 * @brief Returns the new owner for the file.
 *
 * @return The new owner for the file
 */
- (OFString*)owner;

/*!
 * @brief Returns the new group for the file.
 *
 * @return The new group for the file
 */
- (OFString*)group;







@end
#endif







|

















<





|
<






<





<
|



<
<
<
<
<
<
<




















>
>
>
>
>
>
>


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39
40
41
42

43
44
45
46
47
48

49
50
51
52
53

54
55
56
57







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

#ifdef OF_HAVE_CHOWN
/*!
 * @brief An exception indicating that changing the owner of a file failed.
 */
@interface OFChangeFileOwnerFailedException: OFException
{
	OFString *_path, *_owner, *_group;
	int _errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *path, *owner, *group;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased change file owner failed exception.
 *

 * @param path The path of the file
 * @param owner The new owner for the file
 * @param group The new group for the file
 * @return A new, autoreleased change file owner failed exception
 */
+ (instancetype)exceptionWithPath: (OFString*)path

			     owner: (OFString*)owner
			     group: (OFString*)group;

/*!
 * @brief Initializes an already allocated change file owner failed exception.
 *

 * @param path The path of the file
 * @param owner The new owner for the file
 * @param group The new group for the file
 * @return An initialized change file owner failed exception
 */

- initWithPath: (OFString*)path
	  owner: (OFString*)owner
	  group: (OFString*)group;








/*!
 * @brief Returns the path of the file.
 *
 * @return The path of the file
 */
- (OFString*)path;

/*!
 * @brief Returns the new owner for the file.
 *
 * @return The new owner for the file
 */
- (OFString*)owner;

/*!
 * @brief Returns the new group for the file.
 *
 * @return The new group for the file
 */
- (OFString*)group;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end
#endif

Modified src/exceptions/OFChangeFileOwnerFailedException.m from [a798b2bddb] to [363ad2c4c9].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdlib.h>

#import "OFChangeFileOwnerFailedException.h"
#import "OFString.h"

#import "common.h"

#ifndef _WIN32
@implementation OFChangeFileOwnerFailedException
+ (instancetype)exceptionWithClass: (Class)class
			      path: (OFString*)path
			     owner: (OFString*)owner
			     group: (OFString*)group
{
	return [[[self alloc] initWithClass: class
				       path: path
				      owner: owner
				      group: group] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	   path: (OFString*)path
	  owner: (OFString*)owner
	  group: (OFString*)group
{
	self = [super initWithClass: class];

	@try {
		_path  = [path copy];
		_owner = [owner copy];
		_group = [group copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {







|

|
<



|
<




|











<
|



|







19
20
21
22
23
24
25
26
27
28

29
30
31
32

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

49
50
51
52
53
54
55
56
57
58
59
60
#include <stdlib.h>

#import "OFChangeFileOwnerFailedException.h"
#import "OFString.h"

#import "common.h"

#ifdef OF_HAVE_CHOWN
@implementation OFChangeFileOwnerFailedException
+ (instancetype)exceptionWithPath: (OFString*)path

			     owner: (OFString*)owner
			     group: (OFString*)group
{
	return [[[self alloc] initWithPath: path

				      owner: owner
				      group: group] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithPath: (OFString*)path
	  owner: (OFString*)owner
	  group: (OFString*)group
{
	self = [super init];

	@try {
		_path  = [path copy];
		_owner = [owner copy];
		_group = [group copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114





115
116
	[super dealloc];
}

- (OFString*)description
{
	if (_group == nil)
		return [OFString stringWithFormat:
		    @"Failed to change owner for file %@ to %@ in class %@! "
		    ERRFMT, _path, _owner, _inClass, ERRPARAM];
	else if (_owner == nil)
		return [OFString stringWithFormat:
		    @"Failed to change group for file %@ to %@ in class %@! "
		    ERRFMT, _path, _group, _inClass, ERRPARAM];
	else
		return [OFString stringWithFormat:
		    @"Failed to change owner for file %@ to %@:%@ in class %@! "
		    ERRFMT, _path, _owner, _group, _inClass, ERRPARAM];
}

- (int)errNo
{
	return _errNo;
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}

- (OFString*)owner
{
	OF_GETTER(_owner, false)
}

- (OFString*)group
{
	OF_GETTER(_group, false)
}





@end
#endif







|
|


|
|


|
|
<
<
<
<
<
















>
>
>
>
>


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90





91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
	[super dealloc];
}

- (OFString*)description
{
	if (_group == nil)
		return [OFString stringWithFormat:
		    @"Failed to change owner of file %@ to %@! "
		    ERRFMT, _path, _owner, ERRPARAM];
	else if (_owner == nil)
		return [OFString stringWithFormat:
		    @"Failed to change group of file %@ to %@! "
		    ERRFMT, _path, _group, ERRPARAM];
	else
		return [OFString stringWithFormat:
		    @"Failed to change owner of file %@ to %@:%@! "
		    ERRFMT, _path, _owner, _group, ERRPARAM];





}

- (OFString*)path
{
	OF_GETTER(_path, false)
}

- (OFString*)owner
{
	OF_GETTER(_owner, false)
}

- (OFString*)group
{
	OF_GETTER(_group, false)
}

- (int)errNo
{
	return _errNo;
}
@end
#endif

Modified src/exceptions/OFConditionBroadcastFailedException.h from [ee86acd7f5] to [d91cb950af].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFCondition *condition;
#endif

/*!
 * @brief Returns a new, autoreleased condition broadcast failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param condition The condition which could not be broadcasted
 * @return A new, autoreleased condition broadcast failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			 condition: (OFCondition*)condition;

/*!
 * @brief Initializes an already allocated condition broadcast failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param condition The condition which could not be broadcasted
 * @return An initialized condition broadcast failed exception
 */
- initWithClass: (Class)class_
      condition: (OFCondition*)condition;

/*!
 * @brief Returns the condition which could not be broadcasted.
 *
 * @return The condition which could not be broadcasted
 */
- (OFCondition*)condition;
@end







<



|
<




<



<
|








33
34
35
36
37
38
39

40
41
42
43

44
45
46
47

48
49
50

51
52
53
54
55
56
57
58
59
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFCondition *condition;
#endif

/*!
 * @brief Returns a new, autoreleased condition broadcast failed exception.
 *

 * @param condition The condition which could not be broadcasted
 * @return A new, autoreleased condition broadcast failed exception
 */
+ (instancetype)exceptionWithCondition: (OFCondition*)condition;


/*!
 * @brief Initializes an already allocated condition broadcast failed exception.
 *

 * @param condition The condition which could not be broadcasted
 * @return An initialized condition broadcast failed exception
 */

- initWithCondition: (OFCondition*)condition;

/*!
 * @brief Returns the condition which could not be broadcasted.
 *
 * @return The condition which could not be broadcasted
 */
- (OFCondition*)condition;
@end

Modified src/exceptions/OFConditionBroadcastFailedException.m from [342d177e68] to [687deff470].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdlib.h>

#import "OFConditionBroadcastFailedException.h"
#import "OFString.h"
#import "OFCondition.h"

@implementation OFConditionBroadcastFailedException
+ (instancetype)exceptionWithClass: (Class)class
			 condition: (OFCondition*)condition
{
	return [[[self alloc] initWithClass: class
				  condition: condition] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
      condition: (OFCondition*)condition
{
	self = [super initWithClass: class];

	_condition = [condition retain];

	return self;
}

- (void)dealloc
{
	[_condition release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Broadcasting a condition of type %@ failed!", _inClass];
}

- (OFCondition*)condition
{
	OF_GETTER(_condition, false)
}
@end







|
<

|
<


|











<
|

|
















|







19
20
21
22
23
24
25
26

27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdlib.h>

#import "OFConditionBroadcastFailedException.h"
#import "OFString.h"
#import "OFCondition.h"

@implementation OFConditionBroadcastFailedException
+ (instancetype)exceptionWithCondition: (OFCondition*)condition

{
	return [[[self alloc] initWithCondition: condition] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithCondition: (OFCondition*)condition
{
	self = [super init];

	_condition = [condition retain];

	return self;
}

- (void)dealloc
{
	[_condition release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Broadcasting a condition of type %@ failed!", [_condition class]];
}

- (OFCondition*)condition
{
	OF_GETTER(_condition, false)
}
@end

Modified src/exceptions/OFConditionSignalFailedException.h from [8c1e25e6f7] to [29beaca23e].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFCondition *condition;
#endif

/*!
 * @brief Creates a new, autoreleased condition signal failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param condition The condition which could not be signaled
 * @return A new, autoreleased condition signal failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			 condition: (OFCondition*)condition;

/*!
 * @brief Initializes an already allocated condition signal failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param condition The condition which could not be signaled
 * @return An initialized condition signal failed exception
 */
- initWithClass: (Class)class_
      condition: (OFCondition*)condition;

/*!
 * @brief Return the condition which could not be signaled.
 *
 * @return The condition which could not be signaled
 */
- (OFCondition*)condition;
@end







<



|
<




<



<
|








33
34
35
36
37
38
39

40
41
42
43

44
45
46
47

48
49
50

51
52
53
54
55
56
57
58
59
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFCondition *condition;
#endif

/*!
 * @brief Creates a new, autoreleased condition signal failed exception.
 *

 * @param condition The condition which could not be signaled
 * @return A new, autoreleased condition signal failed exception
 */
+ (instancetype)exceptionWithCondition: (OFCondition*)condition;


/*!
 * @brief Initializes an already allocated condition signal failed exception.
 *

 * @param condition The condition which could not be signaled
 * @return An initialized condition signal failed exception
 */

- initWithCondition: (OFCondition*)condition;

/*!
 * @brief Return the condition which could not be signaled.
 *
 * @return The condition which could not be signaled
 */
- (OFCondition*)condition;
@end

Modified src/exceptions/OFConditionSignalFailedException.m from [f4a5f8a3ff] to [86cb7e17c0].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdlib.h>

#import "OFConditionSignalFailedException.h"
#import "OFString.h"
#import "OFCondition.h"

@implementation OFConditionSignalFailedException
+ (instancetype)exceptionWithClass: (Class)class
			 condition: (OFCondition*)condition
{
	return [[[self alloc] initWithClass: class
				  condition: condition] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
      condition: (OFCondition*)condition
{
	self = [super initWithClass: class];

	_condition = [condition retain];

	return self;
}

- (void)dealloc
{
	[_condition release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Signaling a condition of type %@ failed!", _inClass];
}

- (OFCondition*)condition
{
	OF_GETTER(_condition, false)
}
@end







|
<

|
<


|











<
|

|
















|







19
20
21
22
23
24
25
26

27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdlib.h>

#import "OFConditionSignalFailedException.h"
#import "OFString.h"
#import "OFCondition.h"

@implementation OFConditionSignalFailedException
+ (instancetype)exceptionWithCondition: (OFCondition*)condition

{
	return [[[self alloc] initWithCondition: condition] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithCondition: (OFCondition*)condition
{
	self = [super init];

	_condition = [condition retain];

	return self;
}

- (void)dealloc
{
	[_condition release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Signaling a condition of type %@ failed!", [_condition class]];
}

- (OFCondition*)condition
{
	OF_GETTER(_condition, false)
}
@end

Modified src/exceptions/OFConditionStillWaitingException.h from [ac276fe3d0] to [9a12108683].

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFCondition *condition;
#endif

/*!
 * @brief Creates a new, autoreleased condition still waiting exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param condition The condition for which is still being waited
 * @return A new, autoreleased condition still waiting exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			 condition: (OFCondition*)condition;

/*!
 * @brief Initializes an already allocated condition still waiting exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param condition The condition for which is still being waited
 * @return An initialized condition still waiting exception
 */
- initWithClass: (Class)class_
      condition: (OFCondition*)condition;

/*!
 * @brief Return the condition for which is still being waited.
 *
 * @return The condition for which is still being waited
 */
- (OFCondition*)condition;
@end







<



|
<




<



<
|








34
35
36
37
38
39
40

41
42
43
44

45
46
47
48

49
50
51

52
53
54
55
56
57
58
59
60
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFCondition *condition;
#endif

/*!
 * @brief Creates a new, autoreleased condition still waiting exception.
 *

 * @param condition The condition for which is still being waited
 * @return A new, autoreleased condition still waiting exception
 */
+ (instancetype)exceptionWithCondition: (OFCondition*)condition;


/*!
 * @brief Initializes an already allocated condition still waiting exception.
 *

 * @param condition The condition for which is still being waited
 * @return An initialized condition still waiting exception
 */

- initWithCondition: (OFCondition*)condition;

/*!
 * @brief Return the condition for which is still being waited.
 *
 * @return The condition for which is still being waited
 */
- (OFCondition*)condition;
@end

Modified src/exceptions/OFConditionStillWaitingException.m from [0bf03779d3] to [d3b56a4ad3].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdlib.h>

#import "OFConditionStillWaitingException.h"
#import "OFString.h"
#import "OFCondition.h"

@implementation OFConditionStillWaitingException
+ (instancetype)exceptionWithClass: (Class)class
			 condition: (OFCondition*)condition
{
	return [[[self alloc] initWithClass: class
				  condition: condition] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
      condition: (OFCondition*)condition
{
	self = [super initWithClass: class];

	_condition = [condition retain];

	return self;
}

- (void)dealloc
{
	[_condition release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Deallocation of a condition of type %@ was tried, even though a "
	    @"thread was still waiting for it!", _inClass];
}

- (OFCondition*)condition
{
	OF_GETTER(_condition, false)
}
@end







|
<

|
<


|











<
|

|

















|







19
20
21
22
23
24
25
26

27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdlib.h>

#import "OFConditionStillWaitingException.h"
#import "OFString.h"
#import "OFCondition.h"

@implementation OFConditionStillWaitingException
+ (instancetype)exceptionWithCondition: (OFCondition*)condition

{
	return [[[self alloc] initWithCondition: condition] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithCondition: (OFCondition*)condition
{
	self = [super init];

	_condition = [condition retain];

	return self;
}

- (void)dealloc
{
	[_condition release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Deallocation of a condition of type %@ was tried, even though a "
	    @"thread was still waiting for it!", [_condition class]];
}

- (OFCondition*)condition
{
	OF_GETTER(_condition, false)
}
@end

Modified src/exceptions/OFConditionWaitFailedException.h from [3dfb34d904] to [de7db2140c].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFCondition *condition;
#endif

/*!
 * @brief Creates a new, autoreleased condition wait failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param condition The condition for which could not be waited
 * @return A new, autoreleased condition wait failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			 condition: (OFCondition*)condition;

/*!
 * @brief Initializes an already allocated condition wait failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param condition The condition for which could not be waited
 * @return An initialized condition wait failed exception
 */
- initWithClass: (Class)class_
      condition: (OFCondition*)condition;

/*!
 * @brief Return the condition for which could not be waited.
 *
 * @return The condition for which could not be waited
 */
- (OFCondition*)condition;
@end







<



|
<




<



<
|








33
34
35
36
37
38
39

40
41
42
43

44
45
46
47

48
49
50

51
52
53
54
55
56
57
58
59
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFCondition *condition;
#endif

/*!
 * @brief Creates a new, autoreleased condition wait failed exception.
 *

 * @param condition The condition for which could not be waited
 * @return A new, autoreleased condition wait failed exception
 */
+ (instancetype)exceptionWithCondition: (OFCondition*)condition;


/*!
 * @brief Initializes an already allocated condition wait failed exception.
 *

 * @param condition The condition for which could not be waited
 * @return An initialized condition wait failed exception
 */

- initWithCondition: (OFCondition*)condition;

/*!
 * @brief Return the condition for which could not be waited.
 *
 * @return The condition for which could not be waited
 */
- (OFCondition*)condition;
@end

Modified src/exceptions/OFConditionWaitFailedException.m from [6c0165461b] to [65ff5cc010].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdlib.h>

#import "OFConditionWaitFailedException.h"
#import "OFString.h"
#import "OFCondition.h"

@implementation OFConditionWaitFailedException
+ (instancetype)exceptionWithClass: (Class)class
			 condition: (OFCondition*)condition
{
	return [[[self alloc] initWithClass: class
				  condition: condition] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
      condition: (OFCondition*)condition
{
	self = [super initWithClass: class];

	_condition = [condition retain];

	return self;
}

- (void)dealloc
{
	[_condition release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Waiting for a condition of type %@ failed!", _inClass];
}

- (OFCondition*)condition
{
	OF_GETTER(_condition, false)
}
@end







|
<

|
<


|











<
|

|
















|







19
20
21
22
23
24
25
26

27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdlib.h>

#import "OFConditionWaitFailedException.h"
#import "OFString.h"
#import "OFCondition.h"

@implementation OFConditionWaitFailedException
+ (instancetype)exceptionWithCondition: (OFCondition*)condition

{
	return [[[self alloc] initWithCondition: condition] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithCondition: (OFCondition*)condition
{
	self = [super init];

	_condition = [condition retain];

	return self;
}

- (void)dealloc
{
	[_condition release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Waiting for a condition of type %@ failed!", [_condition class]];
}

- (OFCondition*)condition
{
	OF_GETTER(_condition, false)
}
@end

Modified src/exceptions/OFConnectionFailedException.h from [7bbe937501] to [6027f00abb].

39
40
41
42
43
44
45
46
47
48
49

50
51
52
53
54
55

56
57
58
59
60
61
62
63

64
65
66
67
68
69

70
71
72
73
74
75
76
@property (readonly) uint16_t port;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased connection failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which could not connect
 * @param host The host to which the connection failed
 * @param port The port on the host to which the connection failed

 * @return A new, autoreleased connection failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    socket: (OFTCPSocket*)socket
			      host: (OFString*)host
			      port: (uint16_t)port;


/*!
 * @brief Initializes an already allocated connection failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which could not connect
 * @param host The host to which the connection failed
 * @param port The port on the host to which the connection failed

 * @return An initialized connection failed exception
 */
- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket
	   host: (OFString*)host
	   port: (uint16_t)port;


/*!
 * @brief Returns the socket which could not connect.
 *
 * @return The socket which could not connect
 */
- (OFTCPSocket*)socket;







<
<


>


|
<
<
|
>




<
<


>


<
<
|
|
>







39
40
41
42
43
44
45


46
47
48
49
50
51


52
53
54
55
56
57


58
59
60
61
62


63
64
65
66
67
68
69
70
71
72
@property (readonly) uint16_t port;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased connection failed exception.
 *


 * @param host The host to which the connection failed
 * @param port The port on the host to which the connection failed
 * @param socket The socket which could not connect
 * @return A new, autoreleased connection failed exception
 */
+ (instancetype)exceptionWithHost: (OFString*)host


			     port: (uint16_t)port
			   socket: (OFTCPSocket*)socket;

/*!
 * @brief Initializes an already allocated connection failed exception.
 *


 * @param host The host to which the connection failed
 * @param port The port on the host to which the connection failed
 * @param socket The socket which could not connect
 * @return An initialized connection failed exception
 */


- initWithHost: (OFString*)host
	  port: (uint16_t)port
	socket: (OFTCPSocket*)socket;

/*!
 * @brief Returns the socket which could not connect.
 *
 * @return The socket which could not connect
 */
- (OFTCPSocket*)socket;

Modified src/exceptions/OFConnectionFailedException.m from [aea20b11c3] to [6f870ca40c].

21
22
23
24
25
26
27
28
29
30
31

32
33

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100





101
102
103
104
105
106
#import "OFConnectionFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFConnectionFailedException
+ (instancetype)exceptionWithClass: (Class)class
			    socket: (OFTCPSocket*)socket
			      host: (OFString*)host
			      port: (uint16_t)port

{
	return [[[self alloc] initWithClass: class

				     socket: socket
				       host: host
				       port: port] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 socket: (OFTCPSocket*)socket
	   host: (OFString*)host
	   port: (uint16_t)port

{
	self = [super initWithClass: class];

	@try {
		_socket = [socket retain];
		_host   = [host copy];

		_port   = port;
		_errNo  = GET_SOCK_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_socket release];
	[_host release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"A connection to %@ on port %" @PRIu16 @" could not be "
	    @"established in class %@! " ERRFMT, _host, _port, _inClass,
	    ERRPARAM];
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}

- (OFString*)host
{
	OF_GETTER(_host, false)
}

- (uint16_t)port
{
	return _port;
}






- (int)errNo
{
	return _errNo;
}
@end







|
<
<

>

|
>
|
<
<


|











<
<
|

>

|


<

>












|
|








|
|
<
<
<
<
<











>
>
>
>
>






21
22
23
24
25
26
27
28


29
30
31
32
33
34


35
36
37
38
39
40
41
42
43
44
45
46
47
48


49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81





82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#import "OFConnectionFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFConnectionFailedException
+ (instancetype)exceptionWithHost: (OFString*)host


			      port: (uint16_t)port
			   socket: (OFTCPSocket*)socket
{
	return [[[self alloc] initWithHost: host
				      port: port
				    socket: socket] autorelease];


}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}



- initWithHost: (OFString*)host
	   port: (uint16_t)port
	socket: (OFTCPSocket*)socket
{
	self = [super init];

	@try {

		_host   = [host copy];
		_socket = [socket retain];
		_port   = port;
		_errNo  = GET_SOCK_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_host release];
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"A connection to %@ on port %" @PRIu16 @" could not be "
	    @"established in socket of type %@! " ERRFMT, _host, _port,
	    [_socket class], ERRPARAM];





}

- (OFString*)host
{
	OF_GETTER(_host, false)
}

- (uint16_t)port
{
	return _port;
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}

- (int)errNo
{
	return _errNo;
}
@end

Modified src/exceptions/OFCopyFileFailedException.h from [8e2325479f] to [7be6098eb8].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77







78
@property (readonly, copy, nonatomic) OFString *destinationPath;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased copy file failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param sourcePath The original path
 * @param destinationPath The new path
 * @return A new, autoreleased copy file failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			sourcePath: (OFString*)sourcePath
		   destinationPath: (OFString*)destinationPath;

/*!
 * @brief Initializes an already allocated copy file failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param sourcePath The original path
 * @param destinationPath The new path
 * @return An initialized copy file failed exception
 */
-   initWithClass: (Class)class_
       sourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns the path of the source file.
 *
 * @return The path of the source file
 */
- (OFString*)sourcePath;

/*!
 * @brief Returns the destination path.
 *
 * @return The destination path
 */
- (OFString*)destinationPath;







@end







<




|
<





<




<
|


<
<
<
<
<
<
<













>
>
>
>
>
>
>

30
31
32
33
34
35
36

37
38
39
40
41

42
43
44
45
46

47
48
49
50

51
52
53







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@property (readonly, copy, nonatomic) OFString *destinationPath;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased copy file failed exception.
 *

 * @param sourcePath The original path
 * @param destinationPath The new path
 * @return A new, autoreleased copy file failed exception
 */
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath

		   destinationPath: (OFString*)destinationPath;

/*!
 * @brief Initializes an already allocated copy file failed exception.
 *

 * @param sourcePath The original path
 * @param destinationPath The new path
 * @return An initialized copy file failed exception
 */

- initWithSourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath;








/*!
 * @brief Returns the path of the source file.
 *
 * @return The path of the source file
 */
- (OFString*)sourcePath;

/*!
 * @brief Returns the destination path.
 *
 * @return The destination path
 */
- (OFString*)destinationPath;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/exceptions/OFCopyFileFailedException.m from [8f083aa045] to [124bf86a2d].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

#import "OFCopyFileFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFCopyFileFailedException
+ (instancetype)exceptionWithClass: (Class)class
			sourcePath: (OFString*)sourcePath
		   destinationPath: (OFString*)destinationPath
{
	return [[[self alloc] initWithClass: class
				 sourcePath: sourcePath
			    destinationPath: destinationPath] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

-   initWithClass: (Class)class
       sourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath
{
	self = [super initWithClass: class];

	@try {
		_sourcePath = [sourcePath copy];
		_destinationPath = [destinationPath copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];







|
<


|
<



|











<
|


|







20
21
22
23
24
25
26
27

28
29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56

#import "OFCopyFileFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFCopyFileFailedException
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath

		   destinationPath: (OFString*)destinationPath
{
	return [[[self alloc] initWithSourcePath: sourcePath

			    destinationPath: destinationPath] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithSourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath
{
	self = [super init];

	@try {
		_sourcePath = [sourcePath copy];
		_destinationPath = [destinationPath copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94





95

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to copy file %@ to %@ in class %@! " ERRFMT,
	    _sourcePath, _destinationPath, _inClass, ERRPARAM];
}

- (int)errNo
{
	return _errNo;
}

- (OFString*)sourcePath
{
	OF_GETTER(_sourcePath, false)
}

- (OFString*)destinationPath
{
	OF_GETTER(_destinationPath, false)
}





@end







|
|
<
<
<
<
<











>
>
>
>
>

67
68
69
70
71
72
73
74
75





76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to copy file %@ to %@! " ERRFMT, _sourcePath,
	    _destinationPath, ERRPARAM];





}

- (OFString*)sourcePath
{
	OF_GETTER(_sourcePath, false)
}

- (OFString*)destinationPath
{
	OF_GETTER(_destinationPath, false)
}

- (int)errNo
{
	return _errNo;
}
@end

Modified src/exceptions/OFCreateDirectoryFailedException.h from [34b0a07f1e] to [afe76b3887].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66







67
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased create directory failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path A string with the path of the directory which couldn't be created
 * @return A new, autoreleased create directory failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      path: (OFString*)path;

/*!
 * @brief Initializes an already allocated create directory failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path A string with the path of the directory which couldn't be created
 * @return An initialized create directory failed exception
 */
- initWithClass: (Class)class_
	   path: (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns a string with the path of the directory which couldn't be
 *	  created.
 *
 * @return A string with the path of the directory which couldn't be created
 */
- (OFString*)path;







@end







<



|
<




<



<
|
<
<
<
<
<
<
<








>
>
>
>
>
>
>

29
30
31
32
33
34
35

36
37
38
39

40
41
42
43

44
45
46

47







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased create directory failed exception.
 *

 * @param path A string with the path of the directory which couldn't be created
 * @return A new, autoreleased create directory failed exception
 */
+ (instancetype)exceptionWithPath: (OFString*)path;


/*!
 * @brief Initializes an already allocated create directory failed exception.
 *

 * @param path A string with the path of the directory which couldn't be created
 * @return An initialized create directory failed exception
 */

- initWithPath: (OFString*)path;








/*!
 * @brief Returns a string with the path of the directory which couldn't be
 *	  created.
 *
 * @return A string with the path of the directory which couldn't be created
 */
- (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/exceptions/OFCreateDirectoryFailedException.m from [65f145a0a1] to [75c3b48ac7].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

#import "OFCreateDirectoryFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFCreateDirectoryFailedException
+ (instancetype)exceptionWithClass: (Class)class
			      path: (OFString*)path
{
	return [[[self alloc] initWithClass: class
				       path: path] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	   path: (OFString*)path
{
	self = [super initWithClass: class];

	@try {
		_path  = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;







|
<

|
<


|











<
|

|







20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53

#import "OFCreateDirectoryFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFCreateDirectoryFailedException
+ (instancetype)exceptionWithPath: (OFString*)path

{
	return [[[self alloc] initWithPath: path] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithPath: (OFString*)path
{
	self = [super init];

	@try {
		_path  = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
65
66
67
68
69
70
71
72

73



74
75
76
77
78
79
80
81
82
83
84
85

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to create directory %@ in class %@! " ERRFMT, _path,

	    _inClass, ERRPARAM];



}

- (int)errNo
{
	return _errNo;
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}
@end







|
>
|
>
>
>






<
<
<
<
<

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80





81

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to create directory %@! " ERRFMT, _path, ERRPARAM];
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}

- (int)errNo
{
	return _errNo;
}





@end

Modified src/exceptions/OFDeleteDirectoryFailedException.h from [9ce6ca0f5f] to [83541d2a01].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

50





51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased delete directory failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path The path of the directory
 * @return A new, autoreleased delete directory failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      path: (OFString*)path;

/*!
 * @brief Initializes an already allocated delete directory failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path The path of the directory
 * @return An initialized delete directory failed exception
 */

- initWithClass: (Class)class_





	   path: (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns the path of the directory.
 *
 * @return The path of the directory
 */
- (OFString*)path;
@end







<



|
<




<



>
|
>
>
>
>
>
|







<
<
<
<
<
<
<

29
30
31
32
33
34
35

36
37
38
39

40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61







62
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased delete directory failed exception.
 *

 * @param path The path of the directory
 * @return A new, autoreleased delete directory failed exception
 */
+ (instancetype)exceptionWithPath: (OFString*)path;


/*!
 * @brief Initializes an already allocated delete directory failed exception.
 *

 * @param path The path of the directory
 * @return An initialized delete directory failed exception
 */
- initWithPath: (OFString*)path;

/*!
 * @brief Returns the path of the directory.
 *
 * @return The path of the directory
 */
- (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;







@end

Modified src/exceptions/OFDeleteDirectoryFailedException.m from [3c8954df51] to [bb5c3143ac].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

#import "OFDeleteDirectoryFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFDeleteDirectoryFailedException
+ (instancetype)exceptionWithClass: (Class)class
			      path: (OFString*)path_
{
	return [[[self alloc] initWithClass: class
				       path: path_] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	   path: (OFString*)path
{
	self = [super initWithClass: class];

	@try {
		_path  = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;







|
<

|
<


|











<
|

|







20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53

#import "OFDeleteDirectoryFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFDeleteDirectoryFailedException
+ (instancetype)exceptionWithPath: (OFString*)path_

{
	return [[[self alloc] initWithPath: path_] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithPath: (OFString*)path
{
	self = [super init];

	@try {
		_path  = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
65
66
67
68
69
70
71
72

73



74
75
76
77
78
79
80
81
82
83
84
85

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to delete directory %@ in class %@! " ERRFMT, _path,

	    _inClass, ERRPARAM];



}

- (int)errNo
{
	return _errNo;
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}
@end







|
>
|
>
>
>






<
<
<
<
<

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80





81

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to delete directory %@! " ERRFMT, _path, ERRPARAM];
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}

- (int)errNo
{
	return _errNo;
}





@end

Modified src/exceptions/OFDeleteFileFailedException.h from [ed836376b8] to [f7f8c06ebc].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

50





51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased delete file failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path The path of the file
 * @return A new, autoreleased delete file failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      path: (OFString*)path;

/*!
 * @brief Initializes an already allocated delete file failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path The path of the file
 * @return An initialized delete file failed exception
 */

- initWithClass: (Class)class_





	   path: (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns the path of the file.
 *
 * @return The path of the file
 */
- (OFString*)path;
@end







<



|
<




<



>
|
>
>
>
>
>
|







<
<
<
<
<
<
<

29
30
31
32
33
34
35

36
37
38
39

40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61







62
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased delete file failed exception.
 *

 * @param path The path of the file
 * @return A new, autoreleased delete file failed exception
 */
+ (instancetype)exceptionWithPath: (OFString*)path;


/*!
 * @brief Initializes an already allocated delete file failed exception.
 *

 * @param path The path of the file
 * @return An initialized delete file failed exception
 */
- initWithPath: (OFString*)path;

/*!
 * @brief Returns the path of the file.
 *
 * @return The path of the file
 */
- (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;







@end

Modified src/exceptions/OFDeleteFileFailedException.m from [71b956856c] to [889f5dd334].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

#import "OFDeleteFileFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFDeleteFileFailedException
+ (instancetype)exceptionWithClass: (Class)class
			      path: (OFString*)path
{
	return [[[self alloc] initWithClass: class
				       path: path] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	   path: (OFString*)path
{
	self = [super initWithClass: class];

	@try {
		_path  = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;







|
<

|
<


|











<
|

|







20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53

#import "OFDeleteFileFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFDeleteFileFailedException
+ (instancetype)exceptionWithPath: (OFString*)path

{
	return [[[self alloc] initWithPath: path] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithPath: (OFString*)path
{
	self = [super init];

	@try {
		_path  = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
65
66
67
68
69
70
71
72

73



74
75
76
77
78
79
80
81
82
83
84
85

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to delete file %@ in class %@! " ERRFMT, _path, _inClass,

	    ERRPARAM];



}

- (int)errNo
{
	return _errNo;
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}
@end







|
>
|
>
>
>






<
<
<
<
<

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80





81

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to delete file %@! " ERRFMT, _path, ERRPARAM];
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}

- (int)errNo
{
	return _errNo;
}





@end

Modified src/exceptions/OFEnumerationMutationException.h from [878a08d7a2] to [6053c2c8e1].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id object;
#endif

/*!
 * @brief Creates a new, autoreleased enumeration mutation exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param object The object which was mutated during enumeration
 * @return A new, autoreleased enumeration mutation exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    object: (id)object;

/*!
 * @brief Initializes an already allocated enumeration mutation exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param object The object which was mutated during enumeration
 * @return An initialized enumeration mutation exception
 */
- initWithClass: (Class)class_
	 object: (id)object;

/*!
 * @brief Returns the object which was mutated during enumeration.
 *
 * @return The object which was mutated during enumeration
 */
- (id)object;
@end







<



|
<




<



<
|








28
29
30
31
32
33
34

35
36
37
38

39
40
41
42

43
44
45

46
47
48
49
50
51
52
53
54
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id object;
#endif

/*!
 * @brief Creates a new, autoreleased enumeration mutation exception.
 *

 * @param object The object which was mutated during enumeration
 * @return A new, autoreleased enumeration mutation exception
 */
+ (instancetype)exceptionWithObject: (id)object;


/*!
 * @brief Initializes an already allocated enumeration mutation exception.
 *

 * @param object The object which was mutated during enumeration
 * @return An initialized enumeration mutation exception
 */

- initWithObject: (id)object;

/*!
 * @brief Returns the object which was mutated during enumeration.
 *
 * @return The object which was mutated during enumeration
 */
- (id)object;
@end

Modified src/exceptions/OFEnumerationMutationException.m from [df929876a2] to [c30d82b1bf].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

67
68
69
70
71
72
73

#import "OFEnumerationMutationException.h"
#import "OFString.h"

#import "common.h"

@implementation OFEnumerationMutationException
+ (instancetype)exceptionWithClass: (Class)class
			    object: (id)object
{
	return [[[self alloc] initWithClass: class
				     object: object] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 object: (id)object
{
	self = [super initWithClass: class];

	_object = [object retain];

	return self;
}

- (void)dealloc
{
	[_object release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Object of class %@ was mutated during enumeration!", _inClass];

}

- (id)object
{
	OF_GETTER(_object, false)
}
@end







|
<

|
<


|











<
|

|
















|
>







20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

#import "OFEnumerationMutationException.h"
#import "OFString.h"

#import "common.h"

@implementation OFEnumerationMutationException
+ (instancetype)exceptionWithObject: (id)object

{
	return [[[self alloc] initWithObject: object] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithObject: (id)object
{
	self = [super init];

	_object = [object retain];

	return self;
}

- (void)dealloc
{
	[_object release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Object of class %@ was mutated during enumeration!",
	    [_object class]];
}

- (id)object
{
	OF_GETTER(_object, false)
}
@end

Modified src/exceptions/OFException.h from [cc67cf334c] to [2464e12597].

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 * @brief The base class for all exceptions in ObjFW
 *
 * The OFException class is the base class for all exceptions in ObjFW, except
 * the OFAllocFailedException.
 */
@interface OFException: OFObject
{
	Class _inClass;
	void *_backtrace[OF_BACKTRACE_SIZE];
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) Class inClass;
#endif

/*!
 * @brief Creates a new, autoreleased exception.
 *
 * @param class_ The class of the object which caused the exception
 * @return A new, autoreleased exception
 */
+ (instancetype)exceptionWithClass: (Class)class_;

/*!
 * @brief Initializes an already allocated OFException.
 *
 * @param class_ The class of the object which caused the exception
 * @return An initialized OFException
 */
- initWithClass: (Class)class_;

/*!
 * @brief Returns the class of the object in which the exception occurred.
 *
 * @return The class of the object in which the exception occurred
 */
- (Class)inClass;

/*!
 * @brief Returns a description of the exception.
 *
 * @return A description of the exception
 */
- (OFString*)description;







<



<
<
<
<



<


|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







26
27
28
29
30
31
32

33
34
35




36
37
38

39
40
41















42
43
44
45
46
47
48
 * @brief The base class for all exceptions in ObjFW
 *
 * The OFException class is the base class for all exceptions in ObjFW, except
 * the OFAllocFailedException.
 */
@interface OFException: OFObject
{

	void *_backtrace[OF_BACKTRACE_SIZE];
}





/*!
 * @brief Creates a new, autoreleased exception.
 *

 * @return A new, autoreleased exception
 */
+ (instancetype)exception;
















/*!
 * @brief Returns a description of the exception.
 *
 * @return A description of the exception
 */
- (OFString*)description;

Modified src/exceptions/OFException.m from [48e20b7662] to [ef6fdedc48].

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
		return _URC_OK;
	}

	return _URC_END_OF_STACK;
}

@implementation OFException
+ (instancetype)exceptionWithClass: (Class)class
{
	return [[[self alloc] initWithClass: class] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
{
	struct backtrace_ctx ctx;

	self = [super init];

	_inClass = class;

	ctx.backtrace = _backtrace;
	ctx.i = 0;
	_Unwind_Backtrace(backtrace_callback, &ctx);

	return self;
}

- (Class)inClass
{
	return _inClass;
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"An exception of class %@ occurred in class %@!",
	    object_getClass(self), _inClass];
}

- (OFArray*)backtrace
{
	OFMutableArray *backtrace = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	uint_fast8_t i;







|

|




<
<
<
<
<
<
<
<
<
<
<
<




<
<







<
<
<
<
<



|
<







55
56
57
58
59
60
61
62
63
64
65
66
67
68












69
70
71
72


73
74
75
76
77
78
79





80
81
82
83

84
85
86
87
88
89
90
		return _URC_OK;
	}

	return _URC_END_OF_STACK;
}

@implementation OFException
+ (instancetype)exception
{
	return [[[self alloc] init] autorelease];
}

- init
{












	struct backtrace_ctx ctx;

	self = [super init];



	ctx.backtrace = _backtrace;
	ctx.i = 0;
	_Unwind_Backtrace(backtrace_callback, &ctx);

	return self;
}






- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"An exception of type %@ occurred!", [self class]];

}

- (OFArray*)backtrace
{
	OFMutableArray *backtrace = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	uint_fast8_t i;

Modified src/exceptions/OFHTTPRequestFailedException.h from [ca95dac731] to [8a7c6a0eaf].

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@property (readonly, retain, nonatomic) OFHTTPRequest *request;
@property (readonly, retain, nonatomic) OFHTTPRequestReply *reply;
#endif

/*!
 * @brief Creates a new, autoreleased HTTP request failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param request The HTTP request which failed
 * @param reply The reply of the failed HTTP request
 * @return A new, autoreleased HTTP request failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			   request: (OFHTTPRequest*)request
			     reply: (OFHTTPRequestReply*)reply;

/*!
 * @brief Initializes an already allocated HTTP request failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param request The HTTP request which failed
 * @param reply The reply of the failed HTTP request
 * @return A new HTTP request failed exception
 */
- initWithClass: (Class)class_
	request: (OFHTTPRequest*)request
	  reply: (OFHTTPRequestReply*)reply;

/*!
 * @brief Returns the HTTP request which failed.
 *
 * @return The HTTP request which failed
 */







<




|
<





<




<
|







36
37
38
39
40
41
42

43
44
45
46
47

48
49
50
51
52

53
54
55
56

57
58
59
60
61
62
63
64
@property (readonly, retain, nonatomic) OFHTTPRequest *request;
@property (readonly, retain, nonatomic) OFHTTPRequestReply *reply;
#endif

/*!
 * @brief Creates a new, autoreleased HTTP request failed exception.
 *

 * @param request The HTTP request which failed
 * @param reply The reply of the failed HTTP request
 * @return A new, autoreleased HTTP request failed exception
 */
+ (instancetype)exceptionWithRequest: (OFHTTPRequest*)request

			     reply: (OFHTTPRequestReply*)reply;

/*!
 * @brief Initializes an already allocated HTTP request failed exception.
 *

 * @param request The HTTP request which failed
 * @param reply The reply of the failed HTTP request
 * @return A new HTTP request failed exception
 */

- initWithRequest: (OFHTTPRequest*)request
	  reply: (OFHTTPRequestReply*)reply;

/*!
 * @brief Returns the HTTP request which failed.
 *
 * @return The HTTP request which failed
 */

Modified src/exceptions/OFHTTPRequestFailedException.m from [5bea1d2dbc] to [fc85a500ca].

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#import "OFString.h"
#import "OFHTTPRequest.h"
#import "OFHTTPRequestReply.h"

#import "common.h"

@implementation OFHTTPRequestFailedException
+ (instancetype)exceptionWithClass: (Class)class
			   request: (OFHTTPRequest*)request
			     reply: (OFHTTPRequestReply*)reply
{
	return [[[self alloc] initWithClass: class
				    request: request
				      reply: reply] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	request: (OFHTTPRequest*)request
	  reply: (OFHTTPRequestReply*)reply
{
	self = [super initWithClass: class];

	_request = [request retain];
	_reply = [reply retain];

	return self;
}








|
<


|
<



|











<
|


|







22
23
24
25
26
27
28
29

30
31
32

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

48
49
50
51
52
53
54
55
56
57
58
#import "OFString.h"
#import "OFHTTPRequest.h"
#import "OFHTTPRequestReply.h"

#import "common.h"

@implementation OFHTTPRequestFailedException
+ (instancetype)exceptionWithRequest: (OFHTTPRequest*)request

			     reply: (OFHTTPRequestReply*)reply
{
	return [[[self alloc] initWithRequest: request

				      reply: reply] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithRequest: (OFHTTPRequest*)request
	  reply: (OFHTTPRequestReply*)reply
{
	self = [super init];

	_request = [request retain];
	_reply = [reply retain];

	return self;
}

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
		break;
	case OF_HTTP_REQUEST_TYPE_POST:
		type = "POST";
		break;
	}

	return [OFString stringWithFormat:
	    @"A HTTP %s request in class %@ with URL %@ failed with code %d",
	    type, _inClass, [_request URL], [_reply statusCode]];
}

- (OFHTTPRequest*)request
{
	OF_GETTER(_request, false)
}

- (OFHTTPRequestReply*)reply
{
	OF_GETTER(_reply, false)
}
@end







|
|












77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
		break;
	case OF_HTTP_REQUEST_TYPE_POST:
		type = "POST";
		break;
	}

	return [OFString stringWithFormat:
	    @"A HTTP %s request with URL %@ failed with code %d!", type,
	    [_request URL], [_reply statusCode]];
}

- (OFHTTPRequest*)request
{
	OF_GETTER(_request, false)
}

- (OFHTTPRequestReply*)reply
{
	OF_GETTER(_reply, false)
}
@end

Modified src/exceptions/OFHashAlreadyCalculatedException.h from [475c359189] to [26212e193a].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFHash> hashObject;
#endif

/*!
 * @brief Creates a new, autoreleased hash already calculated exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param hashObject The hash which has already been calculated
 * @return A new, autoreleased hash already calculated exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      hash: (id <OFHash>)hashObject;

/*!
 * @brief Initializes an already allocated hash already calculated exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param hashObject The hash which has already been calculated
 * @return An initialized hash already calculated exception
 */
- initWithClass: (Class)class_
	   hash: (id <OFHash>)hashObject;

/*!
 * @brief Returns the hash which has already been calculated.
 *
 * @return The hash which has already been calculated
 */
- (id <OFHash>)hashObject;
@end







<
|


|
<




<
|


<
|








28
29
30
31
32
33
34

35
36
37
38

39
40
41
42

43
44
45

46
47
48
49
50
51
52
53
54
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFHash> hashObject;
#endif

/*!
 * @brief Creates a new, autoreleased hash already calculated exception.
 *

 * @param hash The hash which has already been calculated
 * @return A new, autoreleased hash already calculated exception
 */
+ (instancetype)exceptionWithHash: (id <OFHash>)hash;


/*!
 * @brief Initializes an already allocated hash already calculated exception.
 *

 * @param hash The hash which has already been calculated
 * @return An initialized hash already calculated exception
 */

- initWithHash: (id <OFHash>)hash;

/*!
 * @brief Returns the hash which has already been calculated.
 *
 * @return The hash which has already been calculated
 */
- (id <OFHash>)hashObject;
@end

Modified src/exceptions/OFHashAlreadyCalculatedException.m from [6e036672c0] to [65fa9294da].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

#import "OFHashAlreadyCalculatedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFHashAlreadyCalculatedException
+ (instancetype)exceptionWithClass: (Class)class
			      hash: (id <OFHash>)hash
{
	return [[[self alloc] initWithClass: class
				       hash: hash] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	   hash: (id <OFHash>)hashObject
{
	self = [super initWithClass: class];

	_hashObject = [hashObject retain];

	return self;
}

- (void)dealloc
{
	[_hashObject release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The hash has already been calculated in class %@ and thus no new "
	    @"data can be added", _inClass];
}

- (id <OFHash>)hashObject
{
	OF_GETTER(_hashObject, false)
}
@end







|
<

|
<


|











<
|

|
















|
|







20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

#import "OFHashAlreadyCalculatedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFHashAlreadyCalculatedException
+ (instancetype)exceptionWithHash: (id <OFHash>)hash

{
	return [[[self alloc] initWithHash: hash] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithHash: (id <OFHash>)hashObject
{
	self = [super init];

	_hashObject = [hashObject retain];

	return self;
}

- (void)dealloc
{
	[_hashObject release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The hash of type %@ has already been calculated and thus no new "
	    @"data can be added!", [_hashObject class]];
}

- (id <OFHash>)hashObject
{
	OF_GETTER(_hashObject, false)
}
@end

Modified src/exceptions/OFInitializationFailedException.h from [6fcf1d7853] to [78631141a8].

16
17
18
19
20
21
22






























23

#import "OFException.h"

/*!
 * @brief An exception indicating that initializing something failed.
 */
@interface OFInitializationFailedException: OFException






























@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

#import "OFException.h"

/*!
 * @brief An exception indicating that initializing something failed.
 */
@interface OFInitializationFailedException: OFException
{
	Class _inClass;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) Class inClass;
#endif

/*!
 * @brief Creates a new, autoreleased initialization failed exception.
 *
 * @param class_ The class for which initialization failed
 * @return A new, autoreleased initialization failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_;

/*!
 * @brief Initializes an already allocated initialization failed exception.
 *
 * @param class_ The class for which initialization failed
 * @return An initialized initialization failed exception
 */
- initWithClass: (Class)class_;

/*!
 * @brief Returns the class for which initialization failed.
 *
 * @return The class for which initialization failed
 */
- (Class)inClass;
@end

Modified src/exceptions/OFInitializationFailedException.m from [5b64ada8d8] to [df3cddd866].

11
12
13
14
15
16
17


18
19
20
21


22


























23
24
25
26
27





28
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"



#import "OFInitializationFailedException.h"
#import "OFString.h"



@implementation OFInitializationFailedException


























- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Initialization failed for or in class %@!", _inClass];
}





@end







>
>




>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





>
>
>
>
>

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <stdlib.h>

#import "OFInitializationFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFInitializationFailedException
+ (instancetype)exceptionWithClass: (Class)class
{
	return [[[self alloc] initWithClass: class] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
{
	self = [super init];

	_inClass = class;

	return self;
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Initialization failed for or in class %@!", _inClass];
}

- (Class)inClass
{
	return _inClass;
}
@end

Modified src/exceptions/OFInvalidArgumentException.h from [6c06e4e596] to [b61a357dad].

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

#import "OFException.h"

/*!
 * @brief An exception indicating that the argument is invalid for this method.
 */
@interface OFInvalidArgumentException: OFException
{
	SEL _selector;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) SEL selector;
#endif

/*!
 * @brief Creates a new, autoreleased invalid argument exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param selector The selector which doesn't accept the argument
 * @return A new, autoreleased invalid argument exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			  selector: (SEL)selector;

/*!
 * @brief Initializes an already allocated invalid argument exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param selector The selector which doesn't accept the argument
 * @return An initialized invalid argument exception
 */
- initWithClass: (Class)class_
       selector: (SEL)selector;

/*!
 * @brief Returns the selector to which an invalid argument was passed.
 *
 * @return The selector to which an invalid argument was passed
 */
- (SEL)selector;
@end







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

16
17
18
19
20
21
22


































23

#import "OFException.h"

/*!
 * @brief An exception indicating that the argument is invalid for this method.
 */
@interface OFInvalidArgumentException: OFException


































@end

Modified src/exceptions/OFInvalidArgumentException.m from [64e81089ac] to [70af64a4ed].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <stdlib.h>

#import "OFInvalidArgumentException.h"
#import "OFString.h"

#import "common.h"

@implementation OFInvalidArgumentException
+ (instancetype)exceptionWithClass: (Class)class
			  selector: (SEL)selector
{
	return [[[self alloc] initWithClass: class
				   selector: selector] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
       selector: (SEL)selector
{
	self = [super initWithClass: class];

	_selector = selector;

	return self;
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The argument or receiver for method %s of class %@ is invalid!",
	    sel_getName(_selector), _inClass];
}

- (SEL)selector
{
	return _selector;
}
@end







<
<



<
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


<
<
<
<
|
<
<
<


12
13
14
15
16
17
18


19
20
21


22





























23
24




25



26
27
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"



#import "OFInvalidArgumentException.h"
#import "OFString.h"



@implementation OFInvalidArgumentException





























- (OFString*)description
{




	return @"An invalid argument or receiver has been specified!";



}
@end

Modified src/exceptions/OFInvalidEncodingException.m from [b6ac8f14cb] to [d1d8908c75].

18
19
20
21
22
23
24
25
26
27
28

#import "OFInvalidEncodingException.h"
#import "OFString.h"

@implementation OFInvalidEncodingException
- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The encoding is invalid for class %@!", _inClass];
}
@end







<
|


18
19
20
21
22
23
24

25
26
27

#import "OFInvalidEncodingException.h"
#import "OFString.h"

@implementation OFInvalidEncodingException
- (OFString*)description
{

	return @"An encoding is invalid!";
}
@end

Modified src/exceptions/OFInvalidFormatException.m from [4ebc851ed7] to [df0548a921].

18
19
20
21
22
23
24
25
26
27
28

#import "OFInvalidFormatException.h"
#import "OFString.h"

@implementation OFInvalidFormatException
- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The format is invalid for class %@!", _inClass];
}
@end







<
|


18
19
20
21
22
23
24

25
26
27

#import "OFInvalidFormatException.h"
#import "OFString.h"

@implementation OFInvalidFormatException
- (OFString*)description
{

	return @"A format is invalid!";
}
@end

Modified src/exceptions/OFInvalidJSONException.h from [e45d7a3ec9] to [3557533be7].

17
18
19
20
21
22
23

24
25
26
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50







51
52
53
54
55
56
57
#import "OFException.h"

/*!
 * @brief An exception indicating a JSON representation is invalid.
 */
@interface OFInvalidJSONException: OFException
{

	size_t _line;
}

#ifdef OF_HAVE_PROPERTIES

@property (readonly) size_t line;
#endif

/*!
 * @brief Creates a new, autoreleased invalid JSON exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param line The line in which the parsing error encountered
 * @return A new, autoreleased invalid JSON exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      line: (size_t)line;

/*!
 * @brief Initializes an already allocated invalid JSON exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param line The line in which the parsing error encountered
 * @return An initialized invalid JSON exception
 */
- initWithClass: (Class)class_
	   line: (size_t)line;








/*!
 * @brief Returns the line in which parsing the JSON representation failed.
 *
 * @return The line in which parsing the JSON representation failed
 */
- (size_t)line;
@end







>




>






|



|





|



|


>
>
>
>
>
>
>







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#import "OFException.h"

/*!
 * @brief An exception indicating a JSON representation is invalid.
 */
@interface OFInvalidJSONException: OFException
{
	OFString *_string;
	size_t _line;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *string;
@property (readonly) size_t line;
#endif

/*!
 * @brief Creates a new, autoreleased invalid JSON exception.
 *
 * @param string The string containing the invalid JSON representation
 * @param line The line in which the parsing error encountered
 * @return A new, autoreleased invalid JSON exception
 */
+ (instancetype)exceptionWithString: (OFString*)string
			      line: (size_t)line;

/*!
 * @brief Initializes an already allocated invalid JSON exception.
 *
 * @param string The string containing the invalid JSON representation
 * @param line The line in which the parsing error encountered
 * @return An initialized invalid JSON exception
 */
- initWithString: (OFString*)string
	   line: (size_t)line;

/*!
 * @brief Returns the string containing the invalid JSON representation.
 *
 * @return The string containing the invalid JSON representation
 */
- (OFString*)string;

/*!
 * @brief Returns the line in which parsing the JSON representation failed.
 *
 * @return The line in which parsing the JSON representation failed
 */
- (size_t)line;
@end

Modified src/exceptions/OFInvalidJSONException.m from [e6375e0b23] to [240dacf8f4].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48


49




50
51
52







53
54
55
56
57

58



59
60
61
62
63
64
65

#include <stdlib.h>

#import "OFInvalidJSONException.h"
#import "OFString.h"

@implementation OFInvalidJSONException
+ (instancetype)exceptionWithClass: (Class)class
			      line: (size_t)line
{
	return [[[self alloc] initWithClass: class
				       line: line] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	   line: (size_t)line
{
	self = [super initWithClass: class];



	_line = line;





	return self;
}








- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The JSON representation class %@ tried to parse is invalid in "

	    @"line %zd!", _inClass, _line];



}

- (size_t)line
{
	return _line;
}
@end







|


|















|


|

>
>

>
>
>
>



>
>
>
>
>
>
>




|
>
|
>
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

#include <stdlib.h>

#import "OFInvalidJSONException.h"
#import "OFString.h"

@implementation OFInvalidJSONException
+ (instancetype)exceptionWithString: (OFString*)string
			      line: (size_t)line
{
	return [[[self alloc] initWithString: string
				       line: line] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithString: (OFString*)string
	   line: (size_t)line
{
	self = [super init];

	@try {
		_string = [string copy];
	_line = line;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_string release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The JSON representation is invalid in line %zd!", _line];
}

- (OFString*)string
{
	return _string;
}

- (size_t)line
{
	return _line;
}
@end

Modified src/exceptions/OFInvalidServerReplyException.m from [b835408d30] to [3817c4fdc0].

18
19
20
21
22
23
24
25
26
27
28

#import "OFInvalidServerReplyException.h"
#import "OFString.h"

@implementation OFInvalidServerReplyException
- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Got an invalid reply from the server in class %@!", _inClass];
}
@end







<
|


18
19
20
21
22
23
24

25
26
27

#import "OFInvalidServerReplyException.h"
#import "OFString.h"

@implementation OFInvalidServerReplyException
- (OFString*)description
{

	return @"Got an invalid reply from the server!";
}
@end

Modified src/exceptions/OFLinkFailedException.h from [2ff6890222] to [89eda619ec].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77







78
79
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

#ifndef _WIN32
/*!
 * @brief An exception indicating that creating a link failed.
 */
@interface OFLinkFailedException: OFException
{
	OFString *_sourcePath, *_destinationPath;
	int _errNo;
}

# ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *sourcePath, *destinationPath;
@property (readonly) int errNo;
# endif

/*!
 * @brief Creates a new, autoreleased link failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param sourcePath The source for the link
 * @param destinationPath The destination for the link
 * @return A new, autoreleased link failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			sourcePath: (OFString*)sourcePath
		   destinationPath: (OFString*)destinationPath;

/*!
 * @brief Initializes an already allocated link failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param sourcePath The source for the link
 * @param destinationPath The destination for the link
 * @return An initialized link failed exception
 */
-   initWithClass: (Class)class_
       sourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns a string with the source for the link.
 *
 * @return A string with the source for the link
 */
- (OFString*)sourcePath;

/*!
 * @brief Returns a string with the destination for the link.
 *
 * @return A string with the destination for the link
 */
- (OFString*)destinationPath;







@end
#endif







|

















<




|
<





<




<
|


<
<
<
<
<
<
<













>
>
>
>
>
>
>


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39
40
41

42
43
44
45
46

47
48
49
50

51
52
53







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

#ifdef OF_HAVE_LINK
/*!
 * @brief An exception indicating that creating a link failed.
 */
@interface OFLinkFailedException: OFException
{
	OFString *_sourcePath, *_destinationPath;
	int _errNo;
}

# ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *sourcePath, *destinationPath;
@property (readonly) int errNo;
# endif

/*!
 * @brief Creates a new, autoreleased link failed exception.
 *

 * @param sourcePath The source for the link
 * @param destinationPath The destination for the link
 * @return A new, autoreleased link failed exception
 */
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath

		   destinationPath: (OFString*)destinationPath;

/*!
 * @brief Initializes an already allocated link failed exception.
 *

 * @param sourcePath The source for the link
 * @param destinationPath The destination for the link
 * @return An initialized link failed exception
 */

- initWithSourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath;








/*!
 * @brief Returns a string with the source for the link.
 *
 * @return A string with the source for the link
 */
- (OFString*)sourcePath;

/*!
 * @brief Returns a string with the destination for the link.
 *
 * @return A string with the destination for the link
 */
- (OFString*)destinationPath;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end
#endif

Modified src/exceptions/OFLinkFailedException.m from [a892f44d4d] to [2c1c49820b].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdlib.h>

#import "OFLinkFailedException.h"
#import "OFString.h"

#import "common.h"

#ifndef _WIN32
@implementation OFLinkFailedException
+ (instancetype)exceptionWithClass: (Class)class
			sourcePath: (OFString*)sourcePath
		   destinationPath: (OFString*)destinationPath
{
	return [[[self alloc] initWithClass: class
				 sourcePath: sourcePath
			    destinationPath: destinationPath] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

-   initWithClass: (Class)class
       sourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath
{
	self = [super initWithClass: class];

	@try {
		_sourcePath = [sourcePath copy];
		_destinationPath = [destinationPath copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];







|

|
<


|
<



|











<
|


|







19
20
21
22
23
24
25
26
27
28

29
30
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56
57
#include <stdlib.h>

#import "OFLinkFailedException.h"
#import "OFString.h"

#import "common.h"

#ifdef OF_HAVE_LINK
@implementation OFLinkFailedException
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath

		   destinationPath: (OFString*)destinationPath
{
	return [[[self alloc] initWithSourcePath: sourcePath

			    destinationPath: destinationPath] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithSourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath
{
	self = [super init];

	@try {
		_sourcePath = [sourcePath copy];
		_destinationPath = [destinationPath copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95





96
97

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to link file %@ to %@ in class %@! " ERRFMT, _sourcePath,
	    _destinationPath, _inClass, ERRPARAM];
}

- (int)errNo
{
	return _errNo;
}

- (OFString*)sourcePath
{
	OF_GETTER(_sourcePath, false)
}

- (OFString*)destinationPath
{
	OF_GETTER(_destinationPath, false)
}





@end
#endif







|
|
<
<
<
<
<











>
>
>
>
>


68
69
70
71
72
73
74
75
76





77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to link file %@ to %@! " ERRFMT, _sourcePath,
	    _destinationPath, ERRPARAM];





}

- (OFString*)sourcePath
{
	OF_GETTER(_sourcePath, false)
}

- (OFString*)destinationPath
{
	OF_GETTER(_destinationPath, false)
}

- (int)errNo
{
	return _errNo;
}
@end
#endif

Modified src/exceptions/OFListenFailedException.h from [1610493659] to [e2ca28aebd].

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@property (readonly, retain, nonatomic) OFTCPSocket *socket;
@property (readonly) int backLog, errNo;
#endif

/*!
 * @brief Creates a new, autoreleased listen failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which failed to listen
 * @param backLog The requested size of the back log
 * @return A new, autoreleased listen failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    socket: (OFTCPSocket*)socket
			   backLog: (int)backLog;

/*!
 * @brief Initializes an already allocated listen failed exception
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which failed to listen
 * @param backLog The requested size of the back log
 * @return An initialized listen failed exception
 */
- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket
	backLog: (int)backLog;

/*!
 * @brief Returns the socket which failed to listen.
 *
 * @return The socket which failed to listen
 */







<




|
<





<




<
|







35
36
37
38
39
40
41

42
43
44
45
46

47
48
49
50
51

52
53
54
55

56
57
58
59
60
61
62
63
@property (readonly, retain, nonatomic) OFTCPSocket *socket;
@property (readonly) int backLog, errNo;
#endif

/*!
 * @brief Creates a new, autoreleased listen failed exception.
 *

 * @param socket The socket which failed to listen
 * @param backLog The requested size of the back log
 * @return A new, autoreleased listen failed exception
 */
+ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket

			   backLog: (int)backLog;

/*!
 * @brief Initializes an already allocated listen failed exception
 *

 * @param socket The socket which failed to listen
 * @param backLog The requested size of the back log
 * @return An initialized listen failed exception
 */

- initWithSocket: (OFTCPSocket*)socket
	backLog: (int)backLog;

/*!
 * @brief Returns the socket which failed to listen.
 *
 * @return The socket which failed to listen
 */

Modified src/exceptions/OFListenFailedException.m from [4897d5930c] to [826b1a07e4].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#import "OFListenFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFListenFailedException
+ (instancetype)exceptionWithClass: (Class)class
			    socket: (OFTCPSocket*)socket
			   backLog: (int)backLog
{
	return [[[self alloc] initWithClass: class
				     socket: socket
				    backLog: backLog] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 socket: (OFTCPSocket*)socket
	backLog: (int)backLog
{
	self = [super initWithClass: class];

	_socket  = [socket retain];
	_backLog = backLog;
	_errNo   = GET_SOCK_ERRNO;

	return self;
}

- (void)dealloc
{
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to listen in socket of type %@ with a back log of %d! "
	    ERRFMT, _inClass, _backLog, ERRPARAM];
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}








|
<


|
<



|











<
|


|



















|







21
22
23
24
25
26
27
28

29
30
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#import "OFListenFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFListenFailedException
+ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket

			   backLog: (int)backLog
{
	return [[[self alloc] initWithSocket: socket

				    backLog: backLog] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithSocket: (OFTCPSocket*)socket
	backLog: (int)backLog
{
	self = [super init];

	_socket  = [socket retain];
	_backLog = backLog;
	_errNo   = GET_SOCK_ERRNO;

	return self;
}

- (void)dealloc
{
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to listen in socket of type %@ with a back log of %d! "
	    ERRFMT, [_socket class], _backLog, ERRPARAM];
}

- (OFTCPSocket*)socket
{
	OF_GETTER(_socket, false)
}

Modified src/exceptions/OFLockFailedException.h from [2b07e05b3e] to [6a3162b4c6].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFLocking> lock;
#endif

/*!
 * @brief Creates a new, autoreleased lock failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param lock The lock which could not be locked
 * @return A new, autoreleased lock failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      lock: (id <OFLocking>)lock;

/*!
 * @brief Initializes an already allocated lock failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param lock The lock which could not be locked
 * @return An initialized lock failed exception
 */
- initWithClass: (Class)class_
	   lock: (id <OFLocking>)lock;

/*!
 * @brief Returns the lock which could not be locked.
 *
 * @return The lock which could not be locked
 */
- (id <OFLocking>)lock;
@end







<



|
<




<



<
|








28
29
30
31
32
33
34

35
36
37
38

39
40
41
42

43
44
45

46
47
48
49
50
51
52
53
54
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFLocking> lock;
#endif

/*!
 * @brief Creates a new, autoreleased lock failed exception.
 *

 * @param lock The lock which could not be locked
 * @return A new, autoreleased lock failed exception
 */
+ (instancetype)exceptionWithLock: (id <OFLocking>)lock;


/*!
 * @brief Initializes an already allocated lock failed exception.
 *

 * @param lock The lock which could not be locked
 * @return An initialized lock failed exception
 */

- initWithLock: (id <OFLocking>)lock;

/*!
 * @brief Returns the lock which could not be locked.
 *
 * @return The lock which could not be locked
 */
- (id <OFLocking>)lock;
@end

Modified src/exceptions/OFLockFailedException.m from [3e3ea0f0d5] to [228ff4b707].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

51
52

53
54
55
56
57
58
59
60
 */

#include "config.h"

#import "OFLockFailedException.h"
#import "OFString.h"

#import "macros.h"

@implementation OFLockFailedException
+ (instancetype)exceptionWithClass: (Class)class
			      lock: (id <OFLocking>)lock
{
	return [[[self alloc] initWithClass: class
				       lock: lock] autorelease];
}

- initWithClass: (Class)class
	   lock: (id <OFLocking>)lock
{
	self = [super initWithClass: class];

	_lock = [lock retain];

	return self;
}

- (void)dealloc
{
	[_lock release];

	[super dealloc];
}

- (OFString*)description
{

	return [OFString stringWithFormat:
	    @"A lock of type %@ could not be locked in class %@!",

	    [_lock class], _inClass];
}

- (id <OFLocking>)lock
{
	OF_GETTER(_lock, false)
}
@end







|


|
<

|
<


<
|

|















>

|
>
|







15
16
17
18
19
20
21
22
23
24
25

26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 */

#include "config.h"

#import "OFLockFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFLockFailedException
+ (instancetype)exceptionWithLock: (id <OFLocking>)lock

{
	return [[[self alloc] initWithLock: lock] autorelease];

}


- initWithLock: (id <OFLocking>)lock
{
	self = [super init];

	_lock = [lock retain];

	return self;
}

- (void)dealloc
{
	[_lock release];

	[super dealloc];
}

- (OFString*)description
{
	if (_lock != nil)
	return [OFString stringWithFormat:
		    @"A lock of type %@ could not be locked!", [_lock class]];
	else
		return @"A lock could not be locked!";
}

- (id <OFLocking>)lock
{
	OF_GETTER(_lock, false)
}
@end

Modified src/exceptions/OFMalformedXMLException.h from [d4ce063be2] to [e26d3a6383].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFXMLParser *parser;
#endif

/*!
 * @brief Creates a new, autoreleased malformed XML exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param parser The parser which encountered malformed XML
 * @return A new, autoreleased malformed XML exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    parser: (OFXMLParser*)parser;

/*!
 * @brief Initializes an already allocated malformed XML exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param parser The parser which encountered malformed XML
 * @return An initialized malformed XML exception
 */
- initWithClass: (Class)class_
	 parser: (OFXMLParser*)parser;

/*!
 * @brief Returns the parser which encountered malformed XML.
 *
 * @return The parser which encountered malformed XML
 */
- (OFXMLParser*)parser;
@end







<



|
<




<



<
|








29
30
31
32
33
34
35

36
37
38
39

40
41
42
43

44
45
46

47
48
49
50
51
52
53
54
55
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFXMLParser *parser;
#endif

/*!
 * @brief Creates a new, autoreleased malformed XML exception.
 *

 * @param parser The parser which encountered malformed XML
 * @return A new, autoreleased malformed XML exception
 */
+ (instancetype)exceptionWithParser: (OFXMLParser*)parser;


/*!
 * @brief Initializes an already allocated malformed XML exception.
 *

 * @param parser The parser which encountered malformed XML
 * @return An initialized malformed XML exception
 */

- initWithParser: (OFXMLParser*)parser;

/*!
 * @brief Returns the parser which encountered malformed XML.
 *
 * @return The parser which encountered malformed XML
 */
- (OFXMLParser*)parser;
@end

Modified src/exceptions/OFMalformedXMLException.m from [e6f9f183de] to [6866baec36].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#import "OFMalformedXMLException.h"
#import "OFString.h"
#import "OFXMLParser.h"

#import "common.h"

@implementation OFMalformedXMLException
+ (instancetype)exceptionWithClass: (Class)class
			    parser: (OFXMLParser*)parser
{
	return [[[self alloc] initWithClass: class
				     parser: parser] autorelease];
}

- initWithClass: (Class)class
	 parser: (OFXMLParser*)parser
{
	self = [super initWithClass: class];

	_parser = [parser retain];

	return self;
}

- (void)dealloc
{
	[_parser release];

	[super dealloc];
}

- (OFString*)description
{
	if (_parser != nil)
		return [OFString stringWithFormat:
		    @"The XML parser in class %@ encountered malformed XML in "
		    @"line %zd!", _inClass, [_parser lineNumber]];
	else
		return @"An XML parser encountered malformed XML!";
}

- (OFXMLParser*)parser
{
	OF_GETTER(_parser, false)
}
@end







|
<

|
<


<
|

|

















|
|









19
20
21
22
23
24
25
26

27
28

29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#import "OFMalformedXMLException.h"
#import "OFString.h"
#import "OFXMLParser.h"

#import "common.h"

@implementation OFMalformedXMLException
+ (instancetype)exceptionWithParser: (OFXMLParser*)parser

{
	return [[[self alloc] initWithParser: parser] autorelease];

}


- initWithParser: (OFXMLParser*)parser
{
	self = [super init];

	_parser = [parser retain];

	return self;
}

- (void)dealloc
{
	[_parser release];

	[super dealloc];
}

- (OFString*)description
{
	if (_parser != nil)
		return [OFString stringWithFormat:
		    @"An XML parser of type %@ encountered malformed XML in "
		    @"line %zd!", [_parser class], [_parser lineNumber]];
	else
		return @"An XML parser encountered malformed XML!";
}

- (OFXMLParser*)parser
{
	OF_GETTER(_parser, false)
}
@end

Modified src/exceptions/OFMemoryNotPartOfObjectException.h from [711c041b2a] to [c07cfbf85b].

18
19
20
21
22
23
24

25
26
27
28

29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
44
45

46
47
48
49

50
51
52
53
54
55
56







57

/*!
 * @brief An exception indicating the given memory is not part of the object.
 */
@interface OFMemoryNotPartOfObjectException: OFException
{
	void *_pointer;

}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) void *pointer;

#endif

/*!
 * @brief Creates a new, autoreleased memory not part of object exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param pointer A pointer to the memory that is not part of the object

 * @return A new, autoreleased memory not part of object exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			   pointer: (void*)pointer;

/*!
 * @brief Initializes an already allocated memory not part of object exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param pointer A pointer to the memory that is not part of the object

 * @return An initialized memory not part of object exception
 */
- initWithClass: (Class)class_
	pointer: (void*)pointer;


/*!
 * @brief Returns a pointer to the memory which is not part of the object.
 *
 * @return A pointer to the memory which is not part of the object
 */
- (void*)pointer;







@end







>




>





<

>


|
|




<

>


<
|
>







>
>
>
>
>
>
>

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
44
45

46
47
48
49

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

/*!
 * @brief An exception indicating the given memory is not part of the object.
 */
@interface OFMemoryNotPartOfObjectException: OFException
{
	void *_pointer;
	id _object;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) void *pointer;
@property (readonly, retain, nonatomic) id object;
#endif

/*!
 * @brief Creates a new, autoreleased memory not part of object exception.
 *

 * @param pointer A pointer to the memory that is not part of the object
 * @param object The object which the memory is not part of
 * @return A new, autoreleased memory not part of object exception
 */
+ (instancetype)exceptionWithPointer: (void*)pointer
			      object: (id)object;

/*!
 * @brief Initializes an already allocated memory not part of object exception.
 *

 * @param pointer A pointer to the memory that is not part of the object
 * @param object The object which the memory is not part of
 * @return An initialized memory not part of object exception
 */

- initWithPointer: (void*)pointer
	   object: (id)object;

/*!
 * @brief Returns a pointer to the memory which is not part of the object.
 *
 * @return A pointer to the memory which is not part of the object
 */
- (void*)pointer;

/*!
 * @brief Returns the object which the memory is not part of.
 *
 * @return The object which the memory is not part of
 */
- (id)object;
@end

Modified src/exceptions/OFMemoryNotPartOfObjectException.m from [59ada58b51] to [c419e3c092].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49

50
51
52







53
54
55
56
57
58
59
60
61
62
63
64
65
66





67

#include <stdlib.h>

#import "OFMemoryNotPartOfObjectException.h"
#import "OFString.h"

@implementation OFMemoryNotPartOfObjectException
+ (instancetype)exceptionWithClass: (Class)class
			   pointer: (void*)pointer
{
	return [[[self alloc] initWithClass: class
				    pointer: pointer] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	pointer: (void*)pointer

{
	self = [super initWithClass: class];

	_pointer = pointer;


	return self;
}








- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Memory at %p was not allocated as part of object of class %@, "
	    @"thus the memory allocation was not changed! It is also possible "
	    @"that there was an attempt to free the same memory twice.",
	    _pointer, _inClass];
}

- (void*)pointer
{
	return _pointer;
}





@end







|
|

|
|


|











<
|
>

|


>



>
>
>
>
>
>
>




|


|






>
>
>
>
>

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

#include <stdlib.h>

#import "OFMemoryNotPartOfObjectException.h"
#import "OFString.h"

@implementation OFMemoryNotPartOfObjectException
+ (instancetype)exceptionWithPointer: (void*)pointer
			      object: (id)object
{
	return [[[self alloc] initWithPointer: pointer
				       object: object] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithPointer: (void*)pointer
	   object: (id)object
{
	self = [super init];

	_pointer = pointer;
	_object = [object retain];

	return self;
}

- (void)dealloc
{
	[_object release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Memory at %p was not allocated as part of object of type %@, "
	    @"thus the memory allocation was not changed! It is also possible "
	    @"that there was an attempt to free the same memory twice.",
	    _pointer, [_object class]];
}

- (void*)pointer
{
	return _pointer;
}

- (id)object
{
	return _object;
}
@end

Modified src/exceptions/OFNotConnectedException.h from [78d1f92282] to [6e928fd0ee].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFStreamSocket *socket;
#endif

/*!
 * @brief Creates a new, autoreleased not connected exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which is not connected
 * @return A new, autoreleased not connected exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    socket: (OFStreamSocket*)socket;

/*!
 * @brief Initializes an already allocated not connected exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param socket The socket which is not connected
 * @return An initialized not connected exception
 */
- initWithClass: (Class)class_
	 socket: (OFStreamSocket*)socket;

/*!
 * @brief Returns the socket which is not connected.
 *
 * @return The socket which is not connected
 */
- (OFStreamSocket*)socket;
@end







<



|
<




<



<
|








33
34
35
36
37
38
39

40
41
42
43

44
45
46
47

48
49
50

51
52
53
54
55
56
57
58
59
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFStreamSocket *socket;
#endif

/*!
 * @brief Creates a new, autoreleased not connected exception.
 *

 * @param socket The socket which is not connected
 * @return A new, autoreleased not connected exception
 */
+ (instancetype)exceptionWithSocket: (OFStreamSocket*)socket;


/*!
 * @brief Initializes an already allocated not connected exception.
 *

 * @param socket The socket which is not connected
 * @return An initialized not connected exception
 */

- initWithSocket: (OFStreamSocket*)socket;

/*!
 * @brief Returns the socket which is not connected.
 *
 * @return The socket which is not connected
 */
- (OFStreamSocket*)socket;
@end

Modified src/exceptions/OFNotConnectedException.m from [aa4875b712] to [4793cd3e58].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

68
69
70
71
72
73
74
#import "OFNotConnectedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFNotConnectedException
+ (instancetype)exceptionWithClass: (Class)class
			    socket: (OFStreamSocket*)socket
{
	return [[[self alloc] initWithClass: class
				     socket: socket] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 socket: (OFStreamSocket*)socket
{
	self = [super initWithClass: class];

	_socket = [socket retain];

	return self;
}

- (void)dealloc
{
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The socket of type %@ is not connected or bound!", _inClass];

}

- (OFStreamSocket*)socket
{
	OF_GETTER(_socket, false)
}
@end







|
<

|
<


|











<
|

|
















|
>







21
22
23
24
25
26
27
28

29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#import "OFNotConnectedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFNotConnectedException
+ (instancetype)exceptionWithSocket: (OFStreamSocket*)socket

{
	return [[[self alloc] initWithSocket: socket] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithSocket: (OFStreamSocket*)socket
{
	self = [super init];

	_socket = [socket retain];

	return self;
}

- (void)dealloc
{
	[_socket release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The socket of type %@ is not connected or bound!",
	    [_socket class]];
}

- (OFStreamSocket*)socket
{
	OF_GETTER(_socket, false)
}
@end

Modified src/exceptions/OFNotImplementedException.h from [0e5ad9eeda] to [c744f2f9d8].

19
20
21
22
23
24
25

26
27
28
29

30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
45
46

47
48
49
50

51
52
53
54
55
56
57







58
/*!
 * @brief An exception indicating that a method or part of it is not
 *        implemented.
 */
@interface OFNotImplementedException: OFException
{
	SEL _selector;

}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) SEL selector;

#endif

/*!
 * @brief Creates a new, autoreleased not implemented exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param selector The selector which is not or not fully implemented

 * @return A new, autoreleased not implemented exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			  selector: (SEL)selector;

/*!
 * @brief Initializes an already allocated not implemented exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param selector The selector which is not or not fully implemented

 * @return An initialized not implemented exception
 */
- initWithClass: (Class)class_
       selector: (SEL)selector;


/*!
 * @brief Returns the selector which is not or not fully implemented.
 *
 * @return The selector which is not or not fully implemented
 */
- (SEL)selector;







@end







>




>





<

>


|
|




<

>


<
|
>







>
>
>
>
>
>
>

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
45
46

47
48
49
50

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*!
 * @brief An exception indicating that a method or part of it is not
 *        implemented.
 */
@interface OFNotImplementedException: OFException
{
	SEL _selector;
	id _object;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) SEL selector;
@property (readonly, retain, nonatomic) id object;
#endif

/*!
 * @brief Creates a new, autoreleased not implemented exception.
 *

 * @param selector The selector which is not or not fully implemented
 * @param object The object which does not (fully) implement the selector
 * @return A new, autoreleased not implemented exception
 */
+ (instancetype)exceptionWithSelector: (SEL)selector
			       object: (id)object;

/*!
 * @brief Initializes an already allocated not implemented exception.
 *

 * @param selector The selector which is not or not fully implemented
 * @param object The object which does not (fully) implement the selector
 * @return An initialized not implemented exception
 */

- initWithSelector: (SEL)selector
	    object: (id)object;

/*!
 * @brief Returns the selector which is not or not fully implemented.
 *
 * @return The selector which is not or not fully implemented
 */
- (SEL)selector;

/*!
 * @brief Returns the object which does not (fully) implement the selector.
 *
 * @return The object which does not (fully) implement the selector
 */
- (id)object;
@end

Modified src/exceptions/OFNotImplementedException.m from [08c4d073ff] to [a874727b43].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

48
49
50
51

52
53
54







55
56
57
58
59
60
61
62
63
64
65
66





67

#import "OFNotImplementedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFNotImplementedException
+ (instancetype)exceptionWithClass: (Class)class
			  selector: (SEL)selector
{
	return [[[self alloc] initWithClass: class
				   selector: selector] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
       selector: (SEL)selector

{
	self = [super initWithClass: class];

	_selector = selector;


	return self;
}








- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The selector %s is not understood by class %@ or not (fully) "
	    @"implemented!", sel_getName(_selector), _inClass];
}

- (SEL)selector
{
	return _selector;
}





@end







|
|

|
|


|











<
|
>

|


>



>
>
>
>
>
>
>




|
|






>
>
>
>
>

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

#import "OFNotImplementedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFNotImplementedException
+ (instancetype)exceptionWithSelector: (SEL)selector
			       object: (id)object
{
	return [[[self alloc] initWithSelector: selector
					object: object] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithSelector: (SEL)selector
	    object: (id)object
{
	self = [super init];

	_selector = selector;
	_object = [object retain];

	return self;
}

- (void)dealloc
{
	[_object release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The selector %s is not understood by an object of type %@ or not "
	    @"(fully) implemented!", sel_getName(_selector), [_object class]];
}

- (SEL)selector
{
	return _selector;
}

- (id)object
{
	return _object;
}
@end

Modified src/exceptions/OFOpenFileFailedException.h from [5b0e6f089a] to [73e116f3c1].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77







78
@property (readonly, copy, nonatomic) OFString *path, *mode;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased open file failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path A string with the path of the file tried to open
 * @param mode A string with the mode in which the file should have been opened
 * @return A new, autoreleased open file failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      path: (OFString*)path
			      mode: (OFString*)mode;

/*!
 * @brief Initializes an already allocated open file failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param path A string with the path of the file which couldn't be opened
 * @param mode A string with the mode in which the file should have been opened
 * @return An initialized open file failed exception
 */
- initWithClass: (Class)class_
	   path: (OFString*)path
	   mode: (OFString*)mode;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns a string with the path of the file which couldn't be opened.
 *
 * @return A string with the path of the file which couldn't be opened
 */
- (OFString*)path;

/*!
 * @brief Returns a string with the mode in which the file should have been
 *	  opened.
 *
 * @return A string with the mode in which the file should have been opened
 */
- (OFString*)mode;







@end







<




|
<





<




<
|


<
<
<
<
<
<
<














>
>
>
>
>
>
>

29
30
31
32
33
34
35

36
37
38
39
40

41
42
43
44
45

46
47
48
49

50
51
52







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@property (readonly, copy, nonatomic) OFString *path, *mode;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased open file failed exception.
 *

 * @param path A string with the path of the file tried to open
 * @param mode A string with the mode in which the file should have been opened
 * @return A new, autoreleased open file failed exception
 */
+ (instancetype)exceptionWithPath: (OFString*)path

			      mode: (OFString*)mode;

/*!
 * @brief Initializes an already allocated open file failed exception.
 *

 * @param path A string with the path of the file which couldn't be opened
 * @param mode A string with the mode in which the file should have been opened
 * @return An initialized open file failed exception
 */

- initWithPath: (OFString*)path
	   mode: (OFString*)mode;








/*!
 * @brief Returns a string with the path of the file which couldn't be opened.
 *
 * @return A string with the path of the file which couldn't be opened
 */
- (OFString*)path;

/*!
 * @brief Returns a string with the mode in which the file should have been
 *	  opened.
 *
 * @return A string with the mode in which the file should have been opened
 */
- (OFString*)mode;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/exceptions/OFOpenFileFailedException.m from [1c310618be] to [81dda45767].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

#import "OFOpenFileFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFOpenFileFailedException
+ (instancetype)exceptionWithClass: (Class)class
			      path: (OFString*)path
			      mode: (OFString*)mode
{
	return [[[self alloc] initWithClass: class
				       path: path
				       mode: mode] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	   path: (OFString*)path
	   mode: (OFString*)mode
{
	self = [super initWithClass: class];

	@try {
		_path  = [path copy];
		_mode  = [mode copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];







|
<


|
<



|











<
|


|







20
21
22
23
24
25
26
27

28
29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56

#import "OFOpenFileFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFOpenFileFailedException
+ (instancetype)exceptionWithPath: (OFString*)path

			      mode: (OFString*)mode
{
	return [[[self alloc] initWithPath: path

				       mode: mode] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithPath: (OFString*)path
	   mode: (OFString*)mode
{
	self = [super init];

	@try {
		_path  = [path copy];
		_mode  = [mode copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94





95

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to open file %@ with mode %@ in class %@! " ERRFMT, _path,
	    _mode, _inClass, ERRPARAM];
}

- (int)errNo
{
	return _errNo;
}

- (OFString*)path
{
	OF_GETTER(_path, false)
}

- (OFString*)mode
{
	OF_GETTER(_mode, false)
}





@end







|
|
<
<
<
<
<











>
>
>
>
>

67
68
69
70
71
72
73
74
75





76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to open file %@ with mode %@! " ERRFMT, _path, _mode,
	    ERRPARAM];





}

- (OFString*)path
{
	OF_GETTER(_path, false)
}

- (OFString*)mode
{
	OF_GETTER(_mode, false)
}

- (int)errNo
{
	return _errNo;
}
@end

Modified src/exceptions/OFOutOfMemoryException.h from [fbe9775a49] to [d2a3fed0e6].

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifdef OF_HAVE_PROPERTIES
@property (readonly) size_t requestedSize;
#endif

/*!
 * @brief Creates a new, autoreleased no memory exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param requestedSize The size of the memory that couldn't be allocated
 * @return A new, autoreleased no memory exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
		     requestedSize: (size_t)requestedSize;

/*!
 * @brief Initializes an already allocated no memory exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param requestedSize The size of the memory that couldn't be allocated
 * @return An initialized no memory exception
 */
- initWithClass: (Class)class_
  requestedSize: (size_t)requestedSize;

/*!
 * @brief Returns the size of the memoory that couldn't be allocated.
 *
 * @return The size of the memoory that couldn't be allocated
 */
- (size_t)requestedSize;
@end







<



|
<




<



<
|








27
28
29
30
31
32
33

34
35
36
37

38
39
40
41

42
43
44

45
46
47
48
49
50
51
52
53
#ifdef OF_HAVE_PROPERTIES
@property (readonly) size_t requestedSize;
#endif

/*!
 * @brief Creates a new, autoreleased no memory exception.
 *

 * @param requestedSize The size of the memory that couldn't be allocated
 * @return A new, autoreleased no memory exception
 */
+ (instancetype)exceptionWithRequestedSize: (size_t)requestedSize;


/*!
 * @brief Initializes an already allocated no memory exception.
 *

 * @param requestedSize The size of the memory that couldn't be allocated
 * @return An initialized no memory exception
 */

- initWithRequestedSize: (size_t)requestedSize;

/*!
 * @brief Returns the size of the memoory that couldn't be allocated.
 *
 * @return The size of the memoory that couldn't be allocated
 */
- (size_t)requestedSize;
@end

Modified src/exceptions/OFOutOfMemoryException.m from [598df3b1e8] to [f7d76a1e20].

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

#include "config.h"

#import "OFOutOfMemoryException.h"
#import "OFString.h"

@implementation OFOutOfMemoryException
+ (instancetype)exceptionWithClass: (Class)class
		     requestedSize: (size_t)requestedSize
{
	return [[[self alloc] initWithClass: class
			      requestedSize: requestedSize] autorelease];
}

- initWithClass: (Class)class
  requestedSize: (size_t)requestedSize
{
	self = [super initWithClass: class];

	_requestedSize = requestedSize;

	return self;
}

- (OFString*)description
{
	if (_requestedSize != 0)
		return [OFString stringWithFormat:
		    @"Could not allocate %zu bytes in class %@!",
		    _requestedSize, _inClass];
	else
		return [OFString stringWithFormat:
		    @"Could not allocate enough memory in class %@!", _inClass];
}

- (size_t)requestedSize
{
	return _requestedSize;
}
@end







|
<

|
|


<
|

|










|
<

<
|







16
17
18
19
20
21
22
23

24
25
26
27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42

43

44
45
46
47
48
49
50
51

#include "config.h"

#import "OFOutOfMemoryException.h"
#import "OFString.h"

@implementation OFOutOfMemoryException
+ (instancetype)exceptionWithRequestedSize: (size_t)requestedSize

{
	return [[[self alloc]
	    initWithRequestedSize: requestedSize] autorelease];
}


- initWithRequestedSize: (size_t)requestedSize
{
	self = [super init];

	_requestedSize = requestedSize;

	return self;
}

- (OFString*)description
{
	if (_requestedSize != 0)
		return [OFString stringWithFormat:
		    @"Could not allocate %zu bytes!", _requestedSize];

	else

		return @"Could not allocate enough memory!";
}

- (size_t)requestedSize
{
	return _requestedSize;
}
@end

Modified src/exceptions/OFOutOfRangeException.m from [7a69a18b2f] to [23330f8669].

18
19
20
21
22
23
24
25
26
27
28

#import "OFOutOfRangeException.h"
#import "OFString.h"

@implementation OFOutOfRangeException
- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Value out of range in class %@!", _inClass];
}
@end







<
|


18
19
20
21
22
23
24

25
26
27

#import "OFOutOfRangeException.h"
#import "OFString.h"

@implementation OFOutOfRangeException
- (OFString*)description
{

	return @"Value out of range!";
}
@end

Modified src/exceptions/OFReadFailedException.m from [310691b3aa] to [5b0d85c885].

21
22
23
24
25
26
27
28
29
30
31

#import "common.h"

@implementation OFReadFailedException
- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to read %zu bytes in class %@! " ERRFMT, _requestedLength,
	    _inClass, ERRPARAM];
}
@end







|
|


21
22
23
24
25
26
27
28
29
30
31

#import "common.h"

@implementation OFReadFailedException
- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to read %zu bytes in a stream of type %@! " ERRFMT,
	    _requestedLength, [_stream class], ERRPARAM];
}
@end

Modified src/exceptions/OFReadOrWriteFailedException.h from [9ca5afb590] to [5f7c7893d9].

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@property (readonly) size_t requestedLength;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased read or write failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param stream The stream which caused the read or write failed exception
 * @param requestedLength The requested length of the data that couldn't be
 *			  read / written
 * @return A new, autoreleased read or write failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    stream: (OFStream*)stream
		   requestedLength: (size_t)requestedLength;

/*!
 * @brief Initializes an already allocated read or write failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param stream The stream which caused the read or write failed exception
 * @param requestedLength The requested length of the data that couldn't be
 *			  read / written
 * @return A new open file failed exception
 */
-   initWithClass: (Class)class_
	   stream: (OFStream*)stream
  requestedLength: (size_t)requestedLength;

/*!
 * @brief Returns the stream which caused the read or write failed exception.
 *
 * @return The stream which caused the read or write failed exception
 */







<





|
<





<





<
|







34
35
36
37
38
39
40

41
42
43
44
45
46

47
48
49
50
51

52
53
54
55
56

57
58
59
60
61
62
63
64
@property (readonly) size_t requestedLength;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased read or write failed exception.
 *

 * @param stream The stream which caused the read or write failed exception
 * @param requestedLength The requested length of the data that couldn't be
 *			  read / written
 * @return A new, autoreleased read or write failed exception
 */
+ (instancetype)exceptionWithStream: (OFStream*)stream

		   requestedLength: (size_t)requestedLength;

/*!
 * @brief Initializes an already allocated read or write failed exception.
 *

 * @param stream The stream which caused the read or write failed exception
 * @param requestedLength The requested length of the data that couldn't be
 *			  read / written
 * @return A new open file failed exception
 */

-  initWithStream: (OFStream*)stream
  requestedLength: (size_t)requestedLength;

/*!
 * @brief Returns the stream which caused the read or write failed exception.
 *
 * @return The stream which caused the read or write failed exception
 */

Modified src/exceptions/OFReadOrWriteFailedException.m from [a5ac8c3823] to [81b4e6d457].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75







76
77
78
79
80
81
82
#ifdef OF_HAVE_SOCKETS
# import "OFStreamSocket.h"
#endif

#import "common.h"

@implementation OFReadOrWriteFailedException
+ (instancetype)exceptionWithClass: (Class)class
			    stream: (OFStream*)stream
		   requestedLength: (size_t)requestedLength
{
	return [[[self alloc] initWithClass: class
				     stream: stream
			    requestedLength: requestedLength] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

-   initWithClass: (Class)class
	   stream: (OFStream*)stream
  requestedLength: (size_t)requestedLength
{
	self = [super initWithClass: class];

	_stream = [stream retain];
	_requestedLength = requestedLength;

#ifdef OF_HAVE_SOCKETS
	if ([class isSubclassOfClass: [OFStreamSocket class]])
		_errNo = GET_SOCK_ERRNO;
	else
#endif
		_errNo = GET_ERRNO;

	return self;
}

- (void)dealloc
{
	[_stream release];

	[super dealloc];
}








- (OFStream*)stream
{
	OF_GETTER(_stream, false)
}

- (size_t)requestedLength







|
<


|
<



|











<
|


|





|














>
>
>
>
>
>
>







23
24
25
26
27
28
29
30

31
32
33

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifdef OF_HAVE_SOCKETS
# import "OFStreamSocket.h"
#endif

#import "common.h"

@implementation OFReadOrWriteFailedException
+ (instancetype)exceptionWithStream: (OFStream*)stream

		   requestedLength: (size_t)requestedLength
{
	return [[[self alloc] initWithStream: stream

			    requestedLength: requestedLength] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


-  initWithStream: (OFStream*)stream
  requestedLength: (size_t)requestedLength
{
	self = [super init];

	_stream = [stream retain];
	_requestedLength = requestedLength;

#ifdef OF_HAVE_SOCKETS
	if ([stream isKindOfClass: [OFStreamSocket class]])
		_errNo = GET_SOCK_ERRNO;
	else
#endif
		_errNo = GET_ERRNO;

	return self;
}

- (void)dealloc
{
	[_stream release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to read or write %zu bytes in a stream of type "
	    @"%@! " ERRFMT, _requestedLength, [_stream class], ERRPARAM];
}

- (OFStream*)stream
{
	OF_GETTER(_stream, false)
}

- (size_t)requestedLength

Modified src/exceptions/OFRenameFileFailedException.h from [0227ecc2e0] to [cfd8876f80].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76







77
@property (readonly, copy, nonatomic) OFString *sourcePath, *destinationPath;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased rename file failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param sourcePath The original path
 * @param destinationPath The new path
 * @return A new, autoreleased rename file failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			sourcePath: (OFString*)sourcePath
		   destinationPath: (OFString*)destinationPath;

/*!
 * @brief Initializes an already allocated rename failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param sourcePath The original path
 * @param destinationPath The new path
 * @return An initialized rename file failed exception
 */
-   initWithClass: (Class)class_
       sourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns the original path.
 *
 * @return The original path
 */
- (OFString*)sourcePath;

/*!
 * @brief Returns the new path.
 *
 * @return The new path
 */
- (OFString*)destinationPath;







@end







<




|
<





<




<
|


<
<
<
<
<
<
<













>
>
>
>
>
>
>

29
30
31
32
33
34
35

36
37
38
39
40

41
42
43
44
45

46
47
48
49

50
51
52







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
@property (readonly, copy, nonatomic) OFString *sourcePath, *destinationPath;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased rename file failed exception.
 *

 * @param sourcePath The original path
 * @param destinationPath The new path
 * @return A new, autoreleased rename file failed exception
 */
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath

		   destinationPath: (OFString*)destinationPath;

/*!
 * @brief Initializes an already allocated rename failed exception.
 *

 * @param sourcePath The original path
 * @param destinationPath The new path
 * @return An initialized rename file failed exception
 */

- initWithSourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath;








/*!
 * @brief Returns the original path.
 *
 * @return The original path
 */
- (OFString*)sourcePath;

/*!
 * @brief Returns the new path.
 *
 * @return The new path
 */
- (OFString*)destinationPath;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/exceptions/OFRenameFileFailedException.m from [dc6d7c619a] to [2a65fb8436].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

#import "OFRenameFileFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFRenameFileFailedException
+ (instancetype)exceptionWithClass: (Class)class
			sourcePath: (OFString*)sourcePath
		   destinationPath: (OFString*)destinationPath
{
	return [[[self alloc] initWithClass: class
				 sourcePath: sourcePath
			    destinationPath: destinationPath] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

-   initWithClass: (Class)class
       sourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath
{
	self = [super initWithClass: class];

	@try {
		_sourcePath = [sourcePath copy];
		_destinationPath = [destinationPath copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];







|
<


|
<



|











<
|


|







20
21
22
23
24
25
26
27

28
29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56

#import "OFRenameFileFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFRenameFileFailedException
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath

		   destinationPath: (OFString*)destinationPath
{
	return [[[self alloc] initWithSourcePath: sourcePath

			    destinationPath: destinationPath] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithSourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath
{
	self = [super init];

	@try {
		_sourcePath = [sourcePath copy];
		_destinationPath = [destinationPath copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94





95

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to rename file %@ to %@ in class %@! " ERRFMT,
	    _sourcePath, _destinationPath, _inClass, ERRPARAM];
}

- (int)errNo
{
	return _errNo;
}

- (OFString*)sourcePath
{
	OF_GETTER(_sourcePath, false)
}

- (OFString*)destinationPath
{
	OF_GETTER(_destinationPath, false)
}





@end







|
|
<
<
<
<
<











>
>
>
>
>

67
68
69
70
71
72
73
74
75





76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to rename file %@ to %@! " ERRFMT, _sourcePath,
	    _destinationPath, ERRPARAM];





}

- (OFString*)sourcePath
{
	OF_GETTER(_sourcePath, false)
}

- (OFString*)destinationPath
{
	OF_GETTER(_destinationPath, false)
}

- (int)errNo
{
	return _errNo;
}
@end

Modified src/exceptions/OFSeekFailedException.h from [0430f3b8bb] to [7209419737].

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
@property (readonly) off_t offset;
@property (readonly) int whence, errNo;
#endif

/*!
 * @brief Creates a new, autoreleased seek failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param stream The stream for which seeking failed
 * @param offset The offset to which seeking failed
 * @param whence To what the offset is relative
 * @return A new, autoreleased seek failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    stream: (OFSeekableStream*)stream
			    offset: (off_t)offset
			    whence: (int)whence;

/*!
 * @brief Initializes an already allocated seek failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param stream The stream for which seeking failed
 * @param offset The offset to which seeking failed
 * @param whence To what the offset is relative
 * @return An initialized seek failed exception
 */
- initWithClass: (Class)class_
	 stream: (OFSeekableStream*)stream
	 offset: (off_t)offset
	 whence: (int)whence;

/*!
 * @brief Returns the stream for which seeking failed.
 *
 * @return The stream for which seeking failed







<





|
<






<





<
|







35
36
37
38
39
40
41

42
43
44
45
46
47

48
49
50
51
52
53

54
55
56
57
58

59
60
61
62
63
64
65
66
@property (readonly) off_t offset;
@property (readonly) int whence, errNo;
#endif

/*!
 * @brief Creates a new, autoreleased seek failed exception.
 *

 * @param stream The stream for which seeking failed
 * @param offset The offset to which seeking failed
 * @param whence To what the offset is relative
 * @return A new, autoreleased seek failed exception
 */
+ (instancetype)exceptionWithStream: (OFSeekableStream*)stream

			    offset: (off_t)offset
			    whence: (int)whence;

/*!
 * @brief Initializes an already allocated seek failed exception.
 *

 * @param stream The stream for which seeking failed
 * @param offset The offset to which seeking failed
 * @param whence To what the offset is relative
 * @return An initialized seek failed exception
 */

- initWithStream: (OFSeekableStream*)stream
	 offset: (off_t)offset
	 whence: (int)whence;

/*!
 * @brief Returns the stream for which seeking failed.
 *
 * @return The stream for which seeking failed

Modified src/exceptions/OFSeekFailedException.m from [d5da00b403] to [b56aeff4f4].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

77
78
79
80
81
82
83
#import "OFSeekFailedException.h"
#import "OFString.h"
#import "OFSeekableStream.h"

#import "common.h"

@implementation OFSeekFailedException
+ (instancetype)exceptionWithClass: (Class)class
			    stream: (OFSeekableStream*)stream
			    offset: (off_t)offset
			    whence: (int)whence
{
	return [[[self alloc] initWithClass: class
				     stream: stream
				     offset: offset
				     whence: whence] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 stream: (OFSeekableStream*)stream
	 offset: (off_t)offset
	 whence: (int)whence
{
	self = [super initWithClass: class];

	_stream = [stream retain];
	_offset = offset;
	_whence = whence;
	_errNo = GET_ERRNO;

	return self;
}

- (void)dealloc
{
	[_stream release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Seeking failed in class %@! " ERRFMT, _inClass, ERRPARAM];

}

- (OFSeekableStream*)stream
{
	OF_GETTER(_stream, false)
}








|
<



|
<




|











<
|



|



















|
>







21
22
23
24
25
26
27
28

29
30
31
32

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#import "OFSeekFailedException.h"
#import "OFString.h"
#import "OFSeekableStream.h"

#import "common.h"

@implementation OFSeekFailedException
+ (instancetype)exceptionWithStream: (OFSeekableStream*)stream

			    offset: (off_t)offset
			    whence: (int)whence
{
	return [[[self alloc] initWithStream: stream

				     offset: offset
				     whence: whence] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithStream: (OFSeekableStream*)stream
	 offset: (off_t)offset
	 whence: (int)whence
{
	self = [super init];

	_stream = [stream retain];
	_offset = offset;
	_whence = whence;
	_errNo = GET_ERRNO;

	return self;
}

- (void)dealloc
{
	[_stream release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Seeking failed in stream of type %@! " ERRFMT, [_stream class],
	    ERRPARAM];
}

- (OFSeekableStream*)stream
{
	OF_GETTER(_stream, false)
}

Modified src/exceptions/OFSetOptionFailedException.h from [2d153af019] to [ecea3e530c].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFStream *stream;
#endif

/*!
 * @brief Creates a new, autoreleased set option failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param stream The stream for which the option could not be set
 * @return A new, autoreleased set option failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    stream: (OFStream*)stream;

/*!
 * @brief Initializes an already allocated set option failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param stream The stream for which the option could not be set
 * @return An initialized set option failed exception
 */
- initWithClass: (Class)class_
	 stream: (OFStream*)stream;

/*!
 * @brief Returns the stream for which the option could not be set.
 *
 * @return The stream for which the option could not be set
 */
- (OFStream*)stream;
@end







<



|
<




<



<
|








29
30
31
32
33
34
35

36
37
38
39

40
41
42
43

44
45
46

47
48
49
50
51
52
53
54
55
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFStream *stream;
#endif

/*!
 * @brief Creates a new, autoreleased set option failed exception.
 *

 * @param stream The stream for which the option could not be set
 * @return A new, autoreleased set option failed exception
 */
+ (instancetype)exceptionWithStream: (OFStream*)stream;


/*!
 * @brief Initializes an already allocated set option failed exception.
 *

 * @param stream The stream for which the option could not be set
 * @return An initialized set option failed exception
 */

- initWithStream: (OFStream*)stream;

/*!
 * @brief Returns the stream for which the option could not be set.
 *
 * @return The stream for which the option could not be set
 */
- (OFStream*)stream;
@end

Modified src/exceptions/OFSetOptionFailedException.m from [5401f8aab0] to [57d4b54c8c].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

68
69
70
71
72
73
74
#import "OFSetOptionFailedException.h"
#import "OFString.h"
#import "OFStream.h"

#import "common.h"

@implementation OFSetOptionFailedException
+ (instancetype)exceptionWithClass: (Class)class
			    stream: (OFStream*)stream
{
	return [[[self alloc] initWithClass: class
				     stream: stream] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 stream: (OFStream*)stream
{
	self = [super initWithClass: class];

	_stream = [stream retain];

	return self;
}

- (void)dealloc
{
	[_stream release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Setting an option in class %@ failed!", _inClass];

}

- (OFStream*)stream
{
	OF_GETTER(_stream, false)
}
@end







|
<

|
<


|











<
|

|
















|
>







21
22
23
24
25
26
27
28

29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#import "OFSetOptionFailedException.h"
#import "OFString.h"
#import "OFStream.h"

#import "common.h"

@implementation OFSetOptionFailedException
+ (instancetype)exceptionWithStream: (OFStream*)stream

{
	return [[[self alloc] initWithStream: stream] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithStream: (OFStream*)stream
{
	self = [super init];

	_stream = [stream retain];

	return self;
}

- (void)dealloc
{
	[_stream release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Setting an option in a stream of type %@ failed!",
	    [_stream class]];
}

- (OFStream*)stream
{
	OF_GETTER(_stream, false)
}
@end

Modified src/exceptions/OFStillLockedException.h from [cb52dc053c] to [d04ac10d66].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFLocking> lock;
#endif

/*!
 * @brief Creates a new, autoreleased still locked exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param lock The lock which is still locked
 * @return A new, autoreleased still locked exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      lock: (id <OFLocking>)lock;

/*!
 * @brief Initializes an already allocated still locked exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param lock The lock which is still locked
 * @return An initialized still locked exception
 */
- initWithClass: (Class)class_
	   lock: (id <OFLocking>)lock;

/*!
 * @brief Returns the lock which is still locked.
 *
 * @return The lock which is still locked
 */
- (id <OFLocking>)lock;
@end







<



|
<




<



<
|








28
29
30
31
32
33
34

35
36
37
38

39
40
41
42

43
44
45

46
47
48
49
50
51
52
53
54
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFLocking> lock;
#endif

/*!
 * @brief Creates a new, autoreleased still locked exception.
 *

 * @param lock The lock which is still locked
 * @return A new, autoreleased still locked exception
 */
+ (instancetype)exceptionWithLock: (id <OFLocking>)lock;


/*!
 * @brief Initializes an already allocated still locked exception.
 *

 * @param lock The lock which is still locked
 * @return An initialized still locked exception
 */

- initWithLock: (id <OFLocking>)lock;

/*!
 * @brief Returns the lock which is still locked.
 *
 * @return The lock which is still locked
 */
- (id <OFLocking>)lock;
@end

Modified src/exceptions/OFStillLockedException.m from [509b1a9438] to [ee03dade0c].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

51
52
53



54
55
56
57
58
59
60
 */

#include "config.h"

#import "OFStillLockedException.h"
#import "OFString.h"

#import "macros.h"

@implementation OFStillLockedException
+ (instancetype)exceptionWithClass: (Class)class
			      lock: (id <OFLocking>)lock
{
	return [[[self alloc] initWithClass: class
				       lock: lock] autorelease];
}

- initWithClass: (Class)class
	   lock: (id <OFLocking>)lock
{
	self = [super initWithClass: class];

	_lock = [lock retain];

	return self;
}

- (void)dealloc
{
	[_lock release];

	[super dealloc];
}

- (OFString*)description
{

	return [OFString stringWithFormat:
	    @"Deallocation of a lock of type %@ was tried in class %@, even "
	    @"though it was still locked!", [_lock class], _inClass];



}

- (id <OFLocking>)lock
{
	OF_GETTER(_lock, false)
}
@end







|


|
<

|
<


<
|

|















>

|
|
>
>
>







15
16
17
18
19
20
21
22
23
24
25

26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 */

#include "config.h"

#import "OFStillLockedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFStillLockedException
+ (instancetype)exceptionWithLock: (id <OFLocking>)lock

{
	return [[[self alloc] initWithLock: lock] autorelease];

}


- initWithLock: (id <OFLocking>)lock
{
	self = [super init];

	_lock = [lock retain];

	return self;
}

- (void)dealloc
{
	[_lock release];

	[super dealloc];
}

- (OFString*)description
{
	if (_lock != nil)
	return [OFString stringWithFormat:
		    @"Deallocation of a lock of type %@ even though it was "
		    @"still locked!", [_lock class]];
	else
		return @"Deallocation of a lock even though it was still "
		    @"locked!";
}

- (id <OFLocking>)lock
{
	OF_GETTER(_lock, false)
}
@end

Modified src/exceptions/OFSymlinkFailedException.h from [0ceec2f0f6] to [cfe7a552f7].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77







78
79
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

#ifndef _WIN32
/*!
 * @brief An exception indicating that creating a symlink failed.
 */
@interface OFSymlinkFailedException: OFException
{
	OFString *_sourcePath, *_destinationPath;
	int _errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *sourcePath, *destinationPath;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased symlink failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param sourcePath The source for the symlink
 * @param destinationPath The destination for the symlink
 * @return A new, autoreleased symlink failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			sourcePath: (OFString*)sourcePath
		   destinationPath: (OFString*)destinationPath;

/*!
 * @brief Initializes an already allocated symlink failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param sourcePath The source for the symlink
 * @param destinationPath The destination for the symlink
 * @return An initialized symlink failed exception
 */
-   initWithClass: (Class)class_
       sourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;

/*!
 * @brief Returns a string with the source for the symlink.
 *
 * @return A string with the source for the symlink
 */
- (OFString*)sourcePath;

/*!
 * @brief Returns a string with the destination for the symlink.
 *
 * @return A string with the destination for the symlink
 */
- (OFString*)destinationPath;







@end
#endif







|

















<




|
<





<




<
|


<
<
<
<
<
<
<













>
>
>
>
>
>
>


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39
40
41

42
43
44
45
46

47
48
49
50

51
52
53







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

#ifdef OF_HAVE_SYMLINK
/*!
 * @brief An exception indicating that creating a symlink failed.
 */
@interface OFSymlinkFailedException: OFException
{
	OFString *_sourcePath, *_destinationPath;
	int _errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *sourcePath, *destinationPath;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased symlink failed exception.
 *

 * @param sourcePath The source for the symlink
 * @param destinationPath The destination for the symlink
 * @return A new, autoreleased symlink failed exception
 */
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath

		   destinationPath: (OFString*)destinationPath;

/*!
 * @brief Initializes an already allocated symlink failed exception.
 *

 * @param sourcePath The source for the symlink
 * @param destinationPath The destination for the symlink
 * @return An initialized symlink failed exception
 */

- initWithSourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath;








/*!
 * @brief Returns a string with the source for the symlink.
 *
 * @return A string with the source for the symlink
 */
- (OFString*)sourcePath;

/*!
 * @brief Returns a string with the destination for the symlink.
 *
 * @return A string with the destination for the symlink
 */
- (OFString*)destinationPath;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end
#endif

Modified src/exceptions/OFSymlinkFailedException.m from [514ef35454] to [df9969ee16].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdlib.h>

#import "OFSymlinkFailedException.h"
#import "OFString.h"

#import "common.h"

#ifndef _WIN32
@implementation OFSymlinkFailedException
+ (instancetype)exceptionWithClass: (Class)class
			sourcePath: (OFString*)sourcePath
		   destinationPath: (OFString*)destinationPath
{
	return [[[self alloc] initWithClass: class
				 sourcePath: sourcePath
			    destinationPath: destinationPath] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

-   initWithClass: (Class)class
       sourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath
{
	self = [super initWithClass: class];

	@try {
		_sourcePath = [sourcePath copy];
		_destinationPath = [destinationPath copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];







|

|
<


|
<



|











<
|


|







19
20
21
22
23
24
25
26
27
28

29
30
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56
57
#include <stdlib.h>

#import "OFSymlinkFailedException.h"
#import "OFString.h"

#import "common.h"

#ifdef OF_HAVE_SYMLINK
@implementation OFSymlinkFailedException
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath

		   destinationPath: (OFString*)destinationPath
{
	return [[[self alloc] initWithSourcePath: sourcePath

			    destinationPath: destinationPath] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithSourcePath: (OFString*)sourcePath
  destinationPath: (OFString*)destinationPath
{
	self = [super init];

	@try {
		_sourcePath = [sourcePath copy];
		_destinationPath = [destinationPath copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95





96
97

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to symlink file %@ to %@ in class %@! " ERRFMT,
	    _sourcePath, _destinationPath, _inClass, ERRPARAM];
}

- (int)errNo
{
	return _errNo;
}

- (OFString*)sourcePath
{
	OF_GETTER(_sourcePath, false)
}

- (OFString*)destinationPath
{
	OF_GETTER(_destinationPath, false)
}





@end
#endif







|
|
<
<
<
<
<











>
>
>
>
>


68
69
70
71
72
73
74
75
76





77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to symlink file %@ to %@! " ERRFMT, _sourcePath,
	    _destinationPath, ERRPARAM];





}

- (OFString*)sourcePath
{
	OF_GETTER(_sourcePath, false)
}

- (OFString*)destinationPath
{
	OF_GETTER(_destinationPath, false)
}

- (int)errNo
{
	return _errNo;
}
@end
#endif

Modified src/exceptions/OFThreadJoinFailedException.h from [cce8752e74] to [24a339c50b].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFThread *thread;
#endif

/*!
 * @brief Creates a new, autoreleased thread join failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param thread The thread which could not be joined
 * @return A new, autoreleased thread join failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    thread: (OFThread*)thread;

/*!
 * @brief Initializes an already allocated thread join failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param thread The thread which could not be joined
 * @return An initialized thread join failed exception
 */
- initWithClass: (Class)class_
	 thread: (OFThread*)thread;

/*!
 * @brief Returns the thread which could not be joined.
 *
 * @return The thread which could not be joined
 */
- (OFThread*)thread;
@end







<



|
<




<



<
|








33
34
35
36
37
38
39

40
41
42
43

44
45
46
47

48
49
50

51
52
53
54
55
56
57
58
59
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFThread *thread;
#endif

/*!
 * @brief Creates a new, autoreleased thread join failed exception.
 *

 * @param thread The thread which could not be joined
 * @return A new, autoreleased thread join failed exception
 */
+ (instancetype)exceptionWithThread: (OFThread*)thread;


/*!
 * @brief Initializes an already allocated thread join failed exception.
 *

 * @param thread The thread which could not be joined
 * @return An initialized thread join failed exception
 */

- initWithThread: (OFThread*)thread;

/*!
 * @brief Returns the thread which could not be joined.
 *
 * @return The thread which could not be joined
 */
- (OFThread*)thread;
@end

Modified src/exceptions/OFThreadJoinFailedException.m from [8fca498969] to [aedf7e5de1].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdlib.h>

#import "OFThreadJoinFailedException.h"
#import "OFString.h"
#import "OFThread.h"

@implementation OFThreadJoinFailedException
+ (instancetype)exceptionWithClass: (Class)class
			    thread: (OFThread*)thread
{
	return [[[self alloc] initWithClass: class
				     thread: thread] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 thread: (OFThread*)thread
{
	self = [super initWithClass: class];

	_thread = [thread retain];

	return self;
}

- (void)dealloc
{
	[_thread release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Joining a thread of class %@ failed! Most likely, another thread "
	    @"already waits for the thread to join.", _inClass];
}

- (OFThread*)thread
{
	OF_GETTER(_thread, false)
}
@end







|
<

|
<


|











<
|

|
















|
|







19
20
21
22
23
24
25
26

27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdlib.h>

#import "OFThreadJoinFailedException.h"
#import "OFString.h"
#import "OFThread.h"

@implementation OFThreadJoinFailedException
+ (instancetype)exceptionWithThread: (OFThread*)thread

{
	return [[[self alloc] initWithThread: thread] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithThread: (OFThread*)thread
{
	self = [super init];

	_thread = [thread retain];

	return self;
}

- (void)dealloc
{
	[_thread release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Joining a thread of type %@ failed! Most likely, another thread "
	    @"already waits for the thread to join.", [_thread class]];
}

- (OFThread*)thread
{
	OF_GETTER(_thread, false)
}
@end

Modified src/exceptions/OFThreadStartFailedException.h from [81a280beae] to [cb2508253e].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFThread *thread;
#endif

/*!
 * @brief Creates a new, autoreleased thread start failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param thread The thread which could not be started
 * @return A new, autoreleased thread start failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    thread: (OFThread*)thread;

/*!
 * @brief Initializes an already allocated thread start failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param thread The thread which could not be started
 * @return An initialized thread start failed exception
 */
- initWithClass: (Class)class_
	 thread: (OFThread*)thread;

/*!
 * @brief Returns the thread which could not be started.
 *
 * @return The thread which could not be started
 */
- (OFThread*)thread;
@end







<



|
<




<



<
|








33
34
35
36
37
38
39

40
41
42
43

44
45
46
47

48
49
50

51
52
53
54
55
56
57
58
59
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFThread *thread;
#endif

/*!
 * @brief Creates a new, autoreleased thread start failed exception.
 *

 * @param thread The thread which could not be started
 * @return A new, autoreleased thread start failed exception
 */
+ (instancetype)exceptionWithThread: (OFThread*)thread;


/*!
 * @brief Initializes an already allocated thread start failed exception.
 *

 * @param thread The thread which could not be started
 * @return An initialized thread start failed exception
 */

- initWithThread: (OFThread*)thread;

/*!
 * @brief Returns the thread which could not be started.
 *
 * @return The thread which could not be started
 */
- (OFThread*)thread;
@end

Modified src/exceptions/OFThreadStartFailedException.m from [936c6420ec] to [2884001333].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdlib.h>

#import "OFThreadStartFailedException.h"
#import "OFString.h"
#import "OFThread.h"

@implementation OFThreadStartFailedException
+ (instancetype)exceptionWithClass: (Class)class
			    thread: (OFThread*)thread
{
	return [[[self alloc] initWithClass: class
				     thread: thread] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 thread: (OFThread*)thread
{
	self = [super initWithClass: class];

	_thread = [thread retain];

	return self;
}

- (void)dealloc
{
	[_thread release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Starting a thread of class %@ failed!", _inClass];
}

- (OFThread*)thread
{
	OF_GETTER(_thread, false)
}
@end







|
<

|
<


|











<
|

|
















|







19
20
21
22
23
24
25
26

27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdlib.h>

#import "OFThreadStartFailedException.h"
#import "OFString.h"
#import "OFThread.h"

@implementation OFThreadStartFailedException
+ (instancetype)exceptionWithThread: (OFThread*)thread

{
	return [[[self alloc] initWithThread: thread] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithThread: (OFThread*)thread
{
	self = [super init];

	_thread = [thread retain];

	return self;
}

- (void)dealloc
{
	[_thread release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Starting a thread of type %@ failed!", [_thread class]];
}

- (OFThread*)thread
{
	OF_GETTER(_thread, false)
}
@end

Modified src/exceptions/OFThreadStillRunningException.h from [4064d31434] to [f6cbf16741].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFThread *thread;
#endif

/*!
 * @brief Creates a new, autoreleased thread still running exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param thread The thread which is still running
 * @return A new, autoreleased thread still running exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    thread: (OFThread*)thread;

/*!
 * @brief Initializes an already allocated thread still running exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param thread The thread which is still running
 * @return An initialized thread still running exception
 */
- initWithClass: (Class)class_
	 thread: (OFThread*)thread;

/*!
 * @brief Returns the thread which is still running.
 *
 * @return The thread which is still running
 */
- (OFThread*)thread;
@end







<



|
<




<



<
|








33
34
35
36
37
38
39

40
41
42
43

44
45
46
47

48
49
50

51
52
53
54
55
56
57
58
59
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFThread *thread;
#endif

/*!
 * @brief Creates a new, autoreleased thread still running exception.
 *

 * @param thread The thread which is still running
 * @return A new, autoreleased thread still running exception
 */
+ (instancetype)exceptionWithThread: (OFThread*)thread;


/*!
 * @brief Initializes an already allocated thread still running exception.
 *

 * @param thread The thread which is still running
 * @return An initialized thread still running exception
 */

- initWithThread: (OFThread*)thread;

/*!
 * @brief Returns the thread which is still running.
 *
 * @return The thread which is still running
 */
- (OFThread*)thread;
@end

Modified src/exceptions/OFThreadStillRunningException.m from [d9f583edf6] to [60db06da77].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdlib.h>

#import "OFThreadStillRunningException.h"
#import "OFString.h"
#import "OFThread.h"

@implementation OFThreadStillRunningException
+ (instancetype)exceptionWithClass: (Class)class
			    thread: (OFThread*)thread
{
	return [[[self alloc] initWithClass: class
				     thread: thread] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 thread: (OFThread*)thread
{
	self = [super initWithClass: class];

	_thread = [thread retain];

	return self;
}

- (void)dealloc
{
	[_thread release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Deallocation of a thread of type %@ was tried, even though it "
	    @"was still running!", _inClass];
}

- (OFThread*)thread
{
	OF_GETTER(_thread, false)
}
@end







|
<

|
<


|











<
|

|

















|







19
20
21
22
23
24
25
26

27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdlib.h>

#import "OFThreadStillRunningException.h"
#import "OFString.h"
#import "OFThread.h"

@implementation OFThreadStillRunningException
+ (instancetype)exceptionWithThread: (OFThread*)thread

{
	return [[[self alloc] initWithThread: thread] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithThread: (OFThread*)thread
{
	self = [super init];

	_thread = [thread retain];

	return self;
}

- (void)dealloc
{
	[_thread release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Deallocation of a thread of type %@ was tried, even though it "
	    @"was still running!", [_thread class]];
}

- (OFThread*)thread
{
	OF_GETTER(_thread, false)
}
@end

Modified src/exceptions/OFTruncatedDataException.m from [614023628e] to [1f8e72af66].

18
19
20
21
22
23
24
25
26
27
28
29

#import "OFTruncatedDataException.h"
#import "OFString.h"

@implementation OFTruncatedDataException
- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Truncated data was received or produced in class %@ while it "
	    @"should not have been truncated!", _inClass];
}
@end







<
|
|


18
19
20
21
22
23
24

25
26
27
28

#import "OFTruncatedDataException.h"
#import "OFString.h"

@implementation OFTruncatedDataException
- (OFString*)description
{

	return @"Truncated data was received or produced when it should not "
	    @"have been truncated!";
}
@end

Modified src/exceptions/OFUnboundNamespaceException.h from [449c7bd059] to [8613058bed].

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# endif
@property (readonly, retain, nonatomic) OFXMLElement *element;
#endif

/*!
 * @brief Creates a new, autoreleased unbound namespace exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param namespace_ The namespace which is unbound
 * @param element The element in which the namespace was not bound
 * @return A new, autoreleased unbound namespace exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			 namespace: (OFString*)namespace_
			   element: (OFXMLElement*)element;

/*!
 * @brief Initializes an already allocated unbound namespace exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param namespace_ The namespace which is unbound
 * @param element The element in which the namespace was not bound
 * @return An initialized unbound namespace exception
 */
- initWithClass: (Class)class_
      namespace: (OFString*)namespace_
	element: (OFXMLElement*)element;

/*!
 * @brief Returns the unbound namespace.
 *
 * @return The unbound namespace
 */







<




|
<





<




<
|







35
36
37
38
39
40
41

42
43
44
45
46

47
48
49
50
51

52
53
54
55

56
57
58
59
60
61
62
63
# endif
@property (readonly, retain, nonatomic) OFXMLElement *element;
#endif

/*!
 * @brief Creates a new, autoreleased unbound namespace exception.
 *

 * @param namespace_ The namespace which is unbound
 * @param element The element in which the namespace was not bound
 * @return A new, autoreleased unbound namespace exception
 */
+ (instancetype)exceptionWithNamespace: (OFString*)namespace_

			   element: (OFXMLElement*)element;

/*!
 * @brief Initializes an already allocated unbound namespace exception.
 *

 * @param namespace_ The namespace which is unbound
 * @param element The element in which the namespace was not bound
 * @return An initialized unbound namespace exception
 */

- initWithNamespace: (OFString*)namespace_
	element: (OFXMLElement*)element;

/*!
 * @brief Returns the unbound namespace.
 *
 * @return The unbound namespace
 */

Modified src/exceptions/OFUnboundNamespaceException.m from [37f60bba81] to [37eac853b7].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#import "OFUnboundNamespaceException.h"
#import "OFString.h"
#import "OFXMLElement.h"

#import "common.h"

@implementation OFUnboundNamespaceException
+ (instancetype)exceptionWithClass: (Class)class
			 namespace: (OFString*)namespace
			   element: (OFXMLElement*)element
{
	return [[[self alloc] initWithClass: class
				  namespace: namespace
				    element: element] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
      namespace: (OFString*)namespace
	element: (OFXMLElement*)element
{
	self = [super initWithClass: class];

	@try {
		_namespace = [namespace copy];
		_element = [element retain];
	} @catch (id e) {
		[self release];
		@throw e;







|
<


|
<



|











<
|


|







21
22
23
24
25
26
27
28

29
30
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56
57
#import "OFUnboundNamespaceException.h"
#import "OFString.h"
#import "OFXMLElement.h"

#import "common.h"

@implementation OFUnboundNamespaceException
+ (instancetype)exceptionWithNamespace: (OFString*)namespace

			   element: (OFXMLElement*)element
{
	return [[[self alloc] initWithNamespace: namespace

				    element: element] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithNamespace: (OFString*)namespace
	element: (OFXMLElement*)element
{
	self = [super init];

	@try {
		_namespace = [namespace copy];
		_element = [element retain];
	} @catch (id e) {
		[self release];
		@throw e;
70
71
72
73
74
75
76
77

78
79
80
81
82
83
84
85
86
87
88
89

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The namespace %@ is not bound in class %@", _namespace, _inClass];

}

- (OFString*)namespace
{
	OF_GETTER(_namespace, false)
}

- (OFXMLElement*)element
{
	OF_GETTER(_element, false)
}
@end







|
>












67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The namespace %@ is not bound in an element of type %@!",
	    _namespace, [_element class]];
}

- (OFString*)namespace
{
	OF_GETTER(_namespace, false)
}

- (OFXMLElement*)element
{
	OF_GETTER(_element, false)
}
@end

Modified src/exceptions/OFUnboundPrefixException.h from [b7951aa078] to [b043c011f9].

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@property (readonly, copy, nonatomic) OFString *prefix;
@property (readonly, retain, nonatomic) OFXMLParser *parser;
#endif

/*!
 * @brief Creates a new, autoreleased unbound prefix exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param prefix The prefix which is unbound
 * @param parser The parser which encountered the unbound prefix
 * @return A new, autoreleased unbound prefix exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    prefix: (OFString*)prefix
			    parser: (OFXMLParser*)parser;

/*!
 * @brief Initializes an already allocated unbound prefix exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param prefix The prefix which is unbound
 * @param parser The parser which encountered the unbound prefix
 * @return An initialized unbound prefix exception
 */
- initWithClass: (Class)class_
	 prefix: (OFString*)prefix
	 parser: (OFXMLParser*)parser;

/*!
 * @brief Returns the unbound prefix.
 *
 * @return The unbound prefix
 */







<




|
<





<




<
|







31
32
33
34
35
36
37

38
39
40
41
42

43
44
45
46
47

48
49
50
51

52
53
54
55
56
57
58
59
@property (readonly, copy, nonatomic) OFString *prefix;
@property (readonly, retain, nonatomic) OFXMLParser *parser;
#endif

/*!
 * @brief Creates a new, autoreleased unbound prefix exception.
 *

 * @param prefix The prefix which is unbound
 * @param parser The parser which encountered the unbound prefix
 * @return A new, autoreleased unbound prefix exception
 */
+ (instancetype)exceptionWithPrefix: (OFString*)prefix

			    parser: (OFXMLParser*)parser;

/*!
 * @brief Initializes an already allocated unbound prefix exception.
 *

 * @param prefix The prefix which is unbound
 * @param parser The parser which encountered the unbound prefix
 * @return An initialized unbound prefix exception
 */

- initWithPrefix: (OFString*)prefix
	 parser: (OFXMLParser*)parser;

/*!
 * @brief Returns the unbound prefix.
 *
 * @return The unbound prefix
 */

Modified src/exceptions/OFUnboundPrefixException.m from [ecddbe546f] to [a4f9d416aa].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#import "OFUnboundPrefixException.h"
#import "OFString.h"
#import "OFXMLParser.h"

#import "common.h"

@implementation OFUnboundPrefixException
+ (instancetype)exceptionWithClass: (Class)class
			    prefix: (OFString*)prefix
			    parser: (OFXMLParser*)parser
{
	return [[[self alloc] initWithClass: class
				     prefix: prefix
				     parser: parser] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 prefix: (OFString*)prefix
	 parser: (OFXMLParser*)parser
{
	self = [super initWithClass: class];

	@try {
		_prefix = [prefix copy];
		_parser = [parser retain];
	} @catch (id e) {
		[self release];
		@throw e;







|
<


|
<



|











<
|


|







21
22
23
24
25
26
27
28

29
30
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56
57
#import "OFUnboundPrefixException.h"
#import "OFString.h"
#import "OFXMLParser.h"

#import "common.h"

@implementation OFUnboundPrefixException
+ (instancetype)exceptionWithPrefix: (OFString*)prefix

			    parser: (OFXMLParser*)parser
{
	return [[[self alloc] initWithPrefix: prefix

				     parser: parser] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithPrefix: (OFString*)prefix
	 parser: (OFXMLParser*)parser
{
	self = [super init];

	@try {
		_prefix = [prefix copy];
		_parser = [parser retain];
	} @catch (id e) {
		[self release];
		@throw e;
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The XML parser in class %@ encountered the unbound prefix %@ in "
	    @"line %zd!", _inClass, _prefix, [_parser lineNumber]];
}

- (OFString*)prefix
{
	OF_GETTER(_prefix, false)
}

- (OFXMLParser*)parser
{
	OF_GETTER(_parser, false)
}
@end







|
|












67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"An XML parser of type %@ encountered the unbound prefix %@ in "
	    @"line %zd!", [_parser class], _prefix, [_parser lineNumber]];
}

- (OFString*)prefix
{
	OF_GETTER(_prefix, false)
}

- (OFXMLParser*)parser
{
	OF_GETTER(_parser, false)
}
@end

Modified src/exceptions/OFUnlockFailedException.h from [0bb7635d95] to [a0438c9811].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFLocking> lock;
#endif

/*!
 * @brief Creates a new, autoreleased unlock failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param lock The lock which could not be unlocked
 * @return A new, autoreleased unlock failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      lock: (id <OFLocking>)lock;

/*!
 * @brief Initializes an already allocated unlock failed exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param lock The lock which could not be unlocked
 * @return An initialized unlock failed exception
 */
- initWithClass: (Class)class_
	   lock: (id <OFLocking>)lock;

/*!
 * @brief Returns the lock which could not be unlocked.
 *
 * @return The lock which could not be unlocked
 */
- (id <OFLocking>)lock;
@end







<



|
<




<



<
|








28
29
30
31
32
33
34

35
36
37
38

39
40
41
42

43
44
45

46
47
48
49
50
51
52
53
54
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFLocking> lock;
#endif

/*!
 * @brief Creates a new, autoreleased unlock failed exception.
 *

 * @param lock The lock which could not be unlocked
 * @return A new, autoreleased unlock failed exception
 */
+ (instancetype)exceptionWithLock: (id <OFLocking>)lock;


/*!
 * @brief Initializes an already allocated unlock failed exception.
 *

 * @param lock The lock which could not be unlocked
 * @return An initialized unlock failed exception
 */

- initWithLock: (id <OFLocking>)lock;

/*!
 * @brief Returns the lock which could not be unlocked.
 *
 * @return The lock which could not be unlocked
 */
- (id <OFLocking>)lock;
@end

Modified src/exceptions/OFUnlockFailedException.m from [6c903a202a] to [758cbe9463].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

51
52

53
54
55
56
57
58
59
60
 */

#include "config.h"

#import "OFUnlockFailedException.h"
#import "OFString.h"

#import "macros.h"

@implementation OFUnlockFailedException
+ (instancetype)exceptionWithClass: (Class)class
			      lock: (id <OFLocking>)lock
{
	return [[[self alloc] initWithClass: class
				       lock: lock] autorelease];
}

- initWithClass: (Class)class
	   lock: (id <OFLocking>)lock
{
	self = [super initWithClass: class];

	_lock = [lock retain];

	return self;
}

- (void)dealloc
{
	[_lock release];

	[super dealloc];
}

- (OFString*)description
{

	return [OFString stringWithFormat:
	    @"A lock of class %@ could not be unlocked in class %@!",

	    [_lock class], _inClass];
}

- (id <OFLocking>)lock
{
	OF_GETTER(_lock, false)
}
@end







|


|
<

|
<


<
|

|















>

|
>
|







15
16
17
18
19
20
21
22
23
24
25

26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 */

#include "config.h"

#import "OFUnlockFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFUnlockFailedException
+ (instancetype)exceptionWithLock: (id <OFLocking>)lock

{
	return [[[self alloc] initWithLock: lock] autorelease];

}


- initWithLock: (id <OFLocking>)lock
{
	self = [super init];

	_lock = [lock retain];

	return self;
}

- (void)dealloc
{
	[_lock release];

	[super dealloc];
}

- (OFString*)description
{
	if (_lock != nil)
	return [OFString stringWithFormat:
		    @"A lock of type %@ could not be unlocked!", [_lock class]];
	else
		return @"A lock could not be unlocked!";
}

- (id <OFLocking>)lock
{
	OF_GETTER(_lock, false)
}
@end

Modified src/exceptions/OFUnsupportedProtocolException.h from [b626bac85b] to [eb9f027dc9].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFURL *URL;
#endif

/*!
 * @brief Creates a new, autoreleased unsupported protocol exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param URL The URL whose protocol is unsupported
 * @return A new, autoreleased unsupported protocol exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			       URL: (OFURL*)URL;

/*!
 * @brief Initializes an already allocated unsupported protocol exception
 *
 * @param class_ The class of the object which caused the exception
 * @param URL The URL whose protocol is unsupported
 * @return An initialized unsupported protocol exception
 */
- initWithClass: (Class)class_
	    URL: (OFURL*)URL;

/*!
 * @brief Returns the URL whose protocol is unsupported.
 *
 * @return The URL whose protocol is unsupported
 */
- (OFURL*)URL;
@end







<



|
<




<



<
|








30
31
32
33
34
35
36

37
38
39
40

41
42
43
44

45
46
47

48
49
50
51
52
53
54
55
56
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFURL *URL;
#endif

/*!
 * @brief Creates a new, autoreleased unsupported protocol exception.
 *

 * @param URL The URL whose protocol is unsupported
 * @return A new, autoreleased unsupported protocol exception
 */
+ (instancetype)exceptionWithURL: (OFURL*)URL;


/*!
 * @brief Initializes an already allocated unsupported protocol exception
 *

 * @param URL The URL whose protocol is unsupported
 * @return An initialized unsupported protocol exception
 */

- initWithURL: (OFURL*)URL;

/*!
 * @brief Returns the URL whose protocol is unsupported.
 *
 * @return The URL whose protocol is unsupported
 */
- (OFURL*)URL;
@end

Modified src/exceptions/OFUnsupportedProtocolException.m from [86615f4dc4] to [faf85806a1].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#import "OFUnsupportedProtocolException.h"
#import "OFString.h"
#import "OFURL.h"

#import "common.h"

@implementation OFUnsupportedProtocolException
+ (instancetype)exceptionWithClass: (Class)class
			       URL: (OFURL*)url
{
	return [[[self alloc] initWithClass: class
					URL: url] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	    URL: (OFURL*)URL
{
	self = [super initWithClass: class];

	@try {
		_URL = [URL copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}







|
<

|
<


|











<
|

|







21
22
23
24
25
26
27
28

29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
#import "OFUnsupportedProtocolException.h"
#import "OFString.h"
#import "OFURL.h"

#import "common.h"

@implementation OFUnsupportedProtocolException
+ (instancetype)exceptionWithURL: (OFURL*)url

{
	return [[[self alloc] initWithURL: url] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithURL: (OFURL*)URL
{
	self = [super init];

	@try {
		_URL = [URL copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The protocol of URL %@ is not supported by class %@", _URL,
	    _inClass];
}

- (OFURL*)URL
{
	OF_GETTER(_URL, false)
}
@end







|
<







62
63
64
65
66
67
68
69

70
71
72
73
74
75
76

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The protocol of URL %@ is not supported!", _URL];

}

- (OFURL*)URL
{
	OF_GETTER(_URL, false)
}
@end

Modified src/exceptions/OFUnsupportedVersionException.h from [d4879e4859] to [58fd352d36].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *version;
#endif

/*!
 * @brief Creates a new, autoreleased unsupported version exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param version The version which is unsupported
 * @return A new, autoreleased unsupported version exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			   version: (OFString*)version;

/*!
 * @brief Initializes an already allocated unsupported protocol exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param version The version which is unsupported
 * @return An initialized unsupported version exception
 */
- initWithClass: (Class)class_
	version: (OFString*)version;

/*!
 * @brief Returns the version which is unsupported.
 *
 * @return The version which is unsupported
 */
- (OFString*)version;
@end







<



|
<




<



<
|








28
29
30
31
32
33
34

35
36
37
38

39
40
41
42

43
44
45

46
47
48
49
50
51
52
53
54
#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *version;
#endif

/*!
 * @brief Creates a new, autoreleased unsupported version exception.
 *

 * @param version The version which is unsupported
 * @return A new, autoreleased unsupported version exception
 */
+ (instancetype)exceptionWithVersion: (OFString*)version;


/*!
 * @brief Initializes an already allocated unsupported protocol exception.
 *

 * @param version The version which is unsupported
 * @return An initialized unsupported version exception
 */

- initWithVersion: (OFString*)version;

/*!
 * @brief Returns the version which is unsupported.
 *
 * @return The version which is unsupported
 */
- (OFString*)version;
@end

Modified src/exceptions/OFUnsupportedVersionException.m from [d304c8874c] to [d8db0ec580].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

#import "OFUnsupportedVersionException.h"
#import "OFString.h"

#import "common.h"

@implementation OFUnsupportedVersionException
+ (instancetype)exceptionWithClass: (Class)class
			   version: (OFString*)version
{
	return [[[self alloc] initWithClass: class
				    version: version] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	version: (OFString*)version
{
	self = [super initWithClass: class];

	@try {
		_version = [version copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}







|
<

|
<


|











<
|

|







20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53

#import "OFUnsupportedVersionException.h"
#import "OFString.h"

#import "common.h"

@implementation OFUnsupportedVersionException
+ (instancetype)exceptionWithVersion: (OFString*)version

{
	return [[[self alloc] initWithVersion: version] autorelease];

}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}


- initWithVersion: (OFString*)version
{
	self = [super init];

	@try {
		_version = [version copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Version %@ of the format or protocol is not supported by class "
	    @"%@", _version, _inClass];
}

- (OFString*)version
{
	OF_GETTER(_version, false)
}
@end







|
|







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Version %@ of the format or protocol is not supported!",
	    _version];
}

- (OFString*)version
{
	OF_GETTER(_version, false)
}
@end

Modified src/exceptions/OFWriteFailedException.m from [180ffc9797] to [93caebcf9a].

21
22
23
24
25
26
27
28
29
30
31

#import "common.h"

@implementation OFWriteFailedException
- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to write %zu bytes in class %@! " ERRFMT, _requestedLength,
	    _inClass, ERRPARAM];
}
@end







|
|


21
22
23
24
25
26
27
28
29
30
31

#import "common.h"

@implementation OFWriteFailedException
- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to write %zu bytes in a stream of type %@! " ERRFMT,
	    _requestedLength, [_stream class], ERRPARAM];
}
@end

Modified src/exceptions/common.h from [082aeff5c0] to [adaa2c4822].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#  if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(HAVE_H_ERRNO)
#   define GET_AT_ERRNO	h_errno
#  else
#   define GET_AT_ERRNO	errno
#  endif
# define GET_SOCK_ERRNO	errno
# endif
# define ERRFMT			"Error string was: %s"
# define ERRPARAM		strerror(_errNo)
# ifdef OF_HAVE_SOCKETS
#  if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(HAVE_HSTRERROR)
#   define AT_ERRPARAM		hstrerror(_errNo)
#  else
#   define AT_ERRPARAM		strerror(_errNo)
#  endif
# endif
#else
# include <windows.h>
# define GET_ERRNO		GetLastError()
# ifdef OF_HAVE_SOCKETS
#  define GET_AT_ERRNO		WSAGetLastError()
#  define GET_SOCK_ERRNO	WSAGetLastError()
# endif
# define ERRFMT			"Error code was: %d"
# define ERRPARAM		_errNo
# ifdef OF_HAVE_SOCKETS
#  define AT_ERRPARAM		_errNo
# endif
#endif







|















|





29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#  if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(HAVE_H_ERRNO)
#   define GET_AT_ERRNO	h_errno
#  else
#   define GET_AT_ERRNO	errno
#  endif
# define GET_SOCK_ERRNO	errno
# endif
# define ERRFMT			@"Error string was: %s"
# define ERRPARAM		strerror(_errNo)
# ifdef OF_HAVE_SOCKETS
#  if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(HAVE_HSTRERROR)
#   define AT_ERRPARAM		hstrerror(_errNo)
#  else
#   define AT_ERRPARAM		strerror(_errNo)
#  endif
# endif
#else
# include <windows.h>
# define GET_ERRNO		GetLastError()
# ifdef OF_HAVE_SOCKETS
#  define GET_AT_ERRNO		WSAGetLastError()
#  define GET_SOCK_ERRNO	WSAGetLastError()
# endif
# define ERRFMT			@"Error code was: %d"
# define ERRPARAM		_errNo
# ifdef OF_HAVE_SOCKETS
#  define AT_ERRPARAM		_errNo
# endif
#endif

Modified tests/OFStringTests.m from [5f1c00ddf1] to [a5554c7700].

446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461

	TEST(@"-[insertString:atIndex:]",
	    (s[0] = [OFMutableString stringWithString: @"𝄞öööbä€"]) &&
	    R([s[0] insertString: @"äöü"
			 atIndex: 3]) &&
	    [s[0] isEqual: @"𝄞ööäöüöbä€"])

	EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] "
	    @"#1", OFInvalidEncodingException, [@"foo%bar" stringByURLDecoding])
	EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] "
	    @"#2", OFInvalidEncodingException,
	    [@"foo%FFbar" stringByURLDecoding])

	TEST(@"-[setCharacter:atIndex:]",
	    (s[0] = [OFMutableString stringWithString: @"abäde"]) &&
	    R([s[0] setCharacter: 0xF6







|
|







446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461

	TEST(@"-[insertString:atIndex:]",
	    (s[0] = [OFMutableString stringWithString: @"𝄞öööbä€"]) &&
	    R([s[0] insertString: @"äöü"
			 atIndex: 3]) &&
	    [s[0] isEqual: @"𝄞ööäöüöbä€"])

	EXPECT_EXCEPTION(@"Detect invalid format in -[stringByURLDecoding] "
	    @"#1", OFInvalidFormatException, [@"foo%xbar" stringByURLDecoding])
	EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] "
	    @"#2", OFInvalidEncodingException,
	    [@"foo%FFbar" stringByURLDecoding])

	TEST(@"-[setCharacter:atIndex:]",
	    (s[0] = [OFMutableString stringWithString: @"abäde"]) &&
	    R([s[0] setCharacter: 0xF6
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
	    [[s[0] stringByXMLUnescaping] isEqual: @"<hello> &world'\"!&"] &&
	    [[@"&#x79;" stringByXMLUnescaping] isEqual: @"y"] &&
	    [[@"&#xe4;" stringByXMLUnescaping] isEqual: @"ä"] &&
	    [[@"&#8364;" stringByXMLUnescaping] isEqual: @"€"] &&
	    [[@"&#x1D11E;" stringByXMLUnescaping] isEqual: @"𝄞"])

	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#1", OFInvalidEncodingException, [@"&foo;" stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#2", OFInvalidEncodingException, [@"x&amp" stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#3", OFInvalidEncodingException, [@"&#;" stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#4", OFInvalidEncodingException, [@"&#x;" stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#5", OFInvalidEncodingException, [@"&#g;" stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#6", OFInvalidEncodingException, [@"&#xg;" stringByXMLUnescaping])

	TEST(@"-[stringByXMLUnescapingWithDelegate:]",
	    (h = [[[EntityHandler alloc] init] autorelease]) &&
	    [[@"x&foo;y" stringByXMLUnescapingWithDelegate: h]
	    isEqual: @"xbary"])

#ifdef OF_HAVE_BLOCKS







|

|

|

|

|

|







558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
	    [[s[0] stringByXMLUnescaping] isEqual: @"<hello> &world'\"!&"] &&
	    [[@"&#x79;" stringByXMLUnescaping] isEqual: @"y"] &&
	    [[@"&#xe4;" stringByXMLUnescaping] isEqual: @"ä"] &&
	    [[@"&#8364;" stringByXMLUnescaping] isEqual: @"€"] &&
	    [[@"&#x1D11E;" stringByXMLUnescaping] isEqual: @"𝄞"])

	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#1", OFInvalidFormatException, [@"&foo;" stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#2", OFInvalidFormatException, [@"x&amp" stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#3", OFInvalidFormatException, [@"&#;" stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#4", OFInvalidFormatException, [@"&#x;" stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#5", OFInvalidFormatException, [@"&#g;" stringByXMLUnescaping])
	EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] "
	    @"#6", OFInvalidFormatException, [@"&#xg;" stringByXMLUnescaping])

	TEST(@"-[stringByXMLUnescapingWithDelegate:]",
	    (h = [[[EntityHandler alloc] init] autorelease]) &&
	    [[@"x&foo;y" stringByXMLUnescapingWithDelegate: h]
	    isEqual: @"xbary"])

#ifdef OF_HAVE_BLOCKS