53 |
return 0; |
return 0; |
54 |
} |
} |
55 |
|
|
56 |
optlen = strlen (mh_optptr+1); |
if (strcmp (mh_optptr, "-version") == 0) |
57 |
for (p = mh_opt; p->opt; p++) |
asprintf (&argv[mh_optind], "--version"); |
58 |
{ |
else |
|
if ((p->match_len <= optlen |
|
|
&& memcmp (mh_optptr+1, p->opt, optlen) == 0) |
|
|
|| (p->flags == MH_OPT_BOOL |
|
|
&& optlen > 2 |
|
|
&& memcmp (mh_optptr+1, "no", 2) == 0 |
|
|
&& strlen (p->opt) >= optlen-2 |
|
|
&& memcmp (mh_optptr+3, p->opt, optlen-2) == 0)) |
|
|
break; |
|
|
} |
|
|
|
|
|
if (p->opt) |
|
59 |
{ |
{ |
60 |
char *longopt = p->opt; |
optlen = strlen (mh_optptr+1); |
61 |
switch (p->flags) |
for (p = mh_opt; p->opt; p++) |
62 |
{ |
{ |
63 |
case MH_OPT_BOOL: |
if ((p->match_len <= optlen |
64 |
if (memcmp (mh_optptr+1, "no", 2) == 0) |
&& memcmp (mh_optptr+1, p->opt, optlen) == 0) |
65 |
mh_optarg = "no"; |
|| (p->flags == MH_OPT_BOOL |
66 |
else |
&& optlen > 2 |
67 |
mh_optarg = "yes"; |
&& memcmp (mh_optptr+1, "no", 2) == 0 |
68 |
asprintf (&argv[mh_optind], "--%s=%s", longopt, mh_optarg); |
&& strlen (p->opt) >= optlen-2 |
69 |
break; |
&& memcmp (mh_optptr+3, p->opt, optlen-2) == 0)) |
70 |
|
break; |
|
case MH_OPT_ARG: |
|
|
asprintf (&argv[mh_optind], "--%s", longopt); |
|
|
mh_optarg = argv[++mh_optind]; |
|
|
break; |
|
|
|
|
|
default: |
|
|
asprintf (&argv[mh_optind], "--%s", longopt); |
|
|
mh_optarg = NULL; |
|
71 |
} |
} |
72 |
mh_optind++; |
|
73 |
return 1; |
if (p->opt) |
74 |
} |
{ |
75 |
else if (!strcmp (mh_optptr+1, "help")) |
char *longopt = p->opt; |
76 |
{ |
switch (p->flags) |
77 |
mh_help (mh_opt, doc); |
{ |
78 |
exit (1); |
case MH_OPT_BOOL: |
79 |
|
if (memcmp (mh_optptr+1, "no", 2) == 0) |
80 |
|
mh_optarg = "no"; |
81 |
|
else |
82 |
|
mh_optarg = "yes"; |
83 |
|
asprintf (&argv[mh_optind], "--%s=%s", longopt, mh_optarg); |
84 |
|
break; |
85 |
|
|
86 |
|
case MH_OPT_ARG: |
87 |
|
asprintf (&argv[mh_optind], "--%s", longopt); |
88 |
|
mh_optarg = argv[++mh_optind]; |
89 |
|
break; |
90 |
|
|
91 |
|
default: |
92 |
|
asprintf (&argv[mh_optind], "--%s", longopt); |
93 |
|
mh_optarg = NULL; |
94 |
|
} |
95 |
|
mh_optind++; |
96 |
|
return 1; |
97 |
|
} |
98 |
|
else if (!strcmp (mh_optptr+1, "help")) |
99 |
|
{ |
100 |
|
mh_help (mh_opt, doc); |
101 |
|
exit (1); |
102 |
|
} |
103 |
|
else |
104 |
|
mh_optind++; |
105 |
} |
} |
|
else |
|
|
mh_optind++; |
|
106 |
return '?'; |
return '?'; |
107 |
} |
} |
108 |
|
|
142 |
printf ("\n"); |
printf ("\n"); |
143 |
} |
} |
144 |
printf (" -help\n"); |
printf (" -help\n"); |
145 |
|
printf (" -version\n"); |
146 |
printf (_("\nPlease use GNU long options instead.\n" |
printf (_("\nPlease use GNU long options instead.\n" |
147 |
"Run %s --help for more info on these.\n"), |
"Run %s --help for more info on these.\n"), |
148 |
program_invocation_short_name); |
program_invocation_short_name); |