diff --git a/src/globals.c b/src/globals.c index 8c22cd2f..0d8cf66c 100644 --- a/src/globals.c +++ b/src/globals.c @@ -195,7 +195,7 @@ const char fopen_read_mode[] = "r"; /* ---------------------------------------------------------- */ /* Cmdline options (used at xinit, and then not used anymore) */ /* ---------------------------------------------------------- */ -int cli_opt_argc; +int cli_opt_argc, cli_argc; char **cli_opt_argv = NULL; int cli_opt_netlist_type = 0; int cli_opt_flat_netlist = 0; diff --git a/src/main.c b/src/main.c index f89c116f..e501e19f 100644 --- a/src/main.c +++ b/src/main.c @@ -104,8 +104,8 @@ int main(int argc, char **argv) } else XCloseDisplay(display); } #endif - argc = process_options(argc, argv); - + cli_argc = argc; + cli_opt_argc = process_options(argc, argv); #ifdef __unix__ /* if invoked in background (and not invoked from a command pipeline) detach from console */ if(!fstat(0, &statbuf)) { @@ -125,9 +125,6 @@ int main(int argc, char **argv) * using cli_opt_detach if no windowing exists (has_x == 0) is non sense so do nothing */ - - - cli_opt_argc = argc; cli_opt_argv = my_malloc(_ALLOC_ID_, cli_opt_argc * sizeof(char *)); for(i = 0; i < cli_opt_argc; ++i) { cli_opt_argv[i] = NULL; diff --git a/src/xinit.c b/src/xinit.c index a9fad1b3..f8876a5b 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -2816,7 +2816,6 @@ int Tcl_AppInit(Tcl_Interp *inter) my_strncpy(xctx->sch_to_compare, abs_sym_path(cli_opt_diff, ""), S(xctx->sch_to_compare)); tclsetvar("compare_sch", "1"); } - if(cli_opt_filename[0]) { char f[PATH_MAX]; int file_loaded = 1; @@ -2852,7 +2851,7 @@ int Tcl_AppInit(Tcl_Interp *inter) if(cli_opt_do_netlist) if(!file_loaded) tcleval("exit 1"); if(cli_opt_do_netlist) set_modify(-1); /* set tab/window title */ tclvareval("update_recent_file {", f, "}", NULL); - } else /* if(!cli_opt_filename[0]) */ + } else if(cli_argc == 1) /* if(!cli_opt_filename[0]) */ { char * tmp; char fname[PATH_MAX]; diff --git a/src/xschem.h b/src/xschem.h index 8d7bae63..438c1b34 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1209,7 +1209,8 @@ extern char old_winpath[PATH_MAX]; /* previously switched window, used in callba extern const char fopen_read_mode[]; /* "r" on unix, "rb" on windows */ /*********** Cmdline options (used at xinit, and then not used anymore) ***********/ -extern int cli_opt_argc; +extern int cli_argc; /* copy of main argc */ +extern int cli_opt_argc; /* arguments after stripping off options */ extern char **cli_opt_argv; extern int cli_opt_netlist_type; extern int cli_opt_flat_netlist;