1
0
Fork 0

apt.dat parser: indentation fixes; add a comment

- The first place where indentation is fixed was really misleading, at
  least.

- The added comment "'line' may end with an \r character [...]" just
  clarifies something that has been there for ages, to avoid people
  falling into the trap.
This commit is contained in:
Florent Rougon 2016-04-24 20:10:10 +02:00
parent d85fc7b7e7
commit 2b8937c2c2

View file

@ -129,23 +129,24 @@ public:
throwExceptionIfStreamError(in, "apt.dat", apt_dat); throwExceptionIfStreamError(in, "apt.dat", apt_dat);
while ( std::getline(in, line) ) { while ( std::getline(in, line) ) {
// 'line' may end with an \r character, see above
line_num++; line_num++;
if ( isBlankOrCommentLine(line) ) if ( isBlankOrCommentLine(line) )
continue; continue;
if ((line_num % 100) == 0) { if ((line_num % 100) == 0) {
// every 100 lines // every 100 lines
unsigned int percent = (line_num * 100) / LINES_IN_APT_DAT; unsigned int percent = (line_num * 100) / LINES_IN_APT_DAT;
cache->setRebuildPhaseProgress(NavDataCache::REBUILD_AIRPORTS, percent); cache->setRebuildPhaseProgress(NavDataCache::REBUILD_AIRPORTS, percent);
} }
// Extract the first field into 'line_id' // Extract the first field into 'line_id'
line_id = atoi(line.c_str()); line_id = atoi(line.c_str());
if ( line_id == 1 /* Airport */ || if ( line_id == 1 /* Airport */ ||
line_id == 16 /* Seaplane base */ || line_id == 16 /* Seaplane base */ ||
line_id == 17 /* Heliport */ ) { line_id == 17 /* Heliport */ ) {
parseAirportLine(simgear::strutils::split(line)); parseAirportLine(simgear::strutils::split(line));
} else if ( line_id == 10 ) { // Runway v810 } else if ( line_id == 10 ) { // Runway v810
parseRunwayLine810(simgear::strutils::split(line)); parseRunwayLine810(simgear::strutils::split(line));