OSDN Git Service

Fix any: search bug
authorRandy Baumgarte <randy@fbn.cx>
Mon, 28 Mar 2011 16:30:23 +0000 (12:30 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 3 Apr 2011 18:03:19 +0000 (14:03 -0400)
src/cx/fbn/nevernote/sql/REnSearch.java

index 6079515..1da5abe 100644 (file)
@@ -328,9 +328,9 @@ public class REnSearch {
                int len = search.length();\r
                char nextChar = ' ';\r
                boolean quote = false;\r
-               for (int i=0; i<len; i++) {\r
+               for (int i=0, j=0; i<len; i++, j++) {\r
                        if (search.charAt(i)==nextChar && !quote) {\r
-                               b.setCharAt(i,'\0');\r
+                               b.setCharAt(j,'\0');\r
                                nextChar = ' ';\r
                        } else {\r
                                if (search.charAt(i)=='\"') {\r
@@ -338,6 +338,8 @@ public class REnSearch {
                                                quote=true;\r
                                        } else {\r
                                                quote=false;\r
+                                               j++;\r
+                                               b.insert(j, "\0");\r
                                        }\r
                                }\r
                        }\r
@@ -382,7 +384,6 @@ public class REnSearch {
        // subject date\r
 \r
        private void parseTerms(List<String> words) {\r
-               \r
                for (int i=0; i<words.size(); i++) {\r
                        String word = words.get(i);\r
                        int pos = word.indexOf(":");\r
@@ -397,7 +398,8 @@ public class REnSearch {
                                searchPhrases.add(word.toLowerCase());\r
                        }\r
                        if (!searchPhrase && pos < 0) \r
-                               getWords().add(word); \r
+                               if (word != null && word.length() > 0)\r
+                                       getWords().add(word); \r
 //                             getWords().add("*"+word+"*");           //// WILDCARD\r
                        if (word.startsWith("intitle:")) \r
                                intitle.add("*"+word+"*");\r