summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-04-17 19:19:55 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-04-17 19:19:55 +0000
commit7f65853352818925c7bf16769d1593d64c2adf03 (patch)
tree5db5540f00fc044a644d2f192afb7659d77dfd8c /usr.bin
parentbf9f87b3e1cab110639553772d06abec98a048ba (diff)
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 'usr.bin')
-rw-r--r--usr.bin/mandoc/mansearch.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c
index 7b0a287c47a..2f9e6a7a69a 100644
--- a/usr.bin/mandoc/mansearch.c
+++ b/usr.bin/mandoc/mansearch.c
@@ -1,4 +1,4 @@
-/* $Id: mansearch.c,v 1.22 2014/04/16 21:35:48 schwarze Exp $ */
+/* $Id: mansearch.c,v 1.23 2014/04/17 19:19:54 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -582,7 +582,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])) {
@@ -651,9 +651,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);
@@ -671,9 +674,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;