Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Diff of /lexlib/WordList.cxx [870221] .. [16c356] Maximize Restore

  Switch to side-by-side view

--- a/lexlib/WordList.cxx
+++ b/lexlib/WordList.cxx
@@ -45,22 +45,24 @@
 		prev = curr;
 	}
 	char **keywords = new char *[words + 1];
-	words = 0;
-	prev = '\0';
-	size_t slen = strlen(wordlist);
-	for (size_t k = 0; k < slen; k++) {
-		if (!wordSeparator[static_cast<unsigned char>(wordlist[k])]) {
-			if (!prev) {
-				keywords[words] = &wordlist[k];
-				words++;
-			}
-		} else {
-			wordlist[k] = '\0';
-		}
-		prev = wordlist[k];
-	}
-	keywords[words] = &wordlist[slen];
-	*len = words;
+	int wordsStore = 0;
+	const size_t slen = strlen(wordlist);
+	if (words) {
+		prev = '\0';
+		for (size_t k = 0; k < slen; k++) {
+			if (!wordSeparator[static_cast<unsigned char>(wordlist[k])]) {
+				if (!prev) {
+					keywords[wordsStore] = &wordlist[k];
+					wordsStore++;
+				}
+			} else {
+				wordlist[k] = '\0';
+			}
+			prev = wordlist[k];
+		}
+	}
+	keywords[wordsStore] = &wordlist[slen];
+	*len = wordsStore;
 	return keywords;
 }