From 1df71e9b78fd516f9902f42db733f0b02808ad50 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 5 Jan 2016 21:17:42 +0100 Subject: Fix `generate` problem caused by _boost_ update i.e. the directory tree was not correctly created in all circumstances which led to both the `generate` and `write-file` test cases failing. This was combined with some accumulated changes such as the extraction of process context instantiation. --- src/function/external_command.cc | 41 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'src/function/external_command.cc') diff --git a/src/function/external_command.cc b/src/function/external_command.cc index 606ff8f..dda403e 100644 --- a/src/function/external_command.cc +++ b/src/function/external_command.cc @@ -16,12 +16,6 @@ namespace { using InputXSLT::XercesStringGuard; -inline std::string wrapOutput(const std::string& rawOutput) { - return std::string( - "" + rawOutput + "" - ); -} - inline bool isWrappedOutput(const XMLCh* nodeName) { return xercesc::XMLString::equals( nodeName, @@ -42,7 +36,7 @@ std::unique_ptr readOutput( ); } else { return std::make_unique( - wrapOutput(rawOutput) + "" + rawOutput + "" ); } } @@ -67,6 +61,20 @@ boost::optional importDocumentElement( } } +boost::process::context createContext( + const InputXSLT::FilesystemContext& fsContext) { + boost::process::context context; + + context.environment = boost::process::self::get_environment(); + context.stdout_behavior = boost::process::capture_stream(); + context.stdin_behavior = boost::process::capture_stream(); + context.work_directory = boost::filesystem::canonical( + fsContext.getBase().parent_path() + ).string(); + + return context; +} + } namespace InputXSLT { @@ -76,21 +84,13 @@ DomDocumentCache::document_ptr FunctionExternalCommand::constructDocument( std::string command, boost::optional input ) const { - DomDocumentCache::document_ptr domDocument( + DomDocumentCache::document_ptr domDocument{ DomDocumentCache::createDocument("content") - ); - - boost::process::context context; - context.environment = boost::process::self::get_environment(); - context.stdout_behavior = boost::process::capture_stream(); - context.stdin_behavior = boost::process::capture_stream(); - context.work_directory = boost::filesystem::canonical( - fsContext.getBase().parent_path() - ).string(); + }; - boost::process::child commandProcess( - boost::process::launch_shell(command, context) - ); + boost::process::child commandProcess{ + boost::process::launch_shell(command, createContext(fsContext)) + }; if ( input ) { boost::process::postream& inputStream = commandProcess.get_stdin(); @@ -140,7 +140,6 @@ DomDocumentCache::document_ptr FunctionExternalCommand::constructDocument( result.setAttribute("result", "error"); } - return domDocument; } -- cgit v1.2.3