diff options
Diffstat (limited to 'cpp')
-rwxr-xr-x | cpp/src/Slice/Preprocessor.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 68f68c1c851..eed134be39b 100755 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -150,7 +150,16 @@ Slice::Preprocessor::preprocess(bool keepComments) { argv[i + 1] = (char*) args[i].c_str(); } - + + // + // Mcpp redirects stdin which causes problems for Python + // and Ruby applications which use loadSlice. Therefore + // we need to save handle to stdin so we can restore it + // after mcpp has finished its processing. + // + int stdin_save; + stdin_save = dup(0); + // // Call mcpp using memory buffer. // @@ -159,6 +168,14 @@ Slice::Preprocessor::preprocess(bool keepComments) delete[] argv; // + // Restore stdin. + // + fflush(stdin); + ::close(0); + dup2(stdin_save, 0); + ::close(stdin_save); + + // // Write output to temporary file. Print errors to stderr. // string result; @@ -167,7 +184,7 @@ Slice::Preprocessor::preprocess(bool keepComments) _cppFile = ".preprocess." + IceUtil::generateUUID(); SignalHandler::addFile(_cppFile); #ifdef _WIN32 - _cppHandle = ::_wfopen(IceUtil::stringToWstring(_cppFile).c_str(), IceUtil::stringToWstring("w+").c_str()); + _cppHandle = ::_fopen(_cppFile.c_str(), "w+"); #else _cppHandle = ::fopen(_cppFile.c_str(), "w+"); #endif |