summary refs log tree commit diff stats
path: root/src/fe-gtk/chanlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe-gtk/chanlist.c')
-rw-r--r--src/fe-gtk/chanlist.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/fe-gtk/chanlist.c b/src/fe-gtk/chanlist.c
index 628aeacd..869187e1 100644
--- a/src/fe-gtk/chanlist.c
+++ b/src/fe-gtk/chanlist.c
@@ -76,13 +76,11 @@ chanlist_match (server *serv, const char *str)
 	{
 	case 1:
 		return match (gtk_entry_get_text (GTK_ENTRY (serv->gui->chanlist_wild)), str);
-#ifndef WIN32
 	case 2:
 		if (!serv->gui->have_regex)
 			return 0;
-		/* regex returns 0 if it's a match: */
-		return !regexec (&serv->gui->chanlist_match_regex, str, 1, NULL, REG_NOTBOL);
-#endif
+
+		return g_regex_match (serv->gui->chanlist_match_regex, str, 0, NULL);
 	default:	/* case 0: */
 		return nocasestrstr (str, gtk_entry_get_text (GTK_ENTRY (serv->gui->chanlist_wild))) ? 1 : 0;
 	}
@@ -406,18 +404,20 @@ chanlist_search_pressed (GtkButton * button, server *serv)
 static void
 chanlist_find_cb (GtkWidget * wid, server *serv)
 {
-#ifndef WIN32
+	char *pattern = gtk_entry_get_text (GTK_ENTRY (wid));
+
 	/* recompile the regular expression. */
 	if (serv->gui->have_regex)
 	{
 		serv->gui->have_regex = 0;
-		regfree (&serv->gui->chanlist_match_regex);
+		g_regex_unref (serv->gui->chanlist_match_regex);
 	}
 
-	if (regcomp (&serv->gui->chanlist_match_regex, gtk_entry_get_text (GTK_ENTRY (wid)),
-					 REG_ICASE | REG_EXTENDED | REG_NOSUB) == 0)
+	serv->gui->chanlist_match_regex = g_regex_new (pattern, G_REGEX_CASELESS | G_REGEX_EXTENDED,
+												G_REGEX_MATCH_NOTBOL, NULL);
+
+	if (serv->gui->chanlist_match_regex)
 		serv->gui->have_regex = 1;
-#endif
 }
 
 static void
@@ -655,13 +655,11 @@ chanlist_destroy_widget (GtkWidget *wid, server *serv)
 		serv->gui->chanlist_tag = 0;
 	}
 
-#ifndef WIN32
 	if (serv->gui->have_regex)
 	{
-		regfree (&serv->gui->chanlist_match_regex);
+		g_regex_unref (serv->gui->chanlist_match_regex);
 		serv->gui->have_regex = 0;
 	}
-#endif
 }
 
 static void
@@ -902,9 +900,7 @@ chanlist_opengui (server *serv, int do_refresh)
 	wid = gtk_combo_box_text_new ();
 	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (wid), _("Simple Search"));
 	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (wid), _("Pattern Match (Wildcards)"));
-#ifndef WIN32
 	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (wid), _("Regular Expression"));
-#endif
 	gtk_combo_box_set_active (GTK_COMBO_BOX (wid), serv->gui->chanlist_search_type);
 	gtk_table_attach (GTK_TABLE (table), wid, 1, 2, 1, 2,
 							GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);