From b8535d00548599bd7f7afe1800f73f23f6f89ddd Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Mon, 13 Jul 2009 02:58:00 +0000 Subject: Using std::string for space buffer to ensure deletion. Fixed name clash with Borland C++ 5.5 including Windows.h when string included. --- src/Editor.cxx | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Editor.cxx b/src/Editor.cxx index 6c6922648..9bd18d570 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -10,6 +10,16 @@ #include #include +#include + +// With Borland C++ 5.5, including includes Windows.h leading to defining +// FindText to FindTextA which makes calls here to Document::FindText fail. +#ifdef __BORLANDC__ +#ifdef FindText +#undef FindText +#endif +#endif + #include "Platform.h" #include "Scintilla.h" @@ -3628,14 +3638,12 @@ void Editor::ChangeSize() { } int Editor::InsertSpace(int position, unsigned int spaces) { - if (spaces > 0) { - char *spaceText = new char[spaces]; - memset(spaceText, ' ', spaces); - pdoc->InsertString(position, spaceText, spaces); - position += spaces; - delete []spaceText; - } - return position; + if (spaces > 0) { + std::string spaceText(spaces, ' '); + pdoc->InsertString(position, spaceText.c_str(), spaces); + position += spaces; + } + return position; } void Editor::AddChar(char ch) { -- cgit v1.2.3