[PATCH] Patch for bug 12528: mdssvc with static smbd

Ralph Böhme slow at samba.org
Fri Jan 20 14:31:11 UTC 2017


Hi!

Attached is a patch for bug 12528.

Splitting this out from the thread about using flex/bison for Spotlight and
MS-WSP as it's completely unrelated.

Cheerio!
-slow
-------------- next part --------------
From 904810e208b4352e5e89efe621e7b1bdd322c4f8 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Thu, 19 Jan 2017 07:39:37 +0100
Subject: [PATCH 1/2] s3/rpc_server/mdssvc: use flex noyyalloc noyyrealloc

Redefine the symbols used for malloc and realloc in the flex source
instead of running sed over the generated one.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12528

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source3/rpc_server/mdssvc/Makefile       |   3 -
 source3/rpc_server/mdssvc/sparql_lexer.c | 202 +++++++++++++++++--------------
 source3/rpc_server/mdssvc/sparql_lexer.l |   4 +-
 3 files changed, 112 insertions(+), 97 deletions(-)

diff --git a/source3/rpc_server/mdssvc/Makefile b/source3/rpc_server/mdssvc/Makefile
index 3b0983f..3de4a46 100644
--- a/source3/rpc_server/mdssvc/Makefile
+++ b/source3/rpc_server/mdssvc/Makefile
@@ -1,6 +1,5 @@
 BISON=bison
 FLEX=flex
-SED=sed
 
 PARSER=sparql_parser
 LEXER=sparql_lexer
@@ -12,5 +11,3 @@ $(PARSER).c: $(PARSER).y
 
 $(LEXER).c: $(LEXER).l
 	$(FLEX) -o $@ $<
-	$(SED) -i s/malloc/SMB_MALLOC/g $@
-	$(SED) -i s/realloc/SMB_REALLOC/g $@
diff --git a/source3/rpc_server/mdssvc/sparql_lexer.c b/source3/rpc_server/mdssvc/sparql_lexer.c
index 34bc0ca..4c76f45 100644
--- a/source3/rpc_server/mdssvc/sparql_lexer.c
+++ b/source3/rpc_server/mdssvc/sparql_lexer.c
@@ -8,8 +8,8 @@
 
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 37
+#define YY_FLEX_MINOR_VERSION 6
+#define YY_FLEX_SUBMINOR_VERSION 0
 #if YY_FLEX_SUBMINOR_VERSION > 0
 #define FLEX_BETA
 #endif
@@ -142,7 +142,15 @@ typedef unsigned int flex_uint32_t;
 
 /* Size of default input buffer. */
 #ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
 #define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
 #endif
 
 /* The state buf must be large enough to hold one state per character in the main buffer.
@@ -168,13 +176,14 @@ extern FILE *yyin, *yyout;
 #define EOB_ACT_LAST_MATCH 2
 
     #define YY_LESS_LINENO(n)
+    #define YY_LINENO_REWIND_TO(ptr)
     
 /* Return all but the first "n" matched characters back to the input stream. */
 #define yyless(n) \
 	do \
 		{ \
 		/* Undo effects of setting up yytext. */ \
-        int yyless_macro_arg = (n); \
+        yy_size_t yyless_macro_arg = (n); \
         YY_LESS_LINENO(yyless_macro_arg);\
 		*yy_cp = (yy_hold_char); \
 		YY_RESTORE_YY_MORE_OFFSET \
@@ -205,7 +214,7 @@ struct yy_buffer_state
 	yy_size_t yy_n_chars;
 
 	/* Whether we "own" the buffer - i.e., we know we created it,
-	 * and can SMB_REALLOC() it to grow it, and should free() it to
+	 * and can realloc() it to grow it, and should free() it to
 	 * delete it.
 	 */
 	int yy_is_our_buffer;
@@ -304,7 +313,7 @@ YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str  );
 YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len  );
 
 void *yyalloc (yy_size_t  );
-void *yySMB_REALLOC (void *,yy_size_t  );
+void *yyrealloc (void *,yy_size_t  );
 void yyfree (void *  );
 
 #define yy_new_buffer yy_create_buffer
@@ -344,11 +353,17 @@ extern int yylineno;
 int yylineno = 1;
 
 extern char *yytext;
+#ifdef yytext_ptr
+#undef yytext_ptr
+#endif
 #define yytext_ptr yytext
 
 static yy_state_type yy_get_previous_state (void );
 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
 static int yy_get_next_buffer (void );
+#if defined(__GNUC__) && __GNUC__ >= 3
+__attribute__((__noreturn__))
+#endif
 static void yy_fatal_error (yyconst char msg[]  );
 
 /* Done after the current pattern has been matched and before the
@@ -380,7 +395,7 @@ static yyconst flex_int16_t yy_accept[57] =
        16,    0,    1,    0,    2,    0
     } ;
 
-static yyconst flex_int32_t yy_ec[256] =
+static yyconst YY_CHAR yy_ec[256] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    2,    2,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -412,7 +427,7 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static yyconst flex_int32_t yy_meta[35] =
+static yyconst YY_CHAR yy_meta[35] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    2,    1,
         2,    1,    1,    1,    2,    2,    2,    2,    2,    2,
@@ -420,7 +435,7 @@ static yyconst flex_int32_t yy_meta[35] =
         1,    2,    2,    2
     } ;
 
-static yyconst flex_int16_t yy_base[58] =
+static yyconst flex_uint16_t yy_base[58] =
     {   0,
         0,    0,   91,   92,   92,   77,   92,   61,   82,   92,
        92,    3,   92,   92,   74,   92,   14,   25,   15,   56,
@@ -440,7 +455,7 @@ static yyconst flex_int16_t yy_def[58] =
        17,   56,   17,   56,   56,    0,   56
     } ;
 
-static yyconst flex_int16_t yy_nxt[127] =
+static yyconst flex_uint16_t yy_nxt[127] =
     {   0,
         4,    5,    6,    7,    8,    9,   10,   11,   12,   13,
        12,   14,   15,   16,   17,   12,   12,   12,   18,   12,
@@ -515,7 +530,9 @@ char *yytext;
 #include "sparql_parser.h"
 
 #define YY_NO_INPUT
-#line 519 "sparql_lexer.c"
+#define yyalloc SMB_MALLOC
+#define yyrealloc SMB_REALLOC
+#line 536 "sparql_lexer.c"
 
 #define INITIAL 0
 
@@ -548,11 +565,11 @@ void yyset_extra (YY_EXTRA_TYPE user_defined  );
 
 FILE *yyget_in (void );
 
-void yyset_in  (FILE * in_str  );
+void yyset_in  (FILE * _in_str  );
 
 FILE *yyget_out (void );
 
-void yyset_out  (FILE * out_str  );
+void yyset_out  (FILE * _out_str  );
 
 yy_size_t yyget_leng (void );
 
@@ -560,7 +577,7 @@ char *yyget_text (void );
 
 int yyget_lineno (void );
 
-void yyset_lineno (int line_number  );
+void yyset_lineno (int _line_number  );
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -574,6 +591,10 @@ extern int yywrap (void );
 #endif
 #endif
 
+#ifndef YY_NO_UNPUT
+    
+#endif
+
 #ifndef yytext_ptr
 static void yy_flex_strncpy (char *,yyconst char *,int );
 #endif
@@ -594,7 +615,12 @@ static int input (void );
 
 /* Amount of stuff to slurp up with each read. */
 #ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
 #define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
 #endif
 
 /* Copy whatever the last rule matched to the standard output. */
@@ -681,7 +707,7 @@ extern int yylex (void);
 
 /* Code executed at the end of each rule. */
 #ifndef YY_BREAK
-#define YY_BREAK break;
+#define YY_BREAK /*LINTED*/break;
 #endif
 
 #define YY_RULE_SETUP \
