diff options
author | nyamatongwe <devnull@localhost> | 2012-06-17 13:38:21 +1000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2012-06-17 13:38:21 +1000 |
commit | 0d2bd5e004b657be9bd66e26161f1cf7299707ea (patch) | |
tree | cb92a15ff4afba794cd8cc8ee0bf9ecd75bccfd1 /src/Document.cxx | |
parent | 6b61cd57097eba543a36f6cd78954c43e31a7bef (diff) | |
download | scintilla-mirror-0d2bd5e004b657be9bd66e26161f1cf7299707ea.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()); } } |