summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--expac.c20
-rw-r--r--expac.h7
2 files changed, 10 insertions, 17 deletions
diff --git a/expac.c b/expac.c
index 7c912c0..772ff60 100644
--- a/expac.c
+++ b/expac.c
@@ -43,7 +43,6 @@
#define DEFAULT_DELIM "\n"
#define DEFAULT_LISTDELIM " "
#define DEFAULT_TIMEFMT "%c"
-#define FORMAT_TOKENS "BCDEGLMNOPRSVabdhmnprsuvw%"
#define SIZE_TOKENS "BKMGTPEZY\0"
#ifndef PATH_MAX
@@ -58,7 +57,7 @@ bool opt_readone = false;
bool opt_verbose = false;
char opt_humansize = 'B';
PackageCorpus opt_corpus = CORPUS_LOCAL;
-SearchWhat opt_what = 0;
+SearchWhat opt_what = SEARCH_EXACT;
const char *opt_format = NULL;
const char *opt_timefmt = DEFAULT_TIMEFMT;
const char *opt_listdelim = DEFAULT_LISTDELIM;
@@ -188,7 +187,7 @@ static int parse_options(int argc, char *argv[]) {
opt_delim = optarg;
break;
case 'g':
- opt_what |= SEARCH_GROUPS;
+ opt_what = SEARCH_GROUPS;
break;
case 'l':
opt_listdelim = optarg;
@@ -207,7 +206,7 @@ static int parse_options(int argc, char *argv[]) {
opt_corpus = CORPUS_FILE;
break;
case 's':
- opt_what |= SEARCH_REGEX;
+ opt_what = SEARCH_REGEX;
break;
case 't':
opt_timefmt = optarg;
@@ -596,10 +595,9 @@ static alpm_list_t *search_groups(alpm_list_t *dbs, alpm_list_t *groupnames) {
static alpm_list_t *search_exact(alpm_list_t *dblist, alpm_list_t *targets) {
char *pkgname, *reponame;
alpm_list_t *results = NULL;
- alpm_list_t *t;
/* resolve each target individually from the repo pool */
- for (t = targets; t; t = t->next) {
+ for (alpm_list_t *t = targets; t; t = t->next) {
alpm_pkg_t *pkg = NULL;
alpm_list_t *r;
int found = 0;
@@ -637,17 +635,13 @@ static alpm_list_t *resolve_targets(alpm_list_t *dblist, alpm_list_t *targets) {
if (targets == NULL)
return all_packages(dblist);
- /* no method specified */
- if ((opt_what & (_SEARCH_MAX - 1)) == 0)
- return search_exact(dblist, targets);
-
- if (opt_what & SEARCH_REGEX)
+ if (opt_what == SEARCH_REGEX)
return search_packages(dblist, targets);
- if (opt_what & SEARCH_GROUPS)
+ if (opt_what == SEARCH_GROUPS)
return search_groups(dblist, targets);
- return NULL;
+ return search_exact(dblist, targets);
}
void expac_free(Expac *expac) {
diff --git a/expac.h b/expac.h
index 0d6c5b6..d2c6a5a 100644
--- a/expac.h
+++ b/expac.h
@@ -10,10 +10,9 @@ typedef enum PackageCorpus {
} PackageCorpus;
typedef enum SearchWhat {
- SEARCH_GROUPS = (1 << 0),
- SEARCH_REGEX = (1 << 1),
- SEARCH_EXACT = (1 << 2),
- _SEARCH_MAX = (1 << 15),
+ SEARCH_EXACT,
+ SEARCH_GROUPS,
+ SEARCH_REGEX,
} SearchWhat;
typedef struct Expac {