@@ -691,14 +717,10 @@ extern int yylex (void);
  */
 YY_DECL
 {
-	register yy_state_type yy_current_state;
-	register char *yy_cp, *yy_bp;
-	register int yy_act;
+	yy_state_type yy_current_state;
+	char *yy_cp, *yy_bp;
+	int yy_act;
     
-#line 39 "sparql_lexer.l"
-
-#line 701 "sparql_lexer.c"
-
 	if ( !(yy_init) )
 		{
 		(yy_init) = 1;
@@ -725,7 +747,12 @@ YY_DECL
 		yy_load_buffer_state( );
 		}
 
-	while ( 1 )		/* loops until end-of-file is reached */
+	{
+#line 41 "sparql_lexer.l"
+
+#line 754 "sparql_lexer.c"
+
+	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
 		yy_cp = (yy_c_buf_p);
 
@@ -741,7 +768,7 @@ YY_DECL
 yy_match:
 		do
 			{
-			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
 			if ( yy_accept[yy_current_state] )
 				{
 				(yy_last_accepting_state) = yy_current_state;
@@ -782,96 +809,96 @@ do_action:	/* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 40 "sparql_lexer.l"
+#line 42 "sparql_lexer.l"
 return FUNC_INRANGE;
 	YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 41 "sparql_lexer.l"
+#line 43 "sparql_lexer.l"
 return DATE_ISO;
 	YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 42 "sparql_lexer.l"
+#line 44 "sparql_lexer.l"
 {yylval.bval = false; return BOOL;}
 	YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 43 "sparql_lexer.l"
+#line 45 "sparql_lexer.l"
 {yylval.bval = true; return BOOL;}
 	YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 44 "sparql_lexer.l"
+#line 46 "sparql_lexer.l"
 return QUOTE;
 	YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 45 "sparql_lexer.l"
+#line 47 "sparql_lexer.l"
 return OBRACE;
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 46 "sparql_lexer.l"
+#line 48 "sparql_lexer.l"
 return CBRACE;
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 47 "sparql_lexer.l"
+#line 49 "sparql_lexer.l"
 return AND;
 	YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 48 "sparql_lexer.l"
+#line 50 "sparql_lexer.l"
 return OR;
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 49 "sparql_lexer.l"
+#line 51 "sparql_lexer.l"
 return EQUAL;
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 50 "sparql_lexer.l"
+#line 52 "sparql_lexer.l"
 return UNEQUAL;
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 51 "sparql_lexer.l"
+#line 53 "sparql_lexer.l"
 return EQUAL;
 	YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 52 "sparql_lexer.l"
+#line 54 "sparql_lexer.l"
 return LT;
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 53 "sparql_lexer.l"
+#line 55 "sparql_lexer.l"
 return GT;
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 54 "sparql_lexer.l"
+#line 56 "sparql_lexer.l"
 return COMMA;
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 55 "sparql_lexer.l"
+#line 57 "sparql_lexer.l"
 {yylval.sval = talloc_strdup(talloc_tos(), yytext); return WORD;}
 	YY_BREAK
 case 17:
 /* rule 17 can match eol */
 YY_RULE_SETUP
-#line 56 "sparql_lexer.l"
+#line 58 "sparql_lexer.l"
 /* ignore */
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 57 "sparql_lexer.l"
+#line 59 "sparql_lexer.l"
 ECHO;
 	YY_BREAK
-#line 875 "sparql_lexer.c"
+#line 902 "sparql_lexer.c"
 case YY_STATE_EOF(INITIAL):
 	yyterminate();
 
@@ -1002,6 +1029,7 @@ case YY_STATE_EOF(INITIAL):
 			"fatal flex scanner internal error--no action found" );
 	} /* end of action switch */
 		} /* end of scanning one token */
+	} /* end of user's declarations */
 } /* end of yylex */
 
 /* yy_get_next_buffer - try to read in a new buffer
@@ -1013,9 +1041,9 @@ case YY_STATE_EOF(INITIAL):
  */
 static int yy_get_next_buffer (void)
 {
-    	register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
-	register char *source = (yytext_ptr);
-	register int number_to_move, i;
+    	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+	char *source = (yytext_ptr);
+	yy_size_t number_to_move, i;
 	int ret_val;
 
 	if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@@ -1044,7 +1072,7 @@ static int yy_get_next_buffer (void)
 	/* Try to read more data. */
 
 	/* First move last chars to start of buffer. */
-	number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+	number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
 
 	for ( i = 0; i < number_to_move; ++i )
 		*(dest++) = *(source++);
@@ -1057,7 +1085,7 @@ static int yy_get_next_buffer (void)
 
 	else
 		{
-			yy_size_t num_to_read =
+			int num_to_read =
 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
 
 		while ( num_to_read <= 0 )
@@ -1080,7 +1108,7 @@ static int yy_get_next_buffer (void)
 
 				b->yy_ch_buf = (char *)
 					/* Include room in for 2 EOB chars. */
-					yySMB_REALLOC((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
+					yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
 				}
 			else
 				/* Can't grow it, we don't own it. */
@@ -1129,7 +1157,7 @@ static int yy_get_next_buffer (void)
 	if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
 		/* Extend the array by 50%, plus the number we really need. */
 		yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
-		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yySMB_REALLOC((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
+		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
 		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
 			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
 	}
@@ -1147,14 +1175,14 @@ static int yy_get_next_buffer (void)
 
     static yy_state_type yy_get_previous_state (void)
 {
-	register yy_state_type yy_current_state;
-	register char *yy_cp;
+	yy_state_type yy_current_state;
+	char *yy_cp;
     
 	yy_current_state = (yy_start);
 
 	for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
 		{
-		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
 		if ( yy_accept[yy_current_state] )
 			{
 			(yy_last_accepting_state) = yy_current_state;
@@ -1179,10 +1207,10 @@ static int yy_get_next_buffer (void)
  */
     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
 {
-	register int yy_is_jam;
-    	register char *yy_cp = (yy_c_buf_p);
+	int yy_is_jam;
+    	char *yy_cp = (yy_c_buf_p);
 
-	register YY_CHAR yy_c = 1;
+	YY_CHAR yy_c = 1;
 	if ( yy_accept[yy_current_state] )
 		{
 		(yy_last_accepting_state) = yy_current_state;
@@ -1200,6 +1228,10 @@ static int yy_get_next_buffer (void)
 		return yy_is_jam ? 0 : yy_current_state;
 }
 
+#ifndef YY_NO_UNPUT
+
+#endif
+
 #ifndef YY_NO_INPUT
 #ifdef __cplusplus
     static int yyinput (void)
@@ -1349,7 +1381,7 @@ static void yy_load_buffer_state  (void)
 	if ( ! b )
 		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
 
-	b->yy_buf_size = size;
+	b->yy_buf_size = (yy_size_t)size;
 
 	/* yy_ch_buf has to be 2 characters longer than the size given because
 	 * we need to put in 2 end-of-buffer characters.
@@ -1502,9 +1534,9 @@ static void yyensure_buffer_stack (void)
 
 		/* First allocation is just for 2 elements, since we don't know if this
 		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
-		 * immediate SMB_REALLOC on the next call.
+		 * immediate realloc on the next call.
          */
-		num_to_alloc = 1;
+      num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
 		(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
 								(num_to_alloc * sizeof(struct yy_buffer_state*)
 								);
@@ -1521,10 +1553,10 @@ static void yyensure_buffer_stack (void)
 	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
 
 		/* Increase the buffer to prepare for a possible push. */
-		int grow_size = 8 /* arbitrary grow size */;
+		yy_size_t grow_size = 8 /* arbitrary grow size */;
 
 		num_to_alloc = (yy_buffer_stack_max) + grow_size;
-		(yy_buffer_stack) = (struct yy_buffer_state**)yySMB_REALLOC
+		(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
 								((yy_buffer_stack),
 								num_to_alloc * sizeof(struct yy_buffer_state*)
 								);
@@ -1629,7 +1661,7 @@ YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len
 
 static void yy_fatal_error (yyconst char* msg )
 {
-    	(void) fprintf( stderr, "%s\n", msg );
+			(void) fprintf( stderr, "%s\n", msg );
 	exit( YY_EXIT_FAILURE );
 }
 
@@ -1640,7 +1672,7 @@ static void yy_fatal_error (yyconst char* msg )
 	do \
 		{ \
 		/* Undo effects of setting up yytext. */ \
-        int yyless_macro_arg = (n); \
+        yy_size_t yyless_macro_arg = (n); \
         YY_LESS_LINENO(yyless_macro_arg);\
 		yytext[yyleng] = (yy_hold_char); \
 		(yy_c_buf_p) = yytext + yyless_macro_arg; \
@@ -1695,29 +1727,29 @@ char *yyget_text  (void)
 }
 
 /** Set the current line number.
- * @param line_number
+ * @param _line_number line number
  * 
  */
-void yyset_lineno (int  line_number )
+void yyset_lineno (int  _line_number )
 {
     
-    yylineno = line_number;
+    yylineno = _line_number;
 }
 
 /** Set the input stream. This does not discard the current
  * input buffer.
- * @param in_str A readable stream.
+ * @param _in_str A readable stream.
  * 
  * @see yy_switch_to_buffer
  */
-void yyset_in (FILE *  in_str )
+void yyset_in (FILE *  _in_str )
 {
-        yyin = in_str ;
+        yyin = _in_str ;
 }
 
-void yyset_out (FILE *  out_str )
+void yyset_out (FILE *  _out_str )
 {
-        yyout = out_str ;
+        yyout = _out_str ;
 }
 
 int yyget_debug  (void)
@@ -1725,9 +1757,9 @@ int yyget_debug  (void)
         return yy_flex_debug;
 }
 
-void yyset_debug (int  bdebug )
+void yyset_debug (int  _bdebug )
 {
-        yy_flex_debug = bdebug ;
+        yy_flex_debug = _bdebug ;
 }
 
 static int yy_init_globals (void)
@@ -1787,7 +1819,8 @@ int yylex_destroy  (void)
 #ifndef yytext_ptr
 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
 {
-	register int i;
+		
+	int i;
 	for ( i = 0; i < n; ++i )
 		s1[i] = s2[i];
 }
@@ -1796,7 +1829,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
 #ifdef YY_NEED_STRLEN
 static int yy_flex_strlen (yyconst char * s )
 {
-	register int n;
+	int n;
 	for ( n = 0; s[n]; ++n )
 		;
 
@@ -1804,31 +1837,14 @@ static int yy_flex_strlen (yyconst char * s )
 }
 #endif
 
-void *yyalloc (yy_size_t  size )
-{
-	return (void *) SMB_MALLOC( size );
-}
-
-void *yySMB_REALLOC  (void * ptr, yy_size_t  size )
-{
-	/* The cast to (char *) in the following accommodates both
-	 * implementations that use char* generic pointers, and those
-	 * that use void* generic pointers.  It works with the latter
-	 * because both ANSI C and C++ allow castless assignment from
-	 * any pointer type to void*, and deal with argument conversions
-	 * as though doing an assignment.
-	 */
-	return (void *) SMB_REALLOC( (char *) ptr, size );
-}
-
 void yyfree (void * ptr )
 {
-	free( (char *) ptr );	/* see yySMB_REALLOC() for (char *) cast */
+			free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
 }
 
 #define YYTABLES_NAME "yytables"
 
-#line 57 "sparql_lexer.l"
+#line 59 "sparql_lexer.l"
 
 
 
diff --git a/source3/rpc_server/mdssvc/sparql_lexer.l b/source3/rpc_server/mdssvc/sparql_lexer.l
index cbcd358..01c896f 100644
--- a/source3/rpc_server/mdssvc/sparql_lexer.l
+++ b/source3/rpc_server/mdssvc/sparql_lexer.l
@@ -23,9 +23,11 @@
 #include "sparql_parser.h"
 
 #define YY_NO_INPUT
+#define yyalloc SMB_MALLOC
+#define yyrealloc SMB_REALLOC
 %}
 
-%option nounput
+%option nounput noyyalloc noyyrealloc
 
 ASC     [a-zA-Z0-9_\*\:\-\.]
 U       [\x80-\xbf]
-- 
2.7.4


From b81135f1184c9d39ec8ecd30ba069955e2b7f972 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Wed, 18 Jan 2017 19:18:40 +0100
Subject: [PATCH 2/2] s3/rpc_server/mdssvc: prefix public flex and bison global
 symbols

This fixes a clash with a parser in Heimdal when building with
--nonshared-binary=smbd/smbd:

...
[3139/3620] Linking default/source3/smbd/smbd
...
default/source4/heimdal/lib/hx509/sel-lex_116.o: In function `yy_get_previous_state':
/usr/build/packages/samba-4.5/bin/../source4/heimdal/lib/hx509/sel-lex.c:1122:multiple definition of `yyin'
default/source3/rpc_server/mdssvc/sparql_lexer_28.o:/usr/build/packages/samba-4.5/bin/sparql_lexer.c:1149:first defined here
...

The fix is to use namespace prefixes in the parser and the lexer as
described here:
<https://www.gnu.org/software/bison/manual/html_node/Multiple-Parsers.html>

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12528

Signed-off-by: Ralph Boehme <slow at samba.org>
---
 source3/rpc_server/mdssvc/sparql_lexer.c  | 401 ++++++++++++++++--------------
 source3/rpc_server/mdssvc/sparql_lexer.l  |   8 +-
 source3/rpc_server/mdssvc/sparql_parser.c | 152 +++++------
 source3/rpc_server/mdssvc/sparql_parser.h |  24 +-
 source3/rpc_server/mdssvc/sparql_parser.y |  25 +-
 5 files changed, 322 insertions(+), 288 deletions(-)

diff --git a/source3/rpc_server/mdssvc/sparql_lexer.c b/source3/rpc_server/mdssvc/sparql_lexer.c
index 4c76f45..39539c5 100644
--- a/source3/rpc_server/mdssvc/sparql_lexer.c
+++ b/source3/rpc_server/mdssvc/sparql_lexer.c
@@ -6,6 +6,25 @@
 
 /* A lexical scanner generated by flex */
 
+#define yy_create_buffer mdsyy_create_buffer
+#define yy_delete_buffer mdsyy_delete_buffer
+#define yy_flex_debug mdsyy_flex_debug
+#define yy_init_buffer mdsyy_init_buffer
+#define yy_flush_buffer mdsyy_flush_buffer
+#define yy_load_buffer_state mdsyy_load_buffer_state
+#define yy_switch_to_buffer mdsyy_switch_to_buffer
+#define yyin mdsyyin
+#define yyleng mdsyyleng
+#define yylex mdsyylex
+#define yylineno mdsyylineno
+#define yyout mdsyyout
+#define yyrestart mdsyyrestart
+#define yytext mdsyytext
+#define yywrap mdsyywrap
+#define yyalloc mdsyyalloc
+#define yyrealloc mdsyyrealloc
+#define yyfree mdsyyfree
+
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
 #define YY_FLEX_MINOR_VERSION 6
@@ -136,7 +155,7 @@ typedef unsigned int flex_uint32_t;
 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
 
 /* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart(yyin  )
+#define YY_NEW_FILE mdsyyrestart(mdsyyin  )
 
 #define YY_END_OF_BUFFER_CHAR 0
 
@@ -167,9 +186,9 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
 typedef size_t yy_size_t;
 #endif
 
-extern yy_size_t yyleng;
+extern yy_size_t mdsyyleng;
 
-extern FILE *yyin, *yyout;
+extern FILE *mdsyyin, *mdsyyout;
 
 #define EOB_ACT_CONTINUE_SCAN 0
 #define EOB_ACT_END_OF_FILE 1
@@ -182,13 +201,13 @@ extern FILE *yyin, *yyout;
 #define yyless(n) \
 	do \
 		{ \
-		/* Undo effects of setting up yytext. */ \
+		/* Undo effects of setting up mdsyytext. */ \
         yy_size_t yyless_macro_arg = (n); \
         YY_LESS_LINENO(yyless_macro_arg);\
 		*yy_cp = (yy_hold_char); \
 		YY_RESTORE_YY_MORE_OFFSET \
 		(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
-		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+		YY_DO_BEFORE_ACTION; /* set up mdsyytext again */ \
 		} \
 	while ( 0 )
 
@@ -251,8 +270,8 @@ struct yy_buffer_state
 	 * possible backing-up.
 	 *
 	 * When we actually see the EOF, we change the status to "new"
-	 * (via yyrestart()), so that the user can continue scanning by
-	 * just pointing yyin at a new input file.
+	 * (via mdsyyrestart()), so that the user can continue scanning by
+	 * just pointing mdsyyin at a new input file.
 	 */
 #define YY_BUFFER_EOF_PENDING 2
 
@@ -279,51 +298,51 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
  */
 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
 
-/* yy_hold_char holds the character lost when yytext is formed. */
+/* yy_hold_char holds the character lost when mdsyytext is formed. */
 static char yy_hold_char;
 static yy_size_t yy_n_chars;		/* number of characters read into yy_ch_buf */
-yy_size_t yyleng;
+yy_size_t mdsyyleng;
 
 /* Points to current character in buffer. */
 static char *yy_c_buf_p = (char *) 0;
 static int yy_init = 0;		/* whether we need to initialize */
 static int yy_start = 0;	/* start state number */
 
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin.  A bit of a hack ...
+/* Flag which is used to allow mdsyywrap()'s to do buffer switches
+ * instead of setting up a fresh mdsyyin.  A bit of a hack ...
  */
 static int yy_did_buffer_switch_on_eof;
 
-void yyrestart (FILE *input_file  );
-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size  );
-void yy_delete_buffer (YY_BUFFER_STATE b  );
-void yy_flush_buffer (YY_BUFFER_STATE b  );
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer  );
-void yypop_buffer_state (void );
+void mdsyyrestart (FILE *input_file  );
+void mdsyy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
+YY_BUFFER_STATE mdsyy_create_buffer (FILE *file,int size  );
+void mdsyy_delete_buffer (YY_BUFFER_STATE b  );
+void mdsyy_flush_buffer (YY_BUFFER_STATE b  );
+void mdsyypush_buffer_state (YY_BUFFER_STATE new_buffer  );
+void mdsyypop_buffer_state (void );
 
-static void yyensure_buffer_stack (void );
-static void yy_load_buffer_state (void );
-static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file  );
+static void mdsyyensure_buffer_stack (void );
+static void mdsyy_load_buffer_state (void );
+static void mdsyy_init_buffer (YY_BUFFER_STATE b,FILE *file  );
 
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
+#define YY_FLUSH_BUFFER mdsyy_flush_buffer(YY_CURRENT_BUFFER )
 
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size  );
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str  );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len  );
+YY_BUFFER_STATE mdsyy_scan_buffer (char *base,yy_size_t size  );
+YY_BUFFER_STATE mdsyy_scan_string (yyconst char *yy_str  );
+YY_BUFFER_STATE mdsyy_scan_bytes (yyconst char *bytes,yy_size_t len  );
 
-void *yyalloc (yy_size_t  );
-void *yyrealloc (void *,yy_size_t  );
-void yyfree (void *  );
+void *mdsyyalloc (yy_size_t  );
+void *mdsyyrealloc (void *,yy_size_t  );
+void mdsyyfree (void *  );
 
-#define yy_new_buffer yy_create_buffer
+#define yy_new_buffer mdsyy_create_buffer
 
 #define yy_set_interactive(is_interactive) \
 	{ \
 	if ( ! YY_CURRENT_BUFFER ){ \
-        yyensure_buffer_stack (); \
+        mdsyyensure_buffer_stack (); \
 		YY_CURRENT_BUFFER_LVALUE =    \
-            yy_create_buffer(yyin,YY_BUF_SIZE ); \
+            mdsyy_create_buffer(mdsyyin,YY_BUF_SIZE ); \
 	} \
 	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
 	}
@@ -331,9 +350,9 @@ void yyfree (void *  );
 #define yy_set_bol(at_bol) \
 	{ \
 	if ( ! YY_CURRENT_BUFFER ){\
-        yyensure_buffer_stack (); \
+        mdsyyensure_buffer_stack (); \
 		YY_CURRENT_BUFFER_LVALUE =    \
-            yy_create_buffer(yyin,YY_BUF_SIZE ); \
+            mdsyy_create_buffer(mdsyyin,YY_BUF_SIZE ); \
 	} \
 	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
 	}
@@ -344,19 +363,19 @@ void yyfree (void *  );
 
 typedef unsigned char YY_CHAR;
 
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+FILE *mdsyyin = (FILE *) 0, *mdsyyout = (FILE *) 0;
 
 typedef int yy_state_type;
 
-extern int yylineno;
+extern int mdsyylineno;
 
-int yylineno = 1;
+int mdsyylineno = 1;
 
-extern char *yytext;
+extern char *mdsyytext;
 #ifdef yytext_ptr
 #undef yytext_ptr
 #endif
-#define yytext_ptr yytext
+#define yytext_ptr mdsyytext
 
 static yy_state_type yy_get_previous_state (void );
 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
@@ -367,11 +386,11 @@ __attribute__((__noreturn__))
 static void yy_fatal_error (yyconst char msg[]  );
 
 /* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
+ * corresponding action - sets up mdsyytext.
  */
 #define YY_DO_BEFORE_ACTION \
 	(yytext_ptr) = yy_bp; \
-	yyleng = (size_t) (yy_cp - yy_bp); \
+	mdsyyleng = (size_t) (yy_cp - yy_bp); \
 	(yy_hold_char) = *yy_cp; \
 	*yy_cp = '\0'; \
 	(yy_c_buf_p) = yy_cp;
@@ -494,8 +513,8 @@ static yyconst flex_int16_t yy_chk[127] =
 static yy_state_type yy_last_accepting_state;
 static char *yy_last_accepting_cpos;
 
-extern int yy_flex_debug;
-int yy_flex_debug = 0;
+extern int mdsyy_flex_debug;
+int mdsyy_flex_debug = 0;
 
 /* The intent behind this definition is that it'll catch
  * any uses of REJECT which flex missed.
@@ -504,7 +523,7 @@ int yy_flex_debug = 0;
 #define yymore() yymore_used_but_not_detected
 #define YY_MORE_ADJ 0
 #define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
+char *mdsyytext;
 #line 1 "sparql_lexer.l"
 /*
    Unix SMB/CIFS implementation.
@@ -530,9 +549,9 @@ char *yytext;
 #include "sparql_parser.h"
 
 #define YY_NO_INPUT
-#define yyalloc SMB_MALLOC
-#define yyrealloc SMB_REALLOC
-#line 536 "sparql_lexer.c"
+#define mdsyyalloc SMB_MALLOC
+#define mdsyyrealloc SMB_REALLOC
+#line 555 "sparql_lexer.c"
 
 #define INITIAL 0
 
@@ -553,31 +572,31 @@ static int yy_init_globals (void );
 /* Accessor methods to globals.
    These are made visible to non-reentrant scanners for convenience. */
 
-int yylex_destroy (void );
+int mdsyylex_destroy (void );
 
-int yyget_debug (void );
+int mdsyyget_debug (void );
 
-void yyset_debug (int debug_flag  );
+void mdsyyset_debug (int debug_flag  );
 
-YY_EXTRA_TYPE yyget_extra (void );
+YY_EXTRA_TYPE mdsyyget_extra (void );
 
-void yyset_extra (YY_EXTRA_TYPE user_defined  );
+void mdsyyset_extra (YY_EXTRA_TYPE user_defined  );
 
-FILE *yyget_in (void );
+FILE *mdsyyget_in (void );
 
-void yyset_in  (FILE * _in_str  );
+void mdsyyset_in  (FILE * _in_str  );
 
-FILE *yyget_out (void );
+FILE *mdsyyget_out (void );
 
-void yyset_out  (FILE * _out_str  );
+void mdsyyset_out  (FILE * _out_str  );
 
-yy_size_t yyget_leng (void );
+yy_size_t mdsyyget_leng (void );
 
-char *yyget_text (void );
+char *mdsyyget_text (void );
 
-int yyget_lineno (void );
+int mdsyyget_lineno (void );
 
-void yyset_lineno (int _line_number  );
+void mdsyyset_lineno (int _line_number  );
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -585,9 +604,9 @@ void yyset_lineno (int _line_number  );
 
 #ifndef YY_SKIP_YYWRAP
 #ifdef __cplusplus
-extern "C" int yywrap (void );
+extern "C" int mdsyywrap (void );
 #else
-extern int yywrap (void );
+extern int mdsyywrap (void );
 #endif
 #endif
 
@@ -628,7 +647,7 @@ static int input (void );
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#define ECHO do { if (fwrite( mdsyytext, mdsyyleng, 1, mdsyyout )) {} } while (0)
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
@@ -641,18 +660,18 @@ static int input (void );
 		int c = '*'; \
 		size_t n; \
 		for ( n = 0; n < max_size && \
-			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+			     (c = getc( mdsyyin )) != EOF && c != '\n'; ++n ) \
 			buf[n] = (char) c; \
 		if ( c == '\n' ) \
 			buf[n++] = (char) c; \
-		if ( c == EOF && ferror( yyin ) ) \
+		if ( c == EOF && ferror( mdsyyin ) ) \
 			YY_FATAL_ERROR( "input in flex scanner failed" ); \
 		result = n; \
 		} \
 	else \
 		{ \
 		errno=0; \
-		while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+		while ( (result = fread(buf, 1, max_size, mdsyyin))==0 && ferror(mdsyyin)) \
 			{ \
 			if( errno != EINTR) \
 				{ \
@@ -660,7 +679,7 @@ static int input (void );
 				break; \
 				} \
 			errno=0; \
-			clearerr(yyin); \
+			clearerr(mdsyyin); \
 			} \
 		}\
 \
@@ -693,12 +712,12 @@ static int input (void );
 #ifndef YY_DECL
 #define YY_DECL_IS_OURS 1
 
-extern int yylex (void);
+extern int mdsyylex (void);
 
-#define YY_DECL int yylex (void)
+#define YY_DECL int mdsyylex (void)
 #endif /* !YY_DECL */
 
-/* Code executed at the beginning of each rule, after yytext and yyleng
+/* Code executed at the beginning of each rule, after mdsyytext and mdsyyleng
  * have been set up.
  */
 #ifndef YY_USER_ACTION
@@ -732,31 +751,31 @@ YY_DECL
 		if ( ! (yy_start) )
 			(yy_start) = 1;	/* first start state */
 
-		if ( ! yyin )
-			yyin = stdin;
+		if ( ! mdsyyin )
+			mdsyyin = stdin;
 
-		if ( ! yyout )
-			yyout = stdout;
+		if ( ! mdsyyout )
+			mdsyyout = stdout;
 
 		if ( ! YY_CURRENT_BUFFER ) {
-			yyensure_buffer_stack ();
+			mdsyyensure_buffer_stack ();
 			YY_CURRENT_BUFFER_LVALUE =
-				yy_create_buffer(yyin,YY_BUF_SIZE );
+				mdsyy_create_buffer(mdsyyin,YY_BUF_SIZE );
 		}
 
-		yy_load_buffer_state( );
+		mdsyy_load_buffer_state( );
 		}
 
 	{
 #line 41 "sparql_lexer.l"
 
-#line 754 "sparql_lexer.c"
+#line 773 "sparql_lexer.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
 		yy_cp = (yy_c_buf_p);
 
-		/* Support of yytext. */
+		/* Support of mdsyytext. */
 		*yy_cp = (yy_hold_char);
 
 		/* yy_bp points to the position in yy_ch_buf of the start of
@@ -820,12 +839,12 @@ return DATE_ISO;
 case 3:
 YY_RULE_SETUP
 #line 44 "sparql_lexer.l"
-{yylval.bval = false; return BOOL;}
+{mdsyylval.bval = false; return BOOL;}
 	YY_BREAK
 case 4:
 YY_RULE_SETUP
 #line 45 "sparql_lexer.l"
-{yylval.bval = true; return BOOL;}
+{mdsyylval.bval = true; return BOOL;}
 	YY_BREAK
 case 5:
 YY_RULE_SETUP
@@ -885,7 +904,7 @@ return COMMA;
 case 16:
 YY_RULE_SETUP
 #line 57 "sparql_lexer.l"
-{yylval.sval = talloc_strdup(talloc_tos(), yytext); return WORD;}
+{mdsyylval.sval = talloc_strdup(talloc_tos(), mdsyytext); return WORD;}
 	YY_BREAK
 case 17:
 /* rule 17 can match eol */
@@ -898,7 +917,7 @@ YY_RULE_SETUP
 #line 59 "sparql_lexer.l"
 ECHO;
 	YY_BREAK
-#line 902 "sparql_lexer.c"
+#line 921 "sparql_lexer.c"
 case YY_STATE_EOF(INITIAL):
 	yyterminate();
 
@@ -915,15 +934,15 @@ case YY_STATE_EOF(INITIAL):
 			{
 			/* We're scanning a new file or input source.  It's
 			 * possible that this happened because the user
-			 * just pointed yyin at a new source and called
-			 * yylex().  If so, then we have to assure
+			 * just pointed mdsyyin at a new source and called
+			 * mdsyylex().  If so, then we have to assure
 			 * consistency between YY_CURRENT_BUFFER and our
 			 * globals.  Here is the right place to do so, because
 			 * this is the first action (other than possibly a
 			 * back-up) that will match for the new input source.
 			 */
 			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
-			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+			YY_CURRENT_BUFFER_LVALUE->yy_input_file = mdsyyin;
 			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
 			}
 
@@ -976,11 +995,11 @@ case YY_STATE_EOF(INITIAL):
 				{
 				(yy_did_buffer_switch_on_eof) = 0;
 
-				if ( yywrap( ) )
+				if ( mdsyywrap( ) )
 					{
 					/* Note: because we've taken care in
 					 * yy_get_next_buffer() to have set up
-					 * yytext, we can now set up
+					 * mdsyytext, we can now set up
 					 * yy_c_buf_p so that if some total
 					 * hoser (like flex itself) wants to
 					 * call the scanner after we return the
@@ -1030,7 +1049,7 @@ case YY_STATE_EOF(INITIAL):
 	} /* end of action switch */
 		} /* end of scanning one token */
 	} /* end of user's declarations */
-} /* end of yylex */
+} /* end of mdsyylex */
 
 /* yy_get_next_buffer - try to read in a new buffer
  *
@@ -1108,7 +1127,7 @@ static int yy_get_next_buffer (void)
 
 				b->yy_ch_buf = (char *)
 					/* Include room in for 2 EOB chars. */
