mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
Remove the regexp_compiled field.
It was made redundant by the introduction of the pointer to the GRegex structure. Silence the compiler warning in textbuffer.c about preg being initialized by setting it to NULL.
This commit is contained in:
parent
b5a727c87c
commit
3fcd3cd2b9
@ -66,10 +66,8 @@ static int ignore_match_pattern(IGNORE_REC *rec, const char *text)
|
||||
if (text == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (rec->regexp) {
|
||||
return rec->regexp_compiled &&
|
||||
g_regex_match(rec->preg, text, 0, NULL);
|
||||
}
|
||||
if (rec->regexp)
|
||||
return rec->preg && g_regex_match(rec->preg, text, 0, NULL);
|
||||
|
||||
return rec->fullword ?
|
||||
stristr_full(text, rec->pattern) != NULL :
|
||||
@ -322,10 +320,8 @@ static void ignore_remove_config(IGNORE_REC *rec)
|
||||
|
||||
static void ignore_init_rec(IGNORE_REC *rec)
|
||||
{
|
||||
if (rec->regexp_compiled) {
|
||||
if (rec->preg != NULL)
|
||||
g_regex_unref(rec->preg);
|
||||
rec->regexp_compiled = FALSE;
|
||||
}
|
||||
|
||||
if (rec->regexp && rec->pattern != NULL) {
|
||||
GError *re_error;
|
||||
@ -335,8 +331,6 @@ static void ignore_init_rec(IGNORE_REC *rec)
|
||||
if (rec->preg == NULL) {
|
||||
g_warning("Failed to compile regexp '%s': %s", rec->pattern, re_error->message);
|
||||
g_error_free(re_error);
|
||||
} else {
|
||||
rec->regexp_compiled = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -358,7 +352,7 @@ static void ignore_destroy(IGNORE_REC *rec, int send_signal)
|
||||
if (send_signal)
|
||||
signal_emit("ignore destroyed", 1, rec);
|
||||
|
||||
if (rec->regexp_compiled) g_regex_unref(rec->preg);
|
||||
if (rec->preg != NULL) g_regex_unref(rec->preg);
|
||||
if (rec->channels != NULL) g_strfreev(rec->channels);
|
||||
g_free_not_null(rec->mask);
|
||||
g_free_not_null(rec->servertag);
|
||||
|
@ -16,7 +16,6 @@ struct _IGNORE_REC {
|
||||
unsigned int regexp:1;
|
||||
unsigned int fullword:1;
|
||||
unsigned int replies:1; /* ignore replies to nick in channel */
|
||||
unsigned int regexp_compiled:1; /* should always be TRUE, unless regexp is invalid */
|
||||
GRegex *preg;
|
||||
};
|
||||
|
||||
|
@ -58,7 +58,7 @@ static void ignore_print(int index, IGNORE_REC *rec)
|
||||
g_string_append(options, "-regexp ");
|
||||
if (rec->pattern == NULL)
|
||||
g_string_append(options, "[INVALID! -pattern missing] ");
|
||||
else if (!rec->regexp_compiled)
|
||||
else if (rec->preg == NULL)
|
||||
g_string_append(options, "[INVALID!] ");
|
||||
}
|
||||
if (rec->fullword) g_string_append(options, "-full ");
|
||||
|
@ -101,7 +101,7 @@ static void hilight_destroy(HILIGHT_REC *rec)
|
||||
{
|
||||
g_return_if_fail(rec != NULL);
|
||||
|
||||
if (rec->regexp_compiled) g_regex_unref(rec->preg);
|
||||
if (rec->preg != NULL) g_regex_unref(rec->preg);
|
||||
if (rec->channels != NULL) g_strfreev(rec->channels);
|
||||
g_free_not_null(rec->color);
|
||||
g_free_not_null(rec->act_color);
|
||||
@ -118,15 +118,10 @@ static void hilights_destroy_all(void)
|
||||
|
||||
static void hilight_init_rec(HILIGHT_REC *rec)
|
||||
{
|
||||
if (rec->regexp_compiled) {
|
||||
if (rec->preg != NULL)
|
||||
g_regex_unref(rec->preg);
|
||||
rec->regexp_compiled = FALSE;
|
||||
}
|
||||
|
||||
rec->preg = g_regex_new(rec->text, G_REGEX_CASELESS, 0, NULL);
|
||||
|
||||
if (rec->preg != NULL)
|
||||
rec->regexp_compiled = TRUE;
|
||||
}
|
||||
|
||||
void hilight_create(HILIGHT_REC *rec)
|
||||
@ -201,7 +196,7 @@ static int hilight_match_text(HILIGHT_REC *rec, const char *text,
|
||||
if (rec->regexp) {
|
||||
GMatchInfo *match;
|
||||
|
||||
if (rec->regexp_compiled) {
|
||||
if (rec->preg != NULL) {
|
||||
g_regex_match (rec->preg, text, 0, &match);
|
||||
|
||||
if (g_match_info_matches(match)) {
|
||||
@ -504,7 +499,7 @@ static void hilight_print(int index, HILIGHT_REC *rec)
|
||||
if (rec->case_sensitive) g_string_append(options, "-matchcase ");
|
||||
if (rec->regexp) {
|
||||
g_string_append(options, "-regexp ");
|
||||
if (!rec->regexp_compiled)
|
||||
if (rec->preg == NULL)
|
||||
g_string_append(options, "[INVALID!] ");
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ struct _HILIGHT_REC {
|
||||
unsigned int fullword:1; /* match `text' only for full words */
|
||||
unsigned int regexp:1; /* `text' is a regular expression */
|
||||
unsigned int case_sensitive:1;/* `text' must match case */
|
||||
unsigned int regexp_compiled:1; /* should always be TRUE, unless regexp is invalid */
|
||||
GRegex *preg;
|
||||
char *servertag;
|
||||
};
|
||||
|
@ -543,6 +543,8 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
|
||||
g_return_val_if_fail(buffer != NULL, NULL);
|
||||
g_return_val_if_fail(text != NULL, NULL);
|
||||
|
||||
preg = NULL;
|
||||
|
||||
if (regexp) {
|
||||
preg = g_regex_new(text, (case_sensitive ? 0 : G_REGEX_CASELESS), 0, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user