aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mansearch.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-17 19:20:01 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-17 19:20:01 +0000
commitd00afb2a8826f2b94a706afc3104dbf7a83f0d46 (patch)
treeef46242f633204b04c3df824e7c1713965c85888 /mansearch.c
parent49218f3a03d34d07bd65bab6b920d81cb2b7499b (diff)
downloadmandoc-d00afb2a8826f2b94a706afc3104dbf7a83f0d46.tar.gz
mandoc-d00afb2a8826f2b94a706afc3104dbf7a83f0d46.tar.zst
mandoc-d00afb2a8826f2b94a706afc3104dbf7a83f0d46.zip
Garbage collect one pair of needless parentheses in SQL code generation;
note this doesn't affect performance, SQLite generates the same byte code. While here, make the calls to exprspec() easier to understand.
Diffstat (limited to 'mansearch.c')
-rw-r--r--mansearch.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/mansearch.c b/mansearch.c
index 1854eeca..97843024 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -1,4 +1,4 @@
-/* $Id: mansearch.c,v 1.32 2014/04/16 21:36:18 schwarze Exp $ */
+/* $Id: mansearch.c,v 1.33 2014/04/17 19:20:01 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -590,7 +590,7 @@ exprcomp(const struct mansearch *search, int argc, char *argv[])
first = cur = NULL;
logic = igncase = toclose = 0;
- toopen = 1;
+ toopen = NULL != search->sec || NULL != search->arch;
for (i = 0; i < argc; i++) {
if (0 == strcmp("(", argv[i])) {
@@ -659,9 +659,12 @@ exprcomp(const struct mansearch *search, int argc, char *argv[])
if (toopen || logic || igncase || toclose)
goto fail;
- cur->close++;
- cur = exprspec(cur, TYPE_arch, search->arch, "^(%s|any)$");
- exprspec(cur, TYPE_sec, search->sec, "^%s$");
+ if (NULL != search->sec || NULL != search->arch)
+ cur->close++;
+ if (NULL != search->arch)
+ cur = exprspec(cur, TYPE_arch, search->arch, "^(%s|any)$");
+ if (NULL != search->sec)
+ exprspec(cur, TYPE_sec, search->sec, "^%s$");
return(first);
@@ -679,9 +682,6 @@ exprspec(struct expr *cur, uint64_t key, const char *value,
char *cp;
int irc;
- if (NULL == value)
- return(cur);
-
mandoc_asprintf(&cp, format, value);
cur->next = mandoc_calloc(1, sizeof(struct expr));
cur = cur->next;