Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: Assertion failure during savegame load when FREECIV_PA
Home

[Freeciv-Dev] Re: Assertion failure during savegame load when FREECIV_PA

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Assertion failure during savegame load when FREECIV_PATH is set but empty (PR#1341)
From: Steven Taschuk <staschuk@xxxxxxxxxxxxxxx>
Date: Sun, 24 Mar 2002 11:27:41 -0800 (PST)

Jason Short wrote:
> Steven Taschuk wrote:
> > I suggest the following patch.
> >
> > --- common/shared.c.distribution        Sat Mar 23 11:12:02 2002
> > +++ common/shared.c     Sat Mar 23 12:38:22 2002
> > @@ -602,6 +602,10 @@
> >      char *path = getenv("FREECIV_PATH");
> >      if (!path) {
> >        path = DEFAULT_DATA_PATH;
> > +    } else if (*path == '\0') {
> > +      freelog( LOG_ERROR, _("FREECIV_PATH is set but empty; "
> > +                            "using default path instead.") );
> > +      path = DEFAULT_DATA_PATH;
> >      }
> >      path = mystrdup(path);     /* something we can strtok */
>
> This would probably still fail under FREECIV_PATH=" ".

I am not sure why you say so.  Strtok returns NULL to indicate there
are no more tokens, ie., when the string being tokenized is empty.  The
string " " contains one token, the string " " itself, and the first
call to strtok will return it.  (Subsequent strtok calls are checked
for NULL by the do loop condition.)

Am I missing something?



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