diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-02-01 14:01:10 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-02-01 14:01:10 -0330 |
commit | ebf526bc944045bd6d9fc6ef9721c9f56e18151c (patch) | |
tree | a5249f0e9f8a048dfad3d8f67a4200f4d6f918d2 /cpp/src/Slice/Preprocessor.cpp | |
parent | Fixed slice include directory (diff) | |
download | ice-ebf526bc944045bd6d9fc6ef9721c9f56e18151c.tar.bz2 ice-ebf526bc944045bd6d9fc6ef9721c9f56e18151c.tar.xz ice-ebf526bc944045bd6d9fc6ef9721c9f56e18151c.zip |
Bug 2672 - mcpp messing up interactive python/ruby demos
Diffstat (limited to 'cpp/src/Slice/Preprocessor.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 |