-					yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
+					mdsyyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
 				}
 			else
 				/* Can't grow it, we don't own it. */
@@ -1140,7 +1159,7 @@ static int yy_get_next_buffer (void)
 		if ( number_to_move == YY_MORE_ADJ )
 			{
 			ret_val = EOB_ACT_END_OF_FILE;
-			yyrestart(yyin  );
+			mdsyyrestart(mdsyyin  );
 			}
 
 		else
@@ -1157,7 +1176,7 @@ static int yy_get_next_buffer (void)
 	if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
 		/* Extend the array by 50%, plus the number we really need. */
 		yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
-		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
+		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) mdsyyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
 		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
 			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
 	}
@@ -1273,13 +1292,13 @@ static int yy_get_next_buffer (void)
 					 */
 
 					/* Reset buffer status. */
-					yyrestart(yyin );
+					mdsyyrestart(mdsyyin );
 
 					/*FALLTHROUGH*/
 
 				case EOB_ACT_END_OF_FILE:
 					{
-					if ( yywrap( ) )
+					if ( mdsyywrap( ) )
 						return EOF;
 
 					if ( ! (yy_did_buffer_switch_on_eof) )
@@ -1299,7 +1318,7 @@ static int yy_get_next_buffer (void)
 		}
 
 	c = *(unsigned char *) (yy_c_buf_p);	/* cast for 8-bit char's */
