diff --git a/dbcon/ddlpackage/ddl-scan.cpp b/dbcon/ddlpackage/ddl-scan.cpp index e31ad509e..0633e72f8 100644 --- a/dbcon/ddlpackage/ddl-scan.cpp +++ b/dbcon/ddlpackage/ddl-scan.cpp @@ -5,29 +5,10 @@ /* A lexical scanner generated by flex */ -#define yy_create_buffer ddl_create_buffer -#define yy_delete_buffer ddl_delete_buffer -#define yy_flex_debug ddl_flex_debug -#define yy_init_buffer ddl_init_buffer -#define yy_flush_buffer ddl_flush_buffer -#define yy_load_buffer_state ddl_load_buffer_state -#define yy_switch_to_buffer ddl_switch_to_buffer -#define yyin ddlin -#define yyleng ddlleng -#define yylex ddllex -#define yylineno ddllineno -#define yyout ddlout -#define yyrestart ddlrestart -#define yytext ddltext -#define yywrap ddlwrap -#define yyalloc ddlalloc -#define yyrealloc ddlrealloc -#define yyfree ddlfree - #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -72,6 +53,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -102,8 +84,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -137,24 +117,41 @@ typedef unsigned int flex_uint32_t; */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ -#define BEGIN (yy_start) = 1 + 2 * +#define BEGIN yyg->yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ -#define YY_START (((yy_start) - 1) / 2) +#define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE ddlrestart(ddlin ) +#define YY_NEW_FILE ddlrestart(yyin ,yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 @@ -172,15 +169,6 @@ typedef unsigned int flex_uint32_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern yy_size_t ddlleng; - -extern FILE *ddlin, *ddlout; - #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 @@ -191,17 +179,22 @@ extern FILE *ddlin, *ddlout; #define yyless(n) \ do \ { \ - /* Undo effects of setting up ddltext. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ + *yy_cp = yyg->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 ddltext again */ \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) -#define unput(c) yyunput( c, (yytext_ptr) ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE @@ -220,7 +213,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - yy_size_t yy_n_chars; + int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -261,78 +254,58 @@ struct yy_buffer_state * * When we actually see the EOF, we change the status to "new" * (via ddlrestart()), so that the user can continue scanning by - * just pointing ddlin at a new input file. + * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] -/* yy_hold_char holds the character lost when ddltext 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 ddlleng; +void ddlrestart (FILE *input_file ,yyscan_t yyscanner ); +void ddl_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE ddl_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void ddl_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void ddl_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void ddlpush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void ddlpop_buffer_state (yyscan_t yyscanner ); -/* 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 */ +static void ddlensure_buffer_stack (yyscan_t yyscanner ); +static void ddl_load_buffer_state (yyscan_t yyscanner ); +static void ddl_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); -/* Flag which is used to allow ddlwrap()'s to do buffer switches - * instead of setting up a fresh ddlin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; +#define YY_FLUSH_BUFFER ddl_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) -void ddlrestart (FILE *input_file ); -void ddl_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE ddl_create_buffer (FILE *file,int size ); -void ddl_delete_buffer (YY_BUFFER_STATE b ); -void ddl_flush_buffer (YY_BUFFER_STATE b ); -void ddlpush_buffer_state (YY_BUFFER_STATE new_buffer ); -void ddlpop_buffer_state (void ); +YY_BUFFER_STATE ddl_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE ddl_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE ddl_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); -static void ddlensure_buffer_stack (void ); -static void ddl_load_buffer_state (void ); -static void ddl_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER ddl_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE ddl_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE ddl_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE ddl_scan_bytes (yyconst char *bytes,yy_size_t len ); - -void *ddlalloc (yy_size_t ); -void *ddlrealloc (void *,yy_size_t ); -void ddlfree (void * ); +void *ddlalloc (yy_size_t ,yyscan_t yyscanner ); +void *ddlrealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void ddlfree (void * ,yyscan_t yyscanner ); #define yy_new_buffer ddl_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - ddlensure_buffer_stack (); \ + ddlensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - ddl_create_buffer(ddlin,YY_BUF_SIZE ); \ + ddl_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } @@ -340,9 +313,9 @@ void ddlfree (void * ); #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - ddlensure_buffer_stack (); \ + ddlensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - ddl_create_buffer(ddlin,YY_BUF_SIZE ); \ + ddl_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } @@ -351,36 +324,29 @@ void ddlfree (void * ); /* Begin user sect3 */ -#define ddlwrap() 1 +#define ddlwrap(n) 1 #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; -FILE *ddlin = (FILE *) 0, *ddlout = (FILE *) 0; - typedef int yy_state_type; -extern int ddllineno; +#define yytext_ptr yytext_r -int ddllineno = 1; - -extern char *ddltext; -#define yytext_ptr ddltext - -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 ); -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); /* Done after the current pattern has been matched and before the - * corresponding action - sets up ddltext. + * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - ddlleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; + yyg->yy_c_buf_p = yy_cp; #define YY_NUM_RULES 85 #define YY_END_OF_BUFFER 86 @@ -778,12 +744,6 @@ static yyconst flex_int16_t yy_chk[879] = 392, 392, 392, 392, 392, 392, 392, 392 } ; -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int ddl_flex_debug; -int ddl_flex_debug = 0; - /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ @@ -791,7 +751,6 @@ int ddl_flex_debug = 0; #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -char *ddltext; /* Copyright (C) 2014 InfiniDB, Inc. This program is free software; you can redistribute it and/or @@ -821,13 +780,9 @@ char *ddltext; #endif int lineno = 1; -void ddlerror(char *s); +void ddlerror(yyscan_t yyscanner, char *s); -/* Handles to the buffer that the lexer uses internally */ -static YY_BUFFER_STATE scanbufhandle; -static char *scanbuf; - -static char* scanner_copy (char *str); +static char* scanner_copy(char *str, yyscan_t yyscanner); /* %option header-file="ddl-scan.h" */ @@ -849,36 +804,84 @@ static char* scanner_copy (char *str); #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals (void ); +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals (yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int ddllex_init (yyscan_t* scanner); + +int ddllex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int ddllex_destroy (void ); +int ddllex_destroy (yyscan_t yyscanner ); -int ddlget_debug (void ); +int ddlget_debug (yyscan_t yyscanner ); -void ddlset_debug (int debug_flag ); +void ddlset_debug (int debug_flag ,yyscan_t yyscanner ); -YY_EXTRA_TYPE ddlget_extra (void ); +YY_EXTRA_TYPE ddlget_extra (yyscan_t yyscanner ); -void ddlset_extra (YY_EXTRA_TYPE user_defined ); +void ddlset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); -FILE *ddlget_in (void ); +FILE *ddlget_in (yyscan_t yyscanner ); -void ddlset_in (FILE * in_str ); +void ddlset_in (FILE * in_str ,yyscan_t yyscanner ); -FILE *ddlget_out (void ); +FILE *ddlget_out (yyscan_t yyscanner ); -void ddlset_out (FILE * out_str ); +void ddlset_out (FILE * out_str ,yyscan_t yyscanner ); -yy_size_t ddlget_leng (void ); +int ddlget_leng (yyscan_t yyscanner ); -char *ddlget_text (void ); +char *ddlget_text (yyscan_t yyscanner ); -int ddlget_lineno (void ); +int ddlget_lineno (yyscan_t yyscanner ); -void ddlset_lineno (int line_number ); +void ddlset_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * ddlget_lval (yyscan_t yyscanner ); + +void ddlset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -886,26 +889,26 @@ void ddlset_lineno (int line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int ddlwrap (void ); +extern "C" int ddlwrap (yyscan_t yyscanner ); #else -extern int ddlwrap (void ); +extern int ddlwrap (yyscan_t yyscanner ); #endif #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus -static int yyinput (void ); +static int yyinput (yyscan_t yyscanner ); #else -static int input (void ); +static int input (yyscan_t yyscanner ); #endif #endif @@ -920,7 +923,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( ddltext, ddlleng, 1, ddlout )) {} } while (0) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -931,20 +934,20 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + unsigned n; \ for ( n = 0; n < max_size && \ - (c = getc( ddlin )) != EOF && c != '\n'; ++n ) \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ - if ( c == EOF && ferror( ddlin ) ) \ + if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, ddlin))==0 && ferror(ddlin)) \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -952,7 +955,7 @@ static int input (void ); break; \ } \ errno=0; \ - clearerr(ddlin); \ + clearerr(yyin); \ } \ }\ \ @@ -974,7 +977,7 @@ static int input (void ); /* Report a fatal error. */ #ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) #endif /* end tables serialization structures and prototypes */ @@ -985,12 +988,14 @@ static int input (void ); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int ddllex (void); +extern int ddllex \ + (YYSTYPE * yylval_param ,yyscan_t yyscanner); -#define YY_DECL int ddllex (void) +#define YY_DECL int ddllex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) #endif /* !YY_DECL */ -/* Code executed at the beginning of each rule, after ddltext and ddlleng +/* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION @@ -1012,54 +1017,57 @@ YY_DECL register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; - - if ( !(yy_init) ) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) { - (yy_init) = 1; + yyg->yy_init = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ - if ( ! ddlin ) - ddlin = stdin; + if ( ! yyin ) + yyin = stdin; - if ( ! ddlout ) - ddlout = stdout; + if ( ! yyout ) + yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { - ddlensure_buffer_stack (); + ddlensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - ddl_create_buffer(ddlin,YY_BUF_SIZE ); + ddl_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } - ddl_load_buffer_state( ); + ddl_load_buffer_state(yyscanner ); } while ( 1 ) /* loops until end-of-file is reached */ { - yy_cp = (yy_c_buf_p); + yy_cp = yyg->yy_c_buf_p; - /* Support of ddltext. */ - *yy_cp = (yy_hold_char); + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; - yy_current_state = (yy_start); + yy_current_state = yyg->yy_start; yy_match: do { register 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; - (yy_last_accepting_cpos) = yy_cp; + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1076,8 +1084,8 @@ yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } @@ -1089,9 +1097,9 @@ do_action: /* This label is used only to access EOF actions. */ { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; case 1: @@ -1136,11 +1144,11 @@ YY_RULE_SETUP YY_BREAK case 11: /* rule 11 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up ddltext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up ddltext again */ +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -{BEGIN(check1); ddllval.str = scanner_copy(ddltext); return CP_SEARCH_CONDITION_TEXT;} +{BEGIN(check1); ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return CP_SEARCH_CONDITION_TEXT;} YY_BREAK case 12: YY_RULE_SETUP @@ -1148,31 +1156,31 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -{BEGIN(inquote);return ddltext[0];} +{BEGIN(inquote);return yytext[0];} YY_BREAK case 14: /* rule 14 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up ddltext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up ddltext again */ +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -{BEGIN(endquote); ddllval.str = scanner_copy(ddltext); return SCONST;} +{BEGIN(endquote); ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return SCONST;} YY_BREAK case 15: YY_RULE_SETUP -{BEGIN(0); return ddltext[0];} +{BEGIN(0); return yytext[0];} YY_BREAK case 16: YY_RULE_SETUP -{ddllval.str = scanner_copy(ddltext); return ICONST;} +{ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return ICONST;} YY_BREAK case 17: YY_RULE_SETUP -{ddllval.str = scanner_copy(ddltext); return FCONST;} +{ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return FCONST;} YY_BREAK case 18: YY_RULE_SETUP -{ddllval.str = scanner_copy(ddltext); return FCONST;} +{ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return FCONST;} YY_BREAK case 19: YY_RULE_SETUP @@ -1204,7 +1212,7 @@ YY_RULE_SETUP YY_BREAK case 26: YY_RULE_SETUP -{ddllval.str=strdup("date"); return DATE;} +{ddlget_lval(yyscanner)->str=strdup("date"); return DATE;} YY_BREAK case 27: YY_RULE_SETUP @@ -1432,12 +1440,12 @@ YY_RULE_SETUP YY_BREAK case 82: YY_RULE_SETUP -{ddllval.str = scanner_copy(ddltext); return IDENT;} +{ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return IDENT;} YY_BREAK case 83: YY_RULE_SETUP { - return ddltext[0]; + return ddlget_text(yyscanner)[0]; } YY_BREAK case 84: @@ -1460,25 +1468,25 @@ case YY_STATE_EOF(endquote): case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); + *yy_cp = yyg->yy_hold_char; YY_RESTORE_YY_MORE_OFFSET if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user - * just pointed ddlin at a new source and called + * just pointed yyin at a new source and called * ddllex(). 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 = ddlin; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } @@ -1489,13 +1497,13 @@ case YY_STATE_EOF(endquote): * end-of-buffer state). Contrast this with the test * in input(). */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state( yyscanner ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have @@ -1506,43 +1514,43 @@ case YY_STATE_EOF(endquote): * will run more slowly). */ - yy_next_state = yy_try_NUL_trans( yy_current_state ); + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); + yy_cp = ++yyg->yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { - yy_cp = (yy_c_buf_p); + yy_cp = yyg->yy_c_buf_p; goto yy_find_action; } } - else switch ( yy_get_next_buffer( ) ) + else switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_END_OF_FILE: { - (yy_did_buffer_switch_on_eof) = 0; + yyg->yy_did_buffer_switch_on_eof = 0; - if ( ddlwrap( ) ) + if ( ddlwrap(yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up - * ddltext, we can now set up + * yytext, 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 * YY_NULL, it'll still work - another * YY_NULL will get returned. */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; @@ -1550,30 +1558,30 @@ case YY_STATE_EOF(endquote): else { - if ( ! (yy_did_buffer_switch_on_eof) ) + if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state( yyscanner ); - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state( yyscanner ); - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; @@ -1593,20 +1601,21 @@ case YY_STATE_EOF(endquote): * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -static int yy_get_next_buffer (void) +static int yy_get_next_buffer (yyscan_t yyscanner) { - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; register int number_to_move, i; int ret_val; - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. @@ -1626,7 +1635,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 = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1635,25 +1644,25 @@ static int yy_get_next_buffer (void) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; 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 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1662,7 +1671,7 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - ddlrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + ddlrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); } else /* Can't grow it, we don't own it. */ @@ -1672,7 +1681,7 @@ static int yy_get_next_buffer (void) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; @@ -1684,17 +1693,17 @@ static int yy_get_next_buffer (void) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); + yyg->yy_n_chars, (size_t) num_to_read ); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } - if ( (yy_n_chars) == 0 ) + if ( yyg->yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - ddlrestart(ddlin ); + ddlrestart(yyin ,yyscanner); } else @@ -1708,39 +1717,40 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((yy_size_t) (yyg->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 *) ddlrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ddlrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ - static yy_state_type yy_get_previous_state (void) + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { register yy_state_type yy_current_state; register char *yy_cp; - - yy_current_state = (yy_start); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { register 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; - (yy_last_accepting_cpos) = yy_cp; + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1759,16 +1769,17 @@ static int yy_get_next_buffer (void) * synopsis * next_state = yy_try_NUL_trans( current_state ); */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + register char *yy_cp = yyg->yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1779,37 +1790,38 @@ static int yy_get_next_buffer (void) yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 392); - return yy_is_jam ? 0 : yy_current_state; + return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_INPUT #ifdef __cplusplus - static int yyinput (void) + static int yyinput (yyscan_t yyscanner) #else - static int input (void) + static int input (yyscan_t yyscanner) #endif { int c; - - *(yy_c_buf_p) = (yy_hold_char); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; + *yyg->yy_c_buf_p = '\0'; else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); + int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; - switch ( yy_get_next_buffer( ) ) + switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() @@ -1823,34 +1835,34 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - ddlrestart(ddlin ); + ddlrestart(yyin ,yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( ddlwrap( ) ) + if ( ddlwrap(yyscanner ) ) return EOF; - if ( ! (yy_did_buffer_switch_on_eof) ) + if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus - return yyinput(); + return yyinput(yyscanner); #else - return input(); + return input(yyscanner); #endif } case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; break; } } } - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve ddltext */ - (yy_hold_char) = *++(yy_c_buf_p); + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; return c; } @@ -1858,76 +1870,79 @@ static int yy_get_next_buffer (void) /** Immediately switch to a different input stream. * @param input_file A readable stream. - * + * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ - void ddlrestart (FILE * input_file ) + void ddlrestart (FILE * input_file , yyscan_t yyscanner) { - + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! YY_CURRENT_BUFFER ){ - ddlensure_buffer_stack (); + ddlensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - ddl_create_buffer(ddlin,YY_BUF_SIZE ); + ddl_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } - ddl_init_buffer(YY_CURRENT_BUFFER,input_file ); - ddl_load_buffer_state( ); + ddl_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + ddl_load_buffer_state(yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. - * + * @param yyscanner The scanner object. */ - void ddl_switch_to_buffer (YY_BUFFER_STATE new_buffer ) + void ddl_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { - + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* TODO. We should be able to replace this entire function body * with * ddlpop_buffer_state(); * ddlpush_buffer_state(new_buffer); */ - ddlensure_buffer_stack (); + ddlensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } YY_CURRENT_BUFFER_LVALUE = new_buffer; - ddl_load_buffer_state( ); + ddl_load_buffer_state(yyscanner ); /* We don't actually know whether we did this switch during * EOF (ddlwrap()) processing, but the only time this flag * is looked at is after ddlwrap() is called, so it's safe * to go ahead and always set it. */ - (yy_did_buffer_switch_on_eof) = 1; + yyg->yy_did_buffer_switch_on_eof = 1; } -static void ddl_load_buffer_state (void) +static void ddl_load_buffer_state (yyscan_t yyscanner) { - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - ddlin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * + * @param yyscanner The scanner object. * @return the allocated buffer state. */ - YY_BUFFER_STATE ddl_create_buffer (FILE * file, int size ) + YY_BUFFER_STATE ddl_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) ddlalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) ddlalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in ddl_create_buffer()" ); @@ -1936,24 +1951,25 @@ static void ddl_load_buffer_state (void) /* 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 *) ddlalloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) ddlalloc(b->yy_buf_size + 2 ,yyscanner ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in ddl_create_buffer()" ); b->yy_is_our_buffer = 1; - ddl_init_buffer(b,file ); + ddl_init_buffer(b,file ,yyscanner); return b; } /** Destroy the buffer. * @param b a buffer created with ddl_create_buffer() - * + * @param yyscanner The scanner object. */ - void ddl_delete_buffer (YY_BUFFER_STATE b ) + void ddl_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { - + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) return; @@ -1961,21 +1977,26 @@ static void ddl_load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - ddlfree((void *) b->yy_ch_buf ); + ddlfree((void *) b->yy_ch_buf ,yyscanner ); - ddlfree((void *) b ); + ddlfree((void *) b ,yyscanner ); } +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a ddlrestart() or at EOF. */ - static void ddl_init_buffer (YY_BUFFER_STATE b, FILE * file ) + static void ddl_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; - - ddl_flush_buffer(b ); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + ddl_flush_buffer(b ,yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; @@ -1996,11 +2017,12 @@ static void ddl_load_buffer_state (void) /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * + * @param yyscanner The scanner object. */ - void ddl_flush_buffer (YY_BUFFER_STATE b ) + void ddl_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { - if ( ! b ) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) return; b->yy_n_chars = 0; @@ -2018,114 +2040,117 @@ static void ddl_load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - ddl_load_buffer_state( ); + ddl_load_buffer_state(yyscanner ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. - * + * @param yyscanner The scanner object. */ -void ddlpush_buffer_state (YY_BUFFER_STATE new_buffer ) +void ddlpush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { - if (new_buffer == NULL) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) return; - ddlensure_buffer_stack(); + ddlensure_buffer_stack(yyscanner); /* This block is copied from ddl_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; + yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from ddl_switch_to_buffer. */ - ddl_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; + ddl_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. - * + * @param yyscanner The scanner object. */ -void ddlpop_buffer_state (void) +void ddlpop_buffer_state (yyscan_t yyscanner) { - if (!YY_CURRENT_BUFFER) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) return; - ddl_delete_buffer(YY_CURRENT_BUFFER ); + ddl_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { - ddl_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; + ddl_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void ddlensure_buffer_stack (void) +static void ddlensure_buffer_stack (yyscan_t yyscanner) { - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) { + int num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { /* 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 realloc on the next call. */ num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)ddlalloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)ddlalloc (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in ddlensure_buffer_stack()" ); - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; return; } - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)ddlrealloc - ((yy_buffer_stack), + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)ddlrealloc + (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in ddlensure_buffer_stack()" ); /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; } } /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer - * + * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE ddl_scan_buffer (char * base, yy_size_t size ) +YY_BUFFER_STATE ddl_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; @@ -2135,7 +2160,7 @@ YY_BUFFER_STATE ddl_scan_buffer (char * base, yy_size_t size ) /* They forgot to leave room for the EOB's. */ return 0; - b = (YY_BUFFER_STATE) ddlalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) ddlalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in ddl_scan_buffer()" ); @@ -2149,7 +2174,7 @@ YY_BUFFER_STATE ddl_scan_buffer (char * base, yy_size_t size ) b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - ddl_switch_to_buffer(b ); + ddl_switch_to_buffer(b ,yyscanner ); return b; } @@ -2157,25 +2182,25 @@ YY_BUFFER_STATE ddl_scan_buffer (char * base, yy_size_t size ) /** Setup the input buffer state to scan a string. The next call to ddllex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan - * + * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * ddl_scan_bytes() instead. */ -YY_BUFFER_STATE ddl_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE ddl_scan_string (yyconst char * yystr , yyscan_t yyscanner) { - return ddl_scan_bytes(yystr,strlen(yystr) ); + return ddl_scan_bytes(yystr,strlen(yystr) ,yyscanner); } /** Setup the input buffer state to scan the given bytes. The next call to ddllex() 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. - * + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE ddl_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +YY_BUFFER_STATE ddl_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; @@ -2184,7 +2209,7 @@ YY_BUFFER_STATE ddl_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 *) ddlalloc(n ); + buf = (char *) ddlalloc(n ,yyscanner ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in ddl_scan_bytes()" ); @@ -2193,7 +2218,7 @@ YY_BUFFER_STATE ddl_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = ddl_scan_buffer(buf,n ); + b = ddl_scan_buffer(buf,n ,yyscanner); if ( ! b ) YY_FATAL_ERROR( "bad buffer in ddl_scan_bytes()" ); @@ -2209,7 +2234,7 @@ YY_BUFFER_STATE ddl_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg ) +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); @@ -2221,117 +2246,264 @@ static void yy_fatal_error (yyconst char* msg ) #define yyless(n) \ do \ { \ - /* Undo effects of setting up ddltext. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - ddltext[ddlleng] = (yy_hold_char); \ - (yy_c_buf_p) = ddltext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - ddlleng = yyless_macro_arg; \ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ -/** Get the current line number. - * +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. */ -int ddlget_lineno (void) +YY_EXTRA_TYPE ddlget_extra (yyscan_t yyscanner) { - - return ddllineno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int ddlget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int ddlget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; } /** Get the input stream. - * + * @param yyscanner The scanner object. */ -FILE *ddlget_in (void) +FILE *ddlget_in (yyscan_t yyscanner) { - return ddlin; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; } /** Get the output stream. - * + * @param yyscanner The scanner object. */ -FILE *ddlget_out (void) +FILE *ddlget_out (yyscan_t yyscanner) { - return ddlout; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; } /** Get the length of the current token. - * + * @param yyscanner The scanner object. */ -yy_size_t ddlget_leng (void) +int ddlget_leng (yyscan_t yyscanner) { - return ddlleng; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; } /** Get the current token. - * + * @param yyscanner The scanner object. */ -char *ddlget_text (void) +char *ddlget_text (yyscan_t yyscanner) { - return ddltext; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void ddlset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; } /** Set the current line number. * @param line_number - * + * @param yyscanner The scanner object. */ -void ddlset_lineno (int line_number ) +void ddlset_lineno (int line_number , yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "ddlset_lineno called with no buffer" , yyscanner); - ddllineno = line_number; + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void ddlset_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "ddlset_column called with no buffer" , yyscanner); + + yycolumn = column_no; } /** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. - * + * @param yyscanner The scanner object. * @see ddl_switch_to_buffer */ -void ddlset_in (FILE * in_str ) +void ddlset_in (FILE * in_str , yyscan_t yyscanner) { - ddlin = in_str ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; } -void ddlset_out (FILE * out_str ) +void ddlset_out (FILE * out_str , yyscan_t yyscanner) { - ddlout = out_str ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; } -int ddlget_debug (void) +int ddlget_debug (yyscan_t yyscanner) { - return ddl_flex_debug; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; } -void ddlset_debug (int bdebug ) +void ddlset_debug (int bdebug , yyscan_t yyscanner) { - ddl_flex_debug = bdebug ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; } -static int yy_init_globals (void) +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * ddlget_lval (yyscan_t yyscanner) { - /* Initialization is the same as for the non-reentrant scanner. + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void ddlset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* ddllex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int ddllex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) ddlalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* ddllex_init_extra has the same functionality as ddllex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to ddlalloc in + * the yyextra field. + */ + +int ddllex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + ddlset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) ddlalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + ddlset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. * This function is called from ddllex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; /* Defined in main.c */ #ifdef YY_STDINIT - ddlin = stdin; - ddlout = stdout; + yyin = stdin; + yyout = stdout; #else - ddlin = (FILE *) 0; - ddlout = (FILE *) 0; + yyin = (FILE *) 0; + yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by @@ -2341,24 +2513,32 @@ static int yy_init_globals (void) } /* ddllex_destroy is for both reentrant and non-reentrant scanners. */ -int ddllex_destroy (void) +int ddllex_destroy (yyscan_t yyscanner) { - + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - ddl_delete_buffer(YY_CURRENT_BUFFER ); + ddl_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; - ddlpop_buffer_state(); + ddlpop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - ddlfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; + ddlfree(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + ddlfree(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time * ddllex() is called, initialization will occur. */ - yy_init_globals( ); + yy_init_globals( yyscanner); + /* Destroy the main struct (reentrant only). */ + ddlfree ( yyscanner , yyscanner ); + yyscanner = NULL; return 0; } @@ -2367,7 +2547,7 @@ int ddllex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) { register int i; for ( i = 0; i < n; ++i ) @@ -2376,7 +2556,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) { register int n; for ( n = 0; s[n]; ++n ) @@ -2386,12 +2566,12 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *ddlalloc (yy_size_t size ) +void *ddlalloc (yy_size_t size , yyscan_t yyscanner) { return (void *) malloc( size ); } -void *ddlrealloc (void * ptr, yy_size_t size ) +void *ddlrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those @@ -2403,74 +2583,80 @@ void *ddlrealloc (void * ptr, yy_size_t size ) return (void *) realloc( (char *) ptr, size ); } -void ddlfree (void * ptr ) +void ddlfree (void * ptr , yyscan_t yyscanner) { free( (char *) ptr ); /* see ddlrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" -void ddlerror(char const *s) +void ddlerror(yyscan_t yyscanner, char const *s) { - printf("yyerror: %d: %s at %s\n", lineno, s, ddltext); + printf("yyerror: %d: %s at %s\n", lineno, s, ddlget_text(yyscanner)); } typedef std::vector valbuf_t; -static valbuf_t valbuf; +#include +#include "sqlparser.h" +using namespace ddlpackage; /* * Called before any actual parsing is done */ -void scanner_init(const char *str) +void scanner_init(const char* str, yyscan_t yyscanner) { size_t slen = strlen(str); + scan_data* pScanData = (scan_data*)ddlget_extra(yyscanner); /* * Might be left over after ereport() */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; // needed for macro YY_CURRENT_BUFFER if (YY_CURRENT_BUFFER) - ddl_delete_buffer(YY_CURRENT_BUFFER); + ddl_delete_buffer(YY_CURRENT_BUFFER,yyscanner); /* * Make a scan buffer with special termination needed by flex. */ - scanbuf = (char *)malloc(slen + 2); - memcpy(scanbuf, str, slen); - scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; - scanbufhandle = ddl_scan_buffer(scanbuf,slen + 2); + pScanData->scanbuf = (char *)malloc(slen + 2); + memcpy(pScanData->scanbuf, str, slen); + pScanData->scanbuf[slen] = pScanData->scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; + pScanData->scanbufhandle = (void*)ddl_scan_buffer(pScanData->scanbuf,slen + 2,yyscanner); + std::cout << "scanner_init " << (uint64_t)pScanData->scanbufhandle << std::endl; BEGIN(INITIAL); - valbuf.clear(); + pScanData->valbuf.clear(); } /* * Called after parsing is done to clean up after scanner_init() */ -void scanner_finish(void) +void scanner_finish(yyscan_t yyscanner) { - char* str; - - ddl_delete_buffer(scanbufhandle); - free(scanbuf); + char* str; + scan_data* pScanData = (scan_data*)ddlget_extra(yyscanner); + std::cout << "scanner_finish " << (uint64_t)pScanData->scanbufhandle << std::endl; + ddl_delete_buffer((YY_BUFFER_STATE)pScanData->scanbufhandle,yyscanner); + free(pScanData->scanbuf); unsigned int i; - for(i=0; ivalbuf.size(); i++) { + str = pScanData->valbuf[i]; + if(str) { // std::cout << "valbuf:(" << str << ")" << std::endl; - free(valbuf[i]); - } + free(pScanData->valbuf[i]); + } } - valbuf.clear(); + pScanData->valbuf.clear(); } -char* scanner_copy (char *str) +char* scanner_copy (char *str, yyscan_t yyscanner) { - char* nv = strdup(str); - if(nv) - valbuf.push_back(nv); - return nv; + char* nv = strdup(str); + if(nv) + ((scan_data*)ddlget_extra(yyscanner))->valbuf.push_back(nv); + return nv; } diff --git a/dbcon/ddlpackage/ddl.l b/dbcon/ddlpackage/ddl.l index 64218bb39..e21b2184d 100644 --- a/dbcon/ddlpackage/ddl.l +++ b/dbcon/ddlpackage/ddl.l @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -29,16 +30,14 @@ #endif int lineno = 1; -void ddlerror(char *s); +void ddlerror(yyscan_t yyscanner, char *s); -/* Handles to the buffer that the lexer uses internally */ -static YY_BUFFER_STATE scanbufhandle; -static char *scanbuf; - -static char* scanner_copy (char *str); +static char* scanner_copy(char *str, yyscan_t yyscanner); %} +%option reentrant +%option bison-bridge %option noyywrap %option nounput /* %option header-file="ddl-scan.h" */ @@ -83,16 +82,16 @@ CHARACTER {return IDB_CHAR;} BIGINT {return BIGINT;} CHECK {BEGIN(check1);return CHECK;} \( {BEGIN(check2); return '(';} -[^)]*/\) {BEGIN(check1); ddllval.str = scanner_copy(ddltext); return CP_SEARCH_CONDITION_TEXT;} +[^)]*/\) {BEGIN(check1); ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return CP_SEARCH_CONDITION_TEXT;} \) {BEGIN(0); return ')';} {quote} {BEGIN(inquote);return yytext[0];} -[^']*/' {BEGIN(endquote); ddllval.str = scanner_copy(ddltext); return SCONST;} +[^']*/' {BEGIN(endquote); ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return SCONST;} ' {BEGIN(0); return yytext[0];} -{integer} {ddllval.str = scanner_copy(ddltext); return ICONST;} -{decimal} {ddllval.str = scanner_copy(ddltext); return FCONST;} -{real} {ddllval.str = scanner_copy(ddltext); return FCONST;} +{integer} {ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return ICONST;} +{decimal} {ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return FCONST;} +{real} {ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return FCONST;} COMMENT {return COMMENT;} COLUMN {return COLUMN;} @@ -101,7 +100,7 @@ CONSTRAINT {return CONSTRAINT;} CONSTRAINTS {return CONSTRAINTS;} CREATE {return CREATE;} CURRENT_USER {return CURRENT_USER;} -DATE {ddllval.str=strdup("date"); return DATE;} +DATE {ddlget_lval(yyscanner)->str=strdup("date"); return DATE;} DATETIME {return DATETIME;} DECIMAL {return DECIMAL;} DEC {return DECIMAL;} @@ -162,10 +161,10 @@ VARBINARY {return VARBINARY;} /* ignore */ } -{identifier} {ddllval.str = scanner_copy(ddltext); return IDENT;} +{identifier} {ddlget_lval(yyscanner)->str = scanner_copy(ddlget_text(yyscanner), yyscanner); return IDENT;} {self} { - return ddltext[0]; + return ddlget_text(yyscanner)[0]; } {grave_accent} { @@ -174,39 +173,44 @@ VARBINARY {return VARBINARY;} %% -void ddlerror(char const *s) +void ddlerror(yyscan_t yyscanner, char const *s) { - printf("yyerror: %d: %s at %s\n", lineno, s, yytext); + printf("yyerror: %d: %s at %s\n", lineno, s, ddlget_text(yyscanner)); } typedef std::vector valbuf_t; -static valbuf_t valbuf; +#include +#include "sqlparser.h" +using namespace ddlpackage; /* * Called before any actual parsing is done */ -void scanner_init(const char *str) +void scanner_init(const char* str, yyscan_t yyscanner) { size_t slen = strlen(str); + scan_data* pScanData = (scan_data*)ddlget_extra(yyscanner); /* * Might be left over after ereport() */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; // needed for macro YY_CURRENT_BUFFER if (YY_CURRENT_BUFFER) - yy_delete_buffer(YY_CURRENT_BUFFER); + yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner); /* * Make a scan buffer with special termination needed by flex. */ - scanbuf = (char *)malloc(slen + 2); - memcpy(scanbuf, str, slen); - scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; - scanbufhandle = yy_scan_buffer(scanbuf, slen + 2); + pScanData->scanbuf = (char *)malloc(slen + 2); + memcpy(pScanData->scanbuf, str, slen); + pScanData->scanbuf[slen] = pScanData->scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; + pScanData->scanbufhandle = (void*)yy_scan_buffer(pScanData->scanbuf, slen + 2, yyscanner); + std::cout << "scanner_init " << (uint64_t)pScanData->scanbufhandle << std::endl; BEGIN(INITIAL); - valbuf.clear(); + pScanData->valbuf.clear(); } @@ -215,27 +219,28 @@ void scanner_init(const char *str) */ -void scanner_finish(void) +void scanner_finish(yyscan_t yyscanner) { - char* str; - - yy_delete_buffer(scanbufhandle); - free(scanbuf); + char* str; + scan_data* pScanData = (scan_data*)ddlget_extra(yyscanner); + std::cout << "scanner_finish " << (uint64_t)pScanData->scanbufhandle << std::endl; + yy_delete_buffer((YY_BUFFER_STATE)pScanData->scanbufhandle, yyscanner); + free(pScanData->scanbuf); unsigned int i; - for(i=0; ivalbuf.size(); i++) { + str = pScanData->valbuf[i]; + if(str) { // std::cout << "valbuf:(" << str << ")" << std::endl; - free(valbuf[i]); - } + free(pScanData->valbuf[i]); + } } - valbuf.clear(); + pScanData->valbuf.clear(); } -char* scanner_copy (char *str) +char* scanner_copy (char *str, yyscan_t yyscanner) { - char* nv = strdup(str); - if(nv) - valbuf.push_back(nv); - return nv; + char* nv = strdup(str); + if(nv) + ((scan_data*)ddlget_extra(yyscanner))->valbuf.push_back(nv); + return nv; } diff --git a/dbcon/ddlpackage/ddl.y b/dbcon/ddlpackage/ddl.y index 1013f5750..51bf0255a 100644 --- a/dbcon/ddlpackage/ddl.y +++ b/dbcon/ddlpackage/ddl.y @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -43,6 +44,7 @@ a more recent version of flex. At the time of this writing, our development systems have: flex version 2.5.4 + MCOL-66 Modify to be a reentrant parser */ %{ @@ -60,13 +62,15 @@ using namespace ddlpackage; /* The user is expect to pass a ParseTree* to grammar_init */ static ParseTree* parseTree; static std::string db_schema; -int ddllex(); -void ddlerror (char const *error); +int ddllex(YYSTYPE* ddllval, void* yyscanner); +void ddlerror (void* yyscanner, char const *error); char* copy_string(const char *str); %} %expect 15 - +%pure-parser +%lex-param {void * scanner} +%parse-param {void * scanner} %debug /* Bison uses this to generate a C union definition. This is used to diff --git a/dbcon/ddlpackage/sqlparser.cpp b/dbcon/ddlpackage/sqlparser.cpp index bbcd4c069..6b1312ed9 100644 --- a/dbcon/ddlpackage/sqlparser.cpp +++ b/dbcon/ddlpackage/sqlparser.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -34,12 +35,13 @@ #include "ddl-gram.h" #endif -void scanner_finish(void); -void scanner_init(const char *str); +void scanner_finish(void* yyscanner); +void scanner_init(const char *str, void* yyscanner); void grammar_init(ddlpackage::ParseTree *ptree, bool); +int ddllex_init_extra(void* user_defined,void** yyscanner); +int ddllex_destroy(void* yyscanner); +int ddlparse(void* yyscanner); void set_schema(std::string schema); -int ddlparse(); - namespace ddlpackage { using namespace std; @@ -62,9 +64,10 @@ namespace ddlpackage { int SqlParser::Parse(const char* sqltext) { - scanner_init(sqltext); + ddllex_init_extra(&scanData, &scanner); + scanner_init(sqltext, scanner); grammar_init(&fParseTree, fDebug); - fStatus = ddlparse(); + fStatus = ddlparse(scanner); return fStatus; } @@ -86,7 +89,8 @@ namespace ddlpackage { SqlParser::~SqlParser() { - scanner_finish(); // free scanner allocated memory + scanner_finish(scanner); // free scanner allocated memory + ddllex_destroy(scanner); } diff --git a/dbcon/ddlpackage/sqlparser.h b/dbcon/ddlpackage/sqlparser.h index 77e19fde0..0f61ea56b 100644 --- a/dbcon/ddlpackage/sqlparser.h +++ b/dbcon/ddlpackage/sqlparser.h @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -67,6 +68,18 @@ typedef SqlStatementList ParseTree; @endverbatim */ +/* + Instance specific data for use by the scanner. +*/ +typedef std::vector valbuf_t; + +struct scan_data +{ + /* Handles to the buffer that the lexer uses internally */ + char* scanbuf; + void* scanbufhandle; // This is a YY_BUFFER_STATE defined in ddl-scan.cpp + valbuf_t valbuf; +}; class SqlParser { @@ -102,6 +115,8 @@ protected: ParseTree fParseTree; int fStatus; ///< return from yyparse() stored here. bool fDebug; ///< Turn on bison debugging. + void* scanner; // yyscan_t * needed for re-entrant flex scanner + scan_data scanData; }; diff --git a/dbcon/ddlpackageproc/altertableprocessor.cpp b/dbcon/ddlpackageproc/altertableprocessor.cpp index b38d0b24c..e078bc24e 100644 --- a/dbcon/ddlpackageproc/altertableprocessor.cpp +++ b/dbcon/ddlpackageproc/altertableprocessor.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -335,6 +336,8 @@ AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::A if (i >= numTries) //error out { logging::Message::Args args; + string strOp("alter"); + args.add(strOp); args.add(processName); args.add((uint64_t)processID); args.add(sessionId); @@ -644,7 +647,10 @@ void AlterTableProcessor::addColumn (uint32_t sessionID, execplan::CalpontSystem aColumnList.push_back(columnDefPtr); bool alterFlag = true; - if (inTableName.fSchema != CALPONT_SCHEMA) + // MCOL-66 The DBRM can't handle concurrent DDL + boost::mutex::scoped_lock lk(dbrmMutex); + + if (inTableName.fSchema != CALPONT_SCHEMA) { VERBOSE_INFO("Writing meta data to SYSCOL"); //send to WES to process bs.restart(); @@ -1061,6 +1067,10 @@ void AlterTableProcessor::dropColumn (uint32_t sessionID, execplan::CalpontSyste OamCache * oamcache = OamCache::makeOamCache(); boost::shared_ptr > dbRootPMMap = oamcache->getDBRootToPMMap(); pmNum = (*dbRootPMMap)[dbRoot]; + + // MCOL-66 The DBRM can't handle concurrent DDL + boost::mutex::scoped_lock lk(dbrmMutex); + try { fWEClient->write(bytestream, (uint32_t)pmNum); diff --git a/dbcon/ddlpackageproc/createtableprocessor.cpp b/dbcon/ddlpackageproc/createtableprocessor.cpp index 2baf090c7..ba1a780a9 100644 --- a/dbcon/ddlpackageproc/createtableprocessor.cpp +++ b/dbcon/ddlpackageproc/createtableprocessor.cpp @@ -249,7 +249,7 @@ keepGoing: } fStartingColOID = fObjectIDManager.allocOIDs(numColumns+numDictCols+1); //include column, oids,dictionary oids and tableoid #ifdef IDB_DDL_DEBUG -cout << "Create table allocOIDs got the stating oid " << fStartingColOID << endl; +cout << fTxnid.id << " Create table allocOIDs got the starting oid " << fStartingColOID << endl; #endif if (fStartingColOID < 0) { @@ -298,12 +298,14 @@ cout << "Create table allocOIDs got the stating oid " << fStartingColOID << endl boost::shared_ptr bsIn; boost::shared_ptr > dbRootPMMap = oamcache->getDBRootToPMMap(); pmNum = (*dbRootPMMap)[dbRoot]; + // MCOL-66 The DBRM can't handle concurrent DDL + boost::mutex::scoped_lock lk(dbrmMutex); try { - fWEClient->write(bytestream, (unsigned)pmNum); #ifdef IDB_DDL_DEBUG -cout << "create table sending We_SVR_WRITE_SYSTABLE to pm " << pmNum << endl; +cout << fTxnid.id << " create table sending We_SVR_WRITE_SYSTABLE to pm " << pmNum << endl; #endif + fWEClient->write(bytestream, (unsigned)pmNum); while (1) { bsIn.reset(new ByteStream()); @@ -320,7 +322,7 @@ cout << "create table sending We_SVR_WRITE_SYSTABLE to pm " << pmNum << endl; errorMsg.clear(); *bsIn >> errorMsg; #ifdef IDB_DDL_DEBUG -cout << "Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl; +cout << fTxnid.id << "Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl; #endif } break; @@ -330,7 +332,7 @@ cout << "Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl; catch (runtime_error& ex) //write error { #ifdef IDB_DDL_DEBUG -cout << "create table got exception" << ex.what() << endl; +cout << fTxnid.id << " create table got exception" << ex.what() << endl; #endif rc = NETWORK_ERROR; errorMsg = ex.what(); @@ -345,6 +347,9 @@ cout << "create table got unknown exception" << endl; if (rc != 0) { +#ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl; +#endif result.result =(ResultCode) rc; Message::Args args; Message message(9); @@ -403,10 +408,10 @@ cout << "create table got unknown exception" << endl; pmNum = (*dbRootPMMap)[dbRoot]; try { - fWEClient->write(bytestream, (uint32_t)pmNum); #ifdef IDB_DDL_DEBUG -cout << "create table sending We_SVR_WRITE_SYSTABLE to pm " << pmNum << endl; +cout << fTxnid.id << " create table sending WE_SVR_WRITE_CREATE_SYSCOLUMN to pm " << pmNum << endl; #endif + fWEClient->write(bytestream, (uint32_t)pmNum); while (1) { bsIn.reset(new ByteStream()); @@ -423,7 +428,7 @@ cout << "create table sending We_SVR_WRITE_SYSTABLE to pm " << pmNum << endl; errorMsg.clear(); *bsIn >> errorMsg; #ifdef IDB_DDL_DEBUG -cout << "Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl; +cout << fTxnid.id << "Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl; #endif } break; @@ -433,7 +438,7 @@ cout << "Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl; catch (runtime_error& ex) //write error { #ifdef IDB_DDL_DEBUG -cout << "create table got exception" << ex.what() << endl; +cout << fTxnid.id << " create table got exception" << ex.what() << endl; #endif rc = NETWORK_ERROR; errorMsg = ex.what(); @@ -442,12 +447,15 @@ cout << "create table got exception" << ex.what() << endl; { rc = NETWORK_ERROR; #ifdef IDB_DDL_DEBUG -cout << "create table got unknown exception" << endl; +cout << fTxnid.id << " create table got unknown exception" << endl; #endif } if (rc != 0) { +#ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Create table WE_SVR_WRITE_CREATE_SYSCOLUMN: " << errorMsg << endl; +#endif result.result =(ResultCode) rc; Message::Args args; Message message(9); @@ -572,6 +580,9 @@ cout << "create table got unknown exception" << endl; pmNum = (*dbRootPMMap)[useDBRoot]; try { +#ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " create table sending WE_SVR_WRITE_CREATETABLEFILES to pm " << pmNum << endl; +#endif fWEClient->write(bytestream, pmNum); while (1) { @@ -631,6 +642,9 @@ cout << "Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl; if (rc != 0) { +#ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Create table We_SVR_WRITE_CREATETABLEFILES: " << errorMsg << endl; +#endif rollBackTransaction( uniqueId, txnID, createTableStmt.fSessionID); //What to do with the error code fSessionManager.rolledback(txnID); } diff --git a/dbcon/ddlpackageproc/ddlpackageprocessor.cpp b/dbcon/ddlpackageproc/ddlpackageprocessor.cpp index 8e95fd22c..390f1bd51 100644 --- a/dbcon/ddlpackageproc/ddlpackageprocessor.cpp +++ b/dbcon/ddlpackageproc/ddlpackageprocessor.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -80,6 +81,7 @@ using namespace ddlpackage; namespace ddlpackageprocessor { +boost::mutex DDLPackageProcessor::dbrmMutex; DDLPackageProcessor::~DDLPackageProcessor() { diff --git a/dbcon/ddlpackageproc/ddlpackageprocessor.h b/dbcon/ddlpackageproc/ddlpackageprocessor.h index 4706bd342..3115f515c 100644 --- a/dbcon/ddlpackageproc/ddlpackageprocessor.h +++ b/dbcon/ddlpackageproc/ddlpackageprocessor.h @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -802,6 +803,8 @@ protected: int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID); int commitTransaction(uint64_t uniqueId, BRM::TxnID txnID); + // MCOL-66 The DBRM can't handle concurrent DDL + static boost::mutex dbrmMutex; private: /** @brief clean beginning and ending glitches and spaces from string * diff --git a/dbcon/ddlpackageproc/droppartitionprocessor.cpp b/dbcon/ddlpackageproc/droppartitionprocessor.cpp index ad3de7754..108c9efc3 100644 --- a/dbcon/ddlpackageproc/droppartitionprocessor.cpp +++ b/dbcon/ddlpackageproc/droppartitionprocessor.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -196,6 +197,8 @@ namespace ddlpackageprocessor { result.result = DROP_ERROR; logging::Message::Args args; + string strOp("drop partition"); + args.add(strOp); args.add(processName); args.add((uint64_t)processID); args.add((uint64_t)sessionID); diff --git a/dbcon/ddlpackageproc/droptableprocessor.cpp b/dbcon/ddlpackageproc/droptableprocessor.cpp index 7c2c27a6e..cd68cc884 100644 --- a/dbcon/ddlpackageproc/droptableprocessor.cpp +++ b/dbcon/ddlpackageproc/droptableprocessor.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -123,7 +124,11 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro uint64_t tableLockId = 0; OamCache* oamcache = OamCache::makeOamCache(); std::vector moduleIds = oamcache->getModuleIds(); - try + + // MCOL-66 The DBRM can't handle concurrent DDL + boost::mutex::scoped_lock lk(dbrmMutex); + + try { //check table lock boost::shared_ptr systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(dropTableStmt.fSessionID); @@ -197,6 +202,8 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro if (i >= numTries) //error out { Message::Args args; + string strOp("drop table"); + args.add(strOp); args.add(processName); args.add((uint64_t)processID); args.add(sessionId); @@ -238,9 +245,9 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro //get a unique number VERBOSE_INFO("Removing the SYSTABLE meta data"); -#ifdef IDB_DDL_DEBUG -cout << "Removing the SYSTABLEs meta data" << endl; -#endif +//#ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Removing the SYSTABLEs meta data" << endl; +//#endif bytestream << (ByteStream::byte)WE_SVR_DELETE_SYSTABLE; bytestream << uniqueId; bytestream << (uint32_t) dropTableStmt.fSessionID; @@ -271,11 +278,11 @@ cout << "Removing the SYSTABLEs meta data" << endl; pmNum = (*dbRootPMMap)[dbRoot]; try { +// #ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Drop table sending WE_SVR_DELETE_SYSTABLES to pm " << pmNum << endl; +//#endif //cout << "deleting systable entries with txnid " << txnID.id << endl; fWEClient->write(bytestream, (uint32_t)pmNum); -#ifdef IDB_DDL_DEBUG -cout << "Drop table sending WE_SVR_DELETE_SYSTABLES to pm " << pmNum << endl; -#endif while (1) { bsIn.reset(new ByteStream()); @@ -297,22 +304,23 @@ cout << "Drop table sending WE_SVR_DELETE_SYSTABLES to pm " << pmNum << endl; } catch (runtime_error& ex) //write error { -#ifdef IDB_DDL_DEBUG -cout << "Drop table got exception" << endl; -#endif +// #ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Drop table got exception" << endl; +// #endif rc = NETWORK_ERROR; errorMsg = ex.what(); } catch (...) { rc = NETWORK_ERROR; -#ifdef IDB_DDL_DEBUG -cout << "Drop table got unknown exception" << endl; -#endif +//#ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Drop table got unknown exception" << endl; +//#endif } if (rc != 0) { + cout << fTxnid.id << " Error in dropping table from systables(" << (int)rc << ") " << errorMsg.c_str() << endl; Message::Args args; Message message(9); args.add("Error in dropping table from systables."); @@ -355,11 +363,10 @@ cout << "Drop table got unknown exception" << endl; pmNum = (*dbRootPMMap)[dbRoot]; try { - //cout << "deleting systable entries with txnid " << txnID.id << endl; +//#ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Drop table sending WE_SVR_DELETE_SYSCOLUMN to pm " << pmNum << endl; +//#endif fWEClient->write(bytestream, (unsigned)pmNum); -#ifdef IDB_DDL_DEBUG -cout << "Drop table sending WE_SVR_DELETE_SYSTABLES to pm " << pmNum << endl; -#endif while (1) { bsIn.reset(new ByteStream()); @@ -381,25 +388,26 @@ cout << "Drop table sending WE_SVR_DELETE_SYSTABLES to pm " << pmNum << endl; } catch (runtime_error& ex) //write error { -#ifdef IDB_DDL_DEBUG -cout << "Drop table got exception" << endl; -#endif +//#ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Drop table got exception" << endl; +//#endif rc = NETWORK_ERROR; errorMsg = ex.what(); } catch (...) { rc = NETWORK_ERROR; -#ifdef IDB_DDL_DEBUG -cout << "Drop table got unknown exception" << endl; -#endif +// #ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Drop table got unknown exception" << endl; +//#endif } if (rc != 0) { + cout << fTxnid.id << " Error in dropping column from systables(" << (int)rc << ") " << errorMsg.c_str() << endl; Message::Args args; Message message(9); - args.add("Error in dropping table from systables."); + args.add("Error in dropping column from systables."); args.add(errorMsg); message.format(args); result.result = (ResultCode)rc; @@ -412,11 +420,16 @@ cout << "Drop table got unknown exception" << endl; } rc = commitTransaction(uniqueId, txnID); - //cout << "commiting transaction " << txnID.id << " and valid is " << txnID.valid << endl; if (rc != 0) + { + cout << txnID.id << " rolledback transaction " << " and valid is " << txnID.valid << endl; fSessionManager.rolledback(txnID); + } else + { + cout << txnID.id << " commiting transaction " << txnID.id << " and valid is " << txnID.valid << endl; fSessionManager.committed(txnID); + } if (rc != 0) { @@ -527,9 +540,9 @@ cout << "Drop table got unknown exception" << endl; { bytestream << (uint32_t) oidList[i]; } -#ifdef IDB_DDL_DEBUG -cout << "Drop table removing column files" << endl; -#endif +//#ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Drop table removing column files" << endl; +//#endif uint32_t msgRecived = 0; try { fWEClient->write_to_all(bytestream); @@ -592,6 +605,9 @@ cout << "Drop table removing column files" << endl; //Flush primProc cache rc = cacheutils::flushOIDsFromCache( oidList ); //Delete extents from extent map +//#ifdef IDB_DDL_DEBUG +cout << fTxnid.id << " Drop table deleteOIDs" << endl; +//#endif rc = fDbrm->deleteOIDs(oidList); if (rc != 0) @@ -879,7 +895,11 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T ByteStream bytestream; ByteStream::byte tmp8; - try { + + // MCOL-66 The DBRM can't handle concurrent DDL + boost::mutex::scoped_lock lk(dbrmMutex); + + try { //Disable extents first int rc1 = fDbrm->markAllPartitionForDeletion( allOidList); if (rc1 != 0) diff --git a/dbcon/ddlpackageproc/restorepartitionprocessor.cpp b/dbcon/ddlpackageproc/restorepartitionprocessor.cpp index 15e31a033..c6859bac6 100644 --- a/dbcon/ddlpackageproc/restorepartitionprocessor.cpp +++ b/dbcon/ddlpackageproc/restorepartitionprocessor.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -160,6 +161,8 @@ namespace ddlpackageprocessor { result.result = DROP_ERROR; logging::Message::Args args; + string strOp("restore partition"); + args.add(strOp); args.add(processName); args.add((uint64_t)processID); args.add((uint64_t)sessionID); diff --git a/dbcon/dmlpackage/dml-scan.cpp b/dbcon/dmlpackage/dml-scan.cpp index 4841cc119..0002697d4 100644 --- a/dbcon/dmlpackage/dml-scan.cpp +++ b/dbcon/dmlpackage/dml-scan.cpp @@ -5,29 +5,10 @@ /* A lexical scanner generated by flex */ -#define yy_create_buffer dml_create_buffer -#define yy_delete_buffer dml_delete_buffer -#define yy_flex_debug dml_flex_debug -#define yy_init_buffer dml_init_buffer -#define yy_flush_buffer dml_flush_buffer -#define yy_load_buffer_state dml_load_buffer_state -#define yy_switch_to_buffer dml_switch_to_buffer -#define yyin dmlin -#define yyleng dmlleng -#define yylex dmllex -#define yylineno dmllineno -#define yyout dmlout -#define yyrestart dmlrestart -#define yytext dmltext -#define yywrap dmlwrap -#define yyalloc dmlalloc -#define yyrealloc dmlrealloc -#define yyfree dmlfree - #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -72,6 +53,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -102,8 +84,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -137,24 +117,41 @@ typedef unsigned int flex_uint32_t; */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ -#define BEGIN (yy_start) = 1 + 2 * +#define BEGIN yyg->yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ -#define YY_START (((yy_start) - 1) / 2) +#define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE dmlrestart(dmlin ) +#define YY_NEW_FILE dmlrestart(yyin ,yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 @@ -172,15 +169,6 @@ typedef unsigned int flex_uint32_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern yy_size_t dmlleng; - -extern FILE *dmlin, *dmlout; - #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 @@ -191,17 +179,22 @@ extern FILE *dmlin, *dmlout; #define yyless(n) \ do \ { \ - /* Undo effects of setting up dmltext. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ + *yy_cp = yyg->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 dmltext again */ \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) -#define unput(c) yyunput( c, (yytext_ptr) ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE @@ -220,7 +213,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - yy_size_t yy_n_chars; + int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -261,78 +254,58 @@ struct yy_buffer_state * * When we actually see the EOF, we change the status to "new" * (via dmlrestart()), so that the user can continue scanning by - * just pointing dmlin at a new input file. + * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] -/* yy_hold_char holds the character lost when dmltext 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 dmlleng; +void dmlrestart (FILE *input_file ,yyscan_t yyscanner ); +void dml_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE dml_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void dml_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void dml_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void dmlpush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void dmlpop_buffer_state (yyscan_t yyscanner ); -/* 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 */ +static void dmlensure_buffer_stack (yyscan_t yyscanner ); +static void dml_load_buffer_state (yyscan_t yyscanner ); +static void dml_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); -/* Flag which is used to allow dmlwrap()'s to do buffer switches - * instead of setting up a fresh dmlin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; +#define YY_FLUSH_BUFFER dml_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) -void dmlrestart (FILE *input_file ); -void dml_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE dml_create_buffer (FILE *file,int size ); -void dml_delete_buffer (YY_BUFFER_STATE b ); -void dml_flush_buffer (YY_BUFFER_STATE b ); -void dmlpush_buffer_state (YY_BUFFER_STATE new_buffer ); -void dmlpop_buffer_state (void ); +YY_BUFFER_STATE dml_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE dml_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE dml_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); -static void dmlensure_buffer_stack (void ); -static void dml_load_buffer_state (void ); -static void dml_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER dml_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE dml_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE dml_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE dml_scan_bytes (yyconst char *bytes,yy_size_t len ); - -void *dmlalloc (yy_size_t ); -void *dmlrealloc (void *,yy_size_t ); -void dmlfree (void * ); +void *dmlalloc (yy_size_t ,yyscan_t yyscanner ); +void *dmlrealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void dmlfree (void * ,yyscan_t yyscanner ); #define yy_new_buffer dml_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - dmlensure_buffer_stack (); \ + dmlensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - dml_create_buffer(dmlin,YY_BUF_SIZE ); \ + dml_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } @@ -340,9 +313,9 @@ void dmlfree (void * ); #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - dmlensure_buffer_stack (); \ + dmlensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ - dml_create_buffer(dmlin,YY_BUF_SIZE ); \ + dml_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } @@ -351,36 +324,29 @@ void dmlfree (void * ); /* Begin user sect3 */ -#define dmlwrap() 1 +#define dmlwrap(n) 1 #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; -FILE *dmlin = (FILE *) 0, *dmlout = (FILE *) 0; - typedef int yy_state_type; -extern int dmllineno; +#define yytext_ptr yytext_r -int dmllineno = 1; - -extern char *dmltext; -#define yytext_ptr dmltext - -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 ); -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); /* Done after the current pattern has been matched and before the - * corresponding action - sets up dmltext. + * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - dmlleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; + yyg->yy_c_buf_p = yy_cp; #define YY_NUM_RULES 103 #define YY_END_OF_BUFFER 104 @@ -778,12 +744,6 @@ static yyconst flex_int16_t yy_chk[874] = 393, 393, 393 } ; -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int dml_flex_debug; -int dml_flex_debug = 0; - /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ @@ -791,7 +751,6 @@ int dml_flex_debug = 0; #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -char *dmltext; /* Copyright (C) 2014 InfiniDB, Inc. This program is free software; you can redistribute it and/or @@ -836,19 +795,15 @@ extern "C" int _isatty(int); #define yyerror dml_yyerror*/ using namespace dmlpackage; -void dmlerror(char const *s); +void dmlerror(yyscan_t yyscanner, char const *s); namespace dmlpackage { int lineno = 1; -/* Handles to the buffer that the lexer uses internally */ -static YY_BUFFER_STATE scanbufhandle; -static char *scanbuf; +static char* scanner_copy (char *str, yyscan_t yyscanner); -static char* scanner_copy (char *str); - - /* macro to save the text and return a token */ -#define TOK(name) { dmllval.strval = scanner_copy(dmltext); return name; } +/* macro to save the text and return a token */ +#define TOK(name) { dmlget_lval(yyscanner)->strval = scanner_copy(dmlget_text(yyscanner), yyscanner); return name; } } #define INITIAL 0 @@ -867,36 +822,84 @@ static char* scanner_copy (char *str); #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals (void ); +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals (yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int dmllex_init (yyscan_t* scanner); + +int dmllex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int dmllex_destroy (void ); +int dmllex_destroy (yyscan_t yyscanner ); -int dmlget_debug (void ); +int dmlget_debug (yyscan_t yyscanner ); -void dmlset_debug (int debug_flag ); +void dmlset_debug (int debug_flag ,yyscan_t yyscanner ); -YY_EXTRA_TYPE dmlget_extra (void ); +YY_EXTRA_TYPE dmlget_extra (yyscan_t yyscanner ); -void dmlset_extra (YY_EXTRA_TYPE user_defined ); +void dmlset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); -FILE *dmlget_in (void ); +FILE *dmlget_in (yyscan_t yyscanner ); -void dmlset_in (FILE * in_str ); +void dmlset_in (FILE * in_str ,yyscan_t yyscanner ); -FILE *dmlget_out (void ); +FILE *dmlget_out (yyscan_t yyscanner ); -void dmlset_out (FILE * out_str ); +void dmlset_out (FILE * out_str ,yyscan_t yyscanner ); -yy_size_t dmlget_leng (void ); +int dmlget_leng (yyscan_t yyscanner ); -char *dmlget_text (void ); +char *dmlget_text (yyscan_t yyscanner ); -int dmlget_lineno (void ); +int dmlget_lineno (yyscan_t yyscanner ); -void dmlset_lineno (int line_number ); +void dmlset_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * dmlget_lval (yyscan_t yyscanner ); + +void dmlset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -904,26 +907,26 @@ void dmlset_lineno (int line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int dmlwrap (void ); +extern "C" int dmlwrap (yyscan_t yyscanner ); #else -extern int dmlwrap (void ); +extern int dmlwrap (yyscan_t yyscanner ); #endif #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus -static int yyinput (void ); +static int yyinput (yyscan_t yyscanner ); #else -static int input (void ); +static int input (yyscan_t yyscanner ); #endif #endif @@ -938,7 +941,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( dmltext, dmlleng, 1, dmlout )) {} } while (0) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -949,20 +952,20 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + unsigned n; \ for ( n = 0; n < max_size && \ - (c = getc( dmlin )) != EOF && c != '\n'; ++n ) \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ - if ( c == EOF && ferror( dmlin ) ) \ + if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, dmlin))==0 && ferror(dmlin)) \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -970,7 +973,7 @@ static int input (void ); break; \ } \ errno=0; \ - clearerr(dmlin); \ + clearerr(yyin); \ } \ }\ \ @@ -992,7 +995,7 @@ static int input (void ); /* Report a fatal error. */ #ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) #endif /* end tables serialization structures and prototypes */ @@ -1003,12 +1006,14 @@ static int input (void ); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int dmllex (void); +extern int dmllex \ + (YYSTYPE * yylval_param ,yyscan_t yyscanner); -#define YY_DECL int dmllex (void) +#define YY_DECL int dmllex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) #endif /* !YY_DECL */ -/* Code executed at the beginning of each rule, after dmltext and dmlleng +/* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION @@ -1030,54 +1035,57 @@ YY_DECL register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; - - if ( !(yy_init) ) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) { - (yy_init) = 1; + yyg->yy_init = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ - if ( ! dmlin ) - dmlin = stdin; + if ( ! yyin ) + yyin = stdin; - if ( ! dmlout ) - dmlout = stdout; + if ( ! yyout ) + yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { - dmlensure_buffer_stack (); + dmlensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - dml_create_buffer(dmlin,YY_BUF_SIZE ); + dml_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } - dml_load_buffer_state( ); + dml_load_buffer_state(yyscanner ); } while ( 1 ) /* loops until end-of-file is reached */ { - yy_cp = (yy_c_buf_p); + yy_cp = yyg->yy_c_buf_p; - /* Support of dmltext. */ - *yy_cp = (yy_hold_char); + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; - yy_current_state = (yy_start); + yy_current_state = yyg->yy_start; yy_match: do { register 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; - (yy_last_accepting_cpos) = yy_cp; + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1094,8 +1102,8 @@ yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } @@ -1107,9 +1115,9 @@ do_action: /* This label is used only to access EOF actions. */ { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; case 1: @@ -1456,7 +1464,7 @@ TOK(COMPARISON) YY_BREAK case 90: YY_RULE_SETUP -{ TOK(dmltext[0]) } +{ TOK(yytext[0]) } YY_BREAK /* names */ case 91: @@ -1487,9 +1495,9 @@ YY_RULE_SETUP YY_BREAK case 98: /* rule 98 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up dmltext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up dmltext again */ +*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ +yyg->yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP {BEGIN(endquote); TOK(STRING) } YY_BREAK @@ -1524,25 +1532,25 @@ case YY_STATE_EOF(endquote): case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); + *yy_cp = yyg->yy_hold_char; YY_RESTORE_YY_MORE_OFFSET if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user - * just pointed dmlin at a new source and called + * just pointed yyin at a new source and called * dmllex(). 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 = dmlin; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } @@ -1553,13 +1561,13 @@ case YY_STATE_EOF(endquote): * end-of-buffer state). Contrast this with the test * in input(). */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state( yyscanner ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have @@ -1570,43 +1578,43 @@ case YY_STATE_EOF(endquote): * will run more slowly). */ - yy_next_state = yy_try_NUL_trans( yy_current_state ); + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); + yy_cp = ++yyg->yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { - yy_cp = (yy_c_buf_p); + yy_cp = yyg->yy_c_buf_p; goto yy_find_action; } } - else switch ( yy_get_next_buffer( ) ) + else switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_END_OF_FILE: { - (yy_did_buffer_switch_on_eof) = 0; + yyg->yy_did_buffer_switch_on_eof = 0; - if ( dmlwrap( ) ) + if ( dmlwrap(yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up - * dmltext, we can now set up + * yytext, 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 * YY_NULL, it'll still work - another * YY_NULL will get returned. */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; @@ -1614,30 +1622,30 @@ case YY_STATE_EOF(endquote): else { - if ( ! (yy_did_buffer_switch_on_eof) ) + if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state( yyscanner ); - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - yy_current_state = yy_get_previous_state( ); + yy_current_state = yy_get_previous_state( yyscanner ); - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; @@ -1657,20 +1665,21 @@ case YY_STATE_EOF(endquote): * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -static int yy_get_next_buffer (void) +static int yy_get_next_buffer (yyscan_t yyscanner) { - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; register int number_to_move, i; int ret_val; - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. @@ -1690,7 +1699,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 = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1699,25 +1708,25 @@ static int yy_get_next_buffer (void) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; 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 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1726,7 +1735,7 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - dmlrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + dmlrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); } else /* Can't grow it, we don't own it. */ @@ -1736,7 +1745,7 @@ static int yy_get_next_buffer (void) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; @@ -1748,17 +1757,17 @@ static int yy_get_next_buffer (void) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); + yyg->yy_n_chars, (size_t) num_to_read ); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } - if ( (yy_n_chars) == 0 ) + if ( yyg->yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - dmlrestart(dmlin ); + dmlrestart(yyin ,yyscanner); } else @@ -1772,39 +1781,40 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if ((yy_size_t) (yyg->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 *) dmlrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) dmlrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ - static yy_state_type yy_get_previous_state (void) + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { register yy_state_type yy_current_state; register char *yy_cp; - - yy_current_state = (yy_start); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { register 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; - (yy_last_accepting_cpos) = yy_cp; + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1823,16 +1833,17 @@ static int yy_get_next_buffer (void) * synopsis * next_state = yy_try_NUL_trans( current_state ); */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + register char *yy_cp = yyg->yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1843,37 +1854,38 @@ static int yy_get_next_buffer (void) yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 393); - return yy_is_jam ? 0 : yy_current_state; + return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_INPUT #ifdef __cplusplus - static int yyinput (void) + static int yyinput (yyscan_t yyscanner) #else - static int input (void) + static int input (yyscan_t yyscanner) #endif { int c; - - *(yy_c_buf_p) = (yy_hold_char); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; + *yyg->yy_c_buf_p = '\0'; else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); + int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; - switch ( yy_get_next_buffer( ) ) + switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() @@ -1887,34 +1899,34 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - dmlrestart(dmlin ); + dmlrestart(yyin ,yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( dmlwrap( ) ) + if ( dmlwrap(yyscanner ) ) return EOF; - if ( ! (yy_did_buffer_switch_on_eof) ) + if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus - return yyinput(); + return yyinput(yyscanner); #else - return input(); + return input(yyscanner); #endif } case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; break; } } } - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve dmltext */ - (yy_hold_char) = *++(yy_c_buf_p); + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; return c; } @@ -1922,76 +1934,79 @@ static int yy_get_next_buffer (void) /** Immediately switch to a different input stream. * @param input_file A readable stream. - * + * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ - void dmlrestart (FILE * input_file ) + void dmlrestart (FILE * input_file , yyscan_t yyscanner) { - + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! YY_CURRENT_BUFFER ){ - dmlensure_buffer_stack (); + dmlensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = - dml_create_buffer(dmlin,YY_BUF_SIZE ); + dml_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } - dml_init_buffer(YY_CURRENT_BUFFER,input_file ); - dml_load_buffer_state( ); + dml_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + dml_load_buffer_state(yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. - * + * @param yyscanner The scanner object. */ - void dml_switch_to_buffer (YY_BUFFER_STATE new_buffer ) + void dml_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { - + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* TODO. We should be able to replace this entire function body * with * dmlpop_buffer_state(); * dmlpush_buffer_state(new_buffer); */ - dmlensure_buffer_stack (); + dmlensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } YY_CURRENT_BUFFER_LVALUE = new_buffer; - dml_load_buffer_state( ); + dml_load_buffer_state(yyscanner ); /* We don't actually know whether we did this switch during * EOF (dmlwrap()) processing, but the only time this flag * is looked at is after dmlwrap() is called, so it's safe * to go ahead and always set it. */ - (yy_did_buffer_switch_on_eof) = 1; + yyg->yy_did_buffer_switch_on_eof = 1; } -static void dml_load_buffer_state (void) +static void dml_load_buffer_state (yyscan_t yyscanner) { - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - dmlin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * + * @param yyscanner The scanner object. * @return the allocated buffer state. */ - YY_BUFFER_STATE dml_create_buffer (FILE * file, int size ) + YY_BUFFER_STATE dml_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) dmlalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) dmlalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in dml_create_buffer()" ); @@ -2000,24 +2015,25 @@ static void dml_load_buffer_state (void) /* 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 *) dmlalloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) dmlalloc(b->yy_buf_size + 2 ,yyscanner ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in dml_create_buffer()" ); b->yy_is_our_buffer = 1; - dml_init_buffer(b,file ); + dml_init_buffer(b,file ,yyscanner); return b; } /** Destroy the buffer. * @param b a buffer created with dml_create_buffer() - * + * @param yyscanner The scanner object. */ - void dml_delete_buffer (YY_BUFFER_STATE b ) + void dml_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { - + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) return; @@ -2025,21 +2041,26 @@ static void dml_load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - dmlfree((void *) b->yy_ch_buf ); + dmlfree((void *) b->yy_ch_buf ,yyscanner ); - dmlfree((void *) b ); + dmlfree((void *) b ,yyscanner ); } +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a dmlrestart() or at EOF. */ - static void dml_init_buffer (YY_BUFFER_STATE b, FILE * file ) + static void dml_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { int oerrno = errno; - - dml_flush_buffer(b ); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + dml_flush_buffer(b ,yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; @@ -2060,11 +2081,12 @@ static void dml_load_buffer_state (void) /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * + * @param yyscanner The scanner object. */ - void dml_flush_buffer (YY_BUFFER_STATE b ) + void dml_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { - if ( ! b ) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) return; b->yy_n_chars = 0; @@ -2082,114 +2104,117 @@ static void dml_load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - dml_load_buffer_state( ); + dml_load_buffer_state(yyscanner ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. - * + * @param yyscanner The scanner object. */ -void dmlpush_buffer_state (YY_BUFFER_STATE new_buffer ) +void dmlpush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { - if (new_buffer == NULL) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) return; - dmlensure_buffer_stack(); + dmlensure_buffer_stack(yyscanner); /* This block is copied from dml_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; + yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from dml_switch_to_buffer. */ - dml_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; + dml_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. - * + * @param yyscanner The scanner object. */ -void dmlpop_buffer_state (void) +void dmlpop_buffer_state (yyscan_t yyscanner) { - if (!YY_CURRENT_BUFFER) + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) return; - dml_delete_buffer(YY_CURRENT_BUFFER ); + dml_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { - dml_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; + dml_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void dmlensure_buffer_stack (void) +static void dmlensure_buffer_stack (yyscan_t yyscanner) { - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) { + int num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { /* 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 realloc on the next call. */ num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)dmlalloc + yyg->yy_buffer_stack = (struct yy_buffer_state**)dmlalloc (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in dmlensure_buffer_stack()" ); - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; return; } - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)dmlrealloc - ((yy_buffer_stack), + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)dmlrealloc + (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in dmlensure_buffer_stack()" ); /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; } } /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer - * + * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE dml_scan_buffer (char * base, yy_size_t size ) +YY_BUFFER_STATE dml_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; @@ -2199,7 +2224,7 @@ YY_BUFFER_STATE dml_scan_buffer (char * base, yy_size_t size ) /* They forgot to leave room for the EOB's. */ return 0; - b = (YY_BUFFER_STATE) dmlalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) dmlalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in dml_scan_buffer()" ); @@ -2213,7 +2238,7 @@ YY_BUFFER_STATE dml_scan_buffer (char * base, yy_size_t size ) b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - dml_switch_to_buffer(b ); + dml_switch_to_buffer(b ,yyscanner ); return b; } @@ -2221,25 +2246,25 @@ YY_BUFFER_STATE dml_scan_buffer (char * base, yy_size_t size ) /** Setup the input buffer state to scan a string. The next call to dmllex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan - * + * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * dml_scan_bytes() instead. */ -YY_BUFFER_STATE dml_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE dml_scan_string (yyconst char * yystr , yyscan_t yyscanner) { - return dml_scan_bytes(yystr,strlen(yystr) ); + return dml_scan_bytes(yystr,strlen(yystr) ,yyscanner); } /** Setup the input buffer state to scan the given bytes. The next call to dmllex() 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. - * + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE dml_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +YY_BUFFER_STATE dml_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; @@ -2248,7 +2273,7 @@ YY_BUFFER_STATE dml_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 *) dmlalloc(n ); + buf = (char *) dmlalloc(n ,yyscanner ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in dml_scan_bytes()" ); @@ -2257,7 +2282,7 @@ YY_BUFFER_STATE dml_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = dml_scan_buffer(buf,n ); + b = dml_scan_buffer(buf,n ,yyscanner); if ( ! b ) YY_FATAL_ERROR( "bad buffer in dml_scan_bytes()" ); @@ -2273,7 +2298,7 @@ YY_BUFFER_STATE dml_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg ) +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); @@ -2285,117 +2310,264 @@ static void yy_fatal_error (yyconst char* msg ) #define yyless(n) \ do \ { \ - /* Undo effects of setting up dmltext. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - dmltext[dmlleng] = (yy_hold_char); \ - (yy_c_buf_p) = dmltext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - dmlleng = yyless_macro_arg; \ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ -/** Get the current line number. - * +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. */ -int dmlget_lineno (void) +YY_EXTRA_TYPE dmlget_extra (yyscan_t yyscanner) { - - return dmllineno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int dmlget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int dmlget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; } /** Get the input stream. - * + * @param yyscanner The scanner object. */ -FILE *dmlget_in (void) +FILE *dmlget_in (yyscan_t yyscanner) { - return dmlin; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; } /** Get the output stream. - * + * @param yyscanner The scanner object. */ -FILE *dmlget_out (void) +FILE *dmlget_out (yyscan_t yyscanner) { - return dmlout; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; } /** Get the length of the current token. - * + * @param yyscanner The scanner object. */ -yy_size_t dmlget_leng (void) +int dmlget_leng (yyscan_t yyscanner) { - return dmlleng; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; } /** Get the current token. - * + * @param yyscanner The scanner object. */ -char *dmlget_text (void) +char *dmlget_text (yyscan_t yyscanner) { - return dmltext; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void dmlset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; } /** Set the current line number. * @param line_number - * + * @param yyscanner The scanner object. */ -void dmlset_lineno (int line_number ) +void dmlset_lineno (int line_number , yyscan_t yyscanner) { + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "dmlset_lineno called with no buffer" , yyscanner); - dmllineno = line_number; + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void dmlset_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "dmlset_column called with no buffer" , yyscanner); + + yycolumn = column_no; } /** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. - * + * @param yyscanner The scanner object. * @see dml_switch_to_buffer */ -void dmlset_in (FILE * in_str ) +void dmlset_in (FILE * in_str , yyscan_t yyscanner) { - dmlin = in_str ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; } -void dmlset_out (FILE * out_str ) +void dmlset_out (FILE * out_str , yyscan_t yyscanner) { - dmlout = out_str ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; } -int dmlget_debug (void) +int dmlget_debug (yyscan_t yyscanner) { - return dml_flex_debug; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; } -void dmlset_debug (int bdebug ) +void dmlset_debug (int bdebug , yyscan_t yyscanner) { - dml_flex_debug = bdebug ; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; } -static int yy_init_globals (void) +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * dmlget_lval (yyscan_t yyscanner) { - /* Initialization is the same as for the non-reentrant scanner. + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void dmlset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* dmllex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int dmllex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) dmlalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* dmllex_init_extra has the same functionality as dmllex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to dmlalloc in + * the yyextra field. + */ + +int dmllex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + dmlset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) dmlalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + dmlset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. * This function is called from dmllex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; /* Defined in main.c */ #ifdef YY_STDINIT - dmlin = stdin; - dmlout = stdout; + yyin = stdin; + yyout = stdout; #else - dmlin = (FILE *) 0; - dmlout = (FILE *) 0; + yyin = (FILE *) 0; + yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by @@ -2405,24 +2577,32 @@ static int yy_init_globals (void) } /* dmllex_destroy is for both reentrant and non-reentrant scanners. */ -int dmllex_destroy (void) +int dmllex_destroy (yyscan_t yyscanner) { - + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - dml_delete_buffer(YY_CURRENT_BUFFER ); + dml_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; - dmlpop_buffer_state(); + dmlpop_buffer_state(yyscanner); } /* Destroy the stack itself. */ - dmlfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; + dmlfree(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + dmlfree(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time * dmllex() is called, initialization will occur. */ - yy_init_globals( ); + yy_init_globals( yyscanner); + /* Destroy the main struct (reentrant only). */ + dmlfree ( yyscanner , yyscanner ); + yyscanner = NULL; return 0; } @@ -2431,7 +2611,7 @@ int dmllex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) { register int i; for ( i = 0; i < n; ++i ) @@ -2440,7 +2620,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) { register int n; for ( n = 0; s[n]; ++n ) @@ -2450,12 +2630,12 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *dmlalloc (yy_size_t size ) +void *dmlalloc (yy_size_t size , yyscan_t yyscanner) { return (void *) malloc( size ); } -void *dmlrealloc (void * ptr, yy_size_t size ) +void *dmlrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those @@ -2467,7 +2647,7 @@ void *dmlrealloc (void * ptr, yy_size_t size ) return (void *) realloc( (char *) ptr, size ); } -void dmlfree (void * ptr ) +void dmlfree (void * ptr , yyscan_t yyscanner) { free( (char *) ptr ); /* see dmlrealloc() for (char *) cast */ } @@ -2476,9 +2656,9 @@ void dmlfree (void * ptr ) using namespace dmlpackage; -void dmlerror(char const *s) +void dmlerror(yyscan_t yyscanner, char const *s) { - printf("yyerror: %d: %s at %s\n", lineno, s, dmltext); + printf("yyerror: %d: %s at %s\n", lineno, s, dmlget_text(yyscanner)); } namespace dmlpackage { @@ -2493,55 +2673,58 @@ valbuf_t get_valbuffer(void) /* * Called before any actual parsing is done */ -void scanner_init(const char *str) +void scanner_init(const char *str, yyscan_t yyscanner) { size_t slen = strlen(str); + scan_data* pScanData = (scan_data*)dmlget_extra(yyscanner); /* * Might be left over after ereport() */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; // needed for macro YY_CURRENT_BUFFER if (YY_CURRENT_BUFFER) - dml_delete_buffer(YY_CURRENT_BUFFER); + dml_delete_buffer(YY_CURRENT_BUFFER,yyscanner); /* * Make a scan buffer with special termination needed by flex. */ - scanbuf = (char *)malloc(slen + 2); - memcpy(scanbuf, str, slen); - scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; - scanbufhandle = dml_scan_buffer(scanbuf,slen + 2); + pScanData->scanbuf = (char *)malloc(slen + 2); + memcpy(pScanData->scanbuf, str, slen); + pScanData->scanbuf[slen] = pScanData->scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; + pScanData->scanbufhandle = dml_scan_buffer(pScanData->scanbuf,slen + 2,yyscanner); BEGIN(INITIAL); - valbuf.clear(); + pScanData->valbuf.clear(); } /* * Called after parsing is done to clean up after scanner_init() */ -void scanner_finish(void) +void scanner_finish(yyscan_t yyscanner) { - char* str; + char* str; + scan_data* pScanData = (scan_data*)dmlget_extra(yyscanner); - dml_delete_buffer(scanbufhandle); - free(scanbuf); + dml_delete_buffer((YY_BUFFER_STATE)pScanData->scanbufhandle,yyscanner); + free(pScanData->scanbuf); unsigned int i; - for(i=0; ivalbuf.size(); i++) { + str = pScanData->valbuf[i]; if(str) { //std::cout << "valbuf:(" << str << ")" << std::endl; - free(valbuf[i]); + free(pScanData->valbuf[i]); } } - valbuf.clear(); + pScanData->valbuf.clear(); } -char* scanner_copy (char *str) +char* scanner_copy (char *str, yyscan_t yyscanner) { char* nv = strdup(str); if(nv) - valbuf.push_back(nv); + ((scan_data*)dmlget_extra(yyscanner))->valbuf.push_back(nv); return nv; } diff --git a/dbcon/dmlpackage/dml.l b/dbcon/dmlpackage/dml.l index 590949432..2ae7e0d70 100644 --- a/dbcon/dmlpackage/dml.l +++ b/dbcon/dmlpackage/dml.l @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -44,25 +45,23 @@ extern "C" int _isatty(int); #define yyerror dml_yyerror*/ using namespace dmlpackage; -void dmlerror(char const *s); +void dmlerror(yyscan_t yyscanner, char const *s); namespace dmlpackage { int lineno = 1; -/* Handles to the buffer that the lexer uses internally */ -static YY_BUFFER_STATE scanbufhandle; -static char *scanbuf; - -static char* scanner_copy (char *str); +static char* scanner_copy (char *str, yyscan_t yyscanner); - /* macro to save the text and return a token */ -#define TOK(name) { dmllval.strval = scanner_copy(dmltext); return name; } +/* macro to save the text and return a token */ +#define TOK(name) { dmlget_lval(yyscanner)->strval = scanner_copy(dmlget_text(yyscanner), yyscanner); return name; } } %} +%option reentrant +%option bison-bridge %option noyywrap %option nounput %x inquote @@ -199,9 +198,9 @@ WORK TOK(WORK) %% using namespace dmlpackage; -void dmlerror(char const *s) +void dmlerror(yyscan_t yyscanner, char const *s) { - printf("yyerror: %d: %s at %s\n", lineno, s, yytext); + printf("yyerror: %d: %s at %s\n", lineno, s, dmlget_text(yyscanner)); } namespace dmlpackage { @@ -216,28 +215,30 @@ valbuf_t get_valbuffer(void) /* * Called before any actual parsing is done */ -void scanner_init(const char *str) +void scanner_init(const char *str, yyscan_t yyscanner) { size_t slen = strlen(str); + scan_data* pScanData = (scan_data*)dmlget_extra(yyscanner); /* * Might be left over after ereport() */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; // needed for macro YY_CURRENT_BUFFER if (YY_CURRENT_BUFFER) - yy_delete_buffer(YY_CURRENT_BUFFER); + yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner); /* * Make a scan buffer with special termination needed by flex. */ - scanbuf = (char *)malloc(slen + 2); - memcpy(scanbuf, str, slen); - scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; - scanbufhandle = yy_scan_buffer(scanbuf, slen + 2); + pScanData->scanbuf = (char *)malloc(slen + 2); + memcpy(pScanData->scanbuf, str, slen); + pScanData->scanbuf[slen] = pScanData->scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; + pScanData->scanbufhandle = yy_scan_buffer(pScanData->scanbuf, slen + 2, yyscanner); BEGIN(INITIAL); - valbuf.clear(); + pScanData->valbuf.clear(); } @@ -246,28 +247,29 @@ void scanner_init(const char *str) */ -void scanner_finish(void) +void scanner_finish(yyscan_t yyscanner) { - char* str; + char* str; + scan_data* pScanData = (scan_data*)dmlget_extra(yyscanner); - yy_delete_buffer(scanbufhandle); - free(scanbuf); + yy_delete_buffer((YY_BUFFER_STATE)pScanData->scanbufhandle, yyscanner); + free(pScanData->scanbuf); unsigned int i; - for(i=0; ivalbuf.size(); i++) { + str = pScanData->valbuf[i]; if(str) { //std::cout << "valbuf:(" << str << ")" << std::endl; - free(valbuf[i]); + free(pScanData->valbuf[i]); } } - valbuf.clear(); + pScanData->valbuf.clear(); } -char* scanner_copy (char *str) +char* scanner_copy (char *str, yyscan_t yyscanner) { char* nv = strdup(str); if(nv) - valbuf.push_back(nv); + ((scan_data*)dmlget_extra(yyscanner))->valbuf.push_back(nv); return nv; } diff --git a/dbcon/dmlpackage/dml.y b/dbcon/dmlpackage/dml.y index 67fdc7372..b26319c0b 100644 --- a/dbcon/dmlpackage/dml.y +++ b/dbcon/dmlpackage/dml.y @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -55,6 +56,7 @@ a more recent version of flex. At the time of this writing, our development systems have: flex version 2.5.4 + MCOL-66 Modify to be a reentrant parser */ %{ #include @@ -72,9 +74,9 @@ using namespace std; using namespace dmlpackage; -int dmllex(); +int dmllex(YYSTYPE* dmllval, void* yyscanner); -void dmlerror (char const *error); +void dmlerror (void* yyscanner, char const *error); namespace dmlpackage { @@ -88,8 +90,12 @@ char* copy_string(const char *str); } %} +%pure-parser +%lex-param {void * scanner} +%parse-param {void * scanner} %debug - /* symbolic tokens */ + +/* symbolic tokens */ %union { int intval; diff --git a/dbcon/dmlpackage/dmlparser.cpp b/dbcon/dmlpackage/dmlparser.cpp index 79b273977..86c0e77eb 100644 --- a/dbcon/dmlpackage/dmlparser.cpp +++ b/dbcon/dmlpackage/dmlparser.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -37,14 +38,16 @@ #include #include -int dmlparse(); +int dmllex_init_extra(void* user_defined, void** yyscanner); +int dmllex_destroy(void* yyscanner); +int dmlparse(void* yyscanner); namespace dmlpackage { using namespace std; - void scanner_finish(void); - void scanner_init(const char *str); + void scanner_finish(void* yyscanner); + void scanner_init(const char *str, void* yyscanner); void grammar_init(dmlpackage::ParseTree* _ptree, bool); valbuf_t get_valbuffer(void); @@ -57,7 +60,8 @@ namespace dmlpackage DMLParser::~DMLParser() { - scanner_finish(); + scanner_finish(scanner); + dmllex_destroy(scanner); } void DMLParser::setDebug(bool debug) @@ -67,9 +71,10 @@ namespace dmlpackage int DMLParser::parse(const char* dmltext) { - scanner_init(dmltext); + dmllex_init_extra(&scanData, &scanner); + scanner_init(dmltext, scanner); grammar_init(&fParseTree, fDebug); - fStatus = dmlparse(); + fStatus = dmlparse(scanner); if (fStatus == 0) { char* str; diff --git a/dbcon/dmlpackage/dmlparser.h b/dbcon/dmlpackage/dmlparser.h index 29a5f2c47..a6132e78d 100644 --- a/dbcon/dmlpackage/dmlparser.h +++ b/dbcon/dmlpackage/dmlparser.h @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -35,9 +36,20 @@ namespace dmlpackage typedef SqlStatementList ParseTree; - /** @brief BISON parser wrapper class - */ - class DMLParser + // instance data for the parser + typedef std::vector valbuf_t; + + struct scan_data + { + /* Handles to the buffer that the lexer uses internally */ + char* scanbuf; + void* scanbufhandle; // This is a YY_BUFFER_STATE defined in ddl-scan.cpp + valbuf_t valbuf; + }; + + /** @brief BISON parser wrapper class + */ + class DMLParser { public: /** @brief ctor @@ -73,6 +85,8 @@ namespace dmlpackage ParseTree fParseTree; int fStatus; bool fDebug; + void* scanner; // yyscan_t * needed for re-entrant flex scanner + scan_data scanData; private: diff --git a/dbcon/dmlpackageproc/deletepackageprocessor.cpp b/dbcon/dmlpackageproc/deletepackageprocessor.cpp index 001993194..22420fc9a 100644 --- a/dbcon/dmlpackageproc/deletepackageprocessor.cpp +++ b/dbcon/dmlpackageproc/deletepackageprocessor.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -190,6 +191,8 @@ namespace dmlpackageprocessor { result.result = DELETE_ERROR; logging::Message::Args args; + string strOp("delete"); + args.add(strOp); args.add(processName); args.add((uint64_t)processID); args.add(sessionId); diff --git a/dbcon/dmlpackageproc/insertpackageprocessor.cpp b/dbcon/dmlpackageproc/insertpackageprocessor.cpp index 61bae74d1..20fc021cb 100644 --- a/dbcon/dmlpackageproc/insertpackageprocessor.cpp +++ b/dbcon/dmlpackageproc/insertpackageprocessor.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -197,6 +198,8 @@ namespace dmlpackageprocessor { result.result = INSERT_ERROR; logging::Message::Args args; + string strOp("insert"); + args.add(strOp); args.add(processName); args.add((uint64_t)processID); args.add(sessionId); diff --git a/dbcon/dmlpackageproc/updatepackageprocessor.cpp b/dbcon/dmlpackageproc/updatepackageprocessor.cpp index 8fe8c5cfb..2cb858261 100644 --- a/dbcon/dmlpackageproc/updatepackageprocessor.cpp +++ b/dbcon/dmlpackageproc/updatepackageprocessor.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -214,6 +215,8 @@ UpdatePackageProcessor::processPackage(dmlpackage::CalpontDMLPackage& cpackage) { result.result = UPDATE_ERROR; logging::Message::Args args; + string strOp("update"); + args.add(strOp); args.add(processName); args.add((uint64_t)processID); args.add(sessionId); diff --git a/dbcon/mysql/mysql.vpj b/dbcon/mysql/mysql.vpj index 307aef375..cdb8f4f12 100644 --- a/dbcon/mysql/mysql.vpj +++ b/dbcon/mysql/mysql.vpj @@ -245,10 +245,15 @@ + + + + + @@ -312,6 +317,7 @@ + diff --git a/ddlproc/ddlproc.cpp b/ddlproc/ddlproc.cpp index dcf1dd4c7..45cf09327 100644 --- a/ddlproc/ddlproc.cpp +++ b/ddlproc/ddlproc.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -117,7 +118,7 @@ int main(int argc, char* argv[]) sigaction(SIGPIPE, &ign, 0); #endif - ddlprocessor::DDLProcessor ddlprocessor(5, 10); + ddlprocessor::DDLProcessor ddlprocessor(1, 20); { Oam oam; diff --git a/dmlproc/batchinsertprocessor.cpp b/dmlproc/batchinsertprocessor.cpp index adfe5408c..f4a83fde8 100644 --- a/dmlproc/batchinsertprocessor.cpp +++ b/dmlproc/batchinsertprocessor.cpp @@ -152,6 +152,8 @@ uint64_t BatchInsertProc::grabTableLock(int32_t sessionId) if (i >= numTries) //error out { logging::Message::Args args; + string strOp("batch insert"); + args.add(strOp); args.add(processName); args.add((uint64_t)processID); args.add(tmpSessionId); diff --git a/dmlproc/batchinsertprocessor.h b/dmlproc/batchinsertprocessor.h index 8e966762e..8a7df5296 100644 --- a/dmlproc/batchinsertprocessor.h +++ b/dmlproc/batchinsertprocessor.h @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/dmlproc/dmlprocessor.cpp b/dmlproc/dmlprocessor.cpp index 597d5863d..4afa3127b 100644 --- a/dmlproc/dmlprocessor.cpp +++ b/dmlproc/dmlprocessor.cpp @@ -1,5 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. - + Copyright (C) 2016 MariaDB Corporation 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 the Free Software Foundation; version 2 of @@ -310,7 +310,6 @@ void PackageHandler::run() try { - switch( fPackageType ) { case dmlpackage::DML_INSERT: @@ -785,29 +784,53 @@ void PackageHandler::run() ml.logWarningMessage( result.message ); } - - // send back the results - messageqcpp::ByteStream results; - messageqcpp::ByteStream::octbyte rowCount = result.rowCount; - messageqcpp::ByteStream::byte retval = result.result; - results << retval; - results << rowCount; - results << result.message.msg(); - results << result.tableLockInfo; // ? connector does not get - // query stats - results << result.queryStats; - results << result.extendedStats; - results << result.miniStats; - result.stats.serialize(results); - fIos.write(results); - //Bug 5226. dmlprocessor thread will close the socket to mysqld. - //if (stmt == "CLEANUP") - // fIos.close(); } + catch(std::exception& e) + { + cout << "dmlprocessor.cpp PackageHandler::run() package type(" + << fPackageType << ") exception: " << e.what() << endl; + logging::LoggingID lid(21); + logging::MessageLog ml(lid); + logging::Message::Args args; + logging::Message message(1); + args.add("dmlprocessor.cpp PackageHandler::run() package type"); + args.add((uint64_t)fPackageType); + args.add(e.what()); + message.format(args); + ml.logErrorMessage(message); + result.result=DMLPackageProcessor::COMMAND_ERROR; + result.message = message; + } catch(...) { - fIos.close(); + logging::LoggingID lid(21); + logging::MessageLog ml(lid); + logging::Message::Args args; + logging::Message message(1); + args.add("dmlprocessor.cpp PackageHandler::run() ... exception package type"); + args.add((uint64_t)fPackageType); + message.format(args); + ml.logErrorMessage(message); + result.result=DMLPackageProcessor::COMMAND_ERROR; + result.message = message; } + // send back the results + messageqcpp::ByteStream results; + messageqcpp::ByteStream::octbyte rowCount = result.rowCount; + messageqcpp::ByteStream::byte retval = result.result; + results << retval; + results << rowCount; + results << result.message.msg(); + results << result.tableLockInfo; // ? connector does not get + // query stats + results << result.queryStats; + results << result.extendedStats; + results << result.miniStats; + result.stats.serialize(results); + fIos.write(results); + //Bug 5226. dmlprocessor thread will close the socket to mysqld. + //if (stmt == "CLEANUP") + // fIos.close(); } void PackageHandler::rollbackPending() @@ -924,15 +947,15 @@ void DMLProcessor::operator()() bs1.reset(new messageqcpp::ByteStream(fIos.read())); //cout << "received from mysql socket " << fIos.getSockID() << endl; } - catch (std::exception&) + catch (std::exception& ex) { //This is an I/O error from InetStreamSocket::read(), just close and move on... - //cout << "runtime error during read on " << fIos.getSockID() << " " << ex.what() << endl; + cout << "runtime error during read on " << fIos.getSockID() << " " << ex.what() << endl; bs1->reset(); } catch (...) { - //cout << "... error during read " << fIos.getSockID() << endl; + cout << "... error during read " << fIos.getSockID() << endl; // all this throw does is cause this thread to silently go away. I doubt this is the right // thing to do... throw; @@ -940,7 +963,7 @@ void DMLProcessor::operator()() if (!bs1 || bs1->length() == 0) { - //cout << "Read 0 bytes. Closing connection " << fIos.getSockID() << endl; + cout << "Read 0 bytes. Closing connection " << fIos.getSockID() << endl; fIos.close(); break; } @@ -1069,8 +1092,11 @@ void DMLProcessor::operator()() { if (packageType == dmlpackage::DML_COMMAND) { + // MCOL-66 It's possible for a commit or rollback to get here if + // the timing is just right. Don't destroy its data + messageqcpp::ByteStream bsctrlc(bs1); dmlpackage::CommandDMLPackage commandPkg; - commandPkg.read(*(bs1.get())); + commandPkg.read(bsctrlc); std::string stmt = commandPkg.get_DMLStatement(); boost::algorithm::to_upper(stmt); trim(stmt); @@ -1288,7 +1314,7 @@ void DMLProcessor::operator()() { if (packageType != dmlpackage::DML_COMMAND) { - txnid = sessionManager.getTxnID(sessionID); + txnid = sessionManager.getTxnID(sessionID); if ( !txnid.valid ) { txnid = sessionManager.newTxnID(sessionID, true); diff --git a/writeengine/server/we_ddlcommandproc.cpp b/writeengine/server/we_ddlcommandproc.cpp index f688c54a1..c8a6e3add 100644 --- a/writeengine/server/we_ddlcommandproc.cpp +++ b/writeengine/server/we_ddlcommandproc.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -159,8 +160,8 @@ uint8_t WE_DDLCommandProc::writeSystable(ByteStream& bs, std::string &err) getColumnsForTable(sessionID, tableName.schema,tableName.table, columns); - column_iterator = columns.begin(); - std::string tmpStr(""); + column_iterator = columns.begin(); + std::string tmpStr(""); while (column_iterator != columns.end()) { @@ -278,13 +279,17 @@ uint8_t WE_DDLCommandProc::writeSystable(ByteStream& bs, std::string &err) ++column_iterator; } - //fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3); + //fWEWrapper.setDebugLevel(WriteEngine::DEBUG_3); fWEWrapper.setTransId(txnID); fWEWrapper.setIsInsert(true); fWEWrapper.setBulkFlag(false); fWEWrapper.startTransaction(txnID); if (0 != colStructs.size()) { + // MCOL-66 The DBRM can't handle concurrent transactions to sys tables + // TODO: This may be redundant + static boost::mutex dbrmMutex; + boost::mutex::scoped_lock lk(dbrmMutex); error = fWEWrapper.insertColumnRec_SYS(txnID, colStructs, colValuesList, dctnryStructList, dctnryValueList, SYSCOLUMN_BASE); @@ -683,7 +688,7 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string &err colValuesList.push_back(colList[n]); dctnryValueList.push_back(dctColList[n]); } - //fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3); + //fWEWrapper.setDebugLevel(WriteEngine::DEBUG_3); error = fWEWrapper.insertColumnRec_SYS(txnID, colStructs, colValuesList, dctnryStructList, dctnryValueList, SYSCOLUMN_BASE); @@ -1042,7 +1047,7 @@ uint8_t WE_DDLCommandProc::writeSyscolumn(ByteStream& bs, std::string & err) colValuesList.push_back(colList[n]); dctnryValueList.push_back(dctColList[n]); } - //fWriteEngine.setDebugLevel(WriteEngine::DEBUG_3); + //fWEWrapper.setDebugLevel(WriteEngine::DEBUG_3); fWEWrapper.setTransId(txnID); fWEWrapper.setIsInsert(true); fWEWrapper.setBulkFlag(false); diff --git a/writeengine/server/we_dmlcommandproc.cpp b/writeengine/server/we_dmlcommandproc.cpp index 1c61b8f26..bb4bd89ec 100644 --- a/writeengine/server/we_dmlcommandproc.cpp +++ b/writeengine/server/we_dmlcommandproc.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -3068,10 +3069,10 @@ uint8_t WE_DMLCommandProc::processBulkRollback(messageqcpp::ByteStream& bs, // but it shouldn't hurt to keep in here. std::cout << "processBulkRollback"; bs >> tableLockID; - std::cout << ": tableLock-"<< tableLockID; + //std::cout << ": tableLock-"<< tableLockID; bs >> tableOID; - std::cout << "; tableOID-" << tableOID; + //std::cout << "; tableOID-" << tableOID; bs >> tableName; if (tableName.length() == 0) diff --git a/writeengine/wrapper/writeengine.cpp b/writeengine/wrapper/writeengine.cpp index bbd168638..d4d0e3553 100644 --- a/writeengine/wrapper/writeengine.cpp +++ b/writeengine/wrapper/writeengine.cpp @@ -1,4 +1,5 @@ /* Copyright (C) 2014 InfiniDB, Inc. + Copyright (C) 2016 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -1955,6 +1956,9 @@ timer.stop("tokenize"); if (rc == NO_ERROR) { + // MCOL-66 The DBRM can't handle concurrent transactions to sys tables + static boost::mutex dbrmMutex; + boost::mutex::scoped_lock lk(dbrmMutex); if (newExtent) { rc = writeColumnRec(txnid, colStructList, colOldValueList, rowIdArray, newColStructList, colNewValueList, tableOid, false); // @bug 5572 HDFS tmp file