From 0d2bd5e004b657be9bd66e26161f1cf7299707ea Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 17 Jun 2012 13:38:21 +1000 Subject: Use std::string instead of fixed size strings. Decrease direct access to the autocompletion list box from outside AutoComplete. --- src/Document.cxx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/Document.cxx') 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()); } } -- cgit v1.2.3