-	*(yy_c_buf_p) = '\0';	/* preserve yytext */
+	*(yy_c_buf_p) = '\0';	/* preserve mdsyytext */
 	(yy_hold_char) = *++(yy_c_buf_p);
 
 	return c;
@@ -1311,32 +1330,32 @@ static int yy_get_next_buffer (void)
  * 
  * @note This function does not reset the start condition to @c INITIAL .
  */
-    void yyrestart  (FILE * input_file )
+    void mdsyyrestart  (FILE * input_file )
 {
     
 	if ( ! YY_CURRENT_BUFFER ){
-        yyensure_buffer_stack ();
+        mdsyyensure_buffer_stack ();
 		YY_CURRENT_BUFFER_LVALUE =
-            yy_create_buffer(yyin,YY_BUF_SIZE );
+            mdsyy_create_buffer(mdsyyin,YY_BUF_SIZE );
 	}
 
-	yy_init_buffer(YY_CURRENT_BUFFER,input_file );
-	yy_load_buffer_state( );
+	mdsyy_init_buffer(YY_CURRENT_BUFFER,input_file );
+	mdsyy_load_buffer_state( );
 }
 
 /** Switch to a different input buffer.
  * @param new_buffer The new input buffer.
  * 
  */
-    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
+    void mdsyy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
 {
     
 	/* TODO. We should be able to replace this entire function body
 	 * with
-	 *		yypop_buffer_state();
-	 *		yypush_buffer_state(new_buffer);
+	 *		mdsyypop_buffer_state();
+	 *		mdsyypush_buffer_state(new_buffer);
      */
-	yyensure_buffer_stack ();
+	mdsyyensure_buffer_stack ();
 	if ( YY_CURRENT_BUFFER == new_buffer )
 		return;
 
@@ -1349,21 +1368,21 @@ static int yy_get_next_buffer (void)
 		}
 
 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
