Mercurial > hg > th-libs
comparison th_args.c @ 127:37bf3d8766b7
Fix long option parsing. I wonder how long that has been broken.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 22 Jun 2014 06:20:26 +0300 |
parents | e37d7c1f8a03 |
children | c22caa6e3fcb |
comparison
equal
deleted
inserted
replaced
126:8efebf863404 | 127:37bf3d8766b7 |
---|---|
224 /* Long option */ | 224 /* Long option */ |
225 for (optN = -1, optLen = i = 0; (i < optListN) && (optN < 0); i++) | 225 for (optN = -1, optLen = i = 0; (i < optListN) && (optN < 0); i++) |
226 if (optList[i].optLong) | 226 if (optList[i].optLong) |
227 { | 227 { |
228 optLen = strlen(optList[i].optLong); | 228 optLen = strlen(optList[i].optLong); |
229 if (strcmp(currArg, optList[i].optLong) == 0) | 229 if (strncmp(currArg, optList[i].optLong, optLen) == 0) |
230 optN = i; | 230 optN = i; |
231 } | 231 } |
232 | 232 |
233 /* Get possible option argument, if needed */ | 233 /* Get possible option argument, if needed */ |
234 if (optN >= 0) | 234 if (optN >= 0) |
235 { | 235 { |
236 if ((optList[optN].flags & OPT_ARGMASK) != 0) | 236 if ((optList[optN].flags & OPT_ARGMASK) != 0) |
237 { | 237 optArg = (currArg[optLen] == '=') ? &currArg[optLen + 1] : NULL; |
238 if (currArg[optLen] == '=') | |
239 optArg = &currArg[optLen + 1]; | |
240 else | |
241 optArg = NULL; | |
242 } | |
243 else | 238 else |
244 optArg = NULL; | 239 optArg = NULL; |
245 | 240 |
246 /* Check if option argument is required */ | 241 /* Check if option argument is required */ |
247 if (!th_args_check_arg(&optList[optN], optArg)) | 242 if (!th_args_check_arg(&optList[optN], optArg)) |