diff options
author | Jose <jose@zeroc.com> | 2016-09-17 00:28:00 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-09-17 00:28:00 +0200 |
commit | 47c3b5d2b03d3286cba2a3b4890e57fdd6135132 (patch) | |
tree | 40e05ffec6df92a5b88fdb675d775580f41547c1 /cpp/src/slice2objc | |
parent | 3.6.3 version fixes (diff) | |
download | ice-47c3b5d2b03d3286cba2a3b4890e57fdd6135132.tar.bz2 ice-47c3b5d2b03d3286cba2a3b4890e57fdd6135132.tar.xz ice-47c3b5d2b03d3286cba2a3b4890e57fdd6135132.zip |
Fix ICE-4787 - slice compilers and unicode paths
Diffstat (limited to 'cpp/src/slice2objc')
-rw-r--r-- | cpp/src/slice2objc/Main.cpp | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/cpp/src/slice2objc/Main.cpp b/cpp/src/slice2objc/Main.cpp index 1a766772ef0..c8d68d39bf1 100644 --- a/cpp/src/slice2objc/Main.cpp +++ b/cpp/src/slice2objc/Main.cpp @@ -53,7 +53,7 @@ interruptedCallback(int signal) } void -usage(const char* n) +usage(const string& n) { cerr << "Usage: " << n << " [options] slice-files...\n"; cerr << @@ -80,7 +80,7 @@ usage(const char* n) } int -main(int argc, char* argv[]) +compile(const vector<string>& argv) { IceUtilInternal::Options opts; opts.addOpt("h", "help"); @@ -101,20 +101,12 @@ main(int argc, char* argv[]) opts.addOpt("", "underscore"); opts.addOpt("", "case-sensitive"); - bool validate = false; - for(int i = 0; i < argc; ++i) - { - if(string(argv[i]) == "--validate") - { - validate = true; - break; - } - } + bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end(); vector<string> args; try { - args = opts.parse(argc, (const char**)argv); + args = opts.parse(argv); } catch(const IceUtilInternal::BadOptException& e) { @@ -334,3 +326,36 @@ main(int argc, char* argv[]) return status; } + +#ifdef _WIN32 +int wmain(int argc, wchar_t* argv[]) +#else +int main(int argc, char* argv[]) +#endif +{ + vector<string> args = Slice::argvToArgs(argc, argv); + try + { + return compile(args); + } + catch(const std::exception& ex) + { + getErrorStream() << args[0] << ": error:" << ex.what() << endl; + return EXIT_FAILURE; + } + catch(const std::string& msg) + { + getErrorStream() << args[0] << ": error:" << msg << endl; + return EXIT_FAILURE; + } + catch(const char* msg) + { + getErrorStream() << args[0] << ": error:" << msg << endl; + return EXIT_FAILURE; + } + catch(...) + { + getErrorStream() << args[0] << ": error:" << "unknown exception" << endl; + return EXIT_FAILURE; + } +} |