]> gitweb.fperrin.net Git - DictionaryPC.git/commitdiff
Another fix to really skip comments.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Thu, 13 Apr 2017 18:37:37 +0000 (20:37 +0200)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Thu, 13 Apr 2017 18:37:37 +0000 (20:37 +0200)
src/com/hughes/android/dictionary/parser/WikiTokenizer.java

index 9f3444f8f06d5ee27cbb8fa5d1fd7741add3e653..83835d95fad90311872adb26d7927ed655b254de 100644 (file)
@@ -481,15 +481,18 @@ public final class WikiTokenizer {
         int firstNewline = -1;
         int[] nextMatch = new int[8];
         for (int i = 0; i < 8; ++i) {
         int firstNewline = -1;
         int[] nextMatch = new int[8];
         for (int i = 0; i < 8; ++i) {
-            nextMatch[i] = wikiText.indexOf(patterns[i], start);
-            if (nextMatch[i] == -1) nextMatch[i] = i > 0 ? 0x7fffffff : wikiText.length();
+            nextMatch[i] = -2;
         }
         while (end < wikiText.length()) {
             // Manual replacement for matcher.find(end),
             // because Java regexp is a ridiculously slow implementation.
             // Initialize to always match the end.
             int matchIdx = 0;
         }
         while (end < wikiText.length()) {
             // Manual replacement for matcher.find(end),
             // because Java regexp is a ridiculously slow implementation.
             // Initialize to always match the end.
             int matchIdx = 0;
-            for (int i = 1; i < 8; ++i) {
+            for (int i = 0; i < 8; ++i) {
+                if (nextMatch[i] <= end) {
+                    nextMatch[i] = wikiText.indexOf(patterns[i], end);
+                    if (nextMatch[i] == -1) nextMatch[i] = i > 0 ? 0x7fffffff : wikiText.length();
+                }
                 if (nextMatch[i] < nextMatch[matchIdx]) {
                     matchIdx = i;
                 }
                 if (nextMatch[i] < nextMatch[matchIdx]) {
                     matchIdx = i;
                 }
@@ -498,8 +501,6 @@ public final class WikiTokenizer {
             int matchStart = nextMatch[matchIdx];
             String matchText = patterns[matchIdx];
             int matchEnd = matchStart + matchText.length();
             int matchStart = nextMatch[matchIdx];
             String matchText = patterns[matchIdx];
             int matchEnd = matchStart + matchText.length();
-            nextMatch[matchIdx] = wikiText.indexOf(patterns[matchIdx], matchEnd);
-            if (nextMatch[matchIdx] == -1) nextMatch[matchIdx] = matchIdx > 0 ? 0x7fffffff : wikiText.length();
             if (matchIdx == 0) {
                 matchText = "";
                 matchEnd = matchStart;
             if (matchIdx == 0) {
                 matchText = "";
                 matchEnd = matchStart;