parse: fix segfaulting prototype-mismatch
authorFabian Kirsch <derFakir@web.de>
Tue, 19 Nov 2013 14:03:35 +0000 (15:03 +0100)
committerOlivier CrĂȘte <olivier.crete@collabora.com>
Fri, 29 Nov 2013 00:05:23 +0000 (19:05 -0500)
Now YYDEBUG is always set, so check it's value

https://bugzilla.gnome.org/show_bug.cgi?id=712679

gst/parse/.gitignore
gst/parse/Makefile.am
gst/parse/grammar.y

index f63ad93..5faa3b3 100644 (file)
@@ -4,6 +4,7 @@ grammar.tab.c
 grammar.tab.h
 lex.yy.c
 parse.c
+parse_lex.h
 lex.priv_gst_parse_yy.c
 *.bb
 *.bbg
index edff324..1d6f8ff 100644 (file)
@@ -1,25 +1,23 @@
 # libgstparse.la is an optionally built helper library linked into core
 noinst_LTLIBRARIES = libgstparse.la
 
-CLEANFILES = grammar.tab.h grammar.output
+CLEANFILES = grammar.tab.h parse_lex.h grammar.output
 EXTRA_DIST = \
        grammar.y \
        parse.l
 
 # uncomment these lines to dist the generated sources
-#BUILT_SOURCES = grammar.tab.h grammar.tab.c lex.priv_gst_parse_yy.c
+#BUILT_SOURCES = grammar.tab.h grammar.tab.c parse_lex.h lex.priv_gst_parse_yy.c
 #libgstparse_la_SOURCES = lex.priv_gst_parse_yy.c grammar.tab.c
 
 # uncomment these lines to _NOT_ dist the generated sources
 nodist_libgstparse_la_SOURCES = lex.priv_gst_parse_yy.c grammar.tab.c
 CLEANFILES += grammar.tab.c lex.priv_gst_parse_yy.c
 
-# can't use GST_ALL_CFLAGS here because that'd pull in -Werror
-libgstparse_la_CFLAGS = -I$(top_srcdir) -I$(top_builddir) \
-       $(GLIB_CFLAGS) $(GST_OPTION_CFLAGS)
+libgstparse_la_CFLAGS = $(GST_ALL_CFLAGS)
 libgstparse_la_LIBADD = $(GST_ALL_LIBS)
 
-noinst_HEADERS = grammar.tab.h types.h
+noinst_HEADERS = grammar.tab.h parse_lex.h types.h
 
 Android.mk: Makefile.am
        androgenizer -:PROJECT gstreamer -:STATIC libgstparse -:TAGS eng debug \
@@ -40,13 +38,11 @@ grammar.tab.c grammar.tab.h: grammar.y
        mv grammar.tab_tmp2.c grammar.tab.c
 
 lex.priv_gst_parse_yy.c: parse.l grammar.tab.h
-       $(AM_V_GEN)$(FLEX_PATH) -Ppriv_gst_parse_yy $^ && \
+       $(AM_V_GEN)$(FLEX_PATH) --header-file=parse_lex.h -Ppriv_gst_parse_yy $^ && \
        mv lex.priv_gst_parse_yy.c lex.priv_gst_parse_yy_tmp.c && \
        echo '#ifdef HAVE_CONFIG_H' > lex.priv_gst_parse_yy_tmp2.c && \
        echo '#include <config.h>' >> lex.priv_gst_parse_yy_tmp2.c && \
        echo '#endif' >> lex.priv_gst_parse_yy_tmp2.c && \
-       echo 'static inline int priv_gst_parse_yyget_column  (void * yyscanner);' >> lex.priv_gst_parse_yy_tmp2.c && \
-       echo 'static inline void priv_gst_parse_yyset_column (int  column_no , void * yyscanner);' >> lex.priv_gst_parse_yy_tmp2.c && \
        cat lex.priv_gst_parse_yy_tmp.c >> lex.priv_gst_parse_yy_tmp2.c && \
        rm lex.priv_gst_parse_yy_tmp.c && \
        mv lex.priv_gst_parse_yy_tmp2.c lex.priv_gst_parse_yy.c
index f533389..7aa6804 100644 (file)
 
 typedef void* yyscan_t;
 
-int priv_gst_parse_yylex (void * yylval_param , yyscan_t yyscanner);
-int priv_gst_parse_yylex_init (yyscan_t scanner);
-int priv_gst_parse_yylex_destroy (yyscan_t scanner);
-struct yy_buffer_state * priv_gst_parse_yy_scan_string (char* , yyscan_t);
-void _gst_parse_yypush_buffer_state (void * new_buffer ,yyscan_t yyscanner );
-void _gst_parse_yypop_buffer_state (yyscan_t yyscanner );
 
 #ifdef __GST_PARSE_TRACE
 static guint __strings;
@@ -206,6 +200,14 @@ YYPRINTF(const char *format, ...)
 
 #endif /* GST_DISABLE_GST_DEBUG */
 
+
+/*
+ * include headers generated by bison & flex, after defining (or not defining) YYDEBUG
+ */
+#include "grammar.tab.h"
+#include "parse_lex.h"
+
+
 #define ADD_MISSING_ELEMENT(graph,name) G_STMT_START {                      \
     if ((graph)->ctx) {                                                     \
       (graph)->ctx->missing_elements =                                      \
@@ -933,7 +935,7 @@ priv_gst_parse_launch (const gchar *str, GError **error, GstParseContext *ctx,
   priv_gst_parse_yylex_init (&scanner);
   priv_gst_parse_yy_scan_string (dstr, scanner);
 
-#ifndef YYDEBUG
+#if YYDEBUG
   yydebug = 1;
 #endif