Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2000:
[Freeciv-Dev] Re: civserver parameter null length (PR#520)
Home

[Freeciv-Dev] Re: civserver parameter null length (PR#520)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ChrisK@xxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: civserver parameter null length (PR#520)
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sat, 19 Aug 2000 23:14:09 +1000 (EST)

On Wed, 16 Aug 2000 Christian Knoke <ChrisK@xxxxxxxx> wrote:

> If you do a
> 
> chris@max:~ > civserver -f ""
> 
> you get
> 
> Freeciv version 1.11.4 Server
> Weitere Informationen zu Freeciv finden Sie auf http://www.freeciv.org/.
> 1: Lade Spiel ''
> civserver: inputfile.c:208: inf_open: Zusicherung »strlen(filename)>0«
> nicht erfüllt.
> Abgebrochen
> chris@max:~ > 

Yes, seems ok to me ;-)

Ok, true, assert shouldn't be triggered by invalid user-data,
and the error message should be nicer.

I suspect we don't actually want any of the command-line
arguments to be empty.  In that case this patch handles all
of them by adjusting get_option().

Regards,
-- David
diff -u -r --exclude-from exclude freeciv-cvs/common/shared.c 
fc-adv/common/shared.c
--- freeciv-cvs/common/shared.c Mon Aug 14 22:38:46 2000
+++ fc-adv/common/shared.c      Sat Aug 19 23:06:20 2000
@@ -122,9 +122,11 @@
 
 /**************************************************************************
   return a char * to the parameter of the option or NULL.
-  *i can be increased to get next string in the array argv[]. 
- **************************************************************************/
-char * get_option(const char *option_name,char **argv,int *i,int argc)
+  *i can be increased to get next string in the array argv[].
+  It is an error for the option to exist but be an empty string.
+  This doesn't use freelog() because it is used before logging is set up.
+**************************************************************************/
+char *get_option(const char *option_name, char **argv, int *i, int argc)
 {
   int len = strlen(option_name);
 
@@ -139,6 +141,10 @@
       if (*i < argc - 1) {
        (*i)++;
        opt = argv[*i];
+       if (strlen(opt)==0) {
+         fprintf(stderr, _("Empty argument for \"%s\".\n"), option_name);
+         exit(1);
+       }
       }        else {
        fprintf(stderr, _("Missing argument for \"%s\".\n"), option_name);
        exit(1);

[Prev in Thread] Current Thread [Next in Thread]