X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAirports%2Frunwayprefs.cxx;h=e6f1eb68a304af390eb76f5df8ece7dd2715e61d;hb=c068049d840c2f4567c7d07e7fb37247d8e23407;hp=4ee6ac7b345a4e9a375e9235280c576acb18b0ad;hpb=45e3b7e2d19e7b0d1201f849c852bae5b6b3005b;p=flightgear.git diff --git a/src/Airports/runwayprefs.cxx b/src/Airports/runwayprefs.cxx index 4ee6ac7b3..e6f1eb68a 100644 --- a/src/Airports/runwayprefs.cxx +++ b/src/Airports/runwayprefs.cxx @@ -29,15 +29,21 @@ #include #include -#include +#include +#include #include +#include +#include + #include
#include #include "runwayprefs.hxx" #include "airport.hxx" +using namespace simgear; + /****************************************************************************** * ScheduleTime ***************e*************************************************************/ @@ -95,7 +101,7 @@ std::string ScheduleTime::getName(time_t dayStart) if ((start.size() != end.size()) || (start.size() != scheduleNames.size())) { SG_LOG(SG_GENERAL, SG_INFO, "Unable to parse schedule times"); - exit(1); + throw sg_exception("Unable to parse schedule times"); } else { int nrItems = start.size(); //cerr << "Nr of items to process: " << nrItems << endl; @@ -142,19 +148,20 @@ void RunwayList::set(const std::string & tp, const std::string & lst) // timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday; // timeCopy = timeCopy.substr(2,timeCopy.length()); type = tp; - std::string rwys = lst; - std::string rwy; - while (rwys.find(",") != std::string::npos) { - rwy = rwys.substr(0, rwys.find(",", 0)); - //cerr << "adding runway [" << rwy << "] to the list " << endl; - preferredRunways.push_back(rwy); - rwys.erase(0, rwys.find(",", 0) + 1); // erase until after the first whitspace - while (rwys[0] == ' ') - rwys.erase(0, 1); // Erase any leading whitespaces. - //cerr << "Remaining runway list " << rwys; + + + + BOOST_FOREACH(std::string s, strutils::split(lst, ",")) { + std::string ident = strutils::strip(s); + + // http://code.google.com/p/flightgear-bugs/issues/detail?id=1137 + if ((ident.size() < 2) || !isdigit(ident[1])) { + SG_LOG(SG_GENERAL, SG_INFO, "RunwayList::set: padding runway ident '" << ident << "'"); + ident = "0" + ident; + } + + preferredRunways.push_back(ident); } - preferredRunways.push_back(rwys); - //exit(1); } void RunwayList::clear()