︙ | | | ︙ | |
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#import "OFMapTable.h"
#import "OFInvalidArgumentException.h"
static uint32_t
stringHash(void *object)
{
return [(OFString *)object hash];
}
static bool
stringEqual(void *object1, void *object2)
{
return [(OFString *)object1 isEqual: (OFString *)object2];
}
|
|
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#import "OFMapTable.h"
#import "OFInvalidArgumentException.h"
static uint32_t
stringHash(void *object)
{
return ((OFString *)object).hash;
}
static bool
stringEqual(void *object1, void *object2)
{
return [(OFString *)object1 isEqual: (OFString *)object2];
}
|
︙ | | | ︙ | |
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
|
}
- (of_unichar_t)nextOption
{
of_options_parser_option_t *iter;
OFString *argument;
if (_done || _index >= [_arguments count])
return '\0';
[_lastLongOption release];
[_argument release];
_lastLongOption = nil;
_argument = nil;
argument = [_arguments objectAtIndex: _index];
if (_subIndex == 0) {
if ([argument length] < 2 ||
[argument characterAtIndex: 0] != '-') {
_done = true;
return '\0';
}
if ([argument isEqual: @"--"]) {
_done = true;
|
|
|
|
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
|
}
- (of_unichar_t)nextOption
{
of_options_parser_option_t *iter;
OFString *argument;
if (_done || _index >= _arguments.count)
return '\0';
[_lastLongOption release];
[_argument release];
_lastLongOption = nil;
_argument = nil;
argument = [_arguments objectAtIndex: _index];
if (_subIndex == 0) {
if (argument.length < 2 ||
[argument characterAtIndex: 0] != '-') {
_done = true;
return '\0';
}
if ([argument isEqual: @"--"]) {
_done = true;
|
︙ | | | ︙ | |
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
_lastOption = '-';
_index++;
if ((pos = [argument rangeOfString: @"="].location) !=
OF_NOT_FOUND) {
of_range_t range = of_range(pos + 1,
[argument length] - pos - 1);
_argument = [[argument
substringWithRange: range] copy];
} else
pos = [argument length];
_lastLongOption = [[argument substringWithRange:
of_range(2, pos - 2)] copy];
objc_autoreleasePoolPop(pool);
option = [_longOptions objectForKey: _lastLongOption];
|
|
|
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
_lastOption = '-';
_index++;
if ((pos = [argument rangeOfString: @"="].location) !=
OF_NOT_FOUND) {
of_range_t range = of_range(pos + 1,
argument.length - pos - 1);
_argument = [[argument
substringWithRange: range] copy];
} else
pos = argument.length;
_lastLongOption = [[argument substringWithRange:
of_range(2, pos - 2)] copy];
objc_autoreleasePoolPop(pool);
option = [_longOptions objectForKey: _lastLongOption];
|
︙ | | | ︙ | |
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
|
}
_subIndex = 1;
}
_lastOption = [argument characterAtIndex: _subIndex++];
if (_subIndex >= [argument length]) {
_index++;
_subIndex = 0;
}
for (iter = _options;
iter->shortOption != '\0' || iter->longOption != nil; iter++) {
if (iter->shortOption == _lastOption) {
if (iter->hasArgument == 0) {
if (iter->isSpecifiedPtr != NULL)
*iter->isSpecifiedPtr = true;
return _lastOption;
}
if (_index >= [_arguments count])
return ':';
argument = [_arguments objectAtIndex: _index];
argument = [argument substringWithRange:
of_range(_subIndex, [argument length] - _subIndex)];
_argument = [argument copy];
if (iter->isSpecifiedPtr != NULL)
*iter->isSpecifiedPtr = true;
if (iter->argumentPtr != NULL)
*iter->argumentPtr =
|
|
|
|
|
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
|
}
_subIndex = 1;
}
_lastOption = [argument characterAtIndex: _subIndex++];
if (_subIndex >= argument.length) {
_index++;
_subIndex = 0;
}
for (iter = _options;
iter->shortOption != '\0' || iter->longOption != nil; iter++) {
if (iter->shortOption == _lastOption) {
if (iter->hasArgument == 0) {
if (iter->isSpecifiedPtr != NULL)
*iter->isSpecifiedPtr = true;
return _lastOption;
}
if (_index >= _arguments.count)
return ':';
argument = [_arguments objectAtIndex: _index];
argument = [argument substringWithRange:
of_range(_subIndex, argument.length - _subIndex)];
_argument = [argument copy];
if (iter->isSpecifiedPtr != NULL)
*iter->isSpecifiedPtr = true;
if (iter->argumentPtr != NULL)
*iter->argumentPtr =
|
︙ | | | ︙ | |
275
276
277
278
279
280
281
282
283
284
|
return '?';
}
- (OFArray *)remainingArguments
{
return [_arguments objectsInRange:
of_range(_index, [_arguments count] - _index)];
}
@end
|
|
|
275
276
277
278
279
280
281
282
283
284
|
return '?';
}
- (OFArray *)remainingArguments
{
return [_arguments objectsInRange:
of_range(_index, _arguments.count - _index)];
}
@end
|