diff options
| author | nyamatongwe <unknown> | 2001-01-23 00:08:29 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2001-01-23 00:08:29 +0000 | 
| commit | 82944ecd7b8558dc6b2c3b22f6a9bc21a0de483b (patch) | |
| tree | 22700ecfd1ea77a9c3939f72ef0e9c4fed7914ab /src | |
| parent | 347e47646b37986d18b0fbb6787fec71bb394483 (diff) | |
| download | scintilla-mirror-82944ecd7b8558dc6b2c3b22f6a9bc21a0de483b.tar.gz | |
New function isspacechar to avoid bugs when character >= 0x80.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Document.cxx | 25 | ||||
| -rw-r--r-- | src/LexCPP.cxx | 6 | 
2 files changed, 18 insertions, 13 deletions
| diff --git a/src/Document.cxx b/src/Document.cxx index 3e017e25e..e65f008e9 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -15,6 +15,11 @@  #include "CellBuffer.h"  #include "Document.h" +// This is ASCII specific but is safe with chars >= 0x80 +inline bool isspacechar(unsigned char ch) { +    return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); +} +  Document::Document() {  	refCount = 0;  #ifdef unix @@ -697,19 +702,19 @@ int Document::NextWordStart(int pos, int delta) {  	if (delta < 0) {  		while (pos > 0 && (cb.CharAt(pos - 1) == ' ' || cb.CharAt(pos - 1) == '\t'))  			pos--; -		if (isspace(cb.CharAt(pos - 1))) {	// Back up to previous line -			while (pos > 0 && isspace(cb.CharAt(pos - 1))) +		if (isspacechar(cb.CharAt(pos - 1))) {	// Back up to previous line +			while (pos > 0 && isspacechar(cb.CharAt(pos - 1)))  				pos--;  		} else {  			bool startAtWordChar = IsWordChar(cb.CharAt(pos - 1)); -			while (pos > 0 && !isspace(cb.CharAt(pos - 1)) && (startAtWordChar == IsWordChar(cb.CharAt(pos - 1)))) +			while (pos > 0 && !isspacechar(cb.CharAt(pos - 1)) && (startAtWordChar == IsWordChar(cb.CharAt(pos - 1))))  				pos--;  		}  	} else {  		bool startAtWordChar = IsWordChar(cb.CharAt(pos)); -		while (pos < (Length()) && isspace(cb.CharAt(pos))) +		while (pos < (Length()) && isspacechar(cb.CharAt(pos)))  			pos++; -		while (pos < (Length()) && !isspace(cb.CharAt(pos)) && (startAtWordChar == IsWordChar(cb.CharAt(pos)))) +		while (pos < (Length()) && !isspacechar(cb.CharAt(pos)) && (startAtWordChar == IsWordChar(cb.CharAt(pos))))  			pos++;  		while (pos < (Length()) && (cb.CharAt(pos) == ' ' || cb.CharAt(pos) == '\t'))  			pos++; @@ -995,10 +1000,10 @@ int Document::WordPartLeft(int pos) {  					--pos;  				if (!ispunct(cb.CharAt(pos)))  					++pos; -			} else if (isspace(startChar)) { -				while (pos > 0 && isspace(cb.CharAt(pos))) +			} else if (isspacechar(startChar)) { +				while (pos > 0 && isspacechar(cb.CharAt(pos)))  					--pos; -				if (!isspace(cb.CharAt(pos))) +				if (!isspacechar(cb.CharAt(pos)))  					++pos;  			}  		} @@ -1034,8 +1039,8 @@ int Document::WordPartRight(int pos) {  	} else if (ispunct(startChar)) {  		while (pos < length && ispunct(cb.CharAt(pos)))  			++pos; -	} else if (isspace(startChar)) { -		while (pos < length && isspace(cb.CharAt(pos))) +	} else if (isspacechar(startChar)) { +		while (pos < length && isspacechar(cb.CharAt(pos)))  			++pos;  	}  	return pos; diff --git a/src/LexCPP.cxx b/src/LexCPP.cxx index 9064cd012..1a2728dc8 100644 --- a/src/LexCPP.cxx +++ b/src/LexCPP.cxx @@ -88,7 +88,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo  			}  			visibleChars = 0;  		} -		if (!isspace(ch)) +		if (!isspacechar(ch))  			visibleChars++;  		if (styler.IsLeadByte(ch)) { @@ -145,7 +145,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo  					i++;  					ch = chNext;  					chNext = styler.SafeGetCharAt(i + 1); -				} while (isspace(ch) && (i < lengthDoc)); +				} while (isspacechar(ch) && (i < lengthDoc));  			} else if (isoperator(ch)) {  				styler.ColourTo(i-1, state);  				styler.ColourTo(i, SCE_C_OPERATOR); @@ -178,7 +178,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo  		} else {  			if (state == SCE_C_PREPROCESSOR) {  				if (stylingWithinPreprocessor) { -					if (isspace(ch)) { +					if (isspacechar(ch)) {  						styler.ColourTo(i-1, state);  						state = SCE_C_DEFAULT;  					} | 
