[Freeciv-Dev] (PR#1752) Command line option -d fails with Xaw client
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
[rfalke - Wed Nov 13 07:08:59 2002]:
> > A final idea would be to introduce a new argument, --gui. Any options
> > before this argument will be handled by FreeCiv. Any options after it
> > will be passed untouched to the GUI. So you could do
> > ./civ -d 0 --gui -d :0
> > to get both behaviors of -d.
>
> Since the gui options aren't used this often I think we should use
> this solution. The delimeter however should be changed to "--".
Yes, I agree now this is the best way to handle it.
See attached patch. You can now do "./civ -d 0 -- -d :0" with gui-xaw.
./civ -- --help gives some useful information.
As a side note, it looks like the information given by ./civ -- --help
was probably supposed to be tacked on to the end of the standard "help"
output, but because this exits immediately after printing the help it
never happened.
jason
Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.151
diff -u -r1.151 civclient.c
--- client/civclient.c 2002/11/14 09:14:50 1.151
+++ client/civclient.c 2002/11/15 03:45:57
@@ -110,8 +110,9 @@
**************************************************************************/
int main(int argc, char *argv[])
{
- int i;
- int loglevel;
+ int i, loglevel;
+ int ui_options = 0;
+ bool ui_separator = FALSE;
char *logfile=NULL;
char *option=NULL;
@@ -125,7 +126,10 @@
i = 1;
while (i < argc) {
- if (is_option("--help", argv[i])) {
+ if (ui_separator) {
+ argv[1 + ui_options] = argv[i];
+ ui_options++;
+ } else if (is_option("--help", argv[i])) {
fprintf(stderr, _("Usage: %s [option ...]\n"
"Valid options are:\n"), argv[0]);
fprintf(stderr, _(" -a, --autoconnect\tSkip connect dialog\n"));
@@ -148,6 +152,9 @@
fprintf(stderr, _(" -t, --tiles FILE\t"
"Use data file FILE.tilespec for tiles\n"));
fprintf(stderr, _(" -v, --version\t\tPrint the version number\n"));
+ fprintf(stderr, _(" --\t\t"
+ "Pass any following options to the UI.\n"
+ "\t\t\tTry \"%s -- --help\" for more.\n"), argv[0]);
exit(EXIT_SUCCESS);
} else if (is_option("--version",argv[i])) {
fprintf(stderr, "%s %s\n", freeciv_name_version(), client_string);
@@ -177,12 +184,18 @@
}
} else if ((option = get_option("--tiles", argv, &i, argc)))
sz_strlcpy(tile_set_name, option);
- else {
+ else if (is_option("--", argv[i])) {
+ ui_separator = TRUE;
+ } else {
fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
exit(EXIT_FAILURE);
}
i++;
} /* of while */
+
+ /* Remove all options except those intended for the UI. */
+ argv[1 + ui_options] = NULL;
+ argc = 1 + ui_options;
log_init(logfile, loglevel, NULL);
- [Freeciv-Dev] (PR#1752) Command line option -d fails with Xaw client,
Jason Short via RT <=
|
|