diff --git a/PageCompiler/src/ApacheCodeWriter.cpp b/PageCompiler/src/ApacheCodeWriter.cpp index 7536f5854..ff542f175 100644 --- a/PageCompiler/src/ApacheCodeWriter.cpp +++ b/PageCompiler/src/ApacheCodeWriter.cpp @@ -1,7 +1,7 @@ // // ApacheCodeWriter.cpp // -// $Id: //poco/1.4/PageCompiler/src/ApacheCodeWriter.cpp#1 $ +// $Id: //poco/1.7/PageCompiler/src/ApacheCodeWriter.cpp#3 $ // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors. diff --git a/PageCompiler/src/ApacheCodeWriter.h b/PageCompiler/src/ApacheCodeWriter.h index e6b85e569..f0e4a0168 100644 --- a/PageCompiler/src/ApacheCodeWriter.h +++ b/PageCompiler/src/ApacheCodeWriter.h @@ -1,7 +1,7 @@ // // ApacheCodeWriter.h // -// $Id: //poco/1.4/PageCompiler/src/ApacheCodeWriter.h#1 $ +// $Id: //poco/1.7/PageCompiler/src/ApacheCodeWriter.h#3 $ // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors. diff --git a/PageCompiler/src/CodeWriter.cpp b/PageCompiler/src/CodeWriter.cpp index 442f38d84..87f5c0b22 100644 --- a/PageCompiler/src/CodeWriter.cpp +++ b/PageCompiler/src/CodeWriter.cpp @@ -1,7 +1,7 @@ // // CodeWriter.cpp // -// $Id: //poco/1.4/PageCompiler/src/CodeWriter.cpp#3 $ +// $Id: //poco/1.7/PageCompiler/src/CodeWriter.cpp#4 $ // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors. @@ -351,7 +351,7 @@ void CodeWriter::writeContent(std::ostream& ostr) if (buffered) { ostr << "\tstd::stringstream responseStream;\n"; - ostr << _page.handler().str(); + ostr << cleanupHandler(_page.handler().str()); if (!chunked) { ostr << "\tresponse.setContentLength(static_cast(responseStream.tellp()));\n"; @@ -363,13 +363,31 @@ void CodeWriter::writeContent(std::ostream& ostr) ostr << "\tstd::ostream& _responseStream = response.send();\n" << "\tPoco::DeflatingOutputStream _gzipStream(_responseStream, Poco::DeflatingStreamBuf::STREAM_GZIP, " << compressionLevel << ");\n" << "\tstd::ostream& responseStream = _compressResponse ? _gzipStream : _responseStream;\n"; - ostr << _page.handler().str(); + ostr << cleanupHandler(_page.handler().str()); ostr << "\tif (_compressResponse) _gzipStream.close();\n"; } else { ostr << "\tstd::ostream& responseStream = response.send();\n"; - ostr << _page.handler().str(); + ostr << cleanupHandler(_page.handler().str()); } } + +std::string CodeWriter::cleanupHandler(std::string handler) +{ + static const std::string EMPTY_WRITE("\tresponseStream << \"\";\n"); + static const std::string NEWLINE_WRITE("\tresponseStream << \"\\n\";\n"); + static const std::string DOUBLE_NEWLINE_WRITE("\tresponseStream << \"\\n\";\n\tresponseStream << \"\\n\";\n"); + static const std::string EMPTY; + + // remove empty writes + Poco::replaceInPlace(handler, EMPTY_WRITE, EMPTY); + // remove consecutive newlines + while (handler.find(DOUBLE_NEWLINE_WRITE) != std::string::npos) + { + Poco::replaceInPlace(handler, DOUBLE_NEWLINE_WRITE, NEWLINE_WRITE); + } + return handler; +} + diff --git a/PageCompiler/src/CodeWriter.h b/PageCompiler/src/CodeWriter.h index 6ba34ef5b..b09a5f22c 100644 --- a/PageCompiler/src/CodeWriter.h +++ b/PageCompiler/src/CodeWriter.h @@ -1,7 +1,7 @@ // // CodeWriter.h // -// $Id: //poco/1.4/PageCompiler/src/CodeWriter.h#1 $ +// $Id: //poco/1.7/PageCompiler/src/CodeWriter.h#4 $ // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors. @@ -67,6 +67,7 @@ protected: void handlerClass(std::ostream& ostr, const std::string& base, const std::string& ctorArg); void factoryClass(std::ostream& ostr, const std::string& base); void factoryImpl(std::ostream& ostr, const std::string& arg); + std::string cleanupHandler(std::string handler); private: CodeWriter(); diff --git a/PageCompiler/src/OSPCodeWriter.cpp b/PageCompiler/src/OSPCodeWriter.cpp index ee085821d..9adeb24fa 100644 --- a/PageCompiler/src/OSPCodeWriter.cpp +++ b/PageCompiler/src/OSPCodeWriter.cpp @@ -1,7 +1,7 @@ // // OSPCodeWriter.cpp // -// $Id: //poco/1.4/PageCompiler/src/OSPCodeWriter.cpp#3 $ +// $Id: //poco/1.7/PageCompiler/src/OSPCodeWriter.cpp#3 $ // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors. diff --git a/PageCompiler/src/OSPCodeWriter.h b/PageCompiler/src/OSPCodeWriter.h index 9372abe4a..21f252bdd 100644 --- a/PageCompiler/src/OSPCodeWriter.h +++ b/PageCompiler/src/OSPCodeWriter.h @@ -1,7 +1,7 @@ // // OSPCodeWriter.h // -// $Id: //poco/1.4/PageCompiler/src/OSPCodeWriter.h#1 $ +// $Id: //poco/1.7/PageCompiler/src/OSPCodeWriter.h#3 $ // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors. diff --git a/PageCompiler/src/Page.cpp b/PageCompiler/src/Page.cpp index 705236b45..2e53ef243 100644 --- a/PageCompiler/src/Page.cpp +++ b/PageCompiler/src/Page.cpp @@ -1,7 +1,7 @@ // // Page.cpp // -// $Id: //poco/1.4/PageCompiler/src/Page.cpp#2 $ +// $Id: //poco/1.7/PageCompiler/src/Page.cpp#3 $ // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors. diff --git a/PageCompiler/src/Page.h b/PageCompiler/src/Page.h index 5e5e6b12b..4cd4937e2 100644 --- a/PageCompiler/src/Page.h +++ b/PageCompiler/src/Page.h @@ -1,7 +1,7 @@ // // Page.h // -// $Id: //poco/1.4/PageCompiler/src/Page.h#2 $ +// $Id: //poco/1.7/PageCompiler/src/Page.h#3 $ // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors. diff --git a/PageCompiler/src/PageCompiler.cpp b/PageCompiler/src/PageCompiler.cpp index 774cc09ba..bb45e44b9 100644 --- a/PageCompiler/src/PageCompiler.cpp +++ b/PageCompiler/src/PageCompiler.cpp @@ -1,7 +1,7 @@ // // PageCompiler.cpp // -// $Id: //poco/1.4/PageCompiler/src/PageCompiler.cpp#4 $ +// $Id: //poco/1.7/PageCompiler/src/PageCompiler.cpp#5 $ // // A compiler that compiler HTML pages containing JSP directives into C++ classes. // @@ -206,7 +206,7 @@ protected: helpFormatter.setHeader( "\n" "The POCO C++ Server Page Compiler.\n" - "Copyright (c) 2008-2016 by Applied Informatics Software Engineering GmbH.\n" + "Copyright (c) 2008-2017 by Applied Informatics Software Engineering GmbH.\n" "All rights reserved.\n\n" "This program compiles web pages containing embedded C++ code " "into a C++ class that can be used with the HTTP server " diff --git a/PageCompiler/src/PageReader.cpp b/PageCompiler/src/PageReader.cpp index 02a08a110..67fd92d4a 100644 --- a/PageCompiler/src/PageReader.cpp +++ b/PageCompiler/src/PageReader.cpp @@ -1,7 +1,7 @@ // // PageReader.cpp // -// $Id: //poco/1.4/PageCompiler/src/PageReader.cpp#1 $ +// $Id: //poco/1.7/PageCompiler/src/PageReader.cpp#3 $ // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors. diff --git a/PageCompiler/src/PageReader.h b/PageCompiler/src/PageReader.h index 4e7ad7934..6af5bb28d 100644 --- a/PageCompiler/src/PageReader.h +++ b/PageCompiler/src/PageReader.h @@ -1,7 +1,7 @@ // // PageReader.h // -// $Id: //poco/1.4/PageCompiler/src/PageReader.h#1 $ +// $Id: //poco/1.7/PageCompiler/src/PageReader.h#3 $ // // Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // and Contributors.