--- a/scintilla/lexlib/SubStyles.h
+++ b/scintilla/lexlib/SubStyles.h
@@ -13,19 +13,24 @@
 #endif
 
 class WordClassifier {
+	int baseStyle;
 	int firstStyle;
 	int lenStyles;
 	std::map<std::string, int> wordToStyle;
 
 public:
 
-	WordClassifier() : firstStyle(0), lenStyles(0) {
+	WordClassifier(int baseStyle_) : baseStyle(baseStyle_), firstStyle(0), lenStyles(0) {
 	}
 
 	void Allocate(int firstStyle_, int lenStyles_) {
 		firstStyle = firstStyle_;
 		lenStyles = lenStyles_;
 		wordToStyle.clear();
+	}
+
+	int Base() const {
+		return baseStyle;
 	}
 
 	int Start() const {
@@ -57,10 +62,12 @@
 	void SetIdentifiers(int style, const char *identifiers) {
 		while (*identifiers) {
 			const char *cpSpace = identifiers;
-			while (*cpSpace && *cpSpace != ' ')
+			while (*cpSpace && !(*cpSpace == ' ' || *cpSpace == '\t' || *cpSpace == '\r' || *cpSpace == '\n'))
 				cpSpace++;
-			std::string word(identifiers, cpSpace - identifiers);
-			wordToStyle[word] = style;
+			if (cpSpace > identifiers) {
+				std::string word(identifiers, cpSpace - identifiers);
+				wordToStyle[word] = style;
+			}
 			identifiers = cpSpace;
 			if (*identifiers)
 				identifiers++;
@@ -105,8 +112,8 @@
 		secondaryDistance(secondaryDistance_),
 		allocated(0) {
 		while (baseStyles[classifications]) {
+			classifiers.push_back(WordClassifier(baseStyles[classifications]));
 			classifications++;
-			classifiers.push_back(WordClassifier());
 		}
 	}
 
@@ -132,6 +139,14 @@
 	int Length(int styleBase) {
 		int block = BlockFromBaseStyle(styleBase);
 		return (block >= 0) ? classifiers[block].Length() : 0;
+	}
+
+	int BaseStyle(int subStyle) const {
+		int block = BlockFromStyle(subStyle);
+		if (block >= 0)
+			return classifiers[block].Base();
+		else
+			return subStyle;
 	}
 
 	int DistanceToSecondaryStyles() const {