-	yy_load_buffer_state( );
+	mdsyy_load_buffer_state( );
 
 	/* We don't actually know whether we did this switch during
-	 * EOF (yywrap()) processing, but the only time this flag
-	 * is looked at is after yywrap() is called, so it's safe
+	 * EOF (mdsyywrap()) processing, but the only time this flag
+	 * is looked at is after mdsyywrap() is called, so it's safe
 	 * to go ahead and always set it.
 	 */
 	(yy_did_buffer_switch_on_eof) = 1;
 }
 
-static void yy_load_buffer_state  (void)
+static void mdsyy_load_buffer_state  (void)
 {
     	(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
 	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
-	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+	mdsyyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
 	(yy_hold_char) = *(yy_c_buf_p);
 }
 
@@ -1373,35 +1392,35 @@ static void yy_load_buffer_state  (void)
  * 
  * @return the allocated buffer state.
  */
-    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size )
+    YY_BUFFER_STATE mdsyy_create_buffer  (FILE * file, int  size )
 {
 	YY_BUFFER_STATE b;
     
-	b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
+	b = (YY_BUFFER_STATE) mdsyyalloc(sizeof( struct yy_buffer_state )  );
 	if ( ! b )
-		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+		YY_FATAL_ERROR( "out of dynamic memory in mdsyy_create_buffer()" );
 
 	b->yy_buf_size = (yy_size_t)size;
 
 	/* yy_ch_buf has to be 2 characters longer than the size given because
 	 * we need to put in 2 end-of-buffer characters.
 	 */
-	b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2  );
+	b->yy_ch_buf = (char *) mdsyyalloc(b->yy_buf_size + 2  );
 	if ( ! b->yy_ch_buf )
-		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+		YY_FATAL_ERROR( "out of dynamic memory in mdsyy_create_buffer()" );
 
 	b->yy_is_our_buffer = 1;
 
-	yy_init_buffer(b,file );
+	mdsyy_init_buffer(b,file );
 
 	return b;
 }
 
 /** Destroy the buffer.
- * @param b a buffer created with yy_create_buffer()
+ * @param b a buffer created with mdsyy_create_buffer()
  * 
  */
-    void yy_delete_buffer (YY_BUFFER_STATE  b )
+    void mdsyy_delete_buffer (YY_BUFFER_STATE  b )
 {
     
 	if ( ! b )
@@ -1411,27 +1430,27 @@ static void yy_load_buffer_state  (void)
 		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
 
 	if ( b->yy_is_our_buffer )
-		yyfree((void *) b->yy_ch_buf  );
+		mdsyyfree((void *) b->yy_ch_buf  );
 
-	yyfree((void *) b  );
+	mdsyyfree((void *) b  );
 }
 
 /* Initializes or reinitializes a buffer.
  * This function is sometimes called more than once on the same buffer,
- * such as during a yyrestart() or at EOF.
+ * such as during a mdsyyrestart() or at EOF.
  */
