diff options
| author | nyamatongwe <unknown> | 2012-06-17 13:38:21 +1000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2012-06-17 13:38:21 +1000 | 
| commit | f0d56e473978dcfa017b6597ef4e2e09e5a477e6 (patch) | |
| tree | c7d9b15f268ef84d933a9931ce05db5a1190ffb1 /src/Document.cxx | |
| parent | 7a340b339181d7e8981ad8d67ec07d75b2e5fa54 (diff) | |
| download | scintilla-mirror-f0d56e473978dcfa017b6597ef4e2e09e5a477e6.tar.gz | |
Use std::string instead of fixed size strings.
Decrease direct access to the autocompletion list box from outside AutoComplete.
Diffstat (limited to 'src/Document.cxx')
| -rw-r--r-- | src/Document.cxx | 21 | 
1 files changed, 9 insertions, 12 deletions
| diff --git a/src/Document.cxx b/src/Document.cxx index 88e45638b..72c931b95 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1026,21 +1026,19 @@ static int NextTab(int pos, int tabSize) {  	return ((pos / tabSize) + 1) * tabSize;  } -static void CreateIndentation(char *linebuf, int length, int indent, int tabSize, bool insertSpaces) { -	length--;	// ensure space for \0 +static std::string CreateIndentation(int indent, int tabSize, bool insertSpaces) { +	std::string indentation;  	if (!insertSpaces) { -		while ((indent >= tabSize) && (length > 0)) { -			*linebuf++ = '\t'; +		while (indent >= tabSize) { +			indentation += '\t';  			indent -= tabSize; -			length--;  		}  	} -	while ((indent > 0) && (length > 0)) { -		*linebuf++ = ' '; +	while (indent > 0) { +		indentation += ' ';  		indent--; -		length--;  	} -	*linebuf = '\0'; +	return indentation;  }  int SCI_METHOD Document::GetLineIndentation(int line) { @@ -1066,13 +1064,12 @@ void Document::SetLineIndentation(int line, int indent) {  	if (indent < 0)  		indent = 0;  	if (indent != indentOfLine) { -		char linebuf[1000]; -		CreateIndentation(linebuf, sizeof(linebuf), indent, tabInChars, !useTabs); +		std::string linebuf = CreateIndentation(indent, tabInChars, !useTabs);  		int thisLineStart = LineStart(line);  		int indentPos = GetLineIndentPosition(line);  		UndoGroup ug(this);  		DeleteChars(thisLineStart, indentPos - thisLineStart); -		InsertCString(thisLineStart, linebuf); +		InsertCString(thisLineStart, linebuf.c_str());  	}  } | 
