From: Ralph Boehme Date: Thu, 19 Jan 2017 06:39:37 +0000 (+0100) Subject: s3/rpc_server/mdssvc: use flex noyyalloc noyyrealloc X-Git-Tag: talloc-2.1.9~359 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7933c2a60fed8b18e88957cfc267990d8d7f0041;p=thirdparty%2Fsamba.git 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 Reviewed-by: David Disseldorp --- diff --git a/source3/rpc_server/mdssvc/Makefile b/source3/rpc_server/mdssvc/Makefile index 3b0983f8e67..3de4a4679ef 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 34bc0ca95b3..4c76f45bada 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 cbcd358d3f0..01c896f9d4f 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]