Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2000:
[Freeciv-Dev] Re: Government file.
Home

[Freeciv-Dev] Re: Government file.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Stig Erik Sandoe <stig@xxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Government file.
From: Nicolas BRUNEL <brunel@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Jan 2000 23:28:10 +0000 (GMT)

> >    Example:
> >      for(i = 0; i < size; i++)
> >          if (ToBeFound == Tab [i]) return i;
> >      becomes
> >      for(i = 0; i < size && ToBeFound != Tab [i]; i++);
> >      return i;
> 
> These don't seem identical to me.  Is it my C knowledge which is
> getting rusty?  (ie the first one says nothing about what to return
> if no element in Tab is '==' to ToBeFound) 

True, the code was 

for(i = 0; i < size; i++)
          if (ToBeFound == Tab [i]) return i;
return size;

And, in government.c, (It's in the patch attached. ) 
 for(i=G_FIRST_FLAG; i<G_LAST_FLAG; i++) {
    if (mystrcasecmp(flag_names[i], s)==0) {
      return i;
    }
  }
  return G_LAST_FLAG;

Bye,

Nicolas




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