Hi All, Someone on the Forum (or was it here?) mentioned a problem where they couldn't use the Airport Search dialog easily because some airports in apt.dat are named in mixed case while some are in all-caps.
Rather than attempt to fix apt.dat (I'm not completely mad ;) ), I've created a small patch to our airport search function so that this search is done case-insensitively. I've done some minimal testing, and it at least appears to be functionally correct. However: a) As I'm sure many people are already aware, I'm not a very good C programmer, so there may be a better way to do this that I'm missing b) This uses the strcasestr() function, which is part of the GNU C library in string.h. What is the best way to check that such a function is available on all our platforms? -Stuart Index: AirportList.cxx =================================================================== RCS file: /var/cvs/FlightGear-0.9/source/src/GUI/AirportList.cxx,v retrieving revision 1.18 diff -u -p -r1.18 AirportList.cxx --- AirportList.cxx 11 Mar 2008 15:58:57 -0000 1.18 +++ AirportList.cxx 31 May 2008 21:12:34 -0000 @@ -30,7 +30,8 @@ AirportList::create_list () const FGAirport *apt = _airports->getAirport(i); STD::string entry(apt->getName() + " (" + apt->getId() + ')'); - if (!_filter.empty() && entry.find(_filter) == STD::string::npos) + // Perform filter check case-insensitively + if (!_filter.empty() && (strcasestr(entry.c_str(), _filter.c_str()) == NULL)) continue; content[n] = new char[entry.size() + 1]; __________________________________________________________ Sent from Yahoo! Mail. A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel