]> git.mxchange.org Git - flightgear.git/commitdiff
Patch from Melchior Franz:
authordavid <david>
Wed, 27 Mar 2002 12:49:29 +0000 (12:49 +0000)
committerdavid <david>
Wed, 27 Mar 2002 12:49:29 +0000 (12:49 +0000)
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.

src/Navaids/ilslist.cxx
src/Navaids/navlist.cxx

index eb9247f0a82385bf09fc56093275bd0d106a3fcf..e7bd0994e76df82cc85f8ca1803049a46459ce62 100644 (file)
@@ -80,8 +80,13 @@ bool FGILSList::init( SGPath path ) {
     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;
@@ -89,9 +94,8 @@ bool FGILSList::init( SGPath path ) {
        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 ) {
index 0bfd42a69189ccc20646444761844814dfd74b2a..3892dcb8da303d360b31f56c31331adf459aa62a 100644 (file)
@@ -79,8 +79,13 @@ bool FGNavList::init( SGPath path ) {
     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;
@@ -88,9 +93,8 @@ bool FGNavList::init( SGPath path ) {
        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' ) {