nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 0b0ddb1e5fe5a96f0addfb04dba0568b143c1e5f
parent 991e49a36a54b4ab7dc6a483f2aadc9477503488
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Mon,  2 Jan 2017 20:25:24 +0100

tweaks: rename a variable, chuck an assert, and frob a comment

Diffstat:
Msrc/search.c | 17+++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/search.c b/src/search.c @@ -39,22 +39,19 @@ static bool history_changed = FALSE; static bool regexp_compiled = FALSE; /* Have we compiled any regular expressions? */ -/* Compile the regular expression regexp to see if it's valid. Return - * TRUE if it is, or FALSE otherwise. */ +/* Compile the given regular expression and store it in search_regexp. + * Return TRUE if the expression is valid, and FALSE otherwise. */ bool regexp_init(const char *regexp) { - int rc; - - assert(!regexp_compiled); - - rc = regcomp(&search_regexp, fixbounds(regexp), + int value = regcomp(&search_regexp, fixbounds(regexp), NANO_REG_EXTENDED | (ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE)); - if (rc != 0) { - size_t len = regerror(rc, &search_regexp, NULL, 0); + /* If regex compilation failed, show the error message. */ + if (value != 0) { + size_t len = regerror(value, &search_regexp, NULL, 0); char *str = charalloc(len); - regerror(rc, &search_regexp, str, len); + regerror(value, &search_regexp, str, len); statusline(ALERT, _("Bad regex \"%s\": %s"), regexp, str); free(str);