ObjFW  Diff

Differences From Artifact [91dcfe7c0f]:

To Artifact [93ab00cf42]:


20
21
22
23
24
25
26
27

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

27
28
29
30
31
32
33
34







-
+







#import "OFOptionsParser.h"
#import "OFApplication.h"
#import "OFArray.h"
#import "OFMapTable.h"

#import "OFInvalidArgumentException.h"

static uint32_t
static unsigned long
stringHash(void *object)
{
	return ((OFString *)object).hash;
}

static bool
stringEqual(void *object1, void *object2)
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97
98
99
100
101
82
83
84
85
86
87
88
89
90
91
92



93
94
95
96
97
98
99







+



-
-
-







				*iter->isSpecifiedPtr = false;
			if (iter->argumentPtr)
				*iter->argumentPtr = nil;

			count++;
		}

		_options = of_malloc(count + 1, sizeof(*_options));
		_longOptions = [[OFMapTable alloc]
		    initWithKeyFunctions: keyFunctions
			 objectFunctions: objectFunctions];
		_options = [self
		    allocMemoryWithSize: sizeof(*_options)
				  count: count + 1];

		for (iter = options, iter2 = _options;
		    iter->shortOption != '\0' || iter->longOption != nil;
		    iter++, iter2++) {
			iter2->shortOption = iter->shortOption;
			iter2->longOption = nil;
			iter2->hasArgument = iter->hasArgument;
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







+







	return self;
}

- (void)dealloc
{
	of_options_parser_option_t *iter;

	free(_options);
	[_longOptions release];

	if (_options != NULL)
		for (iter = _options;
		    iter->shortOption != '\0' || iter->longOption != nil;
		    iter++)
			[iter->longOption release];
193
194
195
196
197
198
199
200

201
202
203
204
205


206
207
208
209
210
211
212
192
193
194
195
196
197
198

199


200


201
202
203
204
205
206
207
208
209







-
+
-
-

-
-
+
+







			size_t pos;
			of_options_parser_option_t *option;

			_lastOption = '-';
			_index++;

			if ((pos = [argument rangeOfString: @"="].location) !=
			    OF_NOT_FOUND) {
			    OF_NOT_FOUND)
				of_range_t range = of_range(pos + 1,
				    argument.length - pos - 1);
				_argument = [[argument
				    substringWithRange: range] copy];
			} else
				    substringFromIndex: pos + 1] copy];
			else
				pos = argument.length;

			_lastLongOption = [[argument substringWithRange:
			    of_range(2, pos - 2)] copy];

			objc_autoreleasePoolPop(pool);

251
252
253
254
255
256
257
258

259
260
261
262
263
264
265
266
248
249
250
251
252
253
254

255

256
257
258
259
260
261
262







-
+
-







				return _lastOption;
			}

			if (_index >= _arguments.count)
				return ':';

			argument = [_arguments objectAtIndex: _index];
			argument = [argument substringWithRange:
			argument = [argument substringFromIndex: _subIndex];
			    of_range(_subIndex, argument.length - _subIndex)];

			_argument = [argument copy];

			if (iter->isSpecifiedPtr != NULL)
				*iter->isSpecifiedPtr = true;
			if (iter->argumentPtr != NULL)
				*iter->argumentPtr =