aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-10-12 05:01:07 +0000
committerGuy Harris <guy@alum.mit.edu>1999-10-12 05:01:07 +0000
commitf3da72ef2fd7486be06c6bb69418d4416fdaf3e6 (patch)
tree745d48db7c24775225b32326c4721af356973484 /gtk
parent1efcb7b2cfc60043e672d5cc4c78aabbe50f5416 (diff)
Have "dfilter_compile()" return 0 on success and 1 on failure, and
return the pointer to the compiled filter through a pointer argument. Have it check whether the filter is a null filter and, if so, free up the filter and supply a filter pointer, rather than obliging its callers to check whether the filter actually has any code. (Well, they may want to check if the filter is null, so that they don't save a pointer to the filter text, e.g. so that the display filter displays as "none" rather than as a blank string in the summary box.) In the process, fix the check in "gtk/file_dlg.c" that tests whether the read filter compiled successfully. svn path=/trunk/; revision=812
Diffstat (limited to 'gtk')
-rw-r--r--gtk/file_dlg.c11
-rw-r--r--gtk/main.c11
2 files changed, 12 insertions, 10 deletions
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index 571dd1c47f..09e4fdd3d3 100644
--- a/gtk/file_dlg.c
+++ b/gtk/file_dlg.c
@@ -1,7 +1,7 @@
/* file_dlg.c
* Dialog boxes for handling files
*
- * $Id: file_dlg.c,v 1.9 1999/10/11 06:39:25 guy Exp $
+ * $Id: file_dlg.c,v 1.10 1999/10/12 05:01:07 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -121,12 +121,9 @@ file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
cf_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION (fs)));
filter_te = gtk_object_get_data(GTK_OBJECT(w), E_RFILTER_TE_KEY);
rfilter = gtk_entry_get_text(GTK_ENTRY(filter_te));
- if (rfilter[0] != '\0') {
- rfcode = dfilter_compile(rfilter);
- if (rfcode != NULL) {
- simple_dialog(ESD_TYPE_WARN, NULL, dfilter_error_msg);
- return;
- }
+ if (dfilter_compile(rfilter, &rfcode) != 0) {
+ simple_dialog(ESD_TYPE_WARN, NULL, dfilter_error_msg);
+ return;
}
/* Try to open the capture file. */
diff --git a/gtk/main.c b/gtk/main.c
index f58481ea4c..7a747cff2e 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.20 1999/10/11 18:02:46 guy Exp $
+ * $Id: main.c,v 1.21 1999/10/12 05:01:07 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -862,14 +862,16 @@ main(int argc, char *argv[])
up on top of us. */
if (cf_name) {
if (rfilter != NULL) {
- rfcode = dfilter_compile(rfilter);
- if (rfcode == NULL) {
+ if (dfilter_compile(rfilter, &rfcode) != 0) {
simple_dialog(ESD_TYPE_WARN, NULL, dfilter_error_msg);
rfilter_parse_failed = TRUE;
}
}
if (!rfilter_parse_failed) {
if ((err = open_cap_file(cf_name, &cf)) == 0) {
+ /* "open_cap_file()" succeeded, so it closed the previous
+ capture file, and thus destroyed any previous read filter
+ attached to "cf". */
cf.rfcode = rfcode;
err = read_cap_file(&cf);
s = strrchr(cf_name, '/');
@@ -878,6 +880,9 @@ main(int argc, char *argv[])
*s = '\0';
}
set_menu_sensitivity("/File/Save As...", TRUE);
+ } else {
+ dfilter_destroy(rfcode);
+ cf.rfcode = NULL;
}
}
}