lkml.org 
[lkml]   [2021]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 08/17] libtracefs: Make parser unique to libtracefs
Date
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Add %define api.prefix and defines to have the parser global variables use
tracefs_* instead of yy*, as without this, if a tool that links to this
library, and tries to use the synth sql parsing, it may end up using its
own yyparse() and friends functions.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
src/sqlhist.y | 10 ++++++++++
src/tracefs-sqlhist.c | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/sqlhist.y b/src/sqlhist.y
index ce9cb58fb3a9..9d03a457ae84 100644
--- a/src/sqlhist.y
+++ b/src/sqlhist.y
@@ -30,6 +30,16 @@ extern void yyerror(struct sqlhist_bison *, char *fmt, ...);
%}

%define api.pure
+
+/* Change the globals to use tracefs_ prefix */
+%define api.prefix{tracefs_}
+%code provides
+{
+ #define YYSTYPE TRACEFS_STYPE
+ #define yylex tracefs_lex
+ #define yyerror tracefs_error
+}
+
%lex-param {void *scanner}
%parse-param {struct sqlhist_bison *sb}

diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c
index e8f77d60659f..933b3609733b 100644
--- a/src/tracefs-sqlhist.c
+++ b/src/tracefs-sqlhist.c
@@ -1021,7 +1021,7 @@ struct tracefs_synth *tracefs_sql(struct tep_handle *tep, const char *name,
return NULL;
}

- ret = yyparse(&sb);
+ ret = tracefs_parse(&sb);
yylex_destroy(sb.scanner);

if (ret)
--
2.30.2
\
 
 \ /
  Last update: 2021-07-31 00:19    [W:0.254 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site