-    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
+    static void mdsyy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
 
 {
 	int oerrno = errno;
     
-	yy_flush_buffer(b );
+	mdsyy_flush_buffer(b );
 
 	b->yy_input_file = file;
 	b->yy_fill_buffer = 1;
 
-    /* If b is the current buffer, then yy_init_buffer was _probably_
-     * called from yyrestart() or through yy_get_next_buffer.
+    /* If b is the current buffer, then mdsyy_init_buffer was _probably_
+     * called from mdsyyrestart() or through yy_get_next_buffer.
      * In that case, we don't want to reset the lineno or column.
      */
     if (b != YY_CURRENT_BUFFER){
@@ -1448,7 +1467,7 @@ static void yy_load_buffer_state  (void)
  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
  * 
  */
-    void yy_flush_buffer (YY_BUFFER_STATE  b )
+    void mdsyy_flush_buffer (YY_BUFFER_STATE  b )
 {
     	if ( ! b )
 		return;
@@ -1468,7 +1487,7 @@ static void yy_load_buffer_state  (void)
 	b->yy_buffer_status = YY_BUFFER_NEW;
 
 	if ( b == YY_CURRENT_BUFFER )
-		yy_load_buffer_state( );
+		mdsyy_load_buffer_state( );
 }
 
 /** Pushes the new state onto the stack. The new state becomes
@@ -1477,14 +1496,14 @@ static void yy_load_buffer_state  (void)
  *  @param new_buffer The new state.
  *  
  */
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
+void mdsyypush_buffer_state (YY_BUFFER_STATE new_buffer )
 {
     	if (new_buffer == NULL)
 		return;
 
-	yyensure_buffer_stack();
+	mdsyyensure_buffer_stack();
 
-	/* This block is copied from yy_switch_to_buffer. */
+	/* This block is copied from mdsyy_switch_to_buffer. */
 	if ( YY_CURRENT_BUFFER )
 		{
 		/* Flush out information for old buffer. */
@@ -1498,8 +1517,8 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
 		(yy_buffer_stack_top)++;
 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
 
-	/* copied from yy_switch_to_buffer. */
-	yy_load_buffer_state( );
+	/* copied from mdsyy_switch_to_buffer. */
+	mdsyy_load_buffer_state( );
 	(yy_did_buffer_switch_on_eof) = 1;
 }
 
@@ -1507,18 +1526,18 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
  *  The next element becomes the new top.
  *  
  */
-void yypop_buffer_state (void)
+void mdsyypop_buffer_state (void)
 {
     	if (!YY_CURRENT_BUFFER)
 		return;
 
-	yy_delete_buffer(YY_CURRENT_BUFFER );
+	mdsyy_delete_buffer(YY_CURRENT_BUFFER );
 	YY_CURRENT_BUFFER_LVALUE = NULL;
 	if ((yy_buffer_stack_top) > 0)
 		--(yy_buffer_stack_top);
 
 	if (YY_CURRENT_BUFFER) {
-		yy_load_buffer_state( );
+		mdsyy_load_buffer_state( );
 		(yy_did_buffer_switch_on_eof) = 1;
 	}
 }
@@ -1526,7 +1545,7 @@ void yypop_buffer_state (void)
 /* Allocates the stack if it does not exist.
  *  Guarantees space for at least one push.
  */
-static void yyensure_buffer_stack (void)
+static void mdsyyensure_buffer_stack (void)
 {
 	yy_size_t num_to_alloc;
     
@@ -1537,11 +1556,11 @@ static void yyensure_buffer_stack (void)
 		 * immediate realloc on the next call.
          */
       num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
-		(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
+		(yy_buffer_stack) = (struct yy_buffer_state**)mdsyyalloc
 								(num_to_alloc * sizeof(struct yy_buffer_state*)
 								);
 		if ( ! (yy_buffer_stack) )
-			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+			YY_FATAL_ERROR( "out of dynamic memory in mdsyyensure_buffer_stack()" );
 								  
 		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
 				
@@ -1556,12 +1575,12 @@ static void yyensure_buffer_stack (void)
 		yy_size_t grow_size = 8 /* arbitrary grow size */;
 
 		num_to_alloc = (yy_buffer_stack_max) + grow_size;
-		(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
+		(yy_buffer_stack) = (struct yy_buffer_state**)mdsyyrealloc
 								((yy_buffer_stack),
 								num_to_alloc * sizeof(struct yy_buffer_state*)
 								);
 		if ( ! (yy_buffer_stack) )
-			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+			YY_FATAL_ERROR( "out of dynamic memory in mdsyyensure_buffer_stack()" );
 
 		/* zero only the new slots.*/
 		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -1575,7 +1594,7 @@ static void yyensure_buffer_stack (void)
  * 
  * @return the newly allocated buffer state object. 
  */
-YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
+YY_BUFFER_STATE mdsyy_scan_buffer  (char * base, yy_size_t  size )
 {
 	YY_BUFFER_STATE b;
     
@@ -1585,9 +1604,9 @@ YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
 		/* They forgot to leave room for the EOB's. */
 		return 0;
 
-	b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
+	b = (YY_BUFFER_STATE) mdsyyalloc(sizeof( struct yy_buffer_state )  );
 	if ( ! b )
-		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+		YY_FATAL_ERROR( "out of dynamic memory in mdsyy_scan_buffer()" );
 
 	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
 	b->yy_buf_pos = b->yy_ch_buf = base;
@@ -1599,33 +1618,33 @@ YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
 	b->yy_fill_buffer = 0;
 	b->yy_buffer_status = YY_BUFFER_NEW;
 
-	yy_switch_to_buffer(b  );
+	mdsyy_switch_to_buffer(b  );
 
 	return b;
 }
 
-/** Setup the input buffer state to scan a string. The next call to yylex() will
+/** Setup the input buffer state to scan a string. The next call to mdsyylex() will
  * scan from a @e copy of @a str.
  * @param yystr a NUL-terminated string to scan
  * 
  * @return the newly allocated buffer state object.
  * @note If you want to scan bytes that may contain NUL values, then use
- *       yy_scan_bytes() instead.
+ *       mdsyy_scan_bytes() instead.
  */
-YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
+YY_BUFFER_STATE mdsyy_scan_string (yyconst char * yystr )
 {
     
-	return yy_scan_bytes(yystr,strlen(yystr) );
+	return mdsyy_scan_bytes(yystr,strlen(yystr) );
 }
 
-/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
+/** Setup the input buffer state to scan the given bytes. The next call to mdsyylex() will
  * scan from a @e copy of @a bytes.
  * @param yybytes the byte buffer to scan
  * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
  * 
  * @return the newly allocated buffer state object.
  */
-YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len )
+YY_BUFFER_STATE mdsyy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len )
 {
 	YY_BUFFER_STATE b;
 	char *buf;
@@ -1634,18 +1653,18 @@ YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len
     
 	/* Get memory for full buffer, including space for trailing EOB's. */
 	n = _yybytes_len + 2;
-	buf = (char *) yyalloc(n  );
+	buf = (char *) mdsyyalloc(n  );
 	if ( ! buf )
-		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+		YY_FATAL_ERROR( "out of dynamic memory in mdsyy_scan_bytes()" );
 
 	for ( i = 0; i < _yybytes_len; ++i )
 		buf[i] = yybytes[i];
 
 	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
 
-	b = yy_scan_buffer(buf,n );
+	b = mdsyy_scan_buffer(buf,n );
 	if ( ! b )
-		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+		YY_FATAL_ERROR( "bad buffer in mdsyy_scan_bytes()" );
 
 	/* It's okay to grow etc. this buffer, and we should throw it
 	 * away when we're done.
@@ -1671,14 +1690,14 @@ static void yy_fatal_error (yyconst char* msg )
 #define yyless(n) \
 	do \
 		{ \
-		/* Undo effects of setting up yytext. */ \
+		/* Undo effects of setting up mdsyytext. */ \
         yy_size_t yyless_macro_arg = (n); \
         YY_LESS_LINENO(yyless_macro_arg);\
-		yytext[yyleng] = (yy_hold_char); \
-		(yy_c_buf_p) = yytext + yyless_macro_arg; \
+		mdsyytext[mdsyyleng] = (yy_hold_char); \
+		(yy_c_buf_p) = mdsyytext + yyless_macro_arg; \
 		(yy_hold_char) = *(yy_c_buf_p); \
 		*(yy_c_buf_p) = '\0'; \
-		yyleng = yyless_macro_arg; \
+		mdsyyleng = yyless_macro_arg; \
 		} \
 	while ( 0 )
 
@@ -1687,85 +1706,85 @@ static void yy_fatal_error (yyconst char* msg )
 /** Get the current line number.
  * 
  */
-int yyget_lineno  (void)
+int mdsyyget_lineno  (void)
 {
         
-    return yylineno;
+    return mdsyylineno;
 }
 
 /** Get the input stream.
  * 
  */
-FILE *yyget_in  (void)
+FILE *mdsyyget_in  (void)
 {
-        return yyin;
+        return mdsyyin;
 }
 
 /** Get the output stream.
  * 
  */
-FILE *yyget_out  (void)
+FILE *mdsyyget_out  (void)
 {
-        return yyout;
+        return mdsyyout;
 }
 
 /** Get the length of the current token.
  * 
  */
-yy_size_t yyget_leng  (void)
+yy_size_t mdsyyget_leng  (void)
 {
-        return yyleng;
+        return mdsyyleng;
 }
 
 /** Get the current token.
  * 
  */
 
-char *yyget_text  (void)
+char *mdsyyget_text  (void)
 {
-        return yytext;
+        return mdsyytext;
 }
 
 /** Set the current line number.
  * @param _line_number line number
  * 
  */
-void yyset_lineno (int  _line_number )
+void mdsyyset_lineno (int  _line_number )
 {
     
-    yylineno = _line_number;
+    mdsyylineno = _line_number;
 }
 
 /** Set the input stream. This does not discard the current
  * input buffer.
  * @param _in_str A readable stream.
  * 
- * @see yy_switch_to_buffer
+ * @see mdsyy_switch_to_buffer
  */
-void yyset_in (FILE *  _in_str )
+void mdsyyset_in (FILE *  _in_str )
 {
-        yyin = _in_str ;
+        mdsyyin = _in_str ;
 }
 
-void yyset_out (FILE *  _out_str )
+void mdsyyset_out (FILE *  _out_str )
 {
-        yyout = _out_str ;
+        mdsyyout = _out_str ;
 }
 
-int yyget_debug  (void)
+int mdsyyget_debug  (void)
 {
-        return yy_flex_debug;
+        return mdsyy_flex_debug;
 }
 
-void yyset_debug (int  _bdebug )
+void mdsyyset_debug (int  _bdebug )
 {
-        yy_flex_debug = _bdebug ;
+        mdsyy_flex_debug = _bdebug ;
 }
 
 static int yy_init_globals (void)
 {
         /* Initialization is the same as for the non-reentrant scanner.
-     * This function is called from yylex_destroy(), so don't allocate here.
+     * This function is called from mdsyylex_destroy(), so don't allocate here.
      */
 
     (yy_buffer_stack) = 0;
@@ -1777,36 +1796,36 @@ static int yy_init_globals (void)
 
 /* Defined in main.c */
 #ifdef YY_STDINIT
-    yyin = stdin;
-    yyout = stdout;
+    mdsyyin = stdin;
+    mdsyyout = stdout;
 #else
-    yyin = (FILE *) 0;
-    yyout = (FILE *) 0;
+    mdsyyin = (FILE *) 0;
+    mdsyyout = (FILE *) 0;
 #endif
 
     /* For future reference: Set errno on error, since we are called by
-     * yylex_init()
+     * mdsyylex_init()
      */
     return 0;
 }
 
-/* yylex_destroy is for both reentrant and non-reentrant scanners. */
-int yylex_destroy  (void)
+/* mdsyylex_destroy is for both reentrant and non-reentrant scanners. */
+int mdsyylex_destroy  (void)
 {
     
     /* Pop the buffer stack, destroying each element. */
 	while(YY_CURRENT_BUFFER){
-		yy_delete_buffer(YY_CURRENT_BUFFER  );
+		mdsyy_delete_buffer(YY_CURRENT_BUFFER  );
 		YY_CURRENT_BUFFER_LVALUE = NULL;
-		yypop_buffer_state();
+		mdsyypop_buffer_state();
 	}
 
 	/* Destroy the stack itself. */
-	yyfree((yy_buffer_stack) );
+	mdsyyfree((yy_buffer_stack) );
 	(yy_buffer_stack) = NULL;
 
     /* Reset the globals. This is important in a non-reentrant scanner so the next time
-     * yylex() is called, initialization will occur. */
+     * mdsyylex() is called, initialization will occur. */
     yy_init_globals( );
 
     return 0;
@@ -1837,9 +1856,9 @@ static int yy_flex_strlen (yyconst char * s )
 }
 #endif
 
-void yyfree (void * ptr )
+void mdsyyfree (void * ptr )
 {
-			free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
+			free( (char *) ptr );	/* see mdsyyrealloc() for (char *) cast */
 }
 
 #define YYTABLES_NAME "yytables"
diff --git a/source3/rpc_server/mdssvc/sparql_lexer.l b/source3/rpc_server/mdssvc/sparql_lexer.l
index 01c896f..8bb48f9 100644
--- a/source3/rpc_server/mdssvc/sparql_lexer.l
+++ b/source3/rpc_server/mdssvc/sparql_lexer.l
@@ -27,7 +27,7 @@
 #define yyrealloc SMB_REALLOC
 %}
 
-%option nounput noyyalloc noyyrealloc
+%option nounput noyyalloc noyyrealloc prefix="mdsyy"
 
 ASC     [a-zA-Z0-9_\*\:\-\.]
 U       [\x80-\xbf]
@@ -41,8 +41,8 @@ UONLY   {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
 %%
 InRange           return FUNC_INRANGE;
 \$time\.iso       return DATE_ISO;
-false             {yylval.bval = false; return BOOL;}
-true              {yylval.bval = true; return BOOL;}
+false             {mdsyylval.bval = false; return BOOL;}
+true              {mdsyylval.bval = true; return BOOL;}
 \"                return QUOTE;
 \(                return OBRACE;
 \)                return CBRACE;
@@ -54,6 +54,6 @@ true              {yylval.bval = true; return BOOL;}
 \<                return LT;
 \>                return GT;
 \,                return COMMA;
-{UANY}+           {yylval.sval = talloc_strdup(talloc_tos(), yytext); return WORD;}
+{UANY}+           {mdsyylval.sval = talloc_strdup(talloc_tos(), mdsyytext); return WORD;}
 [ \t\n]           /* ignore */
 %%
diff --git a/source3/rpc_server/mdssvc/sparql_parser.c b/source3/rpc_server/mdssvc/sparql_parser.c
index 3cd532b..4b26980 100644
--- a/source3/rpc_server/mdssvc/sparql_parser.c
+++ b/source3/rpc_server/mdssvc/sparql_parser.c
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.2.  */
+/* A Bison parser, made by GNU Bison 3.0.4.  */
 
 /* Bison implementation for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "3.0.2"
+#define YYBISON_VERSION "3.0.4"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -59,7 +59,15 @@
 #define YYPULL 1
 
 
+/* Substitute the variable and function names.  */
+#define yyparse         mdsyyparse
+#define yylex           mdsyylex
+#define yyerror         mdsyyerror
+#define yydebug         mdsyydebug
+#define yynerrs         mdsyynerrs
 
+#define yylval          mdsyylval
+#define yychar          mdsyychar
 
 /* Copy the first part of user declarations.  */
 #line 21 "sparql_parser.y" /* yacc.c:339  */
@@ -74,11 +82,11 @@
 
 	struct yy_buffer_state;
 	typedef struct yy_buffer_state *YY_BUFFER_STATE;
-	extern int yylex (void);
-	extern void yyerror (char const *);
-	extern void *yyterminate(void);
-	extern YY_BUFFER_STATE yy_scan_string( const char *str);
-	extern void yy_delete_buffer ( YY_BUFFER_STATE buffer );
+	extern int mdsyylex (void);
+	extern void mdsyyerror (char const *);
+	extern void *mdsyyterminate(void);
+	extern YY_BUFFER_STATE mdsyy_scan_string( const char *str);
+	extern void mdsyy_delete_buffer ( YY_BUFFER_STATE buffer );
 
 	/* forward declarations */
 	static const char *map_expr(const char *attr, char op, const char *val);
@@ -94,7 +102,7 @@
 		const char *result;
 	} *global_sparql_parser_state;
 
-#line 98 "sparql_parser.c" /* yacc.c:339  */
+#line 106 "sparql_parser.c" /* yacc.c:339  */
 
 # ifndef YY_NULLPTR
 #  if defined __cplusplus && 201103L <= __cplusplus
@@ -114,14 +122,14 @@
 
 /* In a future release of Bison, this section will be replaced
    by #include "sparql_parser.h".  */
-#ifndef YY_YY_SPARQL_PARSER_H_INCLUDED
-# define YY_YY_SPARQL_PARSER_H_INCLUDED
+#ifndef YY_MDSYY_SPARQL_PARSER_H_INCLUDED
+# define YY_MDSYY_SPARQL_PARSER_H_INCLUDED
 /* Debug traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG 0
 #endif
 #if YYDEBUG
-extern int yydebug;
+extern int mdsyydebug;
 #endif
 
 /* Token type.  */
@@ -148,7 +156,7 @@ extern int yydebug;
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE YYSTYPE;
+
 union YYSTYPE
 {
 #line 61 "sparql_parser.y" /* yacc.c:355  */
@@ -158,32 +166,34 @@ union YYSTYPE
 	bool bval;
 	time_t tval;
 
-#line 162 "sparql_parser.c" /* yacc.c:355  */
+#line 170 "sparql_parser.c" /* yacc.c:355  */
 };
+
+typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif
 
 
-extern YYSTYPE yylval;
+extern YYSTYPE mdsyylval;
 
-int yyparse (void);
+int mdsyyparse (void);
 /* "%code provides" blocks.  */
 #line 53 "sparql_parser.y" /* yacc.c:355  */
 
 	#include <stdbool.h>
 	#include "mdssvc.h"
 	#define SPRAW_TIME_OFFSET 978307200
-	extern int yywrap(void);
+	extern int mdsyywrap(void);
 	extern bool map_spotlight_to_sparql_query(struct sl_query *slq);
 
-#line 181 "sparql_parser.c" /* yacc.c:355  */
+#line 191 "sparql_parser.c" /* yacc.c:355  */
 
-#endif /* !YY_YY_SPARQL_PARSER_H_INCLUDED  */
+#endif /* !YY_MDSYY_SPARQL_PARSER_H_INCLUDED  */
 
 /* Copy the second part of user declarations.  */
 
-#line 187 "sparql_parser.c" /* yacc.c:358  */
+#line 197 "sparql_parser.c" /* yacc.c:358  */
 
 #ifdef short
 # undef short
@@ -241,7 +251,9 @@ typedef short int yytype_int16;
 #endif
 
 #ifndef YY_ATTRIBUTE
-# if HAVE___ATTRIBUTE__
+# if (defined __GNUC__                                               \
+      && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
+     || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
 #  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
 # else
 #  define YY_ATTRIBUTE(Spec) /* empty */
@@ -480,9 +492,9 @@ static const yytype_uint8 yytranslate[] =
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint8 yyrline[] =
 {
-       0,    83,    83,    85,    89,    95,   118,   125,   128,   131,
-     134,   137,   147,   151,   155,   159,   163,   167,   171,   175,
-     182,   189,   190
+       0,    84,    84,    86,    90,    96,   119,   126,   129,   132,
+     135,   138,   148,   152,   156,   160,   164,   168,   172,   176,
+     183,   190,   191
 };
 #endif
 
@@ -1280,15 +1292,15 @@ yyreduce:
   switch (yyn)
     {
         case 4:
-#line 89 "sparql_parser.y" /* yacc.c:1646  */
+#line 90 "sparql_parser.y" /* yacc.c:1646  */
     {
 	global_sparql_parser_state->result = (yyvsp[0].sval);
 }
-#line 1290 "sparql_parser.c" /* yacc.c:1646  */
+#line 1300 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 5:
-#line 95 "sparql_parser.y" /* yacc.c:1646  */
+#line 96 "sparql_parser.y" /* yacc.c:1646  */
     {
 	/*
 	 * We can't properly handle these in expressions, fortunately this
@@ -1300,11 +1312,11 @@ yyreduce:
 	 */
 	YYABORT;
 }
-#line 1306 "sparql_parser.c" /* yacc.c:1646  */
+#line 1316 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 6:
-#line 118 "sparql_parser.y" /* yacc.c:1646  */
+#line 119 "sparql_parser.y" /* yacc.c:1646  */
     {
 	if (strcmp((yyvsp[-2].sval), (yyvsp[0].sval)) != 0) {
 		(yyval.sval) = talloc_asprintf(talloc_tos(), "{ %s } UNION { %s }", (yyvsp[-2].sval), (yyvsp[0].sval));
@@ -1312,43 +1324,43 @@ yyreduce:
 		(yyval.sval) = talloc_asprintf(talloc_tos(), "%s", (yyvsp[-2].sval));
 	}
 }
-#line 1318 "sparql_parser.c" /* yacc.c:1646  */
+#line 1328 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 7:
-#line 125 "sparql_parser.y" /* yacc.c:1646  */
+#line 126 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = (yyvsp[0].sval);
 }
-#line 1326 "sparql_parser.c" /* yacc.c:1646  */
+#line 1336 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 8:
-#line 128 "sparql_parser.y" /* yacc.c:1646  */
+#line 129 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = (yyvsp[0].sval);
 }
-#line 1334 "sparql_parser.c" /* yacc.c:1646  */
+#line 1344 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 9:
-#line 131 "sparql_parser.y" /* yacc.c:1646  */
+#line 132 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = talloc_asprintf(talloc_tos(), "%s", (yyvsp[-1].sval));
 }
-#line 1342 "sparql_parser.c" /* yacc.c:1646  */
+#line 1352 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 10:
-#line 134 "sparql_parser.y" /* yacc.c:1646  */
+#line 135 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = talloc_asprintf(talloc_tos(), "%s . %s", (yyvsp[-2].sval), (yyvsp[0].sval));
 }
