Mercurial > hg > forks > UniversalIndentGUI
changeset 734:53de31f7e55b
Ensure correct command line parsing on Mac, because when opened with Finder, a curious argument starting with "-psn" will be added.
Undone previous change within TCLAP code.
git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@1011 59b1889a-e5ac-428c-b0c7-476e01d41282
author | thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282> |
---|---|
date | Sun, 12 Sep 2010 18:15:49 +0000 |
parents | fe50761a234f |
children | f2da6de11815 |
files | src/main.cpp src/tclap/CmdLine.h |
diffstat | 2 files changed, 19 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.cpp Tue Sep 07 07:17:38 2010 +0000 +++ b/src/main.cpp Sun Sep 12 18:15:49 2010 +0000 @@ -124,6 +124,25 @@ attachedToConsole = attachToConsole(); #endif +#ifdef __APPLE__ + // Filter out -psn_0_118813 and similar parameters. + std::vector<char*> argList; + for ( int i = 0; i < argc; i++ ) { + QString argString(argv[i]); + + if ( argString.startsWith("-psn_") ) { + argList.push_back(argv[i]); + } + else { +// std::cerr << std::endl << "The parameter "<< i << " is an invalid finder parameter. Parameter was " << argv[i] << std::endl; + } + } + for ( size_t i = 0; i < argList.size(); i++ ) { + argv[i] = argList.at(i); + } + argc = argList.size(); +#endif + // Wrap everything in a try block. Do this every time, // because exceptions will be thrown for problems. try {
--- a/src/tclap/CmdLine.h Tue Sep 07 07:17:38 2010 +0000 +++ b/src/tclap/CmdLine.h Sun Sep 12 18:15:49 2010 +0000 @@ -458,15 +458,6 @@ if ( !matched && _emptyCombined( args[i] ) ) matched = true; -#ifdef __APPLE__ - // If we are running on Mac, opening an app with the finder - // adds a command line arg like this: -^G^Gn_0_516222. - // To avoid a CmdLineParseException set matched to true if - // the arg begines with ^. - if ( !matched && args[i].at(0) == '^' ) - matched = true; -#endif - if ( !matched && !Arg::ignoreRest() ) throw(CmdLineParseException("Couldn't find match " "for argument",