From 143e0506ad92bb44d282400b402972211c13741d Mon Sep 17 00:00:00 2001 From: schwarze Date: Thu, 17 Apr 2014 19:19:54 +0000 Subject: [PATCH] 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. --- usr.bin/mandoc/mansearch.c | 16 ++++++++-------- 1 file 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 * Copyright (c) 2013, 2014 Ingo Schwarze @@ -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; -- 2.20.1