mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-16 09:01:09 +00:00
arguments: improve some operations
Signed-off-by: Donghwa Jeong <dh48.jeong@samsung.com>
This commit is contained in:
parent
a810dc80dd
commit
97d7e88f9a
@ -97,6 +97,15 @@ static void print_usage(const struct option longopts[],
|
|||||||
fprintf(stderr, "Usage: %s ", a_args->progname);
|
fprintf(stderr, "Usage: %s ", a_args->progname);
|
||||||
|
|
||||||
for (opt = longopts, i = 1; opt->name; opt++, i++) {
|
for (opt = longopts, i = 1; opt->name; opt++, i++) {
|
||||||
|
fprintf(stderr, "[");
|
||||||
|
|
||||||
|
if (isprint(opt->val))
|
||||||
|
fprintf(stderr, "-%c|", opt->val);
|
||||||
|
|
||||||
|
fprintf(stderr, "--%s", opt->name);
|
||||||
|
|
||||||
|
if ((opt->has_arg == required_argument) ||
|
||||||
|
(opt->has_arg == optional_argument)) {
|
||||||
int j;
|
int j;
|
||||||
char *uppername;
|
char *uppername;
|
||||||
|
|
||||||
@ -107,25 +116,18 @@ static void print_usage(const struct option longopts[],
|
|||||||
for (j = 0; uppername[j]; j++)
|
for (j = 0; uppername[j]; j++)
|
||||||
uppername[j] = toupper(uppername[j]);
|
uppername[j] = toupper(uppername[j]);
|
||||||
|
|
||||||
fprintf(stderr, "[");
|
|
||||||
|
|
||||||
if (isprint(opt->val))
|
|
||||||
fprintf(stderr, "-%c|", opt->val);
|
|
||||||
|
|
||||||
fprintf(stderr, "--%s", opt->name);
|
|
||||||
|
|
||||||
if (opt->has_arg == required_argument)
|
if (opt->has_arg == required_argument)
|
||||||
fprintf(stderr, "=%s", uppername);
|
fprintf(stderr, "=%s", uppername);
|
||||||
|
else // optional_argument
|
||||||
if (opt->has_arg == optional_argument)
|
|
||||||
fprintf(stderr, "[=%s]", uppername);
|
fprintf(stderr, "[=%s]", uppername);
|
||||||
|
|
||||||
|
free(uppername);
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "] ");
|
fprintf(stderr, "] ");
|
||||||
|
|
||||||
if (!(i % 4))
|
if (!(i % 4))
|
||||||
fprintf(stderr, "\n\t");
|
fprintf(stderr, "\n\t");
|
||||||
|
|
||||||
free(uppername);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user