diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-17 19:20:01 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-17 19:20:01 +0000 |
commit | 751b61131f149061d689b6bac72b4a2c3629e44a (patch) | |
tree | 8294c8a910b876869d710e642df2927ce6469d3f | |
parent | 1c117efbcd50b0ddc64ef8ec0ff4c655be9d3dce (diff) | |
download | mandoc-751b61131f149061d689b6bac72b4a2c3629e44a.tar.gz |
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.
-rw-r--r-- | mansearch.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/mansearch.c b/mansearch.c index 43fe8984..d42b97fb 100644 --- a/mansearch.c +++ b/mansearch.c @@ -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; |