From 7e1b59936865d1a6efced13d2384004d08b99baf Mon Sep 17 00:00:00 2001 From: david Date: Wed, 27 Mar 2002 12:49:29 +0000 Subject: [PATCH] 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. --- src/Navaids/ilslist.cxx | 12 ++++++++---- src/Navaids/navlist.cxx | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Navaids/ilslist.cxx b/src/Navaids/ilslist.cxx index eb9247f0a..e7bd0994e 100644 --- a/src/Navaids/ilslist.cxx +++ b/src/Navaids/ilslist.cxx @@ -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 ) { diff --git a/src/Navaids/navlist.cxx b/src/Navaids/navlist.cxx index 0bfd42a69..3892dcb8d 100644 --- a/src/Navaids/navlist.cxx +++ b/src/Navaids/navlist.cxx @@ -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' ) {