1
0
Fork 0

Patch from Melchior Franz:

When the loop starts, n.type is still undefined, so the while statement
depends on unitialized garbage. The input operator cares for the [End]
bracket anyway (returns if the first character is a '['). So it is safe
to check for it after reading the line and break if necessary.
This commit is contained in:
david 2002-03-27 12:49:29 +00:00
parent 37b60664d1
commit 7e1b599368
2 changed files with 16 additions and 8 deletions

View file

@ -80,8 +80,13 @@ bool FGILSList::init( SGPath path ) {
double min = 1000000.0; double min = 1000000.0;
double max = 0.0; double max = 0.0;
while ( ! in.eof() && ils.get_ilstype() != '[' ) { while ( ! in.eof() ) {
in >> ils; in >> ils;
if ( ils.get_ilstype() == '[' ) {
break;
}
/* cout << "id = " << n.get_ident() << endl; /* cout << "id = " << n.get_ident() << endl;
cout << " type = " << n.get_type() << endl; cout << " type = " << n.get_type() << endl;
cout << " lon = " << n.get_lon() << endl; cout << " lon = " << n.get_lon() << endl;
@ -89,9 +94,8 @@ bool FGILSList::init( SGPath path ) {
cout << " elev = " << n.get_elev() << endl; cout << " elev = " << n.get_elev() << endl;
cout << " freq = " << n.get_freq() << endl; cout << " freq = " << n.get_freq() << endl;
cout << " range = " << n.get_range() << endl; */ cout << " range = " << n.get_range() << endl; */
if ( ils.get_ilstype() != '[' ) {
ilslist[ils.get_locfreq()].push_back(ils); ilslist[ils.get_locfreq()].push_back(ils);
}
in >> skipcomment; in >> skipcomment;
if ( ils.get_locfreq() < min ) { if ( ils.get_locfreq() < min ) {

View file

@ -79,8 +79,13 @@ bool FGNavList::init( SGPath path ) {
double min = 100000; double min = 100000;
double max = 0; double max = 0;
while ( ! in.eof() && n.get_type() != '[' ) { while ( ! in.eof() ) {
in >> n; in >> n;
if ( n.get_type() == '[' ) {
break;
}
/* cout << "id = " << n.get_ident() << endl; /* cout << "id = " << n.get_ident() << endl;
cout << " type = " << n.get_type() << endl; cout << " type = " << n.get_type() << endl;
cout << " lon = " << n.get_lon() << endl; cout << " lon = " << n.get_lon() << endl;
@ -88,9 +93,8 @@ bool FGNavList::init( SGPath path ) {
cout << " elev = " << n.get_elev() << endl; cout << " elev = " << n.get_elev() << endl;
cout << " freq = " << n.get_freq() << endl; cout << " freq = " << n.get_freq() << endl;
cout << " range = " << n.get_range() << endl; */ cout << " range = " << n.get_range() << endl; */
if ( n.get_type() != '[' ) {
navaids[n.get_freq()].push_back(n); navaids[n.get_freq()].push_back(n);
}
in >> skipcomment; in >> skipcomment;
if ( n.get_type() != 'N' ) { if ( n.get_type() != 'N' ) {