From: Brian Aker Date: Mon, 10 Sep 2012 07:42:54 +0000 (-0400) Subject: Fix case where --socket was not always been stored correctly. X-Git-Tag: 1.0.11~1^2~6 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=850df1fbab46a5a658c2fd0c35164ef1c60a22d9;p=awesomized%2Flibmemcached Fix case where --socket was not always been stored correctly. --- diff --git a/libmemcached/backtrace.cc b/libmemcached/backtrace.cc index 3924e0b0..871f27af 100644 --- a/libmemcached/backtrace.cc +++ b/libmemcached/backtrace.cc @@ -59,7 +59,7 @@ void custom_backtrace(void) #ifdef HAVE_EXECINFO_H void *array[50]; - size_t size= backtrace(array, 50); + int size= backtrace(array, 50); char **strings= backtrace_symbols(array, size); if (strings == NULL) @@ -67,7 +67,7 @@ void custom_backtrace(void) return; } - fprintf(stderr, "Number of stack frames obtained: %lu\n", (unsigned long)size); + fprintf(stderr, "Number of stack frames obtained: %d\n", size); char *named_function= (char *)std::realloc(NULL, 1024); @@ -77,7 +77,7 @@ void custom_backtrace(void) return; } - for (size_t x= 1; x < size; x++) + for (int x= 1; x < size; x++) { if (USE_DEMANGLE) { diff --git a/libmemcached/csl/context.cc b/libmemcached/csl/context.cc index 1e6e18ae..16852d5b 100644 --- a/libmemcached/csl/context.cc +++ b/libmemcached/csl/context.cc @@ -97,13 +97,29 @@ void Context::error(const char *error_arg, yytokentype last_token, const char *l } } -const char *Context::set_hostname(const char *str, size_t size) +void Context::hostname(const char *str, size_t size, server_t& server_) { size_t copy_length= size_t(NI_MAXHOST) > size ? size : size_t(NI_MAXHOST); memcpy(_hostname, str, copy_length); _hostname[copy_length]= 0; - return _hostname; + server_.port= MEMCACHED_DEFAULT_PORT; + server_.weight= 1; + server_.c_str= _hostname; + server_.size= size; +} + +bool Context::string_buffer(const char *str, size_t size, memcached_string_t& string_) +{ + if (memcached_string_set(_string_buffer, str, size)) + { + string_.c_str= memcached_string_value(_string_buffer); + string_.size= memcached_string_length(_string_buffer); + + return true; + } + + return false; } bool Context::set_hash(memcached_hash_t hash) diff --git a/libmemcached/csl/context.h b/libmemcached/csl/context.h index 12e028dd..97303c50 100644 --- a/libmemcached/csl/context.h +++ b/libmemcached/csl/context.h @@ -43,26 +43,28 @@ class Context { public: - Context(const char *option_string, size_t option_string_length, memcached_st *memc_arg, + Context(const char *option_string, size_t option_string_length, memcached_st *memc_, memcached_return_t &rc_arg) : previous_token(END), scanner(NULL), + buf(option_string), begin(NULL), pos(0), - memc(NULL), + length(option_string_length), + memc(memc_), rc(rc_arg), _is_server(false), _end(false), _has_hash(false) { _hostname[0]= 0; - buf= option_string; - length= option_string_length; - memc= memc_arg; init_scanner(); rc= MEMCACHED_SUCCESS; memc->state.is_parsing= true; + memcached_string_create(memc, + &_string_buffer, + 1024); } bool end() @@ -95,7 +97,9 @@ public: return _is_server; } - const char *set_hostname(const char *str, size_t size); + void hostname(const char*, size_t, server_t&); + + bool string_buffer(const char*, size_t, memcached_string_t&); const char *hostname() const { @@ -107,6 +111,7 @@ public: ~Context() { + memcached_string_free(&_string_buffer); destroy_scanner(); memc->state.is_parsing= false; } @@ -129,4 +134,5 @@ private: bool _end; char _hostname[NI_MAXHOST]; bool _has_hash; + memcached_string_st _string_buffer; }; diff --git a/libmemcached/csl/parser.cc b/libmemcached/csl/parser.cc index 92662144..87d08dbe 100644 --- a/libmemcached/csl/parser.cc +++ b/libmemcached/csl/parser.cc @@ -1664,7 +1664,7 @@ yyreduce: if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, (yyvsp[(2) - (3)].string).c_str, (yyvsp[(3) - (3)].number)))) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "Failed to add server: %s", (yyvsp[(2) - (3)].string).c_str); + snprintf(buffer, sizeof(buffer), "Failed to add socket: %s", (yyvsp[(2) - (3)].string).c_str); parser_abort(context, buffer); } } diff --git a/libmemcached/csl/parser.yy b/libmemcached/csl/parser.yy index e70bba97..d263aea4 100644 --- a/libmemcached/csl/parser.yy +++ b/libmemcached/csl/parser.yy @@ -251,7 +251,7 @@ expression: if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, $2.c_str, $3))) { char buffer[1024]; - snprintf(buffer, sizeof(buffer), "Failed to add server: %s", $2.c_str); + snprintf(buffer, sizeof(buffer), "Failed to add socket: %s", $2.c_str); parser_abort(context, buffer); } } diff --git a/libmemcached/csl/scanner.cc b/libmemcached/csl/scanner.cc index 76242dfb..c391f48e 100644 --- a/libmemcached/csl/scanner.cc +++ b/libmemcached/csl/scanner.cc @@ -13,27 +13,17 @@ #pragma GCC diagnostic ignored "-Wmissing-declarations" #endif -#define YY_NO_INPUT - #define YY_EXTRA_TYPE Context* -#line 24 "libmemcached/csl/scanner.cc" +#line 22 "libmemcached/csl/scanner.cc" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ -/* %not-for-header */ - -/* %if-c-only */ -/* %if-not-reentrant */ -/* %endif */ -/* %endif */ -/* %ok-for-header */ - #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 @@ -42,32 +32,16 @@ #define FLEX_BETA #endif -/* %if-c++-only */ -/* %endif */ - -/* %if-c-only */ - -/* %endif */ - -/* %if-c-only */ - -/* %endif */ - /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ -/* %if-c-only */ #include #include #include #include -/* %endif */ -/* %if-tables-serialization */ -/* %endif */ /* end standard C headers. */ -/* %if-c-or-c++ */ /* flex integer type definitions */ #ifndef FLEXINT_H @@ -98,6 +72,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 @@ -128,15 +103,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ @@ -158,13 +126,8 @@ typedef unsigned int flex_uint32_t; #define yyconst #endif -/* %not-for-header */ - /* Returned upon end-of-file. */ #define YY_NULL 0 -/* %ok-for-header */ - -/* %not-for-header */ /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, @@ -172,9 +135,6 @@ typedef unsigned int flex_uint32_t; * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) -/* %ok-for-header */ - -/* %if-reentrant */ /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T @@ -193,11 +153,6 @@ typedef void* yyscan_t; #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yy_flex_debug yyg->yy_flex_debug_r -/* %endif */ - -/* %if-not-reentrant */ -/* %endif */ - /* 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. @@ -221,15 +176,7 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -241,14 +188,6 @@ typedef void* yyscan_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif -/* %if-not-reentrant */ -/* %endif */ - -/* %if-c-only */ -/* %if-not-reentrant */ -/* %endif */ -/* %endif */ - #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 @@ -280,12 +219,7 @@ typedef size_t yy_size_t; #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { -/* %if-c-only */ FILE *yy_input_file; -/* %endif */ - -/* %if-c++-only */ -/* %endif */ char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ @@ -346,15 +280,6 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -/* %if-c-only Standard (non-C++) definition */ -/* %not-for-header */ - -/* %if-not-reentrant */ -/* %endif */ -/* %ok-for-header */ - -/* %endif */ - /* 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". @@ -370,15 +295,6 @@ struct yy_buffer_state */ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] -/* %if-c-only Standard (non-C++) definition */ - -/* %if-not-reentrant */ -/* %not-for-header */ - -/* %ok-for-header */ - -/* %endif */ - void config_restart (FILE *input_file ,yyscan_t yyscanner ); void config__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); YY_BUFFER_STATE config__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); @@ -397,8 +313,6 @@ YY_BUFFER_STATE config__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscann YY_BUFFER_STATE config__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); -/* %endif */ - void *config_alloc (yy_size_t ,yyscan_t yyscanner ); void *config_realloc (void *,yy_size_t ,yyscan_t yyscanner ); void config_free (void * ,yyscan_t yyscanner ); @@ -427,42 +341,32 @@ void config_free (void * ,yyscan_t yyscanner ); #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) -/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ /* Begin user sect3 */ #define config_wrap(n) 1 #define YY_SKIP_YYWRAP -#define FLEX_DEBUG - typedef unsigned char YY_CHAR; typedef int yy_state_type; #define yytext_ptr yytext_r -/* %if-c-only Standard (non-C++) definition */ - 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 ); -/* %endif */ - /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ -/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\ yyleng = (size_t) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ -/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ yyg->yy_c_buf_p = yy_cp; -/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ #define YY_NUM_RULES 66 #define YY_END_OF_BUFFER 67 /* This struct is not used in this scanner, @@ -1113,17 +1017,6 @@ static yyconst flex_int16_t yy_chk[1815] = 533, 533, 533, 533 } ; -static yyconst flex_int16_t yy_rule_linenum[66] = - { 0, - 99, 101, 103, 105, 107, 110, 114, 116, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, - 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, - 140, 141, 142, 143, 144, 145, 147, 148, 150, 152, - 154, 155, 156, 157, 158, 159, 161, 162, 165, 170, - 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, - 182, 184, 193, 211, 218 - } ; - /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ @@ -1168,7 +1061,7 @@ static yyconst flex_int16_t yy_rule_linenum[66] = * */ -#line 60 "libmemcached/csl/scanner.l" +#line 58 "libmemcached/csl/scanner.l" #include #include @@ -1189,10 +1082,15 @@ static yyconst flex_int16_t yy_rule_linenum[66] = } \ } +#define YY_FATAL_ERROR(msg) \ +{ \ +} + #define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM) -#line 1196 "libmemcached/csl/scanner.cc" +#define YY_NO_INPUT 1 +#line 1094 "libmemcached/csl/scanner.cc" #define INITIAL 0 @@ -1201,20 +1099,13 @@ static yyconst flex_int16_t yy_rule_linenum[66] = * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ -/* %if-c-only */ #include -/* %endif */ -/* %if-c++-only */ -/* %endif */ #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif -/* %if-c-only Reentrant structure and macros (non-C++). */ -/* %if-reentrant */ - /* Holds the entire state of the reentrant scanner. */ struct yyguts_t { @@ -1251,14 +1142,8 @@ struct yyguts_t }; /* end struct yyguts_t */ -/* %if-c-only */ - static int yy_init_globals (yyscan_t yyscanner ); -/* %endif */ - -/* %if-reentrant */ - /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ # define yylval yyg->yylval_r @@ -1267,10 +1152,6 @@ int config_lex_init (yyscan_t* scanner); int config_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); -/* %endif */ - -/* %endif End reentrant structures and macros. */ - /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ @@ -1300,14 +1181,14 @@ int config_get_lineno (yyscan_t yyscanner ); void config_set_lineno (int line_number ,yyscan_t yyscanner ); -/* %if-bison-bridge */ +int config_get_column (yyscan_t yyscanner ); + +void config_set_column (int column_no ,yyscan_t yyscanner ); YYSTYPE * config_get_lval (yyscan_t yyscanner ); void config_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); -/* %endif */ - /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -1320,12 +1201,6 @@ extern int config_wrap (yyscan_t yyscanner ); #endif #endif -/* %not-for-header */ - -/* %ok-for-header */ - -/* %endif */ - #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif @@ -1335,43 +1210,26 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT -/* %if-c-only Standard (non-C++) definition */ -/* %not-for-header */ #ifdef __cplusplus static int yyinput (yyscan_t yyscanner ); #else static int input (yyscan_t yyscanner ); #endif -/* %ok-for-header */ -/* %endif */ #endif -/* %if-c-only */ - -/* %endif */ - /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO -/* %if-c-only Standard (non-C++) definition */ /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) -/* %endif */ -/* %if-c++-only C++ definition */ -/* %endif */ #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1379,11 +1237,10 @@ static int input (yyscan_t yyscanner ); */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ -/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + unsigned n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1408,8 +1265,6 @@ static int input (yyscan_t yyscanner ); } \ }\ \ -/* %if-c++-only C++ definition \ */\ -/* %endif */ #endif @@ -1428,41 +1283,22 @@ static int input (yyscan_t yyscanner ); /* Report a fatal error. */ #ifndef YY_FATAL_ERROR -/* %if-c-only */ #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ #endif -/* %if-tables-serialization structures and prototypes */ -/* %not-for-header */ - -/* %ok-for-header */ - -/* %not-for-header */ - -/* %tables-yydmap generated elements */ -/* %endif */ /* end tables serialization structures and prototypes */ -/* %ok-for-header */ - /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -/* %if-c-only Standard (non-C++) definition */ extern int config_lex \ (YYSTYPE * yylval_param ,yyscan_t yyscanner); #define YY_DECL int config_lex \ (YYSTYPE * yylval_param , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only C++ definition */ -/* %endif */ #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -1477,15 +1313,12 @@ extern int config_lex \ #define YY_BREAK break; #endif -/* %% [6.0] YY_RULE_SETUP definition goes here */ #define YY_RULE_SETUP \ if ( yyleng > 0 ) \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION -/* %not-for-header */ - /** The main scanner function which does all the work. */ YY_DECL @@ -1495,12 +1328,11 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -/* %% [7.0] user's declarations go here */ -#line 96 "libmemcached/csl/scanner.l" +#line 100 "libmemcached/csl/scanner.l" -#line 1504 "libmemcached/csl/scanner.cc" +#line 1336 "libmemcached/csl/scanner.cc" yylval = yylval_param; @@ -1516,18 +1348,10 @@ YY_DECL yyg->yy_start = 1; /* first start state */ if ( ! yyin ) -/* %if-c-only */ yyin = stdin; -/* %endif */ -/* %if-c++-only */ -/* %endif */ if ( ! yyout ) -/* %if-c-only */ yyout = stdout; -/* %endif */ -/* %if-c++-only */ -/* %endif */ if ( ! YY_CURRENT_BUFFER ) { config_ensure_buffer_stack (yyscanner); @@ -1540,7 +1364,6 @@ YY_DECL while ( 1 ) /* loops until end-of-file is reached */ { -/* %% [8.0] yymore()-related code goes here */ yy_cp = yyg->yy_c_buf_p; /* Support of yytext. */ @@ -1551,7 +1374,6 @@ YY_DECL */ yy_bp = yy_cp; -/* %% [9.0] code to set up and find next match goes here */ yy_current_state = yyg->yy_start; yy_current_state += YY_AT_BOL(); yy_match: @@ -1572,44 +1394,19 @@ yy_match: yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 1740 ); + while ( yy_current_state != 533 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; yy_find_action: -/* %% [10.0] code to find the action number goes here */ yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } YY_DO_BEFORE_ACTION; -/* %% [11.0] code for yylineno update goes here */ - do_action: /* This label is used only to access EOF actions. */ -/* %% [12.0] debug code goes here */ - if ( yy_flex_debug ) - { - if ( yy_act == 0 ) - fprintf( stderr, "--scanner backing up\n" ); - else if ( yy_act < 66 ) - fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], yytext ); - else if ( yy_act == 66 ) - fprintf( stderr, "--accepting default rule (\"%s\")\n", - yytext ); - else if ( yy_act == 67 ) - fprintf( stderr, "--(end of buffer or a NUL)\n" ); - else - fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); - } - switch ( yy_act ) { /* beginning of action switch */ -/* %% [13.0] actions go here */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yyg->yy_hold_char; @@ -1619,28 +1416,28 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 99 "libmemcached/csl/scanner.l" +#line 103 "libmemcached/csl/scanner.l" { return yytext[0];} YY_BREAK case 2: YY_RULE_SETUP -#line 101 "libmemcached/csl/scanner.l" +#line 105 "libmemcached/csl/scanner.l" { yylval->number= atoi(yytext); return (NUMBER); } YY_BREAK case 3: YY_RULE_SETUP -#line 103 "libmemcached/csl/scanner.l" +#line 107 "libmemcached/csl/scanner.l" { yylval->number= atoi(yytext +1); return PORT; } YY_BREAK case 4: YY_RULE_SETUP -#line 105 "libmemcached/csl/scanner.l" +#line 109 "libmemcached/csl/scanner.l" { yylval->number= atoi(yytext +2); return WEIGHT_START; } YY_BREAK case 5: /* rule 5 can match eol */ YY_RULE_SETUP -#line 107 "libmemcached/csl/scanner.l" +#line 111 "libmemcached/csl/scanner.l" ; /* skip whitespace */ YY_BREAK case 6: @@ -1648,224 +1445,224 @@ case 6: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 110 "libmemcached/csl/scanner.l" +#line 114 "libmemcached/csl/scanner.l" { return COMMENT; } YY_BREAK case 7: YY_RULE_SETUP -#line 114 "libmemcached/csl/scanner.l" +#line 118 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; yyextra->set_server(); return yyextra->previous_token= SERVER; } YY_BREAK case 8: YY_RULE_SETUP -#line 116 "libmemcached/csl/scanner.l" +#line 120 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET; } YY_BREAK case 9: YY_RULE_SETUP -#line 118 "libmemcached/csl/scanner.l" +#line 122 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= BINARY_PROTOCOL; } YY_BREAK case 10: YY_RULE_SETUP -#line 119 "libmemcached/csl/scanner.l" +#line 123 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= BUFFER_REQUESTS; } YY_BREAK case 11: YY_RULE_SETUP -#line 120 "libmemcached/csl/scanner.l" +#line 124 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= CONFIGURE_FILE; } YY_BREAK case 12: YY_RULE_SETUP -#line 121 "libmemcached/csl/scanner.l" +#line 125 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= CONNECT_TIMEOUT; } YY_BREAK case 13: YY_RULE_SETUP -#line 122 "libmemcached/csl/scanner.l" +#line 126 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= DISTRIBUTION; } YY_BREAK case 14: YY_RULE_SETUP -#line 123 "libmemcached/csl/scanner.l" +#line 127 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= HASH_WITH_NAMESPACE; } YY_BREAK case 15: YY_RULE_SETUP -#line 124 "libmemcached/csl/scanner.l" +#line 128 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= HASH; } YY_BREAK case 16: YY_RULE_SETUP -#line 125 "libmemcached/csl/scanner.l" +#line 129 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= IO_BYTES_WATERMARK; } YY_BREAK case 17: YY_RULE_SETUP -#line 126 "libmemcached/csl/scanner.l" +#line 130 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= IO_KEY_PREFETCH; } YY_BREAK case 18: YY_RULE_SETUP -#line 127 "libmemcached/csl/scanner.l" +#line 131 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= IO_MSG_WATERMARK; } YY_BREAK case 19: YY_RULE_SETUP -#line 128 "libmemcached/csl/scanner.l" +#line 132 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= NOREPLY; } YY_BREAK case 20: YY_RULE_SETUP -#line 129 "libmemcached/csl/scanner.l" +#line 133 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= NUMBER_OF_REPLICAS; } YY_BREAK case 21: YY_RULE_SETUP -#line 130 "libmemcached/csl/scanner.l" +#line 134 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= POLL_TIMEOUT; } YY_BREAK case 22: YY_RULE_SETUP -#line 131 "libmemcached/csl/scanner.l" +#line 135 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RANDOMIZE_REPLICA_READ; } YY_BREAK case 23: YY_RULE_SETUP -#line 132 "libmemcached/csl/scanner.l" +#line 136 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RCV_TIMEOUT; } YY_BREAK case 24: YY_RULE_SETUP -#line 133 "libmemcached/csl/scanner.l" +#line 137 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= REMOVE_FAILED_SERVERS; } YY_BREAK case 25: YY_RULE_SETUP -#line 134 "libmemcached/csl/scanner.l" +#line 138 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RETRY_TIMEOUT; } YY_BREAK case 26: YY_RULE_SETUP -#line 135 "libmemcached/csl/scanner.l" +#line 139 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SND_TIMEOUT; } YY_BREAK case 27: YY_RULE_SETUP -#line 136 "libmemcached/csl/scanner.l" +#line 140 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_RECV_SIZE; } YY_BREAK case 28: YY_RULE_SETUP -#line 137 "libmemcached/csl/scanner.l" +#line 141 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_SEND_SIZE; } YY_BREAK case 29: YY_RULE_SETUP -#line 138 "libmemcached/csl/scanner.l" +#line 142 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SORT_HOSTS; } YY_BREAK case 30: YY_RULE_SETUP -#line 139 "libmemcached/csl/scanner.l" +#line 143 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SUPPORT_CAS; } YY_BREAK case 31: YY_RULE_SETUP -#line 140 "libmemcached/csl/scanner.l" +#line 144 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPALIVE; } YY_BREAK case 32: YY_RULE_SETUP -#line 141 "libmemcached/csl/scanner.l" +#line 145 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPIDLE; } YY_BREAK case 33: YY_RULE_SETUP -#line 142 "libmemcached/csl/scanner.l" +#line 146 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_NODELAY; } YY_BREAK case 34: YY_RULE_SETUP -#line 143 "libmemcached/csl/scanner.l" +#line 147 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= USE_UDP; } YY_BREAK case 35: YY_RULE_SETUP -#line 144 "libmemcached/csl/scanner.l" +#line 148 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= USER_DATA; } YY_BREAK case 36: YY_RULE_SETUP -#line 145 "libmemcached/csl/scanner.l" +#line 149 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= VERIFY_KEY; } YY_BREAK case 37: YY_RULE_SETUP -#line 147 "libmemcached/csl/scanner.l" +#line 151 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MIN; } YY_BREAK case 38: YY_RULE_SETUP -#line 148 "libmemcached/csl/scanner.l" +#line 152 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MAX; } YY_BREAK case 39: YY_RULE_SETUP -#line 150 "libmemcached/csl/scanner.l" +#line 154 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= NAMESPACE; } YY_BREAK case 40: YY_RULE_SETUP -#line 152 "libmemcached/csl/scanner.l" +#line 156 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= FETCH_VERSION; } YY_BREAK case 41: YY_RULE_SETUP -#line 154 "libmemcached/csl/scanner.l" +#line 158 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= INCLUDE; } YY_BREAK case 42: YY_RULE_SETUP -#line 155 "libmemcached/csl/scanner.l" +#line 159 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RESET; } YY_BREAK case 43: YY_RULE_SETUP -#line 156 "libmemcached/csl/scanner.l" +#line 160 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= PARSER_DEBUG; } YY_BREAK case 44: YY_RULE_SETUP -#line 157 "libmemcached/csl/scanner.l" +#line 161 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SERVERS; } YY_BREAK case 45: YY_RULE_SETUP -#line 158 "libmemcached/csl/scanner.l" +#line 162 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= END; } YY_BREAK case 46: YY_RULE_SETUP -#line 159 "libmemcached/csl/scanner.l" +#line 163 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= ERROR; } YY_BREAK case 47: YY_RULE_SETUP -#line 161 "libmemcached/csl/scanner.l" +#line 165 "libmemcached/csl/scanner.l" { return yyextra->previous_token= TRUE; } YY_BREAK case 48: YY_RULE_SETUP -#line 162 "libmemcached/csl/scanner.l" +#line 166 "libmemcached/csl/scanner.l" { return yyextra->previous_token= FALSE; } YY_BREAK case 49: YY_RULE_SETUP -#line 165 "libmemcached/csl/scanner.l" +#line 169 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return UNKNOWN_OPTION; @@ -1873,73 +1670,69 @@ YY_RULE_SETUP YY_BREAK case 50: YY_RULE_SETUP -#line 170 "libmemcached/csl/scanner.l" +#line 174 "libmemcached/csl/scanner.l" { return CONSISTENT; } YY_BREAK case 51: YY_RULE_SETUP -#line 171 "libmemcached/csl/scanner.l" +#line 175 "libmemcached/csl/scanner.l" { return MODULA; } YY_BREAK case 52: YY_RULE_SETUP -#line 172 "libmemcached/csl/scanner.l" +#line 176 "libmemcached/csl/scanner.l" { return RANDOM; } YY_BREAK case 53: YY_RULE_SETUP -#line 174 "libmemcached/csl/scanner.l" +#line 178 "libmemcached/csl/scanner.l" { return MD5; } YY_BREAK case 54: YY_RULE_SETUP -#line 175 "libmemcached/csl/scanner.l" +#line 179 "libmemcached/csl/scanner.l" { return CRC; } YY_BREAK case 55: YY_RULE_SETUP -#line 176 "libmemcached/csl/scanner.l" +#line 180 "libmemcached/csl/scanner.l" { return FNV1_64; } YY_BREAK case 56: YY_RULE_SETUP -#line 177 "libmemcached/csl/scanner.l" +#line 181 "libmemcached/csl/scanner.l" { return FNV1A_64; } YY_BREAK case 57: YY_RULE_SETUP -#line 178 "libmemcached/csl/scanner.l" +#line 182 "libmemcached/csl/scanner.l" { return FNV1_32; } YY_BREAK case 58: YY_RULE_SETUP -#line 179 "libmemcached/csl/scanner.l" +#line 183 "libmemcached/csl/scanner.l" { return FNV1A_32; } YY_BREAK case 59: YY_RULE_SETUP -#line 180 "libmemcached/csl/scanner.l" +#line 184 "libmemcached/csl/scanner.l" { return HSIEH; } YY_BREAK case 60: YY_RULE_SETUP -#line 181 "libmemcached/csl/scanner.l" +#line 185 "libmemcached/csl/scanner.l" { return MURMUR; } YY_BREAK case 61: YY_RULE_SETUP -#line 182 "libmemcached/csl/scanner.l" +#line 186 "libmemcached/csl/scanner.l" { return JENKINS; } YY_BREAK case 62: YY_RULE_SETUP -#line 184 "libmemcached/csl/scanner.l" +#line 188 "libmemcached/csl/scanner.l" { - yylval->server.port= MEMCACHED_DEFAULT_PORT; - yylval->server.weight= 1; - yylval->server.c_str= yyextra->set_hostname(yytext, yyleng); - if (yylval->server.c_str) - yylval->server.size= yyleng; + yyextra->hostname(yytext, yyleng, yylval->server); return IPADDRESS; } YY_BREAK @@ -1949,17 +1742,12 @@ YY_RULE_SETUP { if (yyextra->is_server()) { - yylval->server.port= MEMCACHED_DEFAULT_PORT; - yylval->server.weight= 1; - yylval->server.c_str= yyextra->set_hostname(yytext, yyleng); - if (yylval->server.c_str) - yylval->server.size= yyleng; + yyextra->hostname(yytext, yyleng, yylval->server); return HOSTNAME; } - yylval->string.c_str = yytext; - yylval->string.size = yyleng; + yyextra->string_buffer(yytext, yyleng, yylval->string); return STRING; } @@ -1967,17 +1755,16 @@ YY_RULE_SETUP case 64: /* rule 64 can match eol */ YY_RULE_SETUP -#line 211 "libmemcached/csl/scanner.l" +#line 206 "libmemcached/csl/scanner.l" { config_get_text(yyscanner)[yyleng -1]= 0; - yylval->string.c_str= yytext +1; - yylval->string.size= yyleng -2; + yyextra->string_buffer(yytext +1, yyleng -2, yylval->string); return QUOTED_STRING; } YY_BREAK case 65: YY_RULE_SETUP -#line 218 "libmemcached/csl/scanner.l" +#line 212 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return UNKNOWN; @@ -1985,10 +1772,10 @@ YY_RULE_SETUP YY_BREAK case 66: YY_RULE_SETUP -#line 223 "libmemcached/csl/scanner.l" +#line 217 "libmemcached/csl/scanner.l" ECHO; YY_BREAK -#line 1992 "libmemcached/csl/scanner.cc" +#line 1779 "libmemcached/csl/scanner.cc" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2055,8 +1842,8 @@ case YY_STATE_EOF(INITIAL): else { -/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */ - yy_cp = yyg->yy_c_buf_p; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; } } @@ -2121,14 +1908,6 @@ case YY_STATE_EOF(INITIAL): } /* end of action switch */ } /* end of scanning one token */ } /* end of config_lex */ -/* %ok-for-header */ - -/* %if-c++-only */ -/* %not-for-header */ - -/* %ok-for-header */ - -/* %endif */ /* yy_get_next_buffer - try to read in a new buffer * @@ -2137,11 +1916,7 @@ case YY_STATE_EOF(INITIAL): * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -/* %if-c-only */ static int yy_get_next_buffer (yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; @@ -2276,25 +2051,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* yy_get_previous_state - get the state just before the EOB char was reached */ -/* %if-c-only */ -/* %not-for-header */ - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { register yy_state_type yy_current_state; register char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -/* %% [15.0] code to get the start state into yy_current_state goes here */ yy_current_state = yyg->yy_start; yy_current_state += YY_AT_BOL(); for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { -/* %% [16.0] code to find the next state goes here */ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { @@ -2318,15 +2085,10 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * synopsis * next_state = yy_try_NUL_trans( current_state ); */ -/* %if-c-only */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { register int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ -/* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ register char *yy_cp = yyg->yy_c_buf_p; register YY_CHAR yy_c = 1; @@ -2347,11 +2109,6 @@ static int yy_get_next_buffer (yyscan_t yyscanner) return yy_is_jam ? 0 : yy_current_state; } -/* %if-c-only */ - -/* %endif */ - -/* %if-c-only */ #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (yyscan_t yyscanner) @@ -2359,9 +2116,6 @@ static int yy_get_next_buffer (yyscan_t yyscanner) static int input (yyscan_t yyscanner) #endif -/* %endif */ -/* %if-c++-only */ -/* %endif */ { int c; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2426,25 +2180,18 @@ static int yy_get_next_buffer (yyscan_t yyscanner) *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ yyg->yy_hold_char = *++yyg->yy_c_buf_p; -/* %% [19.0] update BOL and yylineno */ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); return c; } -/* %if-c-only */ #endif /* ifndef YY_NO_INPUT */ -/* %endif */ /** 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 . */ -/* %if-c-only */ void config_restart (FILE * input_file , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2462,11 +2209,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ -/* %if-c-only */ void config__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2498,11 +2241,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) yyg->yy_did_buffer_switch_on_eof = 1; } -/* %if-c-only */ static void config__load_buffer_state (yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; @@ -2517,11 +2256,7 @@ static void config__load_buffer_state (yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the allocated buffer state. */ -/* %if-c-only */ YY_BUFFER_STATE config__create_buffer (FILE * file, int size , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { YY_BUFFER_STATE b; @@ -2549,11 +2284,7 @@ static void config__load_buffer_state (yyscan_t yyscanner) * @param b a buffer created with config__create_buffer() * @param yyscanner The scanner object. */ -/* %if-c-only */ void config__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2569,26 +2300,11 @@ static void config__load_buffer_state (yyscan_t yyscanner) config_free((void *) b ,yyscanner ); } -/* %if-c-only */ - -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a config_restart() or at EOF. */ -/* %if-c-only */ static void config__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { int oerrno = errno; @@ -2608,13 +2324,8 @@ extern int isatty (int ); b->yy_bs_column = 0; } -/* %if-c-only */ - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + b->yy_is_interactive = 0; -/* %endif */ -/* %if-c++-only */ -/* %endif */ errno = oerrno; } @@ -2622,11 +2333,7 @@ extern int isatty (int ); * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ -/* %if-c-only */ void config__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) @@ -2650,18 +2357,13 @@ extern int isatty (int ); config__load_buffer_state(yyscanner ); } -/* %if-c-or-c++ */ /** 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. */ -/* %if-c-only */ void config_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) @@ -2687,18 +2389,12 @@ void config_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) config__load_buffer_state(yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } -/* %endif */ -/* %if-c-or-c++ */ /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * @param yyscanner The scanner object. */ -/* %if-c-only */ void config_pop_buffer_state (yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!YY_CURRENT_BUFFER) @@ -2714,17 +2410,11 @@ void config_pop_buffer_state (yyscan_t yyscanner) yyg->yy_did_buffer_switch_on_eof = 1; } } -/* %endif */ -/* %if-c-or-c++ */ /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -/* %if-c-only */ static void config_ensure_buffer_stack (yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ { int num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2767,9 +2457,7 @@ static void config_ensure_buffer_stack (yyscan_t yyscanner) yyg->yy_buffer_stack_max = num_to_alloc; } } -/* %endif */ -/* %if-c-only */ /** 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 @@ -2804,9 +2492,7 @@ YY_BUFFER_STATE config__scan_buffer (char * base, yy_size_t size , yyscan_t yy return b; } -/* %endif */ -/* %if-c-only */ /** Setup the input buffer state to scan a string. The next call to config_lex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan @@ -2820,13 +2506,11 @@ YY_BUFFER_STATE config__scan_string (yyconst char * yystr , yyscan_t yyscanner) return config__scan_bytes(yystr,strlen(yystr) ,yyscanner); } -/* %endif */ -/* %if-c-only */ /** Setup the input buffer state to scan the given bytes. The next call to config_lex() 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. */ @@ -2859,21 +2543,16 @@ YY_BUFFER_STATE config__scan_bytes (yyconst char * yybytes, int _yybytes_len , return b; } -/* %endif */ #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif -/* %if-c-only */ static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } -/* %endif */ -/* %if-c++-only */ -/* %endif */ /* Redefine yyless() so it works in section 3 code. */ @@ -2894,9 +2573,6 @@ static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) /* Accessor methods (get/set functions) to struct members. */ -/* %if-c-only */ -/* %if-reentrant */ - /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ @@ -2906,8 +2582,6 @@ YY_EXTRA_TYPE config_get_extra (yyscan_t yyscanner) return yyextra; } -/* %endif */ - /** Get the current line number. * @param yyscanner The scanner object. */ @@ -2971,8 +2645,6 @@ char *config_get_text (yyscan_t yyscanner) return yytext; } -/* %if-reentrant */ - /** 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. @@ -2983,8 +2655,6 @@ void config_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) yyextra = user_defined ; } -/* %endif */ - /** Set the current line number. * @param line_number * @param yyscanner The scanner object. @@ -3045,13 +2715,8 @@ void config_set_debug (int bdebug , yyscan_t yyscanner) yy_flex_debug = bdebug ; } -/* %endif */ - -/* %if-reentrant */ /* Accessor methods for yylval and yylloc */ -/* %if-bison-bridge */ - YYSTYPE * config_get_lval (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -3064,8 +2729,6 @@ void config_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) yylval = yylval_param; } -/* %endif */ - /* User-visible API */ /* config_lex_init is special because it creates the scanner itself, so it is @@ -3130,9 +2793,6 @@ int config_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals return yy_init_globals ( *ptr_yy_globals ); } -/* %endif if-c-only */ - -/* %if-c-only */ static int yy_init_globals (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -3165,9 +2825,7 @@ static int yy_init_globals (yyscan_t yyscanner) */ return 0; } -/* %endif */ -/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */ /* config_lex_destroy is for both reentrant and non-reentrant scanners. */ int config_lex_destroy (yyscan_t yyscanner) { @@ -3192,14 +2850,11 @@ int config_lex_destroy (yyscan_t yyscanner) * config_lex() is called, initialization will occur. */ yy_init_globals( yyscanner); -/* %if-reentrant */ /* Destroy the main struct (reentrant only). */ config_free ( yyscanner , yyscanner ); yyscanner = NULL; -/* %endif */ return 0; } -/* %endif */ /* * Internal utility routines. @@ -3247,14 +2902,9 @@ void config_free (void * ptr , yyscan_t yyscanner) free( (char *) ptr ); /* see config_realloc() for (char *) cast */ } -/* %if-tables-serialization definitions */ -/* %define-yytables The name for this specific scanner's tables. */ #define YYTABLES_NAME "yytables" -/* %endif */ - -/* %ok-for-header */ -#line 223 "libmemcached/csl/scanner.l" +#line 217 "libmemcached/csl/scanner.l" @@ -3266,6 +2916,7 @@ void Context::init_scanner() void Context::destroy_scanner() { + (void)yy_fatal_error; // Removes warning about unused yy_fatal_error() config_lex_destroy(scanner); } diff --git a/libmemcached/csl/scanner.h b/libmemcached/csl/scanner.h index 6aa08a64..ab895707 100644 --- a/libmemcached/csl/scanner.h +++ b/libmemcached/csl/scanner.h @@ -17,21 +17,17 @@ #pragma GCC diagnostic ignored "-Wmissing-declarations" #endif -#define YY_NO_INPUT - #define YY_EXTRA_TYPE Context* -#line 28 "libmemcached/csl/scanner.h" +#line 26 "libmemcached/csl/scanner.h" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ -/* %not-for-header */ - #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 @@ -40,32 +36,16 @@ #define FLEX_BETA #endif -/* %if-c++-only */ -/* %endif */ - -/* %if-c-only */ - -/* %endif */ - -/* %if-c-only */ - -/* %endif */ - /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ -/* %if-c-only */ #include #include #include #include -/* %endif */ -/* %if-tables-serialization */ -/* %endif */ /* end standard C headers. */ -/* %if-c-or-c++ */ /* flex integer type definitions */ #ifndef FLEXINT_H @@ -96,6 +76,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 @@ -126,15 +107,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ @@ -156,12 +130,6 @@ typedef unsigned int flex_uint32_t; #define yyconst #endif -/* %not-for-header */ - -/* %not-for-header */ - -/* %if-reentrant */ - /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T @@ -179,22 +147,9 @@ typedef void* yyscan_t; #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yy_flex_debug yyg->yy_flex_debug_r -/* %endif */ - -/* %if-not-reentrant */ -/* %endif */ - /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif #ifndef YY_TYPEDEF_YY_BUFFER_STATE @@ -202,14 +157,6 @@ typedef void* yyscan_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif -/* %if-not-reentrant */ -/* %endif */ - -/* %if-c-only */ -/* %if-not-reentrant */ -/* %endif */ -/* %endif */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; @@ -219,12 +166,7 @@ typedef size_t yy_size_t; #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { -/* %if-c-only */ FILE *yy_input_file; -/* %endif */ - -/* %if-c++-only */ -/* %endif */ char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ @@ -271,18 +213,6 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -/* %if-c-only Standard (non-C++) definition */ -/* %not-for-header */ - -/* %endif */ - -/* %if-c-only Standard (non-C++) definition */ - -/* %if-not-reentrant */ -/* %not-for-header */ - -/* %endif */ - void config_restart (FILE *input_file ,yyscan_t yyscanner ); void config__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); YY_BUFFER_STATE config__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); @@ -295,26 +225,17 @@ YY_BUFFER_STATE config__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscann YY_BUFFER_STATE config__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); -/* %endif */ - void *config_alloc (yy_size_t ,yyscan_t yyscanner ); void *config_realloc (void *,yy_size_t ,yyscan_t yyscanner ); void config_free (void * ,yyscan_t yyscanner ); -/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ /* Begin user sect3 */ #define config_wrap(n) 1 #define YY_SKIP_YYWRAP -#define FLEX_DEBUG - #define yytext_ptr yytext_r -/* %if-c-only Standard (non-C++) definition */ - -/* %endif */ - #ifdef YY_HEADER_EXPORT_START_CONDITIONS #define INITIAL 0 @@ -325,34 +246,17 @@ void config_free (void * ,yyscan_t yyscanner ); * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ -/* %if-c-only */ #include -/* %endif */ -/* %if-c++-only */ -/* %endif */ #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif -/* %if-c-only Reentrant structure and macros (non-C++). */ -/* %if-reentrant */ - -/* %if-c-only */ - -/* %endif */ - -/* %if-reentrant */ - int config_lex_init (yyscan_t* scanner); int config_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); -/* %endif */ - -/* %endif End reentrant structures and macros. */ - /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ @@ -382,14 +286,14 @@ int config_get_lineno (yyscan_t yyscanner ); void config_set_lineno (int line_number ,yyscan_t yyscanner ); -/* %if-bison-bridge */ +int config_get_column (yyscan_t yyscanner ); + +void config_set_column (int column_no ,yyscan_t yyscanner ); YYSTYPE * config_get_lval (yyscan_t yyscanner ); void config_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); -/* %endif */ - /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -402,10 +306,6 @@ extern int config_wrap (yyscan_t yyscanner ); #endif #endif -/* %not-for-header */ - -/* %endif */ - #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif @@ -415,24 +315,12 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT -/* %if-c-only Standard (non-C++) definition */ -/* %not-for-header */ -/* %endif */ #endif -/* %if-c-only */ - -/* %endif */ - /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Number of entries by which start-condition stack grows. */ @@ -440,40 +328,21 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #define YY_START_STACK_INCR 25 #endif -/* %if-tables-serialization structures and prototypes */ -/* %not-for-header */ - -/* %not-for-header */ - /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -/* %if-c-only Standard (non-C++) definition */ extern int config_lex \ (YYSTYPE * yylval_param ,yyscan_t yyscanner); #define YY_DECL int config_lex \ (YYSTYPE * yylval_param , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only C++ definition */ -/* %endif */ #endif /* !YY_DECL */ -/* %not-for-header */ - -/* %if-c++-only */ -/* %not-for-header */ - -/* %endif */ - /* yy_get_previous_state - get the state just before the EOB char was reached */ -/* %if-c-only */ -/* %not-for-header */ - #undef YY_NEW_FILE #undef YY_FLUSH_BUFFER #undef yy_set_bol @@ -486,9 +355,9 @@ extern int config_lex \ #undef YY_DECL #endif -#line 223 "libmemcached/csl/scanner.l" +#line 217 "libmemcached/csl/scanner.l" -#line 493 "libmemcached/csl/scanner.h" +#line 362 "libmemcached/csl/scanner.h" #undef config_IN_HEADER #endif /* config_HEADER_H */ diff --git a/libmemcached/csl/scanner.l b/libmemcached/csl/scanner.l index 8e404b5f..c5ae5cef 100644 --- a/libmemcached/csl/scanner.l +++ b/libmemcached/csl/scanner.l @@ -49,8 +49,6 @@ #pragma GCC diagnostic ignored "-Wmissing-declarations" #endif -#define YY_NO_INPUT - #define YY_EXTRA_TYPE Context* } @@ -77,6 +75,10 @@ } \ } +#define YY_FATAL_ERROR(msg) \ +{ \ +} + #define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM) @@ -84,14 +86,16 @@ %option 8bit %option bison-bridge +%option never-interactive %option case-insensitive -%option debug +%option noinput %option nounput %option noyywrap %option outfile="libmemcached/csl/scanner.cc" header-file="libmemcached/csl/scanner.h" %option perf-report %option prefix="config_" %option reentrant +%option warn %% @@ -182,36 +186,26 @@ MURMUR { return MURMUR; } JENKINS { return JENKINS; } (([[:digit:]]{1,3}"."){3}([[:digit:]]{1,3})) { - yylval->server.port= MEMCACHED_DEFAULT_PORT; - yylval->server.weight= 1; - yylval->server.c_str= yyextra->set_hostname(yytext, yyleng); - if (yylval->server.c_str) - yylval->server.size= yyleng; + yyextra->hostname(yytext, yyleng, yylval->server); return IPADDRESS; } [[:alnum:]]["."[:alnum:]_-]+[[:alnum:]] { if (yyextra->is_server()) { - yylval->server.port= MEMCACHED_DEFAULT_PORT; - yylval->server.weight= 1; - yylval->server.c_str= yyextra->set_hostname(yytext, yyleng); - if (yylval->server.c_str) - yylval->server.size= yyleng; + yyextra->hostname(yytext, yyleng, yylval->server); return HOSTNAME; } - yylval->string.c_str = yytext; - yylval->string.size = yyleng; + yyextra->string_buffer(yytext, yyleng, yylval->string); return STRING; } L?\"(\\.|[^\\"])*\" { yyget_text(yyscanner)[yyleng -1]= 0; - yylval->string.c_str= yytext +1; - yylval->string.size= yyleng -2; + yyextra->string_buffer(yytext +1, yyleng -2, yylval->string); return QUOTED_STRING; } @@ -230,6 +224,7 @@ void Context::init_scanner() void Context::destroy_scanner() { + (void)yy_fatal_error; // Removes warning about unused yy_fatal_error() yylex_destroy(scanner); } diff --git a/libmemcached/csl/server.h b/libmemcached/csl/server.h index 92f7ed56..fe97eb91 100644 --- a/libmemcached/csl/server.h +++ b/libmemcached/csl/server.h @@ -42,8 +42,8 @@ struct server_t { - in_port_t port; - uint32_t weight; const char *c_str; size_t size; + in_port_t port; + uint32_t weight; }; diff --git a/libmemcached/server.cc b/libmemcached/server.cc index f68e1f6b..20db52b8 100644 --- a/libmemcached/server.cc +++ b/libmemcached/server.cc @@ -194,10 +194,12 @@ uint32_t memcached_server_count(const memcached_st *self) const char *memcached_server_name(const memcached_server_instance_st self) { WATCHPOINT_ASSERT(self); - if (self == NULL) - return NULL; + if (self) + { + return self->hostname; + } - return self->hostname; + return NULL; } in_port_t memcached_server_port(const memcached_server_instance_st self) diff --git a/libmemcached/string.cc b/libmemcached/string.cc index 268a437f..1c44e996 100644 --- a/libmemcached/string.cc +++ b/libmemcached/string.cc @@ -122,6 +122,18 @@ memcached_string_st *memcached_string_create(memcached_st *memc, memcached_strin return self; } +static memcached_return_t memcached_string_append_null(memcached_string_st& string) +{ + if (memcached_failed(_string_check(&string, 1))) + { + return MEMCACHED_MEMORY_ALLOCATION_FAILURE; + } + + *string.end= 0; + + return MEMCACHED_SUCCESS; +} + static memcached_return_t memcached_string_append_null(memcached_string_st *string) { if (memcached_failed(_string_check(string, 1))) @@ -186,6 +198,18 @@ char *memcached_string_c_copy(memcached_string_st *string) return c_ptr; } +bool memcached_string_set(memcached_string_st& string, const char* value, size_t length) +{ + memcached_string_reset(&string); + if (memcached_success(memcached_string_append(&string, value, length))) + { + memcached_string_append_null(string); + return true; + } + + return false; +} + void memcached_string_reset(memcached_string_st *string) { string->end= string->string; diff --git a/libmemcached/string.hpp b/libmemcached/string.hpp index 61a428e2..e2978ccd 100644 --- a/libmemcached/string.hpp +++ b/libmemcached/string.hpp @@ -85,6 +85,8 @@ char *memcached_string_take_value(memcached_string_st *self); char *memcached_string_value_mutable(const memcached_string_st *self); +bool memcached_string_set(memcached_string_st&, const char*, size_t); + void memcached_string_set_length(memcached_string_st *self, size_t length); void memcached_string_set_length(memcached_string_st&, const size_t length); diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index 3b1701e8..d439e35e 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -3312,7 +3312,7 @@ test_return_t analyzer_test(memcached_st *memc) test_return_t util_version_test(memcached_st *memc) { - test_compare(MEMCACHED_SUCCESS, memcached_version(memc)); + test_compare(memcached_version(memc), MEMCACHED_SUCCESS); test_true(libmemcached_util_version_check(memc, 0, 0, 0)); bool if_successful= libmemcached_util_version_check(memc, 9, 9, 9); diff --git a/tests/libmemcached-1.0/parser.cc b/tests/libmemcached-1.0/parser.cc index fc9d3375..a027f50e 100644 --- a/tests/libmemcached-1.0/parser.cc +++ b/tests/libmemcached-1.0/parser.cc @@ -663,6 +663,7 @@ test_return_t test_hostname_port_weight(memcached_st *) struct socket_weight_t { const char *socket; size_t weight; + const char* type; }; static memcached_return_t dump_socket_information(const memcached_st *, @@ -671,15 +672,27 @@ static memcached_return_t dump_socket_information(const memcached_st *, { socket_weight_t *check= (socket_weight_t *)context; - if (strcmp(memcached_server_name(instance), check->socket)) + if (strcmp(memcached_server_type(instance), check->type) == 0) { - Error << memcached_server_name(instance) << " != " << check->socket; - return MEMCACHED_FAILURE; + if (strcmp(memcached_server_name(instance), check->socket) == 0) + { + if (instance->weight == check->weight) + { + return MEMCACHED_SUCCESS; + } + else + { + Error << instance->weight << " != " << check->weight; + } + } + else + { + Error << "'" << memcached_server_name(instance) << "'" << " != " << "'" << check->socket << "'"; + } } - - if (instance->weight == check->weight) + else { - return MEMCACHED_SUCCESS; + Error << "'" << memcached_server_type(instance) << "'" << " != " << "'" << check->type << "'"; } return MEMCACHED_FAILURE; @@ -697,7 +710,7 @@ test_return_t test_parse_socket(memcached_st *) memcached_st *memc= memcached(test_literal_param("--socket=\"/tmp/foo\"")); test_true(memc); - socket_weight_t check= { "/tmp/foo", 1 }; + socket_weight_t check= { "/tmp/foo", 1, "SOCKET"}; test_compare(MEMCACHED_SUCCESS, memcached_server_cursor(memc, callbacks, &check, 1)); memcached_free(memc); @@ -710,7 +723,7 @@ test_return_t test_parse_socket(memcached_st *) memcached_st *memc= memcached(test_literal_param("--socket=\"/tmp/foo\"/?23")); test_true(memc); - socket_weight_t check= { "/tmp/foo", 23 }; + socket_weight_t check= { "/tmp/foo", 23, "SOCKET"}; test_compare(MEMCACHED_SUCCESS, memcached_server_cursor(memc, callbacks, &check, 1)); memcached_free(memc);