From d4f66dfa327bc97e4e1655a027a9c3ff5e6c519c Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 7 Mar 2008 16:01:22 -0500 Subject: [PATCH] ENH: In cmMakefile::IssueMessage use cmDocumentationFormatterText to format the message nicely. --- Source/cmDocumentationFormatterText.cxx | 2 +- Source/cmMakefile.cxx | 39 ++++++------------------- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/Source/cmDocumentationFormatterText.cxx b/Source/cmDocumentationFormatterText.cxx index ca22166c4..b45abf81f 100644 --- a/Source/cmDocumentationFormatterText.cxx +++ b/Source/cmDocumentationFormatterText.cxx @@ -69,7 +69,7 @@ void cmDocumentationFormatterText::PrintPreformatted(std::ostream& os, bool newline = true; for(const char* ptr = text; *ptr; ++ptr) { - if(newline) + if(newline && *ptr != '\n') { os << this->TextIndent; newline = false; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index aaea0dee6..999030244 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -35,6 +35,8 @@ #include "cmake.h" #include // required for atoi +#include "cmDocumentationFormatterText.h" + #include #include @@ -280,32 +282,6 @@ bool cmMakefile::CommandExists(const char* name) const return this->GetCMakeInstance()->CommandExists(name); } -//---------------------------------------------------------------------------- -// Helper function to print a block of text with every line following -// a given prefix. -void cmMakefilePrintPrefixed(std::ostream& os, const char* prefix, - std::string const& msg) -{ - bool newline = true; - for(const char* c = msg.c_str(); *c; ++c) - { - if(newline && *c != '\n') - { - os << prefix; - newline = false; - } - os << *c; - if(*c == '\n') - { - newline = true; - } - } - if(!newline) - { - os << "\n"; - } -} - //---------------------------------------------------------------------------- void cmMakefile::IssueError(std::string const& msg) const { @@ -351,9 +327,13 @@ void cmMakefile::IssueMessage(std::string const& text, bool isError) const } // Add the message text. + { msg << " {\n"; - cmMakefilePrintPrefixed(msg, " ", text); + cmDocumentationFormatterText formatter; + formatter.SetIndent(" "); + formatter.PrintFormatted(msg, text.c_str()); msg << "}"; + } // Add the rest of the context. if(i != this->CallStack.rend()) @@ -3303,7 +3283,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, default: break; } e << "created in source directory \"" - << existing->GetMakefile()->GetCurrentDirectory() << "\".\n" + << existing->GetMakefile()->GetCurrentDirectory() << "\"." << "\n"; e << "Logical target names must be globally unique because:\n" @@ -3316,7 +3296,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, "Consider using the OUTPUT_NAME target property to create two " "targets with the same physical name while keeping logical " "names distinct. " - "Custom targets must simply have globally unique names.\n" + "Custom targets must simply have globally unique names." "\n" "If you are building an older project it is possible that " "it violated this rule but was working accidentally because " @@ -3324,7 +3304,6 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, if(isCustom && existing->GetType() == cmTarget::UTILITY) { e << - "\n" "For projects that care only about Makefile generators and do " "not wish to support Xcode or VS IDE generators, one may add\n" " set_property(GLOBAL PROPERTY ALLOW_DUPLICATE_CUSTOM_TARGETS 1)\n"