-#line 1350 "sparql_parser.c" /* yacc.c:1646  */
+#line 1360 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 11:
-#line 137 "sparql_parser.y" /* yacc.c:1646  */
+#line 138 "sparql_parser.y" /* yacc.c:1646  */
     {
 	if (strcmp((yyvsp[-2].sval), (yyvsp[0].sval)) != 0) {
 		(yyval.sval) = talloc_asprintf(talloc_tos(), "{ %s } UNION { %s }", (yyvsp[-2].sval), (yyvsp[0].sval));
@@ -1356,104 +1368,104 @@ yyreduce:
 		(yyval.sval) = talloc_asprintf(talloc_tos(), "%s", (yyvsp[-2].sval));
 	}
 }
-#line 1362 "sparql_parser.c" /* yacc.c:1646  */
+#line 1372 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 12:
-#line 147 "sparql_parser.y" /* yacc.c:1646  */
+#line 148 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = map_expr((yyvsp[-4].sval), '=', (yyvsp[-1].sval));
 	if ((yyval.sval) == NULL) YYABORT;
 }
-#line 1371 "sparql_parser.c" /* yacc.c:1646  */
+#line 1381 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 13:
-#line 151 "sparql_parser.y" /* yacc.c:1646  */
+#line 152 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = map_expr((yyvsp[-4].sval), '!', (yyvsp[-1].sval));
 	if ((yyval.sval) == NULL) YYABORT;
 }
-#line 1380 "sparql_parser.c" /* yacc.c:1646  */
+#line 1390 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 14:
-#line 155 "sparql_parser.y" /* yacc.c:1646  */
+#line 156 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = map_expr((yyvsp[-4].sval), '<', (yyvsp[-1].sval));
 	if ((yyval.sval) == NULL) YYABORT;
 }
-#line 1389 "sparql_parser.c" /* yacc.c:1646  */
+#line 1399 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 15:
-#line 159 "sparql_parser.y" /* yacc.c:1646  */
+#line 160 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = map_expr((yyvsp[-4].sval), '>', (yyvsp[-1].sval));
 	if ((yyval.sval) == NULL) YYABORT;
 }
-#line 1398 "sparql_parser.c" /* yacc.c:1646  */
+#line 1408 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 16:
-#line 163 "sparql_parser.y" /* yacc.c:1646  */
+#line 164 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = map_expr((yyvsp[-5].sval), '=', (yyvsp[-2].sval));
 	if ((yyval.sval) == NULL) YYABORT;
 }
-#line 1407 "sparql_parser.c" /* yacc.c:1646  */
+#line 1417 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 17:
-#line 167 "sparql_parser.y" /* yacc.c:1646  */
+#line 168 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = map_expr((yyvsp[-5].sval), '!', (yyvsp[-2].sval));
 	if ((yyval.sval) == NULL) YYABORT;
 }
-#line 1416 "sparql_parser.c" /* yacc.c:1646  */
+#line 1426 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 18:
-#line 171 "sparql_parser.y" /* yacc.c:1646  */
+#line 172 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = map_expr((yyvsp[-5].sval), '<', (yyvsp[-2].sval));
 	if ((yyval.sval) == NULL) YYABORT;
 }
-#line 1425 "sparql_parser.c" /* yacc.c:1646  */
+#line 1435 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 19:
-#line 175 "sparql_parser.y" /* yacc.c:1646  */
+#line 176 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = map_expr((yyvsp[-5].sval), '>', (yyvsp[-2].sval));
 	if ((yyval.sval) == NULL) YYABORT;
 }
-#line 1434 "sparql_parser.c" /* yacc.c:1646  */
+#line 1444 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 20:
-#line 182 "sparql_parser.y" /* yacc.c:1646  */
+#line 183 "sparql_parser.y" /* yacc.c:1646  */
     {
 	(yyval.sval) = map_daterange((yyvsp[-5].sval), (yyvsp[-3].tval), (yyvsp[-1].tval));
 	if ((yyval.sval) == NULL) YYABORT;
 }
-#line 1443 "sparql_parser.c" /* yacc.c:1646  */
+#line 1453 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 21:
-#line 189 "sparql_parser.y" /* yacc.c:1646  */
+#line 190 "sparql_parser.y" /* yacc.c:1646  */
     {(yyval.tval) = isodate2unix((yyvsp[-1].sval));}
-#line 1449 "sparql_parser.c" /* yacc.c:1646  */
+#line 1459 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
   case 22:
-#line 190 "sparql_parser.y" /* yacc.c:1646  */
+#line 191 "sparql_parser.y" /* yacc.c:1646  */
     {(yyval.tval) = atoi((yyvsp[0].sval)) + SPRAW_TIME_OFFSET;}
-#line 1455 "sparql_parser.c" /* yacc.c:1646  */
+#line 1465 "sparql_parser.c" /* yacc.c:1646  */
     break;
 
 
-#line 1459 "sparql_parser.c" /* yacc.c:1646  */
+#line 1469 "sparql_parser.c" /* yacc.c:1646  */
       default: break;
     }
   /* User semantic actions sometimes alter yychar, and that requires
@@ -1681,7 +1693,7 @@ yyreturn:
 #endif
   return yyresult;
 }
-#line 193 "sparql_parser.y" /* yacc.c:1906  */
+#line 194 "sparql_parser.y" /* yacc.c:1906  */
 
 
 static time_t isodate2unix(const char *s)
@@ -1922,12 +1934,12 @@ static const char *map_expr(const char *attr, char op, const char *val)
 	return sparql;
 }
 
-void yyerror(const char *str)
+void mdsyyerror(const char *str)
 {
-	DEBUG(1, ("yyerror: %s\n", str));
+	DEBUG(1, ("mdsyyerror: %s\n", str));
 }
 
-int yywrap(void)
+int mdsyywrap(void)
 {
 	return 1;
 }
@@ -1943,15 +1955,15 @@ bool map_spotlight_to_sparql_query(struct sl_query *slq)
 	};
 	int result;
 
-	s.s = yy_scan_string(slq->query_string);
+	s.s = mdsyy_scan_string(slq->query_string);
 	if (s.s == NULL) {
 		TALLOC_FREE(s.frame);
 		return false;
 	}
 	global_sparql_parser_state = &s;
-	result = yyparse();
+	result = mdsyyparse();
 	global_sparql_parser_state = NULL;
-	yy_delete_buffer(s.s);
+	mdsyy_delete_buffer(s.s);
 
 	if (result != 0) {
 		TALLOC_FREE(s.frame);
diff --git a/source3/rpc_server/mdssvc/sparql_parser.h b/source3/rpc_server/mdssvc/sparql_parser.h
index 943ad9a..7fdc5dc 100644
--- a/source3/rpc_server/mdssvc/sparql_parser.h
+++ b/source3/rpc_server/mdssvc/sparql_parser.h
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.2.  */
+/* A Bison parser, made by GNU Bison 3.0.4.  */
 
 /* Bison interface for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -30,14 +30,14 @@
    This special exception was added by the Free Software Foundation in
    version 2.2 of Bison.  */
 
-#ifndef YY_YY_SPARQL_PARSER_H_INCLUDED
-# define YY_YY_SPARQL_PARSER_H_INCLUDED
+#ifndef YY_MDSYY_SPARQL_PARSER_H_INCLUDED
+# define YY_MDSYY_SPARQL_PARSER_H_INCLUDED
 /* Debug traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG 0
 #endif
 #if YYDEBUG
-extern int yydebug;
+extern int mdsyydebug;
 #endif
 
 /* Token type.  */
@@ -64,7 +64,7 @@ extern int yydebug;
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE YYSTYPE;
+
 union YYSTYPE
 {
 #line 61 "sparql_parser.y" /* yacc.c:1909  */
@@ -76,23 +76,25 @@ union YYSTYPE
 
 #line 78 "sparql_parser.h" /* yacc.c:1909  */
 };
+
+typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif
 
 
-extern YYSTYPE yylval;
+extern YYSTYPE mdsyylval;
 
-int yyparse (void);
+int mdsyyparse (void);
 /* "%code provides" blocks.  */
 #line 53 "sparql_parser.y" /* yacc.c:1909  */
 
 	#include <stdbool.h>
 	#include "mdssvc.h"
 	#define SPRAW_TIME_OFFSET 978307200
-	extern int yywrap(void);
+	extern int mdsyywrap(void);
 	extern bool map_spotlight_to_sparql_query(struct sl_query *slq);
 
-#line 97 "sparql_parser.h" /* yacc.c:1909  */
+#line 99 "sparql_parser.h" /* yacc.c:1909  */
 
-#endif /* !YY_YY_SPARQL_PARSER_H_INCLUDED  */
+#endif /* !YY_MDSYY_SPARQL_PARSER_H_INCLUDED  */
diff --git a/source3/rpc_server/mdssvc/sparql_parser.y b/source3/rpc_server/mdssvc/sparql_parser.y
index 7a151dc..4c5d500 100644
--- a/source3/rpc_server/mdssvc/sparql_parser.y
+++ b/source3/rpc_server/mdssvc/sparql_parser.y
@@ -29,11 +29,11 @@
 
 	struct yy_buffer_state;
 	typedef struct yy_buffer_state *YY_BUFFER_STATE;
-	extern int yylex (void);
-	extern void yyerror (char const *);
-	extern void *yyterminate(void);
-	extern YY_BUFFER_STATE yy_scan_string( const char *str);
-	extern void yy_delete_buffer ( YY_BUFFER_STATE buffer );
+	extern int mdsyylex (void);
+	extern void mdsyyerror (char const *);
+	extern void *mdsyyterminate(void);
+	extern YY_BUFFER_STATE mdsyy_scan_string( const char *str);
+	extern void mdsyy_delete_buffer ( YY_BUFFER_STATE buffer );
 
 	/* forward declarations */
 	static const char *map_expr(const char *attr, char op, const char *val);
@@ -54,7 +54,7 @@
 	#include <stdbool.h>
 	#include "mdssvc.h"
 	#define SPRAW_TIME_OFFSET 978307200
-	extern int yywrap(void);
+	extern int mdsyywrap(void);
 	extern bool map_spotlight_to_sparql_query(struct sl_query *slq);
 }
 
@@ -65,6 +65,7 @@
 	time_t tval;
 }
 
+%name-prefix "mdsyy"
 %expect 5
 %error-verbose
 
@@ -430,12 +431,12 @@ static const char *map_expr(const char *attr, char op, const char *val)
 	return sparql;
 }
 
-void yyerror(const char *str)
+void mdsyyerror(const char *str)
 {
-	DEBUG(1, ("yyerror: %s\n", str));
+	DEBUG(1, ("mdsyyerror: %s\n", str));
 }
 
-int yywrap(void)
+int mdsyywrap(void)
 {
 	return 1;
 }
@@ -451,15 +452,15 @@ bool map_spotlight_to_sparql_query(struct sl_query *slq)
 	};
 	int result;
 
-	s.s = yy_scan_string(slq->query_string);
+	s.s = mdsyy_scan_string(slq->query_string);
 	if (s.s == NULL) {
 		TALLOC_FREE(s.frame);
 		return false;
 	}
 	global_sparql_parser_state = &s;
-	result = yyparse();
+	result = mdsyyparse();
 	global_sparql_parser_state = NULL;
-	yy_delete_buffer(s.s);
+	mdsyy_delete_buffer(s.s);
 
 	if (result != 0) {
 		TALLOC_FREE(s.frame);
-- 
2.7.4



More information about the samba-technical mailing list