ObjFW  Check-in [8a7ca573c4]

Overview
Comment:Clean up a lot of code (mostly init methods) and fix a missing rethrow.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8a7ca573c456f6292a26616d193db9eb6b51e8d35db7c330192986620caf5183
User & Date: js on 2010-10-25 23:03:22
Other Links: manifest | tags
Context
2010-10-26
18:24
Define __STDC_LIMIT_MACROS for C++ compatibility. check-in: f9316e0692 user: js tags: trunk
2010-10-25
23:03
Clean up a lot of code (mostly init methods) and fix a missing rethrow. check-in: 8a7ca573c4 user: js tags: trunk
22:28
Update Unicode tables. check-in: 5d3216f476 user: js tags: trunk
Changes

Modified src/OFApplication.m from [b4963086e3] to [c6789a7016].

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
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







+
+
+
-
-
+
+

-
-
-
+

-
+

-
+

-
+


-
-
-
-
-
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+

-
-
-
+
+
+
+
+
+
+







+ (void)terminateWithStatus: (int)status
{
	exit(status);
}

- init
{
	self = [super init];

	@try {
	OFAutoreleasePool *pool;
	char **env;
		OFAutoreleasePool *pool;
		char **env;

	self = [super init];

	environment = [[OFMutableDictionary alloc] init];
		environment = [[OFMutableDictionary alloc] init];

	atexit(atexit_handler);
		atexit(atexit_handler);
#ifdef __MACH__
	env = *_NSGetEnviron();
		env = *_NSGetEnviron();
#else
	env = environ;
		env = environ;
#endif

	pool = [[OFAutoreleasePool alloc] init];
	for (; *env != NULL; env++) {
		OFString *key;
		OFString *value;
		char *sep;
		pool = [[OFAutoreleasePool alloc] init];
		for (; *env != NULL; env++) {
			OFString *key;
			OFString *value;
			char *sep;

		if ((sep = strchr(*env, '=')) == NULL) {
			fprintf(stderr, "Warning: Invalid environment "
			    "variable: %s\n", *env);
			continue;
		}
			if ((sep = strchr(*env, '=')) == NULL) {
				fprintf(stderr, "Warning: Invalid environment "
					       "variable: %s\n", *env);
				continue;
			}

		key = [OFString stringWithCString: *env
					   length: sep - *env];
		value = [OFString stringWithCString: sep + 1];
		[environment setObject: value
				forKey: key];
			key = [OFString stringWithCString: *env
						   length: sep - *env];
			value = [OFString stringWithCString: sep + 1];
			[environment setObject: value
					forKey: key];

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

	return self;
}

- (void)setArgumentCount: (int*)argc_
       andArgumentValues: (char***)argv_
{

Modified src/OFArray.m from [0afd3cde8f] to [9600e51a49].

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
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
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
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







-
+
-
-
-
-
-
+












+
-
-
+
+



-
-



















-
-



+
+





-
-
+
+








-
-
-


+
+
-
+

-
-
-
-
+
+
+
+

-


-
+
+
+



-
+









-
+

+
-
+

-
-
+
+

-


-
+
+
+



-
+








- init
{
	self = [super init];

	@try {
		array = [[OFDataArray alloc] initWithItemSize: sizeof(id)];
	} @catch (OFException *e) {
	} @catch (id e) {
		/*
		 * We can't use [super dealloc] on OS X here. Compiler bug?
		 * [self dealloc] will do here as we check for nil in dealloc.
		 */
		[self dealloc];
		[self release];
		@throw e;
	}

	return self;
}

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

	@try {
		[array addItem: &obj];
		[obj retain];
	} @catch (OFException *e) {
		[self dealloc];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	[obj retain];

	return self;
}

- initWithObjects: (id)first, ...
{
	id ret;
	va_list args;

	va_start(args, first);
	ret = [self initWithObject: first
			   argList: args];
	va_end(args);

	return ret;
}

- initWithObject: (id)first
	 argList: (va_list)args
{
	id obj;

	self = [self init];

	@try {
		id obj;

		[array addItem: &first];
		while ((obj = va_arg(args, id)) != nil) {
			[array addItem: &obj];
			[obj retain];
		}
	} @catch (OFException *e) {
		[self dealloc];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithCArray: (id*)objs
{
	id *obj;
	size_t count;

	self = [self init];

	@try {
		id *obj;
	count = 0;
		size_t count = 0;

	for (obj = objs; *obj != nil; obj++) {
		[*obj retain];
		count++;
	}
		for (obj = objs; *obj != nil; obj++) {
			[*obj retain];
			count++;
		}

	@try {
		[array addNItems: count
		      fromCArray: objs];
	} @catch (OFException *e) {
	} @catch (id e) {
		id *obj;

		for (obj = objs; *obj != nil; obj++)
			[*obj release];

		[self dealloc];
		[self release];
		@throw e;
	}

	return self;
}

- initWithCArray: (id*)objs
	  length: (size_t)len
{
	size_t i;
	self = [self init];

	@try {
	self = [self init];
		size_t i;

	for (i = 0; i < len; i++)
		[objs[i] retain];
		for (i = 0; i < len; i++)
			[objs[i] retain];

	@try {
		[array addNItems: len
		      fromCArray: objs];
	} @catch (OFException *e) {
	} @catch (id e) {
		size_t i;

		for (i = 0; i < len; i++)
			[objs[i] release];

		[self dealloc];
		[self release];
		@throw e;
	}

	return self;
}

- (size_t)count

Modified src/OFAutoreleasePool.m from [4e90c8c96d] to [2e10041b61].

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
122


123
124

125
126
127
128
129


130
131
132
133
134
135
136
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
122
123
124
125
126







-
+
















-
+
















-
-
-
-


+

-
-
+
+

-
+
-
-
-
+
-
+

-
-
+
+


-
+

-
+
-
-
-
+
-
-
-
-
-
+
+
+

-
+

-
+

-
-
+
+

-
+
-


-
-
+
+







#ifdef OF_THREADS
	id last = of_tlskey_get(last_key);
#endif

	if (last == nil) {
		@try {
			[[self alloc] init];
		} @catch (OFException *e) {
		} @catch (id e) {
			[obj release];
			@throw e;
		}

#ifdef OF_THREADS
		last = of_tlskey_get(last_key);
#endif
	}

	if (last == nil) {
		[obj release];
		@throw [OFInitializationFailedException newWithClass: self];
	}

	@try {
		[last addObject: obj];
	} @catch (OFException *e) {
	} @catch (id e) {
		[obj release];
		@throw e;
	}
}

+ (void)releaseAll
{
#ifdef OF_THREADS
	[of_tlskey_get(first_key) release];
#else
	[first release];
#endif
}

- init
{
#ifdef OF_THREADS
	id first;
#endif

	self = [super init];

	@try {
#ifdef OF_THREADS
	first = of_tlskey_get(first_key);
	prev = of_tlskey_get(last_key);
		id first = of_tlskey_get(first_key);
		prev = of_tlskey_get(last_key);

	if (!of_tlskey_set(last_key, self)) {
		if (!of_tlskey_set(last_key, self))
		Class c = isa;
		[super dealloc];
		@throw [OFInitializationFailedException newWithClass: c];
			@throw [OFInitializationFailedException
	}
			    newWithClass: isa];
#else
	prev = last;
	last = self;
		prev = last;
		last = self;
#endif

	if (first == nil) {
		if (first == nil) {
#ifdef OF_THREADS
		if (!of_tlskey_set(first_key, self)) {
			if (!of_tlskey_set(first_key, self)) {
			Class c = isa;

			of_tlskey_set(last_key, prev);
				of_tlskey_set(last_key, prev);

			[super dealloc];
			@throw [OFInitializationFailedException
			    newWithClass: c];
		}
				@throw [OFInitializationFailedException
				    newWithClass: isa];
			}
#else
		first = self;
			first = self;
#endif
	}
		}

	if (prev != nil)
		prev->next = self;
		if (prev != nil)
			prev->next = self;

	size = GROW_SIZE;
		size = GROW_SIZE;
	@try {
		objects = [self allocMemoryForNItems: GROW_SIZE
					    withSize: sizeof(id)];
	} @catch (OFException *e) {
		[self dealloc];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)addObject: (id)obj

Modified src/OFDataArray.m from [3dd22e9f84] to [e2af4c2cc3].

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
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







+
+
-
+





-
-


+
-
+
-
-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+







+ dataArrayWithItemSize: (size_t)is
{
	return [[[self alloc] initWithItemSize: is] autorelease];
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithItemSize: (size_t)is
{
	Class c;

	self = [super init];

	@try {
	if (is == 0) {
		if (is == 0)
		c = isa;
		[super dealloc];
		@throw [OFInvalidArgumentException newWithClass: c
						       selector: _cmd];
	}
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];


	data = NULL;
	itemSize = is;
		data = NULL;
		itemSize = is;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (size_t)count
{
	return count;

Modified src/OFDictionary.m from [2b1836dbc4] to [c675091634].

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
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
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

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
328


329
330





331
332
333
334
335
336
337
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


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
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
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







-
-


-
-
-
-
-
-
-
+
+
+
+


-






-
+

+
-
+

-
+
-
-
-
-
-
-
+
+
+
-
-





-
-
-
-
-
-
-
-
-
+
-
-
-
+
+

-
-
-
+
+
+

-
-
+
+

-


-
-
-
-
+
-
-
-
-
-
+
+
+
+
-
-
-
+
+

-
-
-
-
+
+
+
+
+
+
+
+
+








+
+
+
-
-
+
+

-
-
-






-
-
-
-
-
-
-
-
-
+
-
-
+
-
-


-
-
-
-
+
-
-
-
-
-
+
+
+
+
-
-
-
+
+

-
-
-
-
-
+
+
+
+
+
+
+
+
+
+







-
-
-



+
+









-
+

-
+


-
+


-
+

-
+
-
-
-
-
-
+
-
-
-
+
-
-
-
+
+

-
-
+
+

-
-
-
+
+
+
+

-
-
-
+
+
+

-
-
-
-
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+

-
+

-
-
+
+

-
-
-
+
+
+

-
-
+
+
+

-
+
-
-
-
-
+
+
+
-
-


-
-
-
-
+
-
-
-
-
-
+
+
+
+
-
-
-
+
+

-
-
-
-
+
+
+
+
+

-
-
+
+

-
-
-
-
-
+
+
+
+
+
+
-

-
-
-
-
+
-
-
-
-
-
+
+
+
+
-
-
-
+
+

-
+
+
+
+
+







	return ret;
}

- init
{
	self = [super init];

	size = 1;

	@try {
		data = [self allocMemoryWithSize: sizeof(BUCKET*)];
	} @catch (OFException *e) {
		/*
		 * We can't use [super dealloc] on OS X here. Compiler bug?
		 * Anyway, set size to 0 so that [self dealloc] works.
		 */
		size = 0;
		[self dealloc];
		size = 1;
		data[0] = NULL;
	} @catch (id e) {
		[self release];
		@throw e;
	}
	data[0] = NULL;

	return self;
}

- initWithDictionary: (OFDictionary*)dict
{
	uint32_t i;
	self = [super init];

	@try {
	self = [super init];
		uint32_t i;

	if (dict == nil) {
		if (dict == nil)
		Class c = isa;
		size = 0;
		[self dealloc];
		@throw [OFInvalidArgumentException newWithClass: c
						       selector: _cmd];
	}
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];


	@try {
		data = [self allocMemoryForNItems: dict->size
					 withSize: sizeof(BUCKET*)];

		for (i = 0; i < dict->size; i++)
			data[i] = NULL;
	} @catch (OFException *e) {
		/*
		 * We can't use [super dealloc] on OS X here. Compiler bug?
		 * Anyway, we didn't do anything yet anyway, so [self dealloc]
		 * works.
		 */
		[self dealloc];
		@throw e;
	}


	size = dict->size;
	count = dict->count;
		size = dict->size;
		count = dict->count;

	for (i = 0; i < size; i++) {
		id <OFCopying> key;
		BUCKET *b;
		for (i = 0; i < size; i++) {
			id <OFCopying> key;
			BUCKET *b;

		if (dict->data[i] == NULL || dict->data[i] == DELETED)
			continue;
			if (dict->data[i] == NULL || dict->data[i] == DELETED)
				continue;

		@try {
			b = [self allocMemoryWithSize: sizeof(BUCKET)];
			key = [dict->data[i]->key copy];
		} @catch (OFException *e) {
			[self dealloc];
			@throw e;
		}


		@try {
			[dict->data[i]->object retain];
		} @catch (OFException *e) {
			[(id)key release];
			@try {
				[dict->data[i]->object retain];
			} @catch (id e) {
				[(id)key release];
			[self dealloc];
			@throw e;
		}
				@throw e;
			}

		b->key = key;
		b->object = dict->data[i]->object;
		b->hash = dict->data[i]->hash;
		data[i] = b;
			b->key = key;
			b->object = dict->data[i]->object;
			b->hash = dict->data[i]->hash;

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

	return self;
}

- initWithObject: (id)obj
	  forKey: (id <OFCopying>)key
{
	self = [super init];

	@try {
	uint32_t i;
	BUCKET *b;
		uint32_t i;
		BUCKET *b;

	self = [self init];

	@try {
		data = [self allocMemoryForNItems: 2
					 withSize: sizeof(BUCKET*)];

		size = 2;
		for (i = 0; i < size; i++)
			data[i] = NULL;
	} @catch (OFException *e) {
		/*
		 * We can't use [super dealloc] on OS X here. Compiler bug?
		 * Anyway, we didn't do anything yet anyway, so [self dealloc]
		 * works.
		 */
		[self dealloc];
		@throw e;
	}


	i = [(id)key hash] & 1;
		i = [(id)key hash] & 1;

	@try {
		b = [self allocMemoryWithSize: sizeof(BUCKET)];
		key = [key copy];
	} @catch (OFException *e) {
		[self dealloc];
		@throw e;
	}


	@try {
		[obj retain];
	} @catch (OFException *e) {
		[(id)key release];
		@try {
			[obj retain];
		} @catch (id e) {
			[(id)key release];
		[self dealloc];
		@throw e;
	}
			@throw e;
		}

	b->key = key;
	b->object = obj;
	b->hash = [(id)key hash];
	data[i] = b;
	count = 1;
		b->key = key;
		b->object = obj;
		b->hash = [(id)key hash];

		data[i] = b;
		count = 1;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithObjects: (OFArray*)objs
	  forKeys: (OFArray*)keys
{
	id *objs_carray, *keys_carray;
	size_t i;

	self = [super init];

	@try {
		id *objs_carray, *keys_carray;
		size_t i, nsize;
		uint32_t j;

		keys_carray = [keys cArray];
		objs_carray = [objs cArray];
		count = [keys count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException newWithClass: isa];

		for (size = 1; size < count; size <<= 1);
		for (nsize = 1; nsize < count; nsize <<= 1);

		if (size == 0)
		if (nsize == 0)
			@throw [OFOutOfRangeException newWithClass: isa];

		data = [self allocMemoryForNItems: size
		data = [self allocMemoryForNItems: nsize
					 withSize: sizeof(BUCKET*)];

		for (j = 0; j < size; j++)
		for (j = 0; j < nsize; j++)
			data[j] = NULL;
	} @catch (OFException *e) {

		/*
		 * We can't use [super dealloc] on OS X here. Compiler bug?
		 * Anyway, set size to 0 so that [self dealloc] works.
		 */
		size = 0;
		size = nsize;
		[self dealloc];
		@throw e;
	}


	for (i = 0; i < count; i++) {
		uint32_t j, hash, last;
		for (i = 0; i < count; i++) {
			uint32_t hash, last;

		hash = [keys_carray[i] hash];
		last = size;
			hash = [keys_carray[i] hash];
			last = size;

		for (j = hash & (size - 1); j < last && data[j] != NULL; j++)
			if ([(id)data[j]->key isEqual: keys_carray[i]])
				break;
			for (j = hash & (size - 1); j < last && data[j] != NULL;
			    j++)
				if ([(id)data[j]->key isEqual: keys_carray[i]])
					break;

		/* In case the last bucket is already used */
		if (j >= last) {
			last = hash & (size - 1);
			/* In case the last bucket is already used */
			if (j >= last) {
				last = hash & (size - 1);

			for (j = 0; j < last && data[j] != NULL; j++)
				if ([(id)data[j]->key isEqual: keys_carray[i]])
					break;
		}
				for (j = 0; j < last && data[j] != NULL; j++)
					if ([(id)data[j]->key
					    isEqual: keys_carray[i]])
						break;
			}

		/* Key not in dictionary */
		if (j >= last || data[j] == NULL ||
		    ![(id)data[j]->key isEqual: keys_carray[i]]) {
			BUCKET *b;
			id <OFCopying> key;
			/* Key not in dictionary */
			if (j >= last || data[j] == NULL ||
			    ![(id)data[j]->key isEqual: keys_carray[i]]) {
				BUCKET *b;
				id <OFCopying> key;

			last = size;
				last = size;

			j = hash & (size - 1);
			for (; j < last && data[j] != NULL; j++);
				j = hash & (size - 1);
				for (; j < last && data[j] != NULL; j++);

			/* In case the last bucket is already used */
			if (j >= last) {
				last = hash & (size - 1);
				/* In case the last bucket is already used */
				if (j >= last) {
					last = hash & (size - 1);

				for (j = 0; j < last && data[j] != NULL; j++);
			}
					for (j = 0; j < last && data[j] != NULL;
					    j++);
				}

			if (j >= last) {
				if (j >= last)
				Class c = isa;
				[self dealloc];
				@throw [OFOutOfRangeException newWithClass: c];
			}
					@throw [OFOutOfRangeException
					    newWithClass: isa];


			@try {
				b = [self allocMemoryWithSize: sizeof(BUCKET)];
				key = [keys_carray[i] copy];
			} @catch (OFException *e) {
				[self dealloc];
				@throw e;
			}


			@try {
				[objs_carray[i] retain];
			} @catch (OFException *e) {
				[(id)key release];
				@try {
					[objs_carray[i] retain];
				} @catch (id e) {
					[(id)key release];
				[self dealloc];
				@throw e;
			}
					@throw e;
				}

			b->key = key;
			b->object = objs_carray[i];
			b->hash = hash;
			data[j] = b;
				b->key = key;
				b->object = objs_carray[i];
				b->hash = hash;

				data[j] = b;

			continue;
		}
				continue;
			}

		/*
		 * They key is already in the dictionary. However, we just
		 * replace it so that the programmer gets the same behavior
		 * as if he'd call setObject:forKey: for each key/object pair.
		 */
			/*
			 * The key is already in the dictionary. However, we
			 * just replace it so that the programmer gets the same
			 * behavior as if he'd call setObject:forKey: for each
			 * key/object pair.
			 */
		@try {
			[objs_carray[i] retain];
		} @catch (OFException *e) {
			[self dealloc];
			@throw e;
		}


		@try {
			[data[j]->object release];
		} @catch (OFException *e) {
			[objs_carray[i] release];
			@try {
				[data[j]->object release];
			} @catch (id e) {
				[objs_carray[i] release];
			[self dealloc];
			@throw e;
		}
				@throw e;
			}

		data[j]->object = objs_carray[i];
			data[j]->object = objs_carray[i];
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithKeysAndObjects: (id <OFCopying>)first, ...
{
345
346
347
348
349
350
351

352
353
354
355
356







357

358




359




360
361
362



363
364

365
366
367
368
369



370
371
372

373
374
375
376


377
378
379

380
381
382

383
384
385
386
387
388
389
390
391
392

393
394
395
396

397
398
399
400
401
402
403
404
405
406
407
408
409
410
411



412
413
414
415
416
417
418
419

420
421
422
423
424




425
426
427


428
429
430
431
432





433
434
435


436
437
438


439
440

441
442
443
444
445




446
447
448


449
450
451
452




453
454
455
456



457
458
459
460
461




462
463
464
465
466




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
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



339
340
341

342
343









344




345











346



347
348
349
350

351
352




353





354
355
356
357



358
359
360




361
362
363
364
365
366


367
368
369


370
371
372

373





374
375
376
377



378
379
380



381
382
383
384
385



386
387
388
389




390
391
392
393
394




395
396
397
398
399


400
401
402



403
404
405
406


407
408
409
410

411




412
413
414


415
416




417





418
419
420
421



422
423
424




425
426
427
428
429
430


431
432
433





434
435
436
437
438
439

440




441





442
443
444
445



446
447
448

449
450
451
452
453
454
455
456
457
458
459
460







+
-
-
-
-
-
+
+
+
+
+
+
+

+
-
+
+
+
+

+
+
+
+
-
-
-
+
+
+

-
+
-
-
-
-
-
+
+
+
-

-
+
-
-
-
-
+
+
-
-
-
+


-
+

-
-
-
-
-
-
-
-
-
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-

-
-
-
+
+
+

-


-
-
-
-
+
-
-
-
-
-
+
+
+
+
-
-
-
+
+

-
-
-
-
+
+
+
+
+

-
-
+
+

-
-
+
+

-
+
-
-
-
-
-
+
+
+
+
-
-
-
+
+

-
-
-
+
+
+
+

-
-
-
+
+
+

-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+

-
-
+
+

-
-
-
+
+
+

-
-
+
+
+

-
+
-
-
-
-
+
+
+
-
-


-
-
-
-
+
-
-
-
-
-
+
+
+
+
-
-
-
+
+

-
-
-
-
+
+
+
+
+

-
-
+
+

-
-
-
-
-
+
+
+
+
+
+
-

-
-
-
-
+
-
-
-
-
-
+
+
+
+
-
-
-
+
+

-
+
+
+
+
+








	return ret;
}

- initWithKey: (id <OFCopying>)key
      argList: (va_list)args
{
	self = [super init];
	BUCKET *b;
	id obj;
	size_t i;
	uint32_t j, hash;
	va_list args2;

	@try {
		id obj;
		size_t i, nsize;
		uint32_t j, hash;
		va_list args2;
		BUCKET *b;

		va_copy(args2, args);
	self = [super init];

		if (key == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		if ((obj = va_arg(args, id)) == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

	count = 1;
	for (va_copy(args2, args); va_arg(args2, id) != nil; count++);
	count >>= 1;
		count = 1;
		for (; va_arg(args2, id) != nil; count++);
		count >>= 1;

	if (count > UINT32_MAX) {
		if (count > UINT32_MAX)
		Class c = isa;
		[self dealloc];
		@throw [OFOutOfRangeException newWithClass: c];
	}

			@throw [OFOutOfRangeException newWithClass: isa];

		for (nsize = 1; nsize < count; nsize <<= 1);
	for (size = 1; size < count; size <<= 1);

	if (size == 0) {
		if (nsize == 0)
		Class c = isa;
		[self dealloc];
		@throw [OFOutOfRangeException newWithClass: c];
	}
			@throw [OFOutOfRangeException newWithClass: isa];


	@try {
		data = [self allocMemoryForNItems: size
		data = [self allocMemoryForNItems: nsize
					 withSize: sizeof(BUCKET*)];

		for (j = 0; j < size; j++)
		for (j = 0; j < nsize; j++)
			data[j] = NULL;
	} @catch (OFException *e) {
		/*
		 * We can't use [super dealloc] on OS X here. Compiler bug?
		 * Anyway, set size to 0 so that [self dealloc] works.
		 *                                                    */
		size = 0;
		[self dealloc];
		@throw e;
	}


	if (key == nil) {
		Class c = isa;
		size = 0;
		size = nsize;
		[self dealloc];
		@throw [OFInvalidArgumentException newWithClass: c
						       selector: _cmd];
	}

	if ((obj = va_arg(args, id)) == nil) {
		Class c = isa;
		[self dealloc];
		@throw [OFInvalidArgumentException newWithClass: c
						       selector: _cmd];
	}

	/* Add first key / object pair */
	hash = [(id)key hash];
	j = hash & (size - 1);
		/* Add first key / object pair */
		hash = [(id)key hash];
		j = hash & (size - 1);

	@try {
		b = [self allocMemoryWithSize: sizeof(BUCKET)];
		key = [key copy];
	} @catch (OFException *e) {
		[self dealloc];
		@throw e;
	}


	@try {
		[obj retain];
	} @catch (OFException *e) {
		[(id)key release];
		@try {
			[obj retain];
		} @catch (id e) {
			[(id)key release];
		[self dealloc];
		@throw e;
	}
			@throw e;
		}

	b->key = key;
	b->object = obj;
	b->hash = hash;
	data[j] = b;
		b->key = key;
		b->object = obj;
		b->hash = hash;

		data[j] = b;

	for (i = 1; i < count; i++) {
		uint32_t last;
		for (i = 1; i < count; i++) {
			uint32_t last;

		key = va_arg(args, id <OFCopying>);
		obj = va_arg(args, id);
			key = va_arg(args, id <OFCopying>);
			obj = va_arg(args, id);

		if (key == nil || obj == nil) {
			if (key == nil || obj == nil)
			Class c = isa;
			[self dealloc];
			@throw [OFInvalidArgumentException newWithClass: c
							       selector: _cmd];
		}
				@throw [OFInvalidArgumentException
				    newWithClass: isa
					selector: _cmd];


		hash = [(id)key hash];
		last = size;
			hash = [(id)key hash];
			last = size;

		for (j = hash & (size - 1); j < last && data[j] != NULL; j++)
			if ([(id)data[j]->key isEqual: key])
				break;
			for (j = hash & (size - 1); j < last && data[j] != NULL;
			    j++)
				if ([(id)data[j]->key isEqual: key])
					break;

		/* In case the last bucket is already used */
		if (j >= last) {
			last = hash & (size - 1);
			/* In case the last bucket is already used */
			if (j >= last) {
				last = hash & (size - 1);

			for (j = 0; j < last && data[j] != NULL; j++)
				if ([(id)data[j]->key isEqual: key])
					break;
		}
				for (j = 0; j < last && data[j] != NULL; j++)
					if ([(id)data[j]->key isEqual: key])
						break;
			}

		/* Key not in dictionary */
		if (j >= last || data[j] == NULL ||
		    ![(id)data[j]->key isEqual: key]) {
			last = size;
			/* Key not in dictionary */
			if (j >= last || data[j] == NULL ||
			    ![(id)data[j]->key isEqual: key]) {
				last = size;

			j = hash & (size - 1);
			for (; j < last && data[j] != NULL; j++);
				j = hash & (size - 1);
				for (; j < last && data[j] != NULL; j++);

			/* In case the last bucket is already used */
			if (j >= last) {
				last = hash & (size - 1);
				/* In case the last bucket is already used */
				if (j >= last) {
					last = hash & (size - 1);

				for (j = 0; j < last && data[j] != NULL; j++);
			}
					for (j = 0; j < last && data[j] != NULL;
					    j++);
				}

			if (j >= last) {
				if (j >= last)
				Class c = isa;
				[self dealloc];
				@throw [OFOutOfRangeException newWithClass: c];
			}
					@throw [OFOutOfRangeException
					    newWithClass: isa];


			@try {
				b = [self allocMemoryWithSize: sizeof(BUCKET)];
				key = [key copy];
			} @catch (OFException *e) {
				[self dealloc];
				@throw e;
			}


			@try {
				[obj retain];
			} @catch (OFException *e) {
				[(id)key release];
				@try {
					[obj retain];
				} @catch (id e) {
					[(id)key release];
				[self dealloc];
				@throw e;
			}
					@throw e;
				}

			b->key = key;
			b->object = obj;
			b->hash = hash;
			data[j] = b;
				b->key = key;
				b->object = obj;
				b->hash = hash;

				data[j] = b;

			continue;
		}
				continue;
			}

		/*
		 * They key is already in the dictionary. However, we just
		 * replace it so that the programmer gets the same behavior
		 * as if he'd call setObject:forKey: for each key/object pair.
		 */
			/*
			 * The key is already in the dictionary. However, we
			 * just replace it so that the programmer gets the same
			 * behavior as if he'd call setObject:forKey: for each
			 * key/object pair.
			 */
		@try {
			[obj retain];
		} @catch (OFException *e) {
			[self dealloc];
			@throw e;
		}


		@try {
			[data[j]->object release];
		} @catch (OFException *e) {
			[obj release];
			@try {
				[data[j]->object release];
			} @catch (id e) {
				[obj release];
			[self dealloc];
			@throw e;
		}
				@throw e;
			}

		data[j]->object = obj;
			data[j]->object = obj;
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (id)objectForKey: (id)key
{

Modified src/OFEnumerator.m from [d73a03ff14] to [338aae8b92].

13
14
15
16
17
18
19
20
21




22

23
24
25
26
27
28
29
13
14
15
16
17
18
19


20
21
22
23
24
25
26
27
28
29
30
31
32







-
-
+
+
+
+

+








#import "OFEnumerator.h"
#import "OFExceptions.h"

@implementation OFEnumerator
- init
{
	if (isa == [OFEnumerator class])
		@throw [OFNotImplementedException newWithClass: isa
	if (isa == [OFEnumerator class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
	}

	return [super init];
}

- (id)nextObject
{
	@throw [OFNotImplementedException newWithClass: isa

Modified src/OFExceptions.m from [f32751e237] to [d710bc9531].

147
148
149
150
151
152
153


154

155
156
157
158
159
160
161
147
148
149
150
151
152
153
154
155

156
157
158
159
160
161
162
163







+
+
-
+







+ newWithClass: (Class)class_
{
	return [[self alloc] initWithClass: class_];
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
{
	self = [super init];

249
250
251
252
253
254
255


256

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

260
261
262
263
264
265
266
267







+
+
-
+







{
	return [[self alloc] initWithClass: class_
				   pointer: ptr];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	pointer: (void*)ptr
{
	self = [super initWithClass: class_];
293
294
295
296
297
298
299


300

301
302
303
304
305
306
307
297
298
299
300
301
302
303
304
305

306
307
308
309
310
311
312
313







+
+
-
+







{
	return [[self alloc] initWithClass: class_
				  selector: selector];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
       selector: (SEL)selector_
{
	self = [super initWithClass: class_];
348
349
350
351
352
353
354


355

356
357
358
359
360
361
362
354
355
356
357
358
359
360
361
362

363
364
365
366
367
368
369
370







+
+
-
+







{
	return [[self alloc] initWithClass: class_
				  selector: selector_];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
       selector: (SEL)selector_
{
	self = [super initWithClass: class_];
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
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







+
+
-
+









+
-
-
-
+
+
+
+
+
+
+







	return [(OFOpenFileFailedException*)[self alloc] initWithClass: class_
								  path: path
								  mode: mode];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
	   mode: (OFString*)mode_
{
	self = [super initWithClass: class_];

	@try {
	path  = [path_ copy];
	mode  = [mode_ copy];
	errNo = GET_ERRNO;
		path  = [path_ copy];
		mode  = [mode_ copy];
		errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[path release];
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







+
+
-
+







{
	return [[self alloc] initWithClass: class_
				      size: size];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   size: (size_t)size
{
	self = [super initWithClass: class_];
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
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







+
+
-
+








+
-
-
+
+
+
+
+
+







{
	return [[self alloc] initWithClass: class_
				      path: path_];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
{
	self = [super initWithClass: class_];

	@try {
	path  = [path_ copy];
	errNo = GET_ERRNO;
		path  = [path_ copy];
		errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[path release];
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
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







+
+
-
+









+
-
-
-
+
+
+
+
+
+
+







	    initWithClass: class_
		     path: path
		     mode: mode];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
	   mode: (mode_t)mode_
{
	self = [super initWithClass: class_];

	@try {
	path  = [path_ copy];
	mode  = mode_;
	errNo = GET_ERRNO;
		path  = [path_ copy];
		mode  = mode_;
		errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[path release];
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
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







+
+
-
+










+
-
-
-
-
+
+
+
+
+
+
+
+







				      path: path
				     owner: owner
				     group: group];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
	  owner: (uid_t)owner_
	  group: (gid_t)group_
{
	self = [super initWithClass: class_];

	@try {
	path  = [path_ copy];
	owner = owner_;
	group = group_;
	errNo = GET_ERRNO;
		path  = [path_ copy];
		owner = owner_;
		group = group_;
		errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[path release];
801
802
803
804
805
806
807


808

809
810
811
812
813
814
815
816
817

818
819
820







821
822
823
824
825
826
827
839
840
841
842
843
844
845
846
847

848
849
850
851
852
853
854
855
856
857
858



859
860
861
862
863
864
865
866
867
868
869
870
871
872







+
+
-
+









+
-
-
-
+
+
+
+
+
+
+







	return [[self alloc] initWithClass: class_
				sourcePath: src
			   destinationPath: dst];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

-   initWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dst
{
	self = [super initWithClass: class_];

	@try {
	sourcePath = [src copy];
	destinationPath = [dst copy];
	errNo = GET_ERRNO;
		sourcePath = [src copy];
		destinationPath = [dst copy];
		errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[sourcePath release];
867
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
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
940
941
942
943
944
945







+
+
-
+









+
-
-
-
+
+
+
+
+
+
+







	return [[self alloc] initWithClass: class_
				sourcePath: src
			   destinationPath: dst];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

-   initWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dst
{
	self = [super initWithClass: class_];

	@try {
	sourcePath = [src copy];
	destinationPath = [dst copy];
	errNo = GET_ERRNO;
		sourcePath = [src copy];
		destinationPath = [dst copy];
		errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[sourcePath release];
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
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







+
+
-
+








+
-
-
+
+
+
+
+
+







{
	return [[self alloc] initWithClass: class_
				      path: path_];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
{
	self = [super initWithClass: class_];

	@try {
	path  = [path_ copy];
	errNo = GET_ERRNO;
		path  = [path_ copy];
		errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[path release];
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
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







+
+
-
+








+
-
-
+
+
+
+
+
+







{
	return [[self alloc] initWithClass: class_
				      path: path_];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
{
	self = [super initWithClass: class_];

	@try {
	path  = [path_ copy];
	errNo = GET_ERRNO;
		path  = [path_ copy];
		errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[path release];
1044
1045
1046
1047
1048
1049
1050


1051

1052
1053
1054
1055
1056
1057
1058
1110
1111
1112
1113
1114
1115
1116
1117
1118

1119
1120
1121
1122
1123
1124
1125
1126







+
+
-
+







	return [[self alloc] initWithClass: class_
				sourcePath: src
			   destinationPath: dest];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

-   initWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dest
{
1110
1111
1112
1113
1114
1115
1116


1117

1118
1119
1120
1121
1122
1123
1124
1178
1179
1180
1181
1182
1183
1184
1185
1186

1187
1188
1189
1190
1191
1192
1193
1194







+
+
-
+







	return [[self alloc] initWithClass: class_
				sourcePath: src
			   destinationPath: dest];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

-   initWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dest
{
1231
1232
1233
1234
1235
1236
1237

1238
1239
1240







1241
1242
1243
1244
1245
1246
1247
1301
1302
1303
1304
1305
1306
1307
1308



1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322







+
-
-
-
+
+
+
+
+
+
+








- initWithClass: (Class)class_
	   node: (OFString*)node_
	service: (OFString*)service_
{
	self = [super initWithClass: class_];

	@try {
	node	= [node_ copy];
	service = [service_ copy];
	errNo	= GET_AT_ERRNO;
		node	= [node_ copy];
		service = [service_ copy];
		errNo	= GET_AT_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[node release];
1296
1297
1298
1299
1300
1301
1302


1303

1304
1305
1306
1307
1308
1309
1310
1311
1312

1313
1314
1315







1316
1317
1318
1319
1320
1321
1322
1371
1372
1373
1374
1375
1376
1377
1378
1379

1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390



1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404







+
+
-
+









+
-
-
-
+
+
+
+
+
+
+







	return [[self alloc] initWithClass: class_
				      node: node
				   service: service];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   node: (OFString*)node_
	service: (OFString*)service_
{
	self = [super initWithClass: class_];

	@try {
	node	= [node_ copy];
	service	= [service_ copy];
	errNo	= GET_SOCK_ERRNO;
		node	= [node_ copy];
		service	= [service_ copy];
		errNo	= GET_SOCK_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[node release];
1364
1365
1366
1367
1368
1369
1370


1371

1372
1373
1374
1375
1376
1377
1378
1379
1380
1381

1382
1383
1384
1385








1386
1387
1388
1389
1390
1391
1392
1446
1447
1448
1449
1450
1451
1452
1453
1454

1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466




1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481







+
+
-
+










+
-
-
-
-
+
+
+
+
+
+
+
+







				      node: node
				   service: service
				    family: family];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   node: (OFString*)node_
	service: (OFString*)service_
	 family: (int)family_
{
	self = [super initWithClass: class_];

	@try {
	node	= [node_ copy];
	service	= [service_ copy];
	family	= family_;
	errNo	= GET_SOCK_ERRNO;
		node	= [node_ copy];
		service	= [service_ copy];
		family	= family_;
		errNo	= GET_SOCK_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[node release];
1435
1436
1437
1438
1439
1440
1441


1442

1443
1444
1445
1446
1447
1448
1449
1524
1525
1526
1527
1528
1529
1530
1531
1532

1533
1534
1535
1536
1537
1538
1539
1540







+
+
-
+







{
	return [[self alloc] initWithClass: class_
				   backLog: backlog];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	backLog: (int)backlog
{
	self = [super initWithClass: class_];
1599
1600
1601
1602
1603
1604
1605


1606

1607
1608
1609
1610
1611
1612
1613
1614

1615





1616
1617
1618
1619
1620
1621
1622
1623
1624

1625





1626
1627
1628
1629
1630
1631
1632
1690
1691
1692
1693
1694
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
1720
1721
1722
1723

1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735







+
+
-
+








+
-
+
+
+
+
+









+
-
+
+
+
+
+







{
	return [[self alloc] initWithClass: class_
				    prefix: prefix];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
      namespace: (OFString*)ns_
{
	self = [super initWithClass: class_];

	@try {
	ns = [ns_ copy];
		ns = [ns_ copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithClass: (Class)class_
	 prefix: (OFString*)prefix_
{
	self = [super initWithClass: class_];

	@try {
	prefix = [prefix_ copy];
		prefix = [prefix_ copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[ns release];

Modified src/OFFile.m from [9c2025e097] to [d06bb2b5c9].

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
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







+
+
-
+






+
-
-
+
+
+

-
-
-
+
-
-
-
-
-
+
+
+
-
-
+
-
-
-
-
-
-
+
+
+
+
-
-
+
+
+
+
+







						   sourcePath: src
					      destinationPath: dest];
}
#endif

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithPath: (OFString*)path
	  mode: (OFString*)mode
{
	self = [super init];
	Class c;
	int flags;

	@try {
		int flags;

	self = [super init];

	if ((flags = parse_mode([mode cString])) == -1) {
		if ((flags = parse_mode([mode cString])) == -1)
		c = isa;
		[super dealloc];
		@throw [OFInvalidArgumentException newWithClass: c
						       selector: _cmd];
	}
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];


	if ((fd = open([path cString], flags, DEFAULT_MODE)) == -1) {
		if ((fd = open([path cString], flags, DEFAULT_MODE)) == -1)
		c = isa;
		[super dealloc];
		@throw [OFOpenFileFailedException newWithClass: c
							  path: path
							  mode: mode];
	}
			@throw [OFOpenFileFailedException newWithClass: isa
								  path: path
								  mode: mode];


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

	return self;
}

- initWithFileDescriptor: (int)fd_
{
	self = [super init];
539
540
541
542
543
544
545


546

547
548
549
550
551
552
553
539
540
541
542
543
544
545
546
547

548
549
550
551
552
553
554
555







+
+
-
+







@end

/// \cond internal
@implementation OFFileSingleton
- initWithPath: (OFString*)path
	  mode: (OFString*)mode
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- autorelease
{
	return self;
}

Modified src/OFList.m from [79d7008d03] to [39a49b7b3f].

222
223
224
225
226
227
228
229

230
231
232
233
234
235
236
222
223
224
225
226
227
228

229
230
231
232
233
234
235
236







-
+








			new->count++;

			[o->object retain];

			prev = o;
		}
	} @catch (OFException *e) {
	} @catch (id e) {
		[new release];
		@throw e;
	}

	new->lastListObject = o;

	return new;

Modified src/OFMutableDictionary.m from [078edcac44] to [0596555fcb].

137
138
139
140
141
142
143
144

145

146
147
148
149
150

151
152
153
154
155
156
157
137
138
139
140
141
142
143

144
145
146
147
148
149
150

151
152
153
154
155
156
157
158







-
+

+




-
+







		if (i >= last)
			@throw [OFOutOfRangeException newWithClass: isa];

		b = [self allocMemoryWithSize: sizeof(BUCKET)];

		@try {
			key = [key copy];
		} @catch (OFException *e) {
		} @catch (id e) {
			[self freeMemory: b];
			@throw e;
		}

		@try {
			[obj retain];
		} @catch (OFException *e) {
		} @catch (id e) {
			[self freeMemory: b];
			[(id)key release];
			@throw e;
		}

		b->key = key;
		b->object = obj;

Modified src/OFMutableString.m from [a7c6aaf7d8] to [21aaad94ff].

92
93
94
95
96
97
98
99

100
101
102
103
104
105
106
92
93
94
95
96
97
98

99
100
101
102
103
104
105
106







-
+







		}

		i += clen;
	}

	@try {
		nstr = [self allocMemoryWithSize: nlen + 1];
	} @catch (OFException *e) {
	} @catch (id e) {
		[self freeMemory: ustr];
		@throw e;
	}

	j = 0;

	for (i = 0; i < ulen; i++) {
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
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







-
+













-
+







		if (memcmp(string + i, str_c, str_len))
			continue;

		@try {
			tmp = [self resizeMemory: tmp
					  toSize: tmp_len + i - last +
						  repl_len + 1];
		} @catch (OFException *e) {
		} @catch (id e) {
			[self freeMemory: tmp];
			@throw e;
		}
		memcpy(tmp + tmp_len, string + last, i - last);
		memcpy(tmp + tmp_len + i - last, repl_c, repl_len);
		tmp_len += i - last + repl_len;
		i += str_len - 1;
		last = i + 1;
	}

	@try {
		tmp = [self resizeMemory: tmp
				  toSize: tmp_len + length - last + 1];
	} @catch (OFException *e) {
	} @catch (id e) {
		[self freeMemory: tmp];
		@throw e;
	}
	memcpy(tmp + tmp_len, string + last, length - last);
	tmp_len += length - last;
	tmp[tmp_len] = 0;

Modified src/OFPlugin.m from [510d0be2d3] to [0c901eacaf].

55
56
57
58
59
60
61
62
63




64

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


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







-
-
+
+
+
+

+












	plugin->handle = handle;
	return plugin;
}

- init
{
	if (isa == [OFPlugin class])
		@throw [OFNotImplementedException newWithClass: isa
	if (isa == [OFPlugin class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
	}

	return [super init];
}

- (void)dealloc
{
	dlclose(handle);

	[super dealloc];
}
@end

Modified src/OFStream.m from [712dcb6dbd] to [9e9b9829fb].

26
27
28
29
30
31
32
33
34
35
36




37



38
39
40
41
42
43
44
26
27
28
29
30
31
32




33
34
35
36
37
38
39
40
41
42
43
44
45
46
47







-
-
-
-
+
+
+
+

+
+
+







#import "macros.h"

#import "asprintf.h"

@implementation OFStream
- init
{
	self = [super init];

	if (isa == [OFStream class])
		@throw [OFNotImplementedException newWithClass: isa
	if (isa == [OFStream class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
	}

	self = [super init];

	cache = NULL;
	wBuffer = NULL;

	return self;
}

312
313
314
315
316
317
318
319

320
321
322
323
324
325
326
315
316
317
318
319
320
321

322
323
324
325
326
327
328
329







-
+







						ret_len--;

					@try {
						ret = [OFString
						    stringWithCString: ret_c
							     encoding: encoding
							       length: ret_len];
					} @catch (OFException *e) {
					} @catch (id e) {
						/*
						 * Append data to cache to
						 * prevent loss of data due to
						 * wrong encoding.
						 */
						cache = [self
						    resizeMemory: cache

Modified src/OFStreamObserver.m from [3a6498e60a] to [269a665b2b].

43
44
45
46
47
48
49
50
51


52
53
54
55
56
57
58
43
44
45
46
47
48
49


50
51
52
53
54
55
56
57
58







-
-
+
+







		fds = [[OFDataArray alloc] initWithItemSize:
		    sizeof(struct pollfd)];
		fdToStream = [[OFMutableDictionary alloc] init];
#else
		FD_ZERO(&readfds);
		FD_ZERO(&writefds);
#endif
	} @catch (OFException *e) {
		[self dealloc];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc

Modified src/OFString.h from [5350934922] to [3ca2bba748].

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
131
132
133
134
135
136
137







138
139
140
141
142
143
144







-
-
-
-
-
-
-







 * \param path The path to the file
 * \param encoding The encoding of the file
 * \return A new autoreleased OFString
 */
+ stringWithContentsOfFile: (OFString*)path
		  encoding: (enum of_string_encoding)encoding;

/**
 * Initializes an already allocated OFString.
 *
 * \return An initialized OFString
 */
- init;

/**
 * Initializes an already allocated OFString from a UTF-8 encoded C string.
 *
 * \param str A UTF-8 encoded C string to initialize the OFString with
 * \return An initialized OFString
 */
- initWithCString: (const char*)str;

Modified src/OFString.m from [2546d1519d] to [6583af04e3].

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
339
340

341
342
343
344
345
346
347
348
349


350
351
352
353
354
355
356
357






358
359
360
361
362
363
364
365
366



367
368
369


370
371
372
373




374
375
376
377
378







379
380
381
382
383


384
385

386
387
388

389
390
391
392


393
394
395
396
397
398
399
400

401
402
403
404
405
406
407


























408
409
410
411
412
413
414
415
416
417
















418
419
420


421
422

423
424
425
426
427
428
429
430
431
432
433



434
435

436
437
438


439
440
441
442
443
444
445
446
447
448
449

450
451
452
453
454




455
456
457

458
459
460
461
462
463
464
465
466
467


468
469
470
471
472
473
474
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









339
340
341
342


343
344
345



346
347
348
349





350
351
352
353
354
355
356





357
358


359



360




361
362








363

364





365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390










391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406



407
408
409

410











411
412
413


414



415
416











417





418
419
420
421

422

423










424
425
426
427
428
429
430
431
432







-
-
-
-
-
-
-
-
-



















-
-


+
+
-
+

-
-
+
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+

-
-
+
+

-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
-
-
+
-
-
-
+
-
-
-
-
+
+
-
-
-
-
-
-
-
-
+
-

-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+

-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
+
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
+
+
+
-

-
+
-
-
-
-
-
-
-
-
-
-
+
+







+ stringWithContentsOfFile: (OFString*)path
		  encoding: (enum of_string_encoding)encoding
{
	return [[[self alloc] initWithContentsOfFile: path
					    encoding: encoding] autorelease];
}

- init
{
	[super init];

	string = NULL;

	return self;
}

- initWithCString: (const char*)str
{
	return [self initWithCString: str
			    encoding: OF_STRING_ENCODING_UTF_8
			      length: strlen(str)];
}

- initWithCString: (const char*)str
	 encoding: (enum of_string_encoding)encoding
{
	return [self initWithCString: str
			    encoding: encoding
			      length: strlen(str)];
}

- initWithCString: (const char*)str
	 encoding: (enum of_string_encoding)encoding
	   length: (size_t)len
{
	size_t i, j;

	self = [super init];

	@try {
		size_t i, j;
	length = len;
		const uint16_t *table;

	@try {
		string = [self allocMemoryWithSize: length + 1];
		string = [self allocMemoryWithSize: len + 1];
	} @catch (OFException *e) {
		/*
		 * We can't use [super dealloc] on OS X here.
		 * Compiler bug? Anyway, [self dealloc] will do here as we
		 * don't reimplement dealloc.
		 */
		[self dealloc];
		@throw e;
	}
		length = len;


	switch (encoding) {
	case OF_STRING_ENCODING_UTF_8:
		switch (of_string_check_utf8(str, length)) {
		case 1:
			isUTF8 = YES;
			break;
		case -1:;
		if (encoding == OF_STRING_ENCODING_UTF_8) {
			switch (of_string_check_utf8(str, length)) {
			case 1:
				isUTF8 = YES;
				break;
			case -1:
			/*
			 * We can't use [super dealloc] on OS X here.
			 * Compiler bug? Anyway, [self dealloc] will do here as
			 * we don't reimplement dealloc.
			 */
			Class c = isa;
			[self dealloc];
			@throw [OFInvalidEncodingException newWithClass: c];
		}
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
			}

		memcpy(string, str, length);
		string[length] = 0;
			memcpy(string, str, length);
			string[length] = 0;

		break;
	case OF_STRING_ENCODING_ISO_8859_1:
	case OF_STRING_ENCODING_ISO_8859_15:
			return self;
		}

		if (encoding == OF_STRING_ENCODING_ISO_8859_1) {
	case OF_STRING_ENCODING_WINDOWS_1252:
		for (i = j = 0; i < len; i++) {
			if (!(str[i] & 0x80))
				string[j++] = str[i];
			else {
			for (i = j = 0; i < len; i++) {
				char buf[4];
				size_t bytes;

				if (!(str[i] & 0x80)) {
					string[j++] = str[i];
					continue;
				char buf[4];
				of_unichar_t chr;
				size_t chr_bytes;

				switch (encoding) {
				}

				case OF_STRING_ENCODING_ISO_8859_1:
					chr = (uint8_t)str[i];
				isUTF8 = YES;
					break;
				case OF_STRING_ENCODING_ISO_8859_15:
					chr = of_iso_8859_15[(uint8_t)str[i]];
				bytes = of_string_unicode_to_utf8(
					break;
				case OF_STRING_ENCODING_WINDOWS_1252:
					chr = of_windows_1252[(uint8_t)str[i]];
					break;
				    (uint8_t)str[i], buf);

				default:;
					/*
					 * We can't use [super dealloc] on OS X
					 * here. Compiler bug? Anyway,
					 * [self dealloc] will do here as we
					 * don't reimplement dealloc.
					 */
					Class c = isa;
				if (bytes == 0)
					[self dealloc];
					@throw [OFInvalidEncodingException
					    newWithClass: c];
				}

				if (chr == 0xFFFD) {
					/*
					    newWithClass: isa];

				length += bytes - 1;
				string = [self resizeMemory: string
						     toSize: length + 1];

				memcpy(string + j, buf, bytes);
				j += bytes;
			}

			string[length] = 0;

			return self;
		}

		switch (encoding) {
		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 newWithClass: isa];
		}

					 * We can't use [super dealloc] on OS X
					 * here. Compiler bug? Anyway,
					 * [self dealloc] will do here as we
					 * don't reimplement dealloc.
					 */
					Class c = isa;
					[self dealloc];
					@throw [OFInvalidEncodingException
					    newWithClass: c];
				}
		for (i = j = 0; i < len; i++) {
			char buf[4];
			of_unichar_t chr;
			size_t chr_bytes;

			if (!(str[i] & 0x80)) {
				string[j++] = str[i];
				continue;
			}

			chr = table[(uint8_t)str[i]];

			if (chr == 0xFFFD)
				@throw [OFInvalidEncodingException
				    newWithClass: isa];


				isUTF8 = YES;
				chr_bytes = of_string_unicode_to_utf8(chr, buf);
			isUTF8 = YES;
			chr_bytes = of_string_unicode_to_utf8(chr, buf);

				if (chr_bytes == 0) {
			if (chr_bytes == 0)
					/*
					 * We can't use [super dealloc] on OS X
					 * here. Compiler bug? Anyway,
					 * [self dealloc] will do here as we
					 * don't reimplement dealloc.
					 */
					Class c = isa;
					[self dealloc];
					@throw [OFInvalidEncodingException
					    newWithClass: c];
				}
				@throw [OFInvalidEncodingException
				    newWithClass: isa];


				length += chr_bytes - 1;
			length += chr_bytes - 1;
				@try {
					string = [self resizeMemory: string
							     toSize: length +
			string = [self resizeMemory: string
					     toSize: length + 1];
								     1];
				} @catch (OFException *e) {
					/*
					 * We can't use [super dealloc] on OS X
					 * here. Compiler bug? Anyway,
					 * [self dealloc] will do here as we
					 * don't reimplement dealloc.
					 */
					[self dealloc];
					@throw e;
				}


				memcpy(string + j, buf, chr_bytes);
				j += chr_bytes;
			}
		}
			memcpy(string + j, buf, chr_bytes);
			j += chr_bytes;
		}


		string[length] = 0;

	} @catch (id e) {
		break;
	default:;
		/*
		 * We can't use [super dealloc] on OS X here.
		 * Compiler bug? Anyway, [self dealloc] will do here as we
		 * don't reimplement dealloc.
		 */
		Class c = isa;
		[self dealloc];
		@throw [OFInvalidEncodingException newWithClass: c];
		[self release];
		@throw e;
	}

	return self;
}

- initWithCString: (const char*)str
	   length: (size_t)len
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
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







-
-


-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+








	return ret;
}

- initWithFormat: (OFString*)fmt
       arguments: (va_list)args
{
	int t;

	self = [super init];

	if (fmt == nil) {
		Class c = isa;
		[super dealloc];
		@throw [OFInvalidArgumentException newWithClass: c
						       selector: _cmd];
	}

	if ((t = vasprintf(&string, [fmt cString], args)) == -1) {
		Class c = isa;
		[super dealloc];

		/*
		 * This is only the most likely error to happen. Unfortunately,
		 * there is no good way to check what really happened.
		 */
		@throw [OFOutOfMemoryException newWithClass: c];
	}
	length = t;

	switch (of_string_check_utf8(string, length)) {
	case 1:
		isUTF8 = YES;
		break;
	case -1:;
		Class c = isa;
		free(string);
		[super dealloc];
		@throw [OFInvalidEncodingException newWithClass: c];
	}

	@try {
		int t;

		if (fmt == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		if ((t = vasprintf(&string, [fmt cString], args)) == -1)
			/*
			 * This is only the most likely error to happen.
			 * Unfortunately, there is no good way to check what
			 * really happened.
			 */
			@throw [OFOutOfMemoryException newWithClass: isa];

		@try {
			length = t;

			switch (of_string_check_utf8(string, length)) {
			case 1:
				isUTF8 = YES;
				break;
			case -1:
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
			}

		[self addMemoryToPool: string];
	} @catch (OFException *e) {
		free(string);
			[self addMemoryToPool: string];
		} @catch (id e) {
			free(string);
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithPath: (OFString*)first, ...
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
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
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







+
+
+
-
-
-
+
+
+
-

-
+

-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
-

+
-
-
-
-
+
+
+
+

-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+

-

-
-
-
-

-
-
-
+
+
+

-
-
-
-
-
-
+
+
+
+
+
+

-
+
+
+
+
+








+
+
-
-
+
+

-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+

-
+
-
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+















+
+
+
+
-
-
-
+
+
+

-
+
-
-
-
+
-
-
-
-
-
-
+
-
-
-
+
+
-
-
-
+
+


-
-
-
-
-
-
-
+
-
-



-
-
+
+
+
+
+
+
+








	return ret;
}

- initWithPath: (OFString*)first
     arguments: (va_list)args
{
	self = [super init];

	@try {
	OFString *component;
	size_t len, i;
	va_list args2;
		OFString *component;
		size_t len, i;
		va_list args2;
	Class c;

	self = [super init];
		length = [first cStringLength];

	len = [first cStringLength];
	switch (of_string_check_utf8([first cString], len)) {
	case 1:
		isUTF8 = YES;
		break;
	case -1:
		switch (of_string_check_utf8([first cString], length)) {
		case 1:
			isUTF8 = YES;
			break;
		case -1:
		c = isa;
		[self dealloc];
		@throw [OFInvalidEncodingException newWithClass: c];
	}
			@throw [OFInvalidEncodingException newWithClass: isa];
		}
	length += len;

		/* Calculate length */
	va_copy(args2, args);
	while ((component = va_arg(args2, OFString*)) != nil) {
		len = [component cStringLength];
		length += 1 + len;
		va_copy(args2, args);
		while ((component = va_arg(args2, OFString*)) != nil) {
			len = [component cStringLength];
			length += 1 + len;

		switch (of_string_check_utf8([component cString], len)) {
		case 1:
			isUTF8 = YES;
			break;
		case -1:
			switch (of_string_check_utf8([component cString],
			    len)) {
			case 1:
				isUTF8 = YES;
				break;
			case -1:
			c = isa;
			[self dealloc];
			@throw [OFInvalidEncodingException newWithClass: c];
		}
	}
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
			}
		}

	@try {
		string = [self allocMemoryWithSize: length + 1];
	} @catch (OFException *e) {
		[self dealloc];
		@throw e;
	}

	len = [first cStringLength];
	memcpy(string, [first cString], len);
	i = len;
		len = [first cStringLength];
		memcpy(string, [first cString], len);
		i = len;

	while ((component = va_arg(args, OFString*)) != nil) {
		len = [component cStringLength];
		string[i] = OF_PATH_DELIM;
		memcpy(string + i + 1, [component cString], len);
		i += len + 1;
	}
		while ((component = va_arg(args, OFString*)) != nil) {
			len = [component cStringLength];
			string[i] = OF_PATH_DELIM;
			memcpy(string + i + 1, [component cString], len);
			i += len + 1;
		}

	string[i] = '\0';
		string[i] = '\0';
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithString: (OFString*)str
{
	self = [super init];

	@try {
		/* We have no -[dealloc], so this is ok */
	string = (char*)[str cString];
	length = [str cStringLength];
		string = (char*)[str cString];
		length = [str cStringLength];

	switch (of_string_check_utf8(string, length)) {
	case 1:
		isUTF8 = YES;
		break;
	case -1:;
		switch (of_string_check_utf8(string, length)) {
		case 1:
			isUTF8 = YES;
			break;
		case -1:;
		Class c = isa;
		[self dealloc];
		@throw [OFInvalidEncodingException newWithClass: c];
	}
			@throw [OFInvalidEncodingException newWithClass: isa];
		}

	if ((string = strdup(string)) == NULL) {
		if ((string = strdup(string)) == NULL)
		Class c = isa;
		[self dealloc];
		@throw [OFOutOfMemoryException newWithClass: c
						       size: length + 1];
	}
			@throw [OFOutOfMemoryException newWithClass: isa
							       size: length +
								     1];


	@try {
		[self addMemoryToPool: string];
	} @catch (OFException *e) {
		@try {
			[self addMemoryToPool: string];
		} @catch (id e) {
		/*
		 * We can't use [super dealloc] on OS X here.
		 * Compiler bug? Anyway, [self dealloc] will do here as we
		 * don't reimplement dealloc.
		 */
		free(string);
		[self dealloc];
			free(string);
			@throw e;
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithContentsOfFile: (OFString*)path
{
	return [self initWithContentsOfFile: path
				   encoding: OF_STRING_ENCODING_UTF_8];
}

- initWithContentsOfFile: (OFString*)path
		encoding: (enum of_string_encoding)encoding
{
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFFile *file = nil;
	char *tmp;
	struct stat s;
		OFFile *file;
		char *tmp;
		struct stat s;

	if (stat([path cString], &s) == -1) {
		if (stat([path cString], &s) == -1)
		Class c = isa;
		[super dealloc];
		@throw [OFInitializationFailedException newWithClass: c];
			@throw [OFInitializationFailedException
	}

	if ((tmp = malloc(s.st_size)) == NULL) {
		Class c = isa;
		[super dealloc];
		@throw [OFOutOfMemoryException newWithClass: c
			    newWithClass: isa];
						       size: s.st_size];
	}


		tmp = [self allocMemoryWithSize: s.st_size];
	@try {
		file = [[OFFile alloc] initWithPath: path
					       mode: @"rb"];
		file = [OFFile fileWithPath: path
				       mode: @"rb"];
		[file readExactlyNBytes: s.st_size
			     intoBuffer: tmp];
	} @catch (OFException *e) {
		free(tmp);
		[super dealloc];
		@throw e;
	} @finally {
		[file release];
	}


	@try {
		self = [self initWithCString: tmp
				    encoding: encoding
				      length: s.st_size];
	} @finally {
		free(tmp);

		[self freeMemory: tmp];

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

	return self;
}

- (const char*)cString
{

Modified src/OFTCPSocket.m from [9e5de8c85a] to [fc8eae7a7b].

154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168







-
+







# ifdef OF_THREADS
	@try {
		for (ip = he->h_addr_list; *ip != NULL; ip++)
			[addrlist addItem: ip];

		/* Add the terminating NULL */
		[addrlist addItem: ip];
	} @catch (OFException *e) {
	} @catch (id e) {
		[addrlist release];
		@throw e;
	} @finally {
		[mutex unlock];
	}

	for (ip = [addrlist cArray]; *ip != NULL; ip++) {
342
343
344
345
346
347
348
349

350
351
352
353
354
355
356
342
343
344
345
346
347
348

349
350
351
352
353
354
355
356







-
+







	int s;

	newsock = [OFTCPSocket socket];
	addrlen = sizeof(struct sockaddr);

	@try {
		addr = [newsock allocMemoryWithSize: sizeof(struct sockaddr)];
	} @catch (OFException *e) {
	} @catch (id e) {
		[newsock dealloc];
		@throw e;
	}

	if ((s = accept(sock, addr, &addrlen)) == INVALID_SOCKET) {
		[newsock dealloc];
		@throw [OFAcceptFailedException newWithClass: isa];

Modified src/OFThread.m from [4035170a3e] to [6d911d6e5b].

131
132
133
134
135
136
137


138

139
140
141
142
143
144
145

146





147
148
149
150
151
152
153
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







+
+
-
+







+
-
+
+
+
+
+







	[thread release];

	of_thread_exit();
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

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

	@try {
	object = [obj retain];
		object = [obj retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (id)main
{
	@throw [OFNotImplementedException newWithClass: isa
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
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







+
-
+
-
-
-
-
+
+
+
-
-
+

-
+
-

+
-
+
-
-
-
-
-
-
-
-
+
+
-







	}
}

- init
{
	self = [super init];

	@try {
	if (!of_tlskey_new(&key)) {
		if (!of_tlskey_new(&key))
		Class c = isa;
		[super dealloc];
		@throw [OFInitializationFailedException newWithClass: c];
	}
			@throw [OFInitializationFailedException
			    newWithClass: isa];


	destructor = NULL;
		destructor = NULL;

	@synchronized (tlskeys) {
		@synchronized (tlskeys) {
		@try {
			listobj = [tlskeys appendObject: self];
		}
		} @catch (OFException *e) {
	} @catch (id e) {
			/*
			 * We can't use [super dealloc] on OS X here.
			 * Compiler bug? Anyway, [self dealloc] will do here
			 * as we check listobj != NULL in dealloc.
			 */
			listobj = NULL;
			[self dealloc];
			@throw e;
		[self release];
		@throw e;
		}
	}

	return self;
}

- initWithDestructor: (void(*)(id))destructor_
{
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
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







-
-
-
+
+
+

+


















-
+







- (void)dealloc
{
	if (destructor != NULL)
		destructor(self);

	of_tlskey_free(key);

	@synchronized (tlskeys) {
		/* In case we called [self dealloc] in init */
		if (listobj != NULL)
	/* In case we called [self release] in init */
	if (listobj != NULL) {
		@synchronized (tlskeys) {
			[tlskeys removeListObject: listobj];
		}
	}

	[super dealloc];
}
@end

@implementation OFMutex
+ mutex
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	if (!of_mutex_new(&mutex)) {
		Class c = isa;
		[self dealloc];
		[self release];
		@throw [OFInitializationFailedException newWithClass: c];
	}

	return self;
}

- (void)lock

Modified src/OFXMLAttribute.m from [2b47f3dee2] to [beaa9ae3cf].

27
28
29
30
31
32
33

34
35
36







37
38
39
40
41
42
43
27
28
29
30
31
32
33
34



35
36
37
38
39
40
41
42
43
44
45
46
47
48







+
-
-
-
+
+
+
+
+
+
+








- initWithName: (OFString*)name_
     namespace: (OFString*)ns_
   stringValue: (OFString*)value
{
	self = [super init];

	@try {
	name = [name_ copy];
	ns = [ns_ copy];
	stringValue = [value copy];
		name = [name_ copy];
		ns = [ns_ copy];
		stringValue = [value copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[name release];

Modified src/OFXMLElement.m from [e59c8082fb] to [4e57f733e3].

64
65
66
67
68
69
70


71

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

73
74
75
76
77
78
79
80







+
+
-
+







+ elementWithComment: (OFString*)comment
{
	return [[[self alloc] initWithComment: comment] autorelease];
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: isa
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithName: (OFString*)name_
{
	return [self initWithName: name_
			namespace: nil
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
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







+
-
-
+
+

-
-
-
-
-
-
+
+
+
+
+
+
+
+

-
-
-
+
+
+
+
+
+
+
+








+
-
+
+
+
+
+








+
-
+
+
+
+
+








+
-
+
+
+
+
+








- initWithName: (OFString*)name_
     namespace: (OFString*)ns_
   stringValue: (OFString*)stringval
{
	self = [super init];

	@try {
	name = [name_ copy];
	ns = [ns_ copy];
		name = [name_ copy];
		ns = [ns_ copy];

	if (stringval != nil) {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];;
		[self addChild:
		    [OFXMLElement elementWithCharacters: stringval]];
		[pool release];
	}
		if (stringval != nil) {
			OFAutoreleasePool *pool;

			pool = [[OFAutoreleasePool alloc] init];;
			[self addChild:
			    [OFXMLElement elementWithCharacters: stringval]];
			[pool release];
		}

	namespaces = [[OFMutableDictionary alloc] initWithKeysAndObjects:
	    @"http://www.w3.org/XML/1998/namespace", @"xml",
	    @"http://www.w3.org/2000/xmlns/", @"xmlns", nil];
		namespaces = [[OFMutableDictionary alloc]
		    initWithKeysAndObjects:
		    @"http://www.w3.org/XML/1998/namespace", @"xml",
		    @"http://www.w3.org/2000/xmlns/", @"xmlns", nil];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithCharacters: (OFString*)chars
{
	self = [super init];

	@try {
	characters = [chars copy];
		characters = [chars copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithCDATA: (OFString*)cdata_
{
	self = [super init];

	@try {
	cdata = [cdata_ copy];
		cdata = [cdata_ copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithComment: (OFString*)comment_
{
	self = [super init];

	@try {
	comment = [comment_ copy];
		comment = [comment_ copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (OFString*)name
{
	return [[name copy] autorelease];
225
226
227
228
229
230
231
232

233
234
235
236
237
238
239
250
251
252
253
254
255
256

257
258
259
260
261
262
263
264







-
+







		    (ns != nil ? ns : (OFString*)@"")]) == nil)
			@throw [OFUnboundNamespaceException newWithClass: isa
							       namespace: ns];
		len += [prefix cStringLength] + 1;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (OFException *e) {
		} @catch (id e) {
			[self freeMemory: str_c];
			@throw e;
		}

		memcpy(str_c + i, [prefix cString],
		    [prefix cStringLength]);
		i += [prefix cStringLength];
263
264
265
266
267
268
269
270

271
272
273
274
275
276
277
288
289
290
291
292
293
294

295
296
297
298
299
300
301
302







-
+







		len += [attr_name cStringLength] +
		    (attr_prefix != nil ? [attr_prefix cStringLength] + 1 : 0) +
		    [tmp cStringLength] + 4;

		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (OFException *e) {
		} @catch (id e) {
			[self freeMemory: str_c];
			@throw e;
		}

		str_c[i++] = ' ';
		if (attr_prefix != nil) {
			memcpy(str_c + i, [attr_prefix cString],
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
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







-
+














-
+







			    _stringWithParentNamespaces: all_namespaces
			    parentDefaultNamespace: defaultNamespace] cString]);

		len += [tmp cStringLength] + [name cStringLength] + 2;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (OFException *e) {
		} @catch (id e) {
			[self freeMemory: str_c];
			@throw e;
		}

		str_c[i++] = '>';
		memcpy(str_c + i, [tmp cString], [tmp cStringLength]);
		i += [tmp cStringLength];
		str_c[i++] = '<';
		str_c[i++] = '/';
		if (prefix != nil) {
			len += [prefix cStringLength] + 1;
			@try {
				str_c = [self resizeMemory: str_c
						    toSize: len];
			} @catch (OFException *e) {
			} @catch (id e) {
				[self freeMemory: str_c];
				@throw e;
			}

			memcpy(str_c + i, [prefix cString],
			    [prefix cStringLength]);
			i += [prefix cStringLength];

Modified src/OFXMLElementBuilder.m from [59069a8174] to [eabccc3dd1].

23
24
25
26
27
28
29

30





31
32
33
34
35
36
37
23
24
25
26
27
28
29
30

31
32
33
34
35
36
37
38
39
40
41
42







+
-
+
+
+
+
+







	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	@try {
	stack = [[OFMutableArray alloc] init];
		stack = [[OFMutableArray alloc] init];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[stack release];

Modified src/OFXMLParser.m from [38257f6427] to [54f1adaa82].

140
141
142
143
144
145
146
147
148


149
150
151
152
153
154
155
140
141
142
143
144
145
146


147
148
149
150
151
152
153
154
155







-
-
+
+








		pool = [[OFAutoreleasePool alloc] init];
		dict = [OFMutableDictionary dictionaryWithKeysAndObjects:
		    @"xml", @"http://www.w3.org/XML/1998/namespace",
		    @"xmlns", @"http://www.w3.org/2000/xmlns/", nil];
		[namespaces addObject: dict];
		[pool release];
	} @catch (OFException *e) {
		[self dealloc];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc