diff options
author | Benoit Foucher <benoit@zeroc.com> | 2002-10-29 17:36:01 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2002-10-29 17:36:01 +0000 |
commit | 6c8b1db065f4cb87d490e047a89e2cbad8a6d152 (patch) | |
tree | df2bebe0fbadb2eb3b03cc6fe61242f2da30f111 /cpp/src/slice2docbook/Main.cpp | |
parent | removed AbortException from IcePatch. Fixed exception cleanup code in (diff) | |
download | ice-6c8b1db065f4cb87d490e047a89e2cbad8a6d152.tar.bz2 ice-6c8b1db065f4cb87d490e047a89e2cbad8a6d152.tar.xz ice-6c8b1db065f4cb87d490e047a89e2cbad8a6d152.zip |
Fixed the translators to use the icecpp C preprocessor.
Diffstat (limited to 'cpp/src/slice2docbook/Main.cpp')
-rw-r--r-- | cpp/src/slice2docbook/Main.cpp | 55 |
1 files changed, 13 insertions, 42 deletions
diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index 7073be2d328..d16d7d3afc4 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -12,8 +12,8 @@ // // ********************************************************************** +#include <Slice/Preprocessor.h> #include <Gen.h> -#include <fstream> using namespace std; using namespace Slice; @@ -44,7 +44,7 @@ usage(const char* n) int main(int argc, char* argv[]) { - string cpp("cpp -C"); + string cppArgs; bool debug = false; bool ice = false; bool caseSensitive = false; @@ -57,8 +57,8 @@ main(int argc, char* argv[]) { if(strncmp(argv[idx], "-I", 2) == 0) { - cpp += ' '; - cpp += argv[idx]; + cppArgs += ' '; + cppArgs += argv[idx]; for(int i = idx ; i + 1 < argc ; ++i) { @@ -68,8 +68,8 @@ main(int argc, char* argv[]) } else if(strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0) { - cpp += ' '; - cpp += argv[idx]; + cppArgs += ' '; + cppArgs += argv[idx]; for(int i = idx ; i + 1 < argc ; ++i) { @@ -187,51 +187,22 @@ main(int argc, char* argv[]) for(idx = 2 ; idx < argc ; ++idx) { - string file(argv[idx]); - string suffix; - string::size_type pos = file.rfind('.'); - if(pos != string::npos) - { - suffix = file.substr(pos); - transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower); - } - if(suffix != ".ice") - { - cerr << argv[0] << ": input files must end with `.ice'" << endl; - unit->destroy(); - return EXIT_FAILURE; - } + Preprocessor icecpp(argv[0], argv[idx], cppArgs); + FILE* cppHandle = icecpp.preprocess(true); - ifstream test(argv[idx]); - if(!test) + if(cppHandle == 0) { - cerr << argv[0] << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl; unit->destroy(); return EXIT_FAILURE; } - test.close(); - - string cmd = cpp + " " + argv[idx]; -#ifdef _WIN32 - FILE* cppHandle = _popen(cmd.c_str(), "r"); -#else - FILE* cppHandle = popen(cmd.c_str(), "r"); -#endif - if(cppHandle == 0) + + status = unit->parse(cppHandle, debug); + + if(!icecpp.close()) { - cerr << argv[0] << ": can't run C++ preprocessor: " << strerror(errno) << endl; unit->destroy(); return EXIT_FAILURE; } - - status = unit->parse(cppHandle, debug); - -#ifdef _WIN32 - _pclose(cppHandle); -#else - pclose(cppHandle); -#endif - } if(status == EXIT_SUCCESS) |