wok-next view xplanet/stuff/patches/gcc-6.patch @ rev 21727

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