X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fcsl%2Fcontext.cc;h=1e6e18ae588dae871732473346e4c05a1546e330;hb=1a09bec1c62a5068126735cc0915020bf487f4b1;hp=1a60fede1ad5572117441e4ca364b5db86851c39;hpb=a4f7c3b9413014291d0ca549f32455b3be10a6c0;p=m6w6%2Flibmemcached diff --git a/libmemcached/csl/context.cc b/libmemcached/csl/context.cc index 1a60fede..1e6e18ae 100644 --- a/libmemcached/csl/context.cc +++ b/libmemcached/csl/context.cc @@ -42,15 +42,20 @@ void Context::abort(const char *error_arg, yytokentype last_token, const char *l { rc= MEMCACHED_PARSE_ERROR; (void)last_token; - (void)last_token_str; if (error_arg) { - memcached_set_parser_error(*memc, MEMCACHED_AT, "Error occured while parsing: %s", error_arg); + memcached_set_parser_error(*memc, MEMCACHED_AT, "%s", error_arg); return; } - memcached_set_parser_error(*memc, MEMCACHED_AT, "Error occured while parsing: %s", memcached_strerror(NULL, MEMCACHED_PARSE_ERROR)); + if (last_token_str) + { + memcached_set_parser_error(*memc, MEMCACHED_AT, "%s", last_token_str); + return; + } + + memcached_set_parser_error(*memc, MEMCACHED_AT, "unknown parsing error"); } void Context::error(const char *error_arg, yytokentype last_token, const char *last_token_str) @@ -101,3 +106,17 @@ const char *Context::set_hostname(const char *str, size_t size) return _hostname; } +bool Context::set_hash(memcached_hash_t hash) +{ + if (_has_hash) + { + return false; + } + + if ((memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, hash)) != MEMCACHED_SUCCESS) + { + return false; + } + + return _has_hash= true; +}