commit:     9284822a7e38ffa6533ac3b048a7ea1d2110b14f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 14 15:10:56 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Dec 14 15:10:56 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9284822a

qkeyword: default to ARCH when no arch given

By default just operate on the arch specified by the selected profile.
This is probably going to be useful in the majority of the cases.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h  | 1 +
 main.c     | 2 +-
 qkeyword.c | 8 ++++----
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/applets.h b/applets.h
index e7b81f4..ea4eece 100644
--- a/applets.h
+++ b/applets.h
@@ -152,6 +152,7 @@ static const struct applet_t {
        case 'C': no_colors(); break; \
        default: applet ## _usage(EXIT_FAILURE); break;
 
+extern char *portarch;
 extern char *portroot;
 extern int verbose;
 extern int quiet;

diff --git a/main.c b/main.c
index e0b2b9c..869bf31 100644
--- a/main.c
+++ b/main.c
@@ -31,6 +31,7 @@ int verbose = 0;
 int quiet = 0;
 int twidth;
 char pretend = 0;
+char *portarch;
 char *portroot;
 char *config_protect;
 char *config_protect_mask;
@@ -46,7 +47,6 @@ DECLARE_ARRAY(overlays);
 DECLARE_ARRAY(overlay_names);
 DECLARE_ARRAY(overlay_src);
 
-static char *portarch;
 static char *portedb;
 static char *eprefix;
 static char *accept_license;

diff --git a/qkeyword.c b/qkeyword.c
index 9c7187e..b329068 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -762,11 +762,12 @@ int qkeyword_main(int argc, char **argv)
                }
        }
 
-       data.arch = NULL;
+       data.arch = portarch;
        if (optind < argc)
                data.arch = argv[optind];
 
-       if ((data.arch == NULL && action != 's') || optind + 1 < argc)
+       if (((data.arch == NULL || *data.arch == '\0') && action != 's') ||
+                       optind + 1 < argc)
                qkeyword_usage(EXIT_FAILURE);
 
        if (cat != NULL) {
@@ -803,8 +804,7 @@ int qkeyword_main(int argc, char **argv)
                                  i = qkeyword_dropped(NULL, NULL);             
        break;
                case 't': i = qkeyword_traverse(qkeyword_testing_only, &data);
                                  i = qkeyword_testing_only(NULL, NULL);        
        break;
-               case 's': data.arch = "amd64";  /* doesn't matter, need to be 
set */
-                                 i = qkeyword_traverse(qkeyword_stats, &data);
+               case 's': i = qkeyword_traverse(qkeyword_stats, &data);
                                  i = qkeyword_stats(NULL, NULL);               
        break;
                case 'a': i = qkeyword_traverse(qkeyword_all, &data);           
break;
                case 'n': i = qkeyword_traverse(qkeyword_not, &data);           
break;

Reply via email to