diff options
| -rw-r--r-- | lexers/LexCPP.cxx | 6 | ||||
| -rw-r--r-- | lexers/LexModula.cxx | 12 | ||||
| -rw-r--r-- | lexlib/WordList.cxx | 21 | ||||
| -rw-r--r-- | lexlib/WordList.h | 12 | 
4 files changed, 36 insertions, 15 deletions
| diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx index 0e14eebdb..9b56641e6 100644 --- a/lexers/LexCPP.cxx +++ b/lexers/LexCPP.cxx @@ -455,9 +455,9 @@ int SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) {  			if (n == 4) {  				// Rebuild preprocessorDefinitions  				preprocessorDefinitionsStart.clear(); -				for (int nDefinition = 0; nDefinition < ppDefinitions.len; nDefinition++) { -					char *cpDefinition = ppDefinitions.words[nDefinition]; -					char *cpEquals = strchr(cpDefinition, '='); +				for (int nDefinition = 0; nDefinition < ppDefinitions.Length(); nDefinition++) { +					const char *cpDefinition = ppDefinitions.WordAt(nDefinition); +					const char *cpEquals = strchr(cpDefinition, '=');  					if (cpEquals) {  						std::string name(cpDefinition, cpEquals - cpDefinition);  						std::string val(cpEquals+1); diff --git a/lexers/LexModula.cxx b/lexers/LexModula.cxx index cc5847fd6..ed615609c 100644 --- a/lexers/LexModula.cxx +++ b/lexers/LexModula.cxx @@ -63,16 +63,16 @@ static inline unsigned IsOperator( StyleContext & sc, WordList & op ) {  	s[0] = sc.ch;  	s[1] = sc.chNext;  	s[2] = 0; -	for( i = 0; i < op.len; i++ ) { -		if( ( strlen( op.words[i] ) == 2 ) && -			( s[0] == op.words[i][0] && s[1] == op.words[i][1] ) ) { +	for( i = 0; i < op.Length(); i++ ) { +		if( ( strlen( op.WordAt(i) ) == 2 ) && +			( s[0] == op.WordAt(i)[0] && s[1] == op.WordAt(i)[1] ) ) {  			return 2;  		}  	}  	s[1] = 0; -	for( i = 0; i < op.len; i++ ) { -		if( ( strlen( op.words[i] ) == 1 ) && -			( s[0] == op.words[i][0] ) ) { +	for( i = 0; i < op.Length(); i++ ) { +		if( ( strlen( op.WordAt(i) ) == 1 ) && +			( s[0] == op.WordAt(i)[0] ) ) {  			return 1;  		}  	} diff --git a/lexlib/WordList.cxx b/lexlib/WordList.cxx index 07ca015e3..049bf6ec0 100644 --- a/lexlib/WordList.cxx +++ b/lexlib/WordList.cxx @@ -64,6 +64,18 @@ static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = fa  	return keywords;  } +WordList::WordList(bool onlyLineEnds_) : +	words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_) { +} + +WordList::~WordList() {  +	Clear(); +} + +WordList::operator bool() const { +	return len ? true : false; +} +  bool WordList::operator!=(const WordList &other) const {  	if (len != other.len)  		return true; @@ -74,6 +86,10 @@ bool WordList::operator!=(const WordList &other) const {  	return false;  } +int WordList::Length() const { +	return len; +} +  void WordList::Clear() {  	if (words) {  		delete []list; @@ -213,3 +229,8 @@ bool WordList::InListAbbreviated(const char *s, const char marker) const {  	}  	return false;  } + +const char *WordList::WordAt(int n) const { +	return words[n]; +} + diff --git a/lexlib/WordList.h b/lexlib/WordList.h index ea5be1d55..9c8285ece 100644 --- a/lexlib/WordList.h +++ b/lexlib/WordList.h @@ -15,23 +15,23 @@ namespace Scintilla {  /**   */  class WordList { -public:  	// Each word contains at least one character - a empty word acts as sentinel at the end.  	char **words;  	char *list;  	int len;  	bool onlyLineEnds;	///< Delimited by any white space or only line ends  	int starts[256]; -	WordList(bool onlyLineEnds_ = false) : -		words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_) -		{} -	~WordList() { Clear(); } -	operator bool() const { return len ? true : false; } +public: +	WordList(bool onlyLineEnds_ = false); +	~WordList(); +	operator bool() const;  	bool operator!=(const WordList &other) const; +	int Length() const;  	void Clear();  	void Set(const char *s);  	bool InList(const char *s) const;  	bool InListAbbreviated(const char *s, const char marker) const; +	const char *WordAt(int n) const;  };  #ifdef SCI_NAMESPACE | 
