[Groonga-commit] groonga/groonga [master] Export grn_enctostr()

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Jan 25 16:57:50 JST 2013


Kouhei Sutou	2013-01-25 16:57:50 +0900 (Fri, 25 Jan 2013)

  New Revision: 44b63c92cc3118f08913c2a6e11992cf7ab40d38
  https://github.com/groonga/groonga/commit/44b63c92cc3118f08913c2a6e11992cf7ab40d38

  Log:
    Export grn_enctostr()
    
    grn_enctostr() ->
    grn_encoding_to_string()
    
    Use grn_encoding_ prefix for public API.

  Modified files:
    include/groonga.h
    lib/str.c
    lib/str.h
    plugins/tokenizers/mecab.c
    src/groonga.c
    test/unit/lib/grn-assertions.c

  Modified: include/groonga.h (+11 -0)
===================================================================
--- include/groonga.h    2013-01-25 16:29:39 +0900 (ab26a26)
+++ include/groonga.h    2013-01-25 16:57:50 +0900 (497fb35)
@@ -363,6 +363,17 @@ GRN_API long long int grn_get_default_match_escalation_threshold(void);
  **/
 GRN_API grn_rc grn_set_default_match_escalation_threshold(long long int threshold);
 
+/* grn_encoding */
+/**
+ * grn_encoding_to_string:
+ * @encoding: The encoding.
+ *
+ * Returns string representation for the encoding. For example,
+ * 'grn_encoding_to_string(GRN_ENC_UTF8)' returns '"utf8"'.
+ *
+ * "unknown" is returned for invalid encoding.
+ **/
+GRN_API const char *grn_encoding_to_string(grn_encoding encoding);
 
 /* obj */
 

  Modified: lib/str.c (+1 -1)
===================================================================
--- lib/str.c    2013-01-25 16:29:39 +0900 (a26e1b9)
+++ lib/str.c    2013-01-25 16:57:50 +0900 (6aa34b3)
@@ -1284,7 +1284,7 @@ static const char *grn_enc_string[] = {
 };
 
 const char *
-grn_enctostr(grn_encoding enc)
+grn_encoding_to_string(grn_encoding enc)
 {
   if (enc < (sizeof(grn_enc_string) / sizeof(char *))) {
     return grn_enc_string[enc];

  Modified: lib/str.h (+0 -1)
===================================================================
--- lib/str.h    2013-01-25 16:29:39 +0900 (cdd1291)
+++ lib/str.h    2013-01-25 16:57:50 +0900 (06a825b)
@@ -63,7 +63,6 @@ grn_rc grn_itoa(int i, char *p, char *end, char **rest);
 grn_rc grn_lltoa(int64_t i, char *p, char *end, char **rest);
 grn_rc grn_ulltoa(uint64_t i, char *p, char *end, char **rest);
 GRN_API grn_rc grn_aton(grn_ctx *ctx, const char *p, const char *end, const char **rest, grn_obj *res);
-GRN_API const char *grn_enctostr(grn_encoding enc);
 GRN_API grn_encoding grn_strtoenc(const char *str);
 
 GRN_API void grn_itoh(unsigned int i, char *p, unsigned int len);

  Modified: plugins/tokenizers/mecab.c (+3 -3)
===================================================================
--- plugins/tokenizers/mecab.c    2013-01-25 16:29:39 +0900 (b89ffee)
+++ plugins/tokenizers/mecab.c    2013-01-25 16:57:50 +0900 (c764291)
@@ -116,8 +116,8 @@ mecab_init(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
                      "[tokenizer][mecab] "
                      "MeCab dictionary charset (%s) does not match "
                      "the table encoding: <%s>",
-                     grn_enctostr(sole_mecab_encoding),
-                     grn_enctostr(query->encoding));
+                     grn_encoding_to_string(sole_mecab_encoding),
+                     grn_encoding_to_string(query->encoding));
     return NULL;
   }
 
@@ -266,7 +266,7 @@ check_mecab_dictionary_encoding(grn_ctx *ctx)
                        "[tokenizer][mecab] "
                        "MeCab has no dictionary that uses the context encoding"
                        ": <%s>",
-                       grn_enctostr(encoding));
+                       grn_encoding_to_string(encoding));
     }
   } else {
     GRN_PLUGIN_ERROR(ctx, GRN_TOKENIZER_ERROR,

  Modified: src/groonga.c (+2 -1)
===================================================================
--- src/groonga.c    2013-01-25 16:29:39 +0900 (ef792a4)
+++ src/groonga.c    2013-01-25 16:57:50 +0900 (9890c35)
@@ -2032,7 +2032,8 @@ show_usage(FILE *output)
           "  <db pathname> [<commands>]: in standalone mode\n"
           "  <db pathname>: in server/daemon mode\n"
           "  <dest hostname> [<commands>]: in client mode (default: %s)\n",
-          grn_enctostr(default_encoding), default_port, default_bind_address,
+          grn_encoding_to_string(default_encoding),
+          default_port, default_bind_address,
           default_port, default_hostname, default_protocol,
           default_document_root, default_cache_limit, default_max_num_threads,
           default_log_level, default_log_path, default_query_log_path,

  Modified: test/unit/lib/grn-assertions.c (+2 -2)
===================================================================
--- test/unit/lib/grn-assertions.c    2013-01-25 16:29:39 +0900 (98f21f5)
+++ test/unit/lib/grn-assertions.c    2013-01-25 16:57:50 +0900 (af6e161)
@@ -340,8 +340,8 @@ grn_test_assert_equal_encoding_helper (grn_encoding expected,
                                   " but was: <%s>",
                                   expression_expected,
                                   expression_actual,
-                                  grn_enctostr(expected),
-                                  grn_enctostr(actual)));
+                                  grn_encoding_to_string(expected),
+                                  grn_encoding_to_string(actual)));
   }
 }
 
-------------- next part --------------
HTML����������������������������...
Descargar 



More information about the Groonga-commit mailing list
Back to archive index