[Groonga-commit] groonga/groonga [master] Define tokenized delimiter as macro

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Nov 9 16:38:52 JST 2012


Kouhei Sutou	2012-11-09 16:38:52 +0900 (Fri, 09 Nov 2012)

  New Revision: 0e88dce10437299728ced006411d99fc257e31b0
  https://github.com/groonga/groonga/commit/0e88dce10437299728ced006411d99fc257e31b0

  Log:
    Define tokenized delimiter as macro

  Modified files:
    include/groonga/tokenizer.h
    lib/tokenizer.c

  Modified: include/groonga/tokenizer.h (+3 -0)
===================================================================
--- include/groonga/tokenizer.h    2012-11-09 16:38:01 +0900 (37f9147)
+++ include/groonga/tokenizer.h    2012-11-09 16:38:52 +0900 (ea34ffe)
@@ -26,6 +26,9 @@
 extern "C" {
 #endif  /* __cplusplus */
 
+#define GRN_TOKENIZER_TOKENIZED_DELIMITER_UTF8     "\xEF\xBF\xBE"
+#define GRN_TOKENIZER_TOKENIZED_DELIMITER_UTF8_LEN 3
+
 /*
   grn_tokenizer_charlen() returns the length (#bytes) of the first character
   in the string specified by `str_ptr' and `str_length'. If the starting bytes

  Modified: lib/tokenizer.c (+4 -4)
===================================================================
--- lib/tokenizer.c    2012-11-09 16:38:01 +0900 (1b9085e)
+++ lib/tokenizer.c    2012-11-09 16:38:52 +0900 (7e3581b)
@@ -91,13 +91,13 @@ grn_tokenizer_is_delimiter(grn_ctx *ctx, const char *str_ptr,
     return GRN_FALSE;
   }
 
-  if (str_length != 3) {
+  if (str_length != GRN_TOKENIZER_TOKENIZED_DELIMITER_UTF8_LEN) {
     return GRN_FALSE;
   }
 
-  return binary_string[0] == 0xEF &&
-    binary_string[1] == 0xBF &&
-    binary_string[2] == 0xBE;
+  return memcmp(binary_string,
+                GRN_TOKENIZER_TOKENIZED_DELIMITER_UTF8,
+                GRN_TOKENIZER_TOKENIZED_DELIMITER_UTF8_LEN) == 0;
 }
 
 grn_bool
-------------- next part --------------
HTML����������������������������...
下载 



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