1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
Description: Fix compilation with gcc/g++ 6
Multiple inFile.getline() calls within xplanet test the return
against NULL in a read loop, but g++ 6 doesn't like this. Replace
with checks for inFile.eof() and inFile.fail() instead.
Author: Steve McIntyre <93sam@debian.org>
Bug-Debian: https://bugs.debian.org/811820
Forwarded: Hari Nair <hari@alumni.caltech.edu>
Last-Update: 2016-07-18
--- xplanet-1.3.0.orig/src/libannotate/addArcs.cpp
+++ xplanet-1.3.0/src/libannotate/addArcs.cpp
@@ -258,10 +258,14 @@ addArcs(PlanetProperties *planetProperti
{
ifstream inFile(arcFile.c_str());
char *line = new char[MAX_LINE_LENGTH];
- while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
- readArcFile(line, planet, view, projection,
- planetProperties, annotationMap);
-
+ while (1)
+ {
+ inFile.getline (line, MAX_LINE_LENGTH, '\n');
+ if (inFile.eof() || inFile.fail())
+ break;
+ readArcFile(line, planet, view, projection,
+ planetProperties, annotationMap);
+ }
inFile.close();
delete [] line;
}
@@ -292,9 +296,13 @@ addArcs(View *view, multimap<double, Ann
{
ifstream inFile(arcFile.c_str());
char *line = new char[256];
- while (inFile.getline (line, 256, '\n') != NULL)
- readArcFile(line, NULL, view, NULL, NULL, annotationMap);
-
+ while (1)
+ {
+ inFile.getline (line, 256, '\n');
+ if (inFile.eof() || inFile.fail())
+ break;
+ readArcFile(line, NULL, view, NULL, NULL, annotationMap);
+ }
inFile.close();
delete [] line;
}
--- xplanet-1.3.0.orig/src/libannotate/addMarkers.cpp
+++ xplanet-1.3.0/src/libannotate/addMarkers.cpp
@@ -423,13 +423,16 @@ addMarkers(PlanetProperties *planetPrope
{
ifstream inFile(markerFile.c_str());
char *line = new char[MAX_LINE_LENGTH];
- while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (1)
{
unsigned char color[3];
memcpy(color, planetProperties->MarkerColor(), 3);
string font(planetProperties->MarkerFont());
int fontSize(planetProperties->MarkerFontSize());
+ inFile.getline (line, MAX_LINE_LENGTH, '\n');
+ if (inFile.eof() || inFile.fail())
+ break;
readMarkerFile(line, planet, pixel_radius, X, Y, Z,
view, projection, width, height,
color, font, fontSize,
@@ -469,13 +472,18 @@ addMarkers(View *view, const int width,
{
ifstream inFile(markerFile.c_str());
char *line = new char[MAX_LINE_LENGTH];
- while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
- {
+ while (1)
+ {
+ inFile.getline (line, MAX_LINE_LENGTH, '\n');
+
unsigned char color[3];
memcpy(color, options->Color(), 3);
string font(options->Font());
int fontSize(options->FontSize());
+ if (inFile.eof() || inFile.fail())
+ break;
+
readMarkerFile(line, NULL, 0, 0, 0, 0,
view, NULL, width, height,
color, font, fontSize, 1.0,
--- xplanet-1.3.0.orig/src/libannotate/addSatellites.cpp
+++ xplanet-1.3.0/src/libannotate/addSatellites.cpp
@@ -488,11 +488,23 @@ loadSatelliteVector(PlanetProperties *pl
{
ifstream inFile(tleFile.c_str());
char lines[3][80];
- while (inFile.getline(lines[0], 80) != NULL)
- {
- if ((inFile.getline(lines[1], 80) == NULL)
- || (inFile.getline(lines[2], 80) == NULL))
- {
+ bool malformed_file = false;
+ while (1)
+ {
+ inFile.getline(lines[0], 80);
+ if (inFile.eof() || inFile.fail())
+ break;
+ inFile.getline(lines[1], 80);
+ if (inFile.eof() || inFile.fail())
+ malformed_file = true;
+ else
+ {
+ inFile.getline(lines[2], 80);
+ if (inFile.eof() || inFile.fail())
+ malformed_file = true;
+ }
+ if (malformed_file)
+ {
ostringstream errStr;
errStr << "Malformed TLE file (" << tleFile << ")?\n";
xpWarn(errStr.str(), __FILE__, __LINE__);
@@ -542,10 +554,14 @@ addSatellites(PlanetProperties *planetPr
{
ifstream inFile(satFile.c_str());
char *line = new char[MAX_LINE_LENGTH];
- while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (1)
+ {
+ inFile.getline (line, MAX_LINE_LENGTH, '\n');
+ if (inFile.eof() || inFile.fail())
+ break;
readSatelliteFile(line, planet, view, projection,
planetProperties, annotationMap);
-
+ }
inFile.close();
delete [] line;
}
--- xplanet-1.3.0.orig/src/libmultiple/RayleighScattering.cpp
+++ xplanet-1.3.0/src/libmultiple/RayleighScattering.cpp
@@ -369,8 +369,12 @@ RayleighScattering::readConfigFile(strin
diskTemplate_.clear();
limbTemplate_.clear();
- while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (1)
{
+ inFile.getline(line, MAX_LINE_LENGTH, '\n');
+ if (inFile.eof() || inFile.fail())
+ break;
+
int i = 0;
while (isDelimiter(line[i]))
{
@@ -439,8 +443,12 @@ RayleighScattering::readBlock(ifstream &
values.clear();
char line[MAX_LINE_LENGTH];
- while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (1)
{
+ inFile.getline(line, MAX_LINE_LENGTH, '\n');
+ if (inFile.eof() || inFile.fail())
+ break;
+
int i = 0;
while (isDelimiter(line[i]))
{
@@ -470,8 +478,12 @@ RayleighScattering::readValue(ifstream &
double &value)
{
char line[MAX_LINE_LENGTH];
- while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (1)
{
+ inFile.getline(line, MAX_LINE_LENGTH, '\n');
+ if (inFile.eof() || inFile.fail())
+ break;
+
int i = 0;
while (isDelimiter(line[i]))
{
--- xplanet-1.3.0.orig/src/libmultiple/drawStars.cpp
+++ xplanet-1.3.0/src/libmultiple/drawStars.cpp
@@ -41,8 +41,12 @@ drawStars(DisplayBase *display, View *vi
ifstream inFile(starMap.c_str());
char line[MAX_LINE_LENGTH];
- while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (1)
{
+ inFile.getline(line, MAX_LINE_LENGTH, '\n');
+ if (inFile.eof() || inFile.fail())
+ break;
+
if (line[0] == '#') continue;
double Vmag, RA, Dec;
--- xplanet-1.3.0.orig/src/readConfig.cpp
+++ xplanet-1.3.0/src/readConfig.cpp
@@ -550,9 +550,13 @@ readConfigFile(string configFile, Planet
ifstream inFile(configFile.c_str());
char *line = new char[256];
- while (inFile.getline(line, 256, '\n') != NULL)
+ while (1)
+ {
+ inFile.getline(line, 256, '\n');
+ if (inFile.eof() || inFile.fail())
+ break;
readConfig(line, planetProperties);
-
+ }
// This condition will only be true if [default] is the only
// section in the config file. In this case, set all planet
// properties to the default values.
|