diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-09-25 10:15:15 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-09-26 11:30:35 +0200 |
commit | f4a4ba9ac1b58b4726825400e1edd1bf47d4080a (patch) | |
tree | bac77ca71f40262110433cb4e53fbcb5dc54a42c /desktop/unx | |
parent | 4972652eeba3ffa4d5055493d9275cfdc27b247c (diff) |
Clean up option processing
* Support --version on non-UNX, too.
* Consistently show the first unknown option and the help blob in the presence
of any unknown options.
* There is no need to tunnel --help/--version past oosplash in the soffice
script, as oosplash is prepared to treat them adequately (esp. not pass them
over any pipe); this only added unnecessary variance to what spellings exactly
are supported and how mixtures of --help, --version, and unknown options are
handled.
Change-Id: I617f2e727e2f0eafd34a2de3b85d441c6783ec4f
Diffstat (limited to 'desktop/unx')
-rw-r--r-- | desktop/unx/source/args.c | 39 | ||||
-rw-r--r-- | desktop/unx/source/args.h | 1 | ||||
-rw-r--r-- | desktop/unx/source/start.c | 26 |
3 files changed, 38 insertions, 28 deletions
diff --git a/desktop/unx/source/args.c b/desktop/unx/source/args.c index 0e01123cb242..e08d119397de 100644 --- a/desktop/unx/source/args.c +++ b/desktop/unx/source/args.c @@ -48,30 +48,34 @@ static struct { unsigned int bInhibitSplash : 1; unsigned int bInhibitPagein : 1; unsigned int bInhibitJavaLdx : 1; + unsigned int bInhibitPipe : 1; const char *pPageinType; } pArgDescr[] = { /* have a trailing argument */ - { "pt", 1, 0, 0, 0, NULL }, - { "display", 1, 0, 0, 0, NULL }, + { "pt", 1, 0, 0, 0, 0, NULL }, + { "display", 1, 0, 0, 0, 0, NULL }, /* no splash */ - { "nologo", 0, 1, 0, 0, NULL }, - { "headless", 0, 1, 0, 0, NULL }, - { "invisible", 0, 1, 0, 0, NULL }, - { "quickstart", 0, 1, 0, 0, NULL }, - { "minimized", 0, 1, 0, 0, NULL }, + { "nologo", 0, 1, 0, 0, 0, NULL }, + { "headless", 0, 1, 0, 0, 0, NULL }, + { "invisible", 0, 1, 0, 0, 0, NULL }, + { "quickstart", 0, 1, 0, 0, 0, NULL }, + { "minimized", 0, 1, 0, 0, 0, NULL }, /* pagein bits */ - { "writer", 0, 0, 0, 0, "pagein-writer" }, - { "calc", 0, 0, 0, 0, "pagein-calc" }, - { "draw", 0, 0, 0, 0, "pagein-draw" }, - { "impress", 0, 0, 0, 0, "pagein-impress" }, - - /* nothing much */ - { "version", 0, 1, 1, 1, NULL }, - { "help", 0, 1, 1, 1, NULL }, - { "h", 0, 1, 1, 1, NULL }, - { "?", 0, 1, 1, 1, NULL }, + { "writer", 0, 0, 0, 0, 0, "pagein-writer" }, + { "calc", 0, 0, 0, 0, 0, "pagein-calc" }, + { "draw", 0, 0, 0, 0, 0, "pagein-draw" }, + { "impress", 0, 0, 0, 0, 0, "pagein-impress" }, + + /* Do not send --help/--version over the pipe, as their output shall go to + the calling process's stdout (ideally, this would also happen in the + presence of unknown options); also prevent splash/pagein/javaldx overhead + (as these options will be processed early in soffice_main): */ + { "version", 0, 1, 1, 1, 1, NULL }, + { "help", 0, 1, 1, 1, 1, NULL }, + { "h", 0, 1, 1, 1, 1, NULL }, + { "?", 0, 1, 1, 1, 1, NULL }, }; Args *args_parse (void) @@ -133,6 +137,7 @@ Args *args_parse (void) args->bInhibitSplash |= pArgDescr[j].bInhibitSplash; args->bInhibitPagein |= pArgDescr[j].bInhibitPagein; args->bInhibitJavaLdx |= pArgDescr[j].bInhibitJavaLdx; + args->bInhibitPipe |= pArgDescr[j].bInhibitPipe; if (pArgDescr[j].pPageinType) args->pPageinType = pArgDescr[j].pPageinType; break; diff --git a/desktop/unx/source/args.h b/desktop/unx/source/args.h index 4a0cb55ffcde..9176badbda2a 100644 --- a/desktop/unx/source/args.h +++ b/desktop/unx/source/args.h @@ -38,6 +38,7 @@ typedef struct { sal_Bool bInhibitSplash; // should we show a splash screen sal_Bool bInhibitPagein; // should we run pagein ? sal_Bool bInhibitJavaLdx; // should we run javaldx ? + sal_Bool bInhibitPipe; // for --help and --version sal_uInt32 nArgsEnv; // number of -env: style args sal_uInt32 nArgsTotal; // number of -env: as well as -writer style args diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c index f1e872efa4c9..2800ef337deb 100644 --- a/desktop/unx/source/start.c +++ b/desktop/unx/source/start.c @@ -831,21 +831,24 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) if ( pUsePlugin && !strcmp(pUsePlugin, "svp") ) args->bInhibitSplash = sal_True; - pPipePath = get_pipe_path( args->pAppPath ); - - if ( ( fd = connect_pipe( pPipePath ) ) >= 0 ) + if ( !args->bInhibitPipe ) { - rtl_uString *pCwdPath = NULL; - osl_getProcessWorkingDir( &pCwdPath ); + pPipePath = get_pipe_path( args->pAppPath ); + + if ( ( fd = connect_pipe( pPipePath ) ) >= 0 ) + { + rtl_uString *pCwdPath = NULL; + osl_getProcessWorkingDir( &pCwdPath ); - bSentArgs = send_args( fd, pCwdPath ); + bSentArgs = send_args( fd, pCwdPath ); - close( fd ); - } + close( fd ); + } #if OSL_DEBUG_LEVEL > 1 - else - ustr_debug( "Failed to connect to pipe", pPipePath ); + else + ustr_debug( "Failed to connect to pipe", pPipePath ); #endif + } if ( !bSentArgs ) { @@ -935,7 +938,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) } /* cleanup */ - rtl_uString_release( pPipePath ); + if ( pPipePath ) + rtl_uString_release( pPipePath ); args_free (args); return status; |