diff options
| author | Joe Mueller <unknown> | 2015-07-30 14:35:17 +1000 | 
|---|---|---|
| committer | Joe Mueller <unknown> | 2015-07-30 14:35:17 +1000 | 
| commit | 58471e908a3b74b27379bb19a13d62cd8d4476b0 (patch) | |
| tree | 8f61293f34d008fea20584c631d23e58b3fe53aa /lexers/LexLaTeX.cxx | |
| parent | 2270ab97445c6f12bd0fddb273ab617fdb421594 (diff) | |
| download | scintilla-mirror-58471e908a3b74b27379bb19a13d62cd8d4476b0.tar.gz | |
Use Sci_Position / Sci_PositionU for variables in lexers that represent
positions and line numbers and may be widened to 64-bits in a future release.
Diffstat (limited to 'lexers/LexLaTeX.cxx')
| -rw-r--r-- | lexers/LexLaTeX.cxx | 65 | 
1 files changed, 33 insertions, 32 deletions
| diff --git a/lexers/LexLaTeX.cxx b/lexers/LexLaTeX.cxx index d2ab191fa..7e03a9c4c 100644 --- a/lexers/LexLaTeX.cxx +++ b/lexers/LexLaTeX.cxx @@ -48,33 +48,33 @@ struct latexFoldSave {  class LexerLaTeX : public LexerBase {  private:  	vector<int> modes; -	void setMode(int line, int mode) { -		if (line >= static_cast<int>(modes.size())) modes.resize(line + 1, 0); +	void setMode(Sci_Position line, int mode) { +		if (line >= static_cast<Sci_Position>(modes.size())) modes.resize(line + 1, 0);  		modes[line] = mode;  	} -	int getMode(int line) { -		if (line >= 0 && line < static_cast<int>(modes.size())) return modes[line]; +	int getMode(Sci_Position line) { +		if (line >= 0 && line < static_cast<Sci_Position>(modes.size())) return modes[line];  		return 0;  	} -	void truncModes(int numLines) { -		if (static_cast<int>(modes.size()) > numLines * 2 + 256) +	void truncModes(Sci_Position numLines) { +		if (static_cast<Sci_Position>(modes.size()) > numLines * 2 + 256)  			modes.resize(numLines + 128);  	}  	vector<latexFoldSave> saves; -	void setSave(int line, const latexFoldSave &save) { -		if (line >= static_cast<int>(saves.size())) saves.resize(line + 1); +	void setSave(Sci_Position line, const latexFoldSave &save) { +		if (line >= static_cast<Sci_Position>(saves.size())) saves.resize(line + 1);  		saves[line] = save;  	} -	void getSave(int line, latexFoldSave &save) { -		if (line >= 0 && line < static_cast<int>(saves.size())) save = saves[line]; +	void getSave(Sci_Position line, latexFoldSave &save) { +		if (line >= 0 && line < static_cast<Sci_Position>(saves.size())) save = saves[line];  		else {  			save.structLev = 0;  			for (int i = 0; i < 8; ++i) save.openBegins[i] = 0;  		}  	} -	void truncSaves(int numLines) { -		if (static_cast<int>(saves.size()) > numLines * 2 + 256) +	void truncSaves(Sci_Position numLines) { +		if (static_cast<Sci_Position>(saves.size()) > numLines * 2 + 256)  			saves.resize(numLines + 128);  	}  public: @@ -102,7 +102,7 @@ static bool latexIsLetter(int ch) {  	return IsASCII(ch) && isalpha(ch);  } -static bool latexIsTagValid(int &i, int l, Accessor &styler) { +static bool latexIsTagValid(Sci_Position &i, Sci_Position l, Accessor &styler) {  	while (i < l) {  		if (styler.SafeGetCharAt(i) == '{') {  			while (i < l) { @@ -122,7 +122,7 @@ static bool latexIsTagValid(int &i, int l, Accessor &styler) {  	return false;  } -static bool latexNextNotBlankIs(int i, Accessor &styler, char needle) { +static bool latexNextNotBlankIs(Sci_Position i, Accessor &styler, char needle) {    char ch;  	while (i < styler.Length()) {      ch = styler.SafeGetCharAt(i); @@ -137,10 +137,10 @@ static bool latexNextNotBlankIs(int i, Accessor &styler, char needle) {  	return false;  } -static bool latexLastWordIs(int start, Accessor &styler, const char *needle) { -	unsigned int i = 0; -	unsigned int l = static_cast<unsigned int>(strlen(needle)); -	int ini = start-l+1; +static bool latexLastWordIs(Sci_Position start, Accessor &styler, const char *needle) { +	Sci_PositionU i = 0; +	Sci_PositionU l = static_cast<Sci_PositionU>(strlen(needle)); +	Sci_Position ini = start-l+1;  	char s[32];  	while (i < l && i < 31) { @@ -152,8 +152,8 @@ static bool latexLastWordIs(int start, Accessor &styler, const char *needle) {  	return (strcmp(s, needle) == 0);  } -static bool latexLastWordIsMathEnv(int pos, Accessor &styler) { -	int i, j; +static bool latexLastWordIsMathEnv(Sci_Position pos, Accessor &styler) { +	Sci_Position i, j;  	char s[32];  	const char *mathEnvs[] = { "align", "alignat", "flalign", "gather",  		"multiline", "displaymath", "eqnarray", "equation" }; @@ -196,9 +196,9 @@ void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int  	char chNext = styler.SafeGetCharAt(startPos);  	char chVerbatimDelim = '\0';  	styler.StartSegment(startPos); -	int lengthDoc = startPos + length; +	Sci_Position lengthDoc = startPos + length; -	for (int i = startPos; i < lengthDoc; i++) { +	for (Sci_Position i = startPos; i < lengthDoc; i++) {  		char ch = chNext;  		chNext = styler.SafeGetCharAt(i + 1); @@ -325,7 +325,7 @@ void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int  			case '\\' :  				styler.ColourTo(i - 1, state);  				if (latexIsLetter(chNext)) { -					int match = i + 3; +					Sci_Position match = i + 3;  					if (latexLastWordIs(match, styler, "\\end")) {  						match++;  						if (latexIsTagValid(match, lengthDoc, styler)) { @@ -367,7 +367,7 @@ void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int  			case '\\' :  				styler.ColourTo(i - 1, state);  				if (latexIsLetter(chNext)) { -					int match = i + 3; +					Sci_Position match = i + 3;  					if (latexLastWordIs(match, styler, "\\end")) {  						match++;  						if (latexIsTagValid(match, lengthDoc, styler)) { @@ -418,7 +418,7 @@ void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int  			break;  		case SCE_L_COMMENT2 :  			if (ch == '\\') { -				int match = i + 3; +				Sci_Position match = i + 3;  				if (latexLastWordIs(match, styler, "\\end")) {  					match++;  					if (latexIsTagValid(match, lengthDoc, styler)) { @@ -432,7 +432,7 @@ void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int  			break;  		case SCE_L_VERBATIM :  			if (ch == '\\') { -				int match = i + 3; +				Sci_Position match = i + 3;  				if (latexLastWordIs(match, styler, "\\end")) {  					match++;  					if (latexIsTagValid(match, lengthDoc, styler)) { @@ -474,19 +474,20 @@ void SCI_METHOD LexerLaTeX::Fold(Sci_PositionU startPos, Sci_Position length, in  	const char *structWords[7] = {"part", "chapter", "section", "subsection",  		"subsubsection", "paragraph", "subparagraph"};  	Accessor styler(pAccess, &props); -	unsigned int endPos = startPos + length; -	int curLine = styler.GetLine(startPos); +	Sci_PositionU endPos = startPos + length; +	Sci_Position curLine = styler.GetLine(startPos);  	latexFoldSave save;  	getSave(curLine - 1, save);  	do {  		char ch, buf[16]; -		int i, j, lev = -1; +		Sci_Position i, j; +		int lev = -1;  		bool needFold = false; -		for (i = static_cast<int>(startPos); i < static_cast<int>(endPos); ++i) { +		for (i = static_cast<Sci_Position>(startPos); i < static_cast<Sci_Position>(endPos); ++i) {  			ch = styler.SafeGetCharAt(i);  			if (ch == '\r' || ch == '\n') break;  			if (ch != '\\' || styler.StyleAt(i) != SCE_L_COMMAND) continue; -			for (j = 0; j < 15 && i + 1 < static_cast<int>(endPos); ++j, ++i) { +			for (j = 0; j < 15 && i + 1 < static_cast<Sci_Position>(endPos); ++j, ++i) {  				buf[j] = styler.SafeGetCharAt(i + 1);  				if (!latexIsLetter(buf[j])) break;  			} @@ -522,7 +523,7 @@ void SCI_METHOD LexerLaTeX::Fold(Sci_PositionU startPos, Sci_Position length, in  		setSave(curLine, save);  		++curLine;  		startPos = styler.LineStart(curLine); -		if (static_cast<int>(startPos) == styler.Length()) { +		if (static_cast<Sci_Position>(startPos) == styler.Length()) {  			lev = latexFoldSaveToInt(save);  			styler.SetLevel(curLine, lev);  			setSave(curLine, save); | 
