From 554fa0c12a97aed3440c0fd38e54637f9cedc497 Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Thu, 28 Aug 2008 12:23:47 -0230 Subject: Use tmpfile() to create preporcessor tmp file Set up signal handling in RB/Py/PHP --- cpp/src/Slice/Preprocessor.cpp | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'cpp/src/Slice/Preprocessor.cpp') diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index b9fb132092f..e2ddc5cbe09 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -71,9 +71,6 @@ Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, co Slice::Preprocessor::~Preprocessor() { - _preprocess = 0; - SignalHandler::setCallback(0); - close(); } @@ -176,22 +173,9 @@ Slice::Preprocessor::preprocess(bool keepComments) // char* buf = mcpp_get_mem_buffer(Out); -#ifdef _WIN32 - TCHAR buffer[512]; - DWORD ret = GetTempPath(512, buffer); - if(ret > 512 || ret == 0) - { - fprintf(stderr, "GetTempPath failed (%d)\n", GetLastError()); - } - _cppFile = string(buffer) + "\\.preprocess." + IceUtil::generateUUID(); - _cppHandle = ::_wfopen(IceUtil::stringToWstring(_cppFile).c_str(), IceUtil::stringToWstring("w+").c_str()); -#else - _cppFile = "/tmp/.preprocess." + IceUtil::generateUUID(); - _cppHandle = ::fopen(_cppFile.c_str(), "w+"); -#endif + _cppHandle = tmpfile(); if(_cppHandle != NULL) { - SignalHandler::addFile(_cppFile); if(buf) { ::fwrite(buf, strlen(buf), 1, _cppHandle); @@ -200,7 +184,7 @@ Slice::Preprocessor::preprocess(bool keepComments) } else { - fprintf(stderr, "Could not open temporary file: %s\n", _cppFile.c_str()); + fprintf(stderr, "Could not open temporary file.\n"); } } @@ -468,6 +452,9 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector