From 17fafa155cc4e6e8170c149ee20ef5ac685ee918 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Sat, 15 Dec 2012 02:40:54 +0000 Subject: [PATCH] =?UTF-8?q?Remove=20the=20=E2=80=9Clen=E2=80=9D=20defaulte?= =?UTF-8?q?d=20parameter=20from=20CommandReturnObject::AppendMessage,=20Ap?= =?UTF-8?q?pendWarning=20and=20AppendError.=20=20Nobody=20was=20using=20th?= =?UTF-8?q?em,=20and=20it=20meant=20if=20you=20accidentally=20used=20the?= =?UTF-8?q?=20AppendWarning=20when=20you=20meant=20AppendWarningWithFormat?= =?UTF-8?q?=20with=20an=20integer=20in=20the=20format=20string,=20it=20wou?= =?UTF-8?q?ld=20compile=20and=20then=20return=20your=20string=20plus=20som?= =?UTF-8?q?e=20unknown=20amount=20of=20junk.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit llvm-svn: 170266 --- .../lldb/Interpreter/CommandReturnObject.h | 6 ++--- lldb/source/API/SBCommandReturnObject.cpp | 12 ++++++++- lldb/source/Commands/CommandObjectTarget.cpp | 6 ++--- .../Interpreter/CommandReturnObject.cpp | 25 +++++++------------ 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h index ce062d38845c..737ef525a923 100644 --- a/lldb/include/lldb/Interpreter/CommandReturnObject.h +++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h @@ -118,7 +118,7 @@ public: Clear(); void - AppendMessage (const char *in_string, int len = -1); + AppendMessage (const char *in_string); void AppendMessageWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); @@ -127,13 +127,13 @@ public: AppendRawWarning (const char *in_string, int len = -1); void - AppendWarning (const char *in_string, int len = -1); + AppendWarning (const char *in_string); void AppendWarningWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); void - AppendError (const char *in_string, int len = -1); + AppendError (const char *in_string); void AppendRawError (const char *in_string, int len = -1); diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index 4d0ffc75fe32..4714829c592c 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -281,7 +281,17 @@ SBCommandReturnObject::PutCString(const char* string, int len) { if (m_opaque_ap.get()) { - m_opaque_ap->AppendMessage(string, len); + if (len == 0) + { + return; + } + else if (len > 0) + { + std::string buffer(string, len); + m_opaque_ap->AppendMessage(buffer.c_str()); + } + else + m_opaque_ap->AppendMessage(string); } } diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index d154e28819f8..391cbc42cd19 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -876,7 +876,7 @@ protected: comp_unit->GetDirectory().GetCString(), comp_unit->GetFilename().GetCString()); else - result.AppendError ("no debug information for frame %u\n", frame->GetFrameIndex()); + result.AppendErrorWithFormat ("no debug information for frame %u\n", frame->GetFrameIndex()); } else result.AppendError ("'target variable' takes one or more global variable names as arguments\n"); @@ -3152,13 +3152,13 @@ protected: } else { - result.AppendError ("Couldn't find module matching address: 0x%" PRIx64 ".", m_options.m_module_addr); + result.AppendErrorWithFormat ("Couldn't find module matching address: 0x%" PRIx64 ".", m_options.m_module_addr); result.SetStatus (eReturnStatusFailed); } } else { - result.AppendError ("Couldn't find module containing address: 0x%" PRIx64 ".", m_options.m_module_addr); + result.AppendErrorWithFormat ("Couldn't find module containing address: 0x%" PRIx64 ".", m_options.m_module_addr); result.SetStatus (eReturnStatusFailed); } } diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp index 896ad2b7e84a..c7ab8a988d70 100644 --- a/lldb/source/Interpreter/CommandReturnObject.cpp +++ b/lldb/source/Interpreter/CommandReturnObject.cpp @@ -104,24 +104,19 @@ CommandReturnObject::AppendWarningWithFormat (const char *format, ...) } void -CommandReturnObject::AppendMessage (const char *in_string, int len) +CommandReturnObject::AppendMessage (const char *in_string) { - if (!in_string || len == 0) + if (!in_string || *in_string == '\0') return; - if (len < 0) - GetOutputStream().Printf("%s\n", in_string); - else - GetOutputStream().Printf("%*.*s\n", len, len, in_string); + GetOutputStream().Printf("%s\n", in_string); } void -CommandReturnObject::AppendWarning (const char *in_string, int len) +CommandReturnObject::AppendWarning (const char *in_string) { - if (!in_string) + if (!in_string || *in_string == '\0') return; - if (len < 0) - len = ::strlen (in_string); - GetErrorStream().Printf("warning: %*.*s\n", len, len, in_string); + GetErrorStream().Printf("warning: %s\n", in_string); } // Similar to AppendWarning, but do not prepend 'warning: ' to message, and @@ -138,13 +133,11 @@ CommandReturnObject::AppendRawWarning (const char *in_string, int len) } void -CommandReturnObject::AppendError (const char *in_string, int len) +CommandReturnObject::AppendError (const char *in_string) { - if (!in_string) + if (!in_string || *in_string == '\0') return; - if (len < 0) - len = ::strlen (in_string); - GetErrorStream().Printf ("error: %*.*s\n", len, len, in_string); + GetErrorStream().Printf ("error: %s\n", in_string); } void