This commit is contained in:
@ -25,7 +25,7 @@
|
||||
|
||||
/* this file is supposed to be included by opt.c multiple times */
|
||||
|
||||
/*
|
||||
/*
|
||||
* hawk_getopt is based on BSD getopt.
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
@ -69,18 +69,18 @@ xci_t xgetcli (int argc, xch_t* const* argv, xcli_t* opt)
|
||||
opt->arg = HAWK_NULL;
|
||||
opt->lngopt = HAWK_NULL;
|
||||
|
||||
if (opt->cur == HAWK_NULL)
|
||||
if (opt->cur == HAWK_NULL)
|
||||
{
|
||||
opt->cur = XEMSG;
|
||||
opt->ind = 1;
|
||||
}
|
||||
|
||||
if (*opt->cur == '\0')
|
||||
if (*opt->cur == '\0')
|
||||
{
|
||||
/* update scanning pointer */
|
||||
if (opt->ind >= argc || *(opt->cur = argv[opt->ind]) != '-')
|
||||
if (opt->ind >= argc || *(opt->cur = argv[opt->ind]) != '-')
|
||||
{
|
||||
/* All arguments have been processed or the current
|
||||
/* All arguments have been processed or the current
|
||||
* argument doesn't start with a dash */
|
||||
opt->cur = XEMSG;
|
||||
return XCI_EOF;
|
||||
@ -121,7 +121,7 @@ xci_t xgetcli (int argc, xch_t* const* argv, xcli_t* opt)
|
||||
|
||||
while (*end != '\0' && *end != '=') end++;
|
||||
|
||||
for (o = opt->lng; o->str; o++)
|
||||
for (o = opt->lng; o->str; o++)
|
||||
{
|
||||
const xch_t* str = o->str;
|
||||
|
||||
@ -145,10 +145,10 @@ xci_t xgetcli (int argc, xch_t* const* argv, xcli_t* opt)
|
||||
}
|
||||
else if (opt->arg == HAWK_NULL)
|
||||
{
|
||||
/* check if it has a remaining argument
|
||||
/* check if it has a remaining argument
|
||||
* available */
|
||||
if (argc <= ++opt->ind) return BADARG;
|
||||
/* If so, the next available argument is
|
||||
if (argc <= ++opt->ind) return BADARG;
|
||||
/* If so, the next available argument is
|
||||
* taken to be an option argument */
|
||||
opt->arg = argv[opt->ind];
|
||||
}
|
||||
@ -158,12 +158,12 @@ xci_t xgetcli (int argc, xch_t* const* argv, xcli_t* opt)
|
||||
}
|
||||
|
||||
/*if (*end == HAWK_T('=')) *end = HAWK_T('\0');*/
|
||||
opt->lngopt = opt->cur;
|
||||
opt->lngopt = opt->cur;
|
||||
return BADCH;
|
||||
}
|
||||
|
||||
if ((opt->opt = *opt->cur++) == ':' ||
|
||||
(oli = xfindcharincstr(opt->str, opt->opt)) == HAWK_NULL)
|
||||
(oli = xfindcharincstr(opt->str, opt->opt)) == HAWK_NULL)
|
||||
{
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
@ -174,21 +174,21 @@ xci_t xgetcli (int argc, xch_t* const* argv, xcli_t* opt)
|
||||
return BADCH;
|
||||
}
|
||||
|
||||
if (*++oli != ':')
|
||||
if (*++oli != ':')
|
||||
{
|
||||
/* don't need argument */
|
||||
if (*opt->cur == '\0') opt->ind++;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
/* need an argument */
|
||||
|
||||
if (*opt->cur != '\0')
|
||||
if (*opt->cur != '\0')
|
||||
{
|
||||
/* no white space */
|
||||
opt->arg = opt->cur;
|
||||
}
|
||||
else if (argc <= ++opt->ind)
|
||||
else if (argc <= ++opt->ind)
|
||||
{
|
||||
/* no arg */
|
||||
opt->cur = XEMSG;
|
||||
|
Reference in New Issue
Block a user