You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/10/30 15:52:02 UTC

[3/8] lucy git commit: Adjust for Str_Find changes

Adjust for Str_Find changes


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/fde7f8ca
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/fde7f8ca
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/fde7f8ca

Branch: refs/heads/master
Commit: fde7f8caee401f68440f0e5ee9c74252b2e202d6
Parents: aa35071
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Oct 24 15:26:29 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Oct 24 15:26:29 2015 +0200

----------------------------------------------------------------------
 core/Lucy/Store/FSFolder.c                 |  2 +-
 core/Lucy/Test/Highlight/TestHighlighter.c | 38 ++++++++++++-------------
 core/Lucy/Test/Index/TestSortWriter.c      |  4 +--
 core/Lucy/Test/Search/TestSortSpec.c       |  4 +--
 perl/xs/Lucy/Analysis/RegexTokenizer.c     |  4 +--
 5 files changed, 26 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/fde7f8ca/core/Lucy/Store/FSFolder.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSFolder.c b/core/Lucy/Store/FSFolder.c
index 1570bca..18a114f 100644
--- a/core/Lucy/Store/FSFolder.c
+++ b/core/Lucy/Store/FSFolder.c
@@ -349,7 +349,7 @@ S_create_dir(String *path) {
 
 static bool
 S_is_local_entry(String *path) {
-    return Str_Find_Utf8(path, "/", 1) == -1;
+    return !Str_Contains_Utf8(path, "/", 1);
 }
 
 /***************************************************************************/

http://git-wip-us.apache.org/repos/asf/lucy/blob/fde7f8ca/core/Lucy/Test/Highlight/TestHighlighter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Highlight/TestHighlighter.c b/core/Lucy/Test/Highlight/TestHighlighter.c
index ebd845d..0bdfec1 100644
--- a/core/Lucy/Test/Highlight/TestHighlighter.c
+++ b/core/Lucy/Test/Highlight/TestHighlighter.c
@@ -227,9 +227,9 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
     HitDoc *hit = Hits_Next(hits);
     String *excerpt = Highlighter_Create_Excerpt(highlighter, hit);
     TEST_TRUE(runner,
-              Str_Find_Utf8(excerpt,
-                           "<strong>&#934;</strong> a b c d <strong>x y z</strong>",
-                           54) >= 0,
+              Str_Contains_Utf8(excerpt,
+                                "<strong>&#934;</strong> a b c d <strong>x y z</strong>",
+                                54),
               "highlighter tagged phrase and single term");
     DECREF(excerpt);
 
@@ -239,9 +239,9 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
     Highlighter_Set_Post_Tag(highlighter, post_tag);
     excerpt = Highlighter_Create_Excerpt(highlighter, hit);
     TEST_TRUE(runner,
-              Str_Find_Utf8(excerpt,
-                          "\x1B[1m&#934;\x1B[0m a b c d \x1B[1mx y z\x1B[0m",
-                          36) >= 0,
+              Str_Contains_Utf8(excerpt,
+                                "\x1B[1m&#934;\x1B[0m a b c d \x1B[1mx y z\x1B[0m",
+                                36),
               "set_pre_tag and set_post_tag");
     DECREF(excerpt);
     DECREF(hit);
@@ -249,7 +249,7 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
     hit = Hits_Next(hits);
     excerpt = Highlighter_Create_Excerpt(highlighter, hit);
     TEST_TRUE(runner,
-              Str_Find_Utf8(excerpt, "x", 1) >= 0,
+              Str_Contains_Utf8(excerpt, "x", 1),
               "excerpt field with partial hit doesn't cause highlighter freakout");
     DECREF(excerpt);
     DECREF(hit);
@@ -261,9 +261,9 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
     hit = Hits_Next(hits);
     excerpt = Highlighter_Create_Excerpt(highlighter, hit);
     TEST_TRUE(runner,
-              Str_Find_Utf8(excerpt,
-                          "<strong>b</strong> c d <strong>x y z</strong>",
-                          45) >= 0,
+              Str_Contains_Utf8(excerpt,
+                                "<strong>b</strong> c d <strong>x y z</strong>",
+                                45),
               "query with same word in both phrase and term doesn't cause freakout");
     DECREF(excerpt);
     DECREF(hit);
@@ -276,7 +276,7 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
     hit = Hits_Next(hits);
     excerpt = Highlighter_Create_Excerpt(highlighter, hit);
     TEST_TRUE(runner,
-              Str_Find_Utf8(excerpt, "&quot;", 6) >= 0,
+              Str_Contains_Utf8(excerpt, "&quot;", 6),
               "HTML entity encoded properly");
     DECREF(excerpt);
     DECREF(hit);
@@ -288,9 +288,9 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
     highlighter = Highlighter_new(searcher, query, content, 200);
     hit = Hits_Next(hits);
     excerpt = Highlighter_Create_Excerpt(highlighter, hit);
-    TEST_TRUE(runner,
-              Str_Find_Utf8(excerpt, "&#934;", 6) == -1,
-              "no ellipsis for short excerpt");
+    TEST_FALSE(runner,
+               Str_Contains_Utf8(excerpt, "&#934;", 6),
+               "no ellipsis for short excerpt");
     DECREF(excerpt);
     DECREF(hit);
     DECREF(highlighter);
@@ -303,16 +303,16 @@ test_Create_Excerpt(TestBatchRunner *runner, Searcher *searcher, Obj *query,
     highlighter = Highlighter_new(searcher, query, content, 200);
     excerpt = Highlighter_Create_Excerpt(highlighter, hit);
     TEST_TRUE(runner,
-              Str_Find_Utf8(excerpt, "strong", 5) >= 0,
+              Str_Contains_Utf8(excerpt, "strong", 5),
               "specify field highlights correct field...");
     DECREF(excerpt);
     DECREF(highlighter);
     String *alt = (String*)SSTR_WRAP_UTF8("alt", 3);
     highlighter = Highlighter_new(searcher, query, alt, 200);
     excerpt = Highlighter_Create_Excerpt(highlighter, hit);
-    TEST_TRUE(runner,
-              Str_Find_Utf8(excerpt, "strong", 5) == -1,
-              "... but not another field");
+    TEST_FALSE(runner,
+               Str_Contains_Utf8(excerpt, "strong", 5),
+               "... but not another field");
     DECREF(excerpt);
     DECREF(highlighter);
     DECREF(hit);
@@ -424,7 +424,7 @@ test_hl_selection(TestBatchRunner *runner) {
     String *excerpt = Highlighter_Create_Excerpt(highlighter, hit);
     String *mmm = (String*)SSTR_WRAP_UTF8("MMM", 3);
     String *nnn = (String*)SSTR_WRAP_UTF8("NNN", 3);
-    TEST_TRUE(runner, Str_Find(excerpt, mmm) >= 0 || Str_Find(excerpt, nnn) >= 0,
+    TEST_TRUE(runner, Str_Contains(excerpt, mmm) || Str_Contains(excerpt, nnn),
               "Sentence boundary algo doesn't chop terms");
 
     DECREF(excerpt);

http://git-wip-us.apache.org/repos/asf/lucy/blob/fde7f8ca/core/Lucy/Test/Index/TestSortWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Index/TestSortWriter.c b/core/Lucy/Test/Index/TestSortWriter.c
index bfac610..1ac1c80 100644
--- a/core/Lucy/Test/Index/TestSortWriter.c
+++ b/core/Lucy/Test/Index/TestSortWriter.c
@@ -245,8 +245,8 @@ test_sort_writer(TestBatchRunner *runner) {
         int num_old_seg_files = 0;
         for (uint32_t i = 0, size = Vec_Get_Size(filenames); i < size; ++i) {
             String *filename = (String*)Vec_Fetch(filenames, i);
-            if (Str_Find_Utf8(filename, "seg_1", 5) >= 0
-                || Str_Find_Utf8(filename, "seg_2", 5) >= 0
+            if (Str_Contains_Utf8(filename, "seg_1", 5)
+                || Str_Contains_Utf8(filename, "seg_2", 5)
                ) {
                 ++num_old_seg_files;
             }

http://git-wip-us.apache.org/repos/asf/lucy/blob/fde7f8ca/core/Lucy/Test/Search/TestSortSpec.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Search/TestSortSpec.c b/core/Lucy/Test/Search/TestSortSpec.c
index ce092b8..0540889 100644
--- a/core/Lucy/Test/Search/TestSortSpec.c
+++ b/core/Lucy/Test/Search/TestSortSpec.c
@@ -467,7 +467,7 @@ test_sort_spec(TestBatchRunner *runner) {
     error = Err_trap(S_attempt_sorted_search, &sort_ctx);
     TEST_TRUE(runner, error != NULL
               && Err_is_a(error, ERR)
-              && Str_Find_Utf8(Err_Get_Mess(error), "sortable", 8) != -1,
+              && Str_Contains_Utf8(Err_Get_Mess(error), "sortable", 8),
               "sorting on a non-sortable field throws an error");
     DECREF(error);
 
@@ -475,7 +475,7 @@ test_sort_spec(TestBatchRunner *runner) {
     error = Err_trap(S_attempt_sorted_search, &sort_ctx);
     TEST_TRUE(runner, error != NULL
               && Err_is_a(error, ERR)
-              && Str_Find_Utf8(Err_Get_Mess(error), "sortable", 8) != -1,
+              && Str_Contains_Utf8(Err_Get_Mess(error), "sortable", 8),
               "sorting on an unknown field throws an error");
     DECREF(error);
 #endif

http://git-wip-us.apache.org/repos/asf/lucy/blob/fde7f8ca/perl/xs/Lucy/Analysis/RegexTokenizer.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Analysis/RegexTokenizer.c b/perl/xs/Lucy/Analysis/RegexTokenizer.c
index f95cf0f..f8e5e36 100644
--- a/perl/xs/Lucy/Analysis/RegexTokenizer.c
+++ b/perl/xs/Lucy/Analysis/RegexTokenizer.c
@@ -39,8 +39,8 @@ lucy_RegexTokenizer_init(lucy_RegexTokenizer *self,
     lucy_RegexTokenizerIVARS *const ivars = lucy_RegexTokenizer_IVARS(self);
     #define DEFAULT_PATTERN "\\w+(?:['\\x{2019}]\\w+)*"
     if (pattern) {
-        if (CFISH_Str_Find_Utf8(pattern, "\\p", 2) != -1
-            || CFISH_Str_Find_Utf8(pattern, "\\P", 2) != -1
+        if (CFISH_Str_Contains_Utf8(pattern, "\\p", 2)
+            || CFISH_Str_Contains_Utf8(pattern, "\\P", 2)
            ) {
             CFISH_DECREF(self);
             THROW(CFISH_ERR, "\\p and \\P constructs forbidden");