summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDubiousjim <dubiousjim@gmail.com>2013-06-30 04:02:19 -0400
committerTimo Teräs <timo.teras@iki.fi>2013-06-30 11:16:52 +0300
commitd035ef60d2f3fcaebce19e169401f439e1f35f26 (patch)
treeebd3a1317e98974aa12f7deca6f429f5c89dfacc /src
parentbfa39f6bf6107952b73c21a079129bc55b39a53f (diff)
downloadapk-tools-d035ef60d2f3fcaebce19e169401f439e1f35f26.tar.gz
apk-tools-d035ef60d2f3fcaebce19e169401f439e1f35f26.tar.bz2
apk-tools-d035ef60d2f3fcaebce19e169401f439e1f35f26.tar.xz
apk-tools-d035ef60d2f3fcaebce19e169401f439e1f35f26.zip
apk: infrastructure for short-option-only synonyms
Diffstat (limited to 'src')
-rw-r--r--src/apk.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/apk.c b/src/apk.c
index 17e87d5..a236b37 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -111,13 +111,14 @@ static void print_usage(const char *cmd, const char *args, int num_opts,
int i, j;
indent.x = printf("\nusage: apk %s", cmd) - 1;
- for (i = 0; i < num_opts; i++) {
- j = 0;
- word[j++] = '[';
- j += format_option(&word[j], sizeof(word) - j, &opts[i], "|");
- word[j++] = ']';
- apk_print_indented(&indent, APK_BLOB_PTR_LEN(word, j));
- }
+ for (i = 0; i < num_opts; i++)
+ if (opts[i].name != NULL) {
+ j = 0;
+ word[j++] = '[';
+ j += format_option(&word[j], sizeof(word) - j, &opts[i], "|");
+ word[j++] = ']';
+ apk_print_indented(&indent, APK_BLOB_PTR_LEN(word, j));
+ }
if (args != NULL)
apk_print_indented(&indent, APK_BLOB_STR(args));
printf("\n");
@@ -230,7 +231,7 @@ static void merge_options(struct option *opts, struct apk_option *ao, int num)
int i;
for (i = 0; i < num; i++, opts++, ao++) {
- opts->name = ao->name;
+ opts->name = ao->name ?: "";
opts->has_arg = ao->has_arg;
opts->flag = NULL;
opts->val = ao->val;