summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d42c8a3)
raw | patch | inline | side by side (parent: d42c8a3)
author | Jonas Fonseca <fonseca@diku.dk> | |
Mon, 11 Sep 2006 04:22:51 +0000 (06:22 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Mon, 11 Sep 2006 04:22:51 +0000 (06:22 +0200) |
tig.c | patch | blob | history |
index bcff66f5caa73da750367e27f307b0e08d605fe7..0acb1b0cd33c306d4dd0f4767b97a9bbc5f116a7 100644 (file)
--- a/tig.c
+++ b/tig.c
/* Searching */
char grep[SIZEOF_STR]; /* Search string */
- regex_t regex; /* Pre-compiled regex */
+ regex_t *regex; /* Pre-compiled regex */
/* If non-NULL, points to the view that opened this view. If this view
* is closed tig will switch back to the parent view. */
{
int regex_err;
- if (*view->grep) {
- regfree(&view->regex);
+ if (view->regex) {
+ regfree(view->regex);
*view->grep = 0;
+ } else {
+ view->regex = calloc(1, sizeof(*view->regex));
+ if (!view->regex)
+ return;
}
- regex_err = regcomp(&view->regex, search, REG_EXTENDED);
+ regex_err = regcomp(view->regex, search, REG_EXTENDED);
if (regex_err != 0) {
char buf[SIZEOF_STR] = "unknown error";
- regerror(regex_err, &view->regex, buf, sizeof(buf));
+ regerror(regex_err, view->regex, buf, sizeof(buf));
report("Search failed: %s", buf);
return;
}
if (!*text)
return FALSE;
- if (regexec(&view->regex, text, 1, &pmatch, 0) == REG_NOMATCH)
+ if (regexec(view->regex, text, 1, &pmatch, 0) == REG_NOMATCH)
return FALSE;
return TRUE;
return FALSE;
}
- if (regexec(&view->regex, text, 1, &pmatch, 0) != REG_NOMATCH)
+ if (regexec(view->regex, text, 1, &pmatch, 0) != REG_NOMATCH)
return TRUE;
}