diff options
| author | nyamatongwe <unknown> | 2003-09-08 12:03:21 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2003-09-08 12:03:21 +0000 | 
| commit | 4824ccf30dec38d4dacf6a396d442f414b59e751 (patch) | |
| tree | e692a436c30d3eed7613c2771a496974dcf91fca /src/LexLua.cxx | |
| parent | 6c3b725e23afa2957abbf8e0c01a6770095bfbb9 (diff) | |
| download | scintilla-mirror-4824ccf30dec38d4dacf6a396d442f414b59e751.tar.gz | |
Patch from Philippe to patch restrict local function visibility and improve code.
Diffstat (limited to 'src/LexLua.cxx')
| -rw-r--r-- | src/LexLua.cxx | 27 | 
1 files changed, 17 insertions, 10 deletions
| diff --git a/src/LexLua.cxx b/src/LexLua.cxx index 18612c9ee..926557750 100644 --- a/src/LexLua.cxx +++ b/src/LexLua.cxx @@ -27,21 +27,31 @@ static inline bool IsAWordChar(const int ch) {  	return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.');  } -inline bool IsAWordStart(const int ch) { +static inline bool IsAWordStart(const int ch) {  	return (ch < 0x80) && (isalnum(ch) || ch == '_');  } -inline bool isLuaOperator(char ch) { -	if (isalnum(ch)) +static inline bool IsANumberChar(const int ch) { +	// Not exactly following number definition (several dots are seen as OK, etc.) +	// but probably enough in most cases. +	return (ch < 0x80) && +	        (isdigit(ch) || toupper(ch) == 'E' || +             ch == '.' || ch == '-' || ch == '+'); +} + +static inline bool IsLuaOperator(char ch) { +	if (ch >= 0x80 || isalnum(ch)) {  		return false; +	}  	// '.' left out as it is used to make up numbers  	if (ch == '*' || ch == '/' || ch == '-' || ch == '+' ||  		ch == '(' || ch == ')' || ch == '=' ||  		ch == '{' || ch == '}' || ch == '~' ||  		ch == '[' || ch == ']' || ch == ';' ||  		ch == '<' || ch == '>' || ch == ',' || -		ch == '.' || ch == '^' || ch == '%' || ch == ':') +		ch == '.' || ch == '^' || ch == '%' || ch == ':') {  		return true; +	}  	return false;  } @@ -124,11 +134,8 @@ static void ColouriseLuaDoc(  			sc.SetState(SCE_LUA_DEFAULT);  		} else if (sc.state == SCE_LUA_NUMBER) {  			// We stop the number definition on non-numerical non-dot non-eE non-sign char -			if (!(isdigit(sc.ch) || sc.ch == '.' || -				  toupper(sc.ch) == 'E' || sc.ch == '-' || sc.ch == '+')) { -					// Not exactly following number definition (several dots are seen as OK, etc.) -					// but probably enough in most cases. -					sc.SetState(SCE_LUA_DEFAULT); +			if (!IsANumberChar(sc.ch)) { +				sc.SetState(SCE_LUA_DEFAULT);  			}  		} else if (sc.state == SCE_LUA_IDENTIFIER) {  			if (!IsAWordChar(sc.ch)) { @@ -233,7 +240,7 @@ static void ColouriseLuaDoc(  				sc.Forward();  			} else if (sc.atLineStart && sc.Match('$')) {  				sc.SetState(SCE_LUA_PREPROCESSOR);	// Obsolete since Lua 4.0, but still in old code -			} else if (isLuaOperator(static_cast<char>(sc.ch))) { +			} else if (IsLuaOperator(static_cast<char>(sc.ch))) {  				sc.SetState(SCE_LUA_OPERATOR);  			}  		} | 
