aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>1999-08-14 06:24:27 +0000
committergram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>1999-08-14 06:24:27 +0000
commit507ee64505aa9d7dd63b0312f459c1ed365fe212 (patch)
tree02e3917dd8cc530208292e15b57b998f422e25ce
parentcbd43c7781af30ec37557e76c3cfcf02a7e7cadf (diff)
Modified YACC grammar to use non-yy symbols, to avoid conflicts with
libpcap's that were compiled with symbols beginning with 'yy'. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@487 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--Makefile.am3
-rw-r--r--dfilter-grammar.y6
-rw-r--r--dfilter-scanner.l56
-rw-r--r--dfilter.c11
4 files changed, 38 insertions, 38 deletions
diff --git a/Makefile.am b/Makefile.am
index 5884a32924..c5472f2dcc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,7 +4,8 @@ man_MANS = ethereal.1
sysconf_DATA = manuf
-YFLAGS=-d
+# Any POSIX-compatible YACC should honor the -p flag
+YFLAGS=-d -p dfilter_
ethereal_SOURCES = \
alignment.h \
diff --git a/dfilter-grammar.y b/dfilter-grammar.y
index 8fe13809c0..e79ab2fad3 100644
--- a/dfilter-grammar.y
+++ b/dfilter-grammar.y
@@ -3,7 +3,7 @@
/* dfilter-grammar.y
* Parser for display filters
*
- * $Id: dfilter-grammar.y,v 1.9 1999/08/13 23:47:39 gram Exp $
+ * $Id: dfilter-grammar.y,v 1.10 1999/08/14 06:24:26 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -25,8 +25,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#define yylex dfilter_lex
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -43,7 +41,7 @@
#include <glib.h>
#endif
-#include <string.h> /* during testing */
+#include <string.h>
#ifndef _STDLIB_H
#include <stdlib.h>
diff --git a/dfilter-scanner.l b/dfilter-scanner.l
index cb75f0f76f..ec825c3007 100644
--- a/dfilter-scanner.l
+++ b/dfilter-scanner.l
@@ -3,7 +3,7 @@
/* dfilter-scanner.l
* Scanner for display filters
*
- * $Id: dfilter-scanner.l,v 1.7 1999/08/13 23:47:40 gram Exp $
+ * $Id: dfilter-scanner.l,v 1.8 1999/08/14 06:24:27 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -96,19 +96,19 @@ hexsep [-:\.]
[\t\n ]+ /* ignore whitespace */
-and|\&\& { yylval.operand = TOK_AND; return TOK_AND; }
-or|\|\| { yylval.operand = TOK_OR; return TOK_OR; }
-not|\! { yylval.operand = TOK_NOT; return TOK_NOT; }
-xor|\^\^ { yylval.operand = TOK_XOR; return TOK_XOR; }
-eq|\=\= { yylval.operand = TOK_EQ; return TOK_EQ; }
-ne|\!\= { yylval.operand = TOK_NE; return TOK_NE; }
-gt|\> { yylval.operand = TOK_GT; return TOK_GT; }
-ge|\>\= { yylval.operand = TOK_GE; return TOK_GE; }
-lt|\< { yylval.operand = TOK_LT; return TOK_LT; }
-le|\<\= { yylval.operand = TOK_LE; return TOK_LE; }
+and|\&\& { dfilter_lval.operand = TOK_AND; return TOK_AND; }
+or|\|\| { dfilter_lval.operand = TOK_OR; return TOK_OR; }
+not|\! { dfilter_lval.operand = TOK_NOT; return TOK_NOT; }
+xor|\^\^ { dfilter_lval.operand = TOK_XOR; return TOK_XOR; }
+eq|\=\= { dfilter_lval.operand = TOK_EQ; return TOK_EQ; }
+ne|\!\= { dfilter_lval.operand = TOK_NE; return TOK_NE; }
+gt|\> { dfilter_lval.operand = TOK_GT; return TOK_GT; }
+ge|\>\= { dfilter_lval.operand = TOK_GE; return TOK_GE; }
+lt|\< { dfilter_lval.operand = TOK_LT; return TOK_LT; }
+le|\<\= { dfilter_lval.operand = TOK_LE; return TOK_LE; }
-true { yylval.operand = TOK_TRUE; return TOK_TRUE; }
-false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
+true { dfilter_lval.operand = TOK_TRUE; return TOK_TRUE; }
+false { dfilter_lval.operand = TOK_FALSE; return TOK_FALSE; }
\[{whitespace}*-?[0-9]+{whitespace}*:{whitespace}*[0-9]+{whitespace}*\] { /* range [ x : y ] */
@@ -118,7 +118,7 @@ false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
/* Get the offset from the string */
if ((p = strtok(s, ":"))) {
- yylval.byte_range.offset = strtol(p, NULL, 10);
+ dfilter_lval.byte_range.offset = strtol(p, NULL, 10);
}
else {
g_free(byterange_string);
@@ -127,7 +127,7 @@ false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
/* Get the Length from the string */
if ((p = strtok(NULL, "]"))) {
- yylval.byte_range.length = strtoul(p, NULL, 10);
+ dfilter_lval.byte_range.length = strtoul(p, NULL, 10);
}
else {
g_free(byterange_string);
@@ -140,38 +140,38 @@ false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
({hex}{hexsep}){1,2}{hex} { /* small byte array */
- yylval.bytes = byte_str_to_guint8_array(yytext);
+ dfilter_lval.bytes = byte_str_to_guint8_array(yytext);
return T_VAL_BYTES;
}
({hex}{hexsep}){3}{hex} { /* possibly IPv4 address (e.g., 0.0.0.0) */
- yylval.id = g_strdup(yytext);
+ dfilter_lval.id = g_strdup(yytext);
return T_VAL_UNQUOTED_STRING;
}
({hex}{hexsep}){4}{hex} { /* small byte array */
- yylval.bytes = byte_str_to_guint8_array(yytext);
+ dfilter_lval.bytes = byte_str_to_guint8_array(yytext);
return T_VAL_BYTES;
}
({hex}{hexsep}){5}{hex} { /* possibly Ether Hardware Address */
- /* it's faster to copy six bytes to yylval than to create a GByteArray
+ /* it's faster to copy six bytes to dfilter_lval than to create a GByteArray
* structure and append 6 bytes. That means I'll have to handle this
* overloaded meaning of 6 bytes == 1 ether in the parser (what happens
* when a T_VAL_ETHER is passed when an expression expects a T_VAL_BYTES?),
* but the speed of processing T_VAL_ETHER's makes up for the added
* complexity.
*/
- ether_str_to_guint8_array(yytext, yylval.ether);
+ ether_str_to_guint8_array(yytext, dfilter_lval.ether);
return T_VAL_ETHER;
}
({hex}{hexsep}){6,}{hex} { /* large byte array */
- yylval.bytes = byte_str_to_guint8_array(yytext);
+ dfilter_lval.bytes = byte_str_to_guint8_array(yytext);
return T_VAL_BYTES;
}
@@ -179,13 +179,13 @@ false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
int retval = 0;
enum ftenum ftype;
- yylval.variable = dfilter_lookup_token(yytext);
- if (yylval.variable == 0) {
- yylval.id = g_strdup(yytext);
+ dfilter_lval.variable = dfilter_lookup_token(yytext);
+ if (dfilter_lval.variable == 0) {
+ dfilter_lval.id = g_strdup(yytext);
return T_VAL_UNQUOTED_STRING;
}
- ftype = proto_registrar_get_ftype(yylval.variable);
+ ftype = proto_registrar_get_ftype(dfilter_lval.variable);
switch (ftype) {
case FT_UINT8:
case FT_VALS_UINT8:
@@ -227,18 +227,18 @@ false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
}
[0-9]+ { /* decimal or octal values */
- yylval.id = g_strdup(yytext);
+ dfilter_lval.id = g_strdup(yytext);
return T_VAL_UNQUOTED_STRING;
}
0[xX][A-Fa-f0-9]+ { /* hex values */
- yylval.id = g_strdup(yytext);
+ dfilter_lval.id = g_strdup(yytext);
return T_VAL_UNQUOTED_STRING;
}
[0-9\:\.]+ {
- yylval.id = g_strdup(yytext);
+ dfilter_lval.id = g_strdup(yytext);
return T_VAL_UNQUOTED_STRING;
}
diff --git a/dfilter.c b/dfilter.c
index 470657c1bc..4a2c171a50 100644
--- a/dfilter.c
+++ b/dfilter.c
@@ -1,7 +1,7 @@
/* dfilter.c
* Routines for display filters
*
- * $Id: dfilter.c,v 1.9 1999/08/13 23:47:40 gram Exp $
+ * $Id: dfilter.c,v 1.10 1999/08/14 06:24:27 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -53,7 +53,7 @@
#include "dfilter-int.h"
#include "dfilter-grammar.h"
-int yyparse(void); /* yacc entry-point */
+int dfilter_parse(void); /* yacc entry-point */
#define DFILTER_LEX_ABBREV_OFFSET 2000
@@ -126,7 +126,7 @@ dfilter_compile(dfilter *df, gchar *dfilter_text)
global_df = df;
/* The magic happens right here. */
- retval = yyparse();
+ retval = dfilter_parse();
/* clean up lex */
dfilter_scanner_cleanup();
@@ -209,7 +209,7 @@ clear_byte_array(gpointer data, gpointer user_data)
}
void
-yyerror(char *s)
+dfilter_error(char *s)
{
/* fprintf(stderr, "%s\n", s);
Do not report the error, just let yyparse() return 1 */
@@ -218,8 +218,9 @@ yyerror(char *s)
void
dfilter_yyerror(char *fmt, ...)
{
+ /* XXX - is this cool? check for mem leak */
global_df->dftree = NULL;
- yyerror(fmt);
+ dfilter_error(fmt);
}
/* lookup an abbreviation in our token tree, returing the ID #