X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Foptions.cc;h=35e8b783ac6e782507f989aebbd6be2748bfed0c;hb=ecf02b501d387ee5761eb31db6f760de60ac09a1;hp=cd6d28d4eb2e08d8a0cbaa11f7fa26f66b6b34b2;hpb=9da805a13af25708dcf567f15ea7c1acf31462f1;p=awesomized%2Flibmemcached diff --git a/libmemcached/options.cc b/libmemcached/options.cc index cd6d28d4..35e8b783 100644 --- a/libmemcached/options.cc +++ b/libmemcached/options.cc @@ -40,7 +40,7 @@ #include #include -int libmemcached_parse(type_st *, yyscan_t *); +int libmemcached_parse(Context*, yyscan_t *); const char *memcached_parse_filename(memcached_st *memc) { @@ -86,7 +86,7 @@ memcached_return_t libmemcached_check_configuration(const char *option_string, s memcached_return_t rc= memcached_parse_configuration(memc_ptr, option_string, length); if (rc != MEMCACHED_SUCCESS && error_buffer && error_buffer_size) { - strncpy(error_buffer, error_buffer_size, memcached_last_error_message(memc_ptr)); + strncpy(error_buffer, memcached_last_error_message(memc_ptr), error_buffer_size); } if (rc== MEMCACHED_SUCCESS && memcached_behavior_get(memc_ptr, MEMCACHED_BEHAVIOR_LOAD_FROM_FILE)) @@ -96,7 +96,7 @@ memcached_return_t libmemcached_check_configuration(const char *option_string, s if (rc != MEMCACHED_SUCCESS && error_buffer && error_buffer_size) { - strncpy(error_buffer, error_buffer_size, memcached_last_error_message(memc_ptr)); + strncpy(error_buffer, memcached_last_error_message(memc_ptr), error_buffer_size); } } @@ -107,25 +107,16 @@ memcached_return_t libmemcached_check_configuration(const char *option_string, s memcached_return_t memcached_parse_configuration(memcached_st *self, char const *option_string, size_t length) { - type_st pp; - memset(&pp, 0, sizeof(type_st)); - WATCHPOINT_ASSERT(self); if (! self) return memcached_set_error(self, MEMCACHED_INVALID_ARGUMENTS, NULL); - pp.buf= option_string; - pp.memc= self; - pp.length= length; - libmemcached_lex_init(&pp.yyscanner); - libmemcached_set_extra(&pp, pp.yyscanner); - bool success= libmemcached_parse(&pp, pp.yyscanner) == 0; - libmemcached_lex_destroy(pp.yyscanner); + memcached_return_t rc; + Context context(option_string, length, self, rc); - if (not success) - return memcached_set_error(self, MEMCACHED_PARSE_ERROR, NULL); + libmemcached_parse(&context, context.scanner); - return MEMCACHED_SUCCESS; + return rc; } void memcached_set_configuration_file(memcached_st *self, const char *filename, size_t filename_length)