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.
double min = 1000000.0;
double max = 0.0;
- while ( ! in.eof() && ils.get_ilstype() != '[' ) {
+ while ( ! in.eof() ) {
in >> ils;
+
+ if ( ils.get_ilstype() == '[' ) {
+ break;
+ }
+
/* cout << "id = " << n.get_ident() << endl;
cout << " type = " << n.get_type() << endl;
cout << " lon = " << n.get_lon() << endl;
cout << " elev = " << n.get_elev() << endl;
cout << " freq = " << n.get_freq() << 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;
if ( ils.get_locfreq() < min ) {
double min = 100000;
double max = 0;
- while ( ! in.eof() && n.get_type() != '[' ) {
+ while ( ! in.eof() ) {
in >> n;
+
+ if ( n.get_type() == '[' ) {
+ break;
+ }
+
/* cout << "id = " << n.get_ident() << endl;
cout << " type = " << n.get_type() << endl;
cout << " lon = " << n.get_lon() << endl;
cout << " elev = " << n.get_elev() << endl;
cout << " freq = " << n.get_freq() << 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;
if ( n.get_type() != 'N' ) {