fix build with clang6; partly from freebsd

This commit is contained in:
jasper 2018-04-08 19:30:11 +00:00
parent 6e754d9114
commit 98cd2de891
6 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-src_libannotate_addArcs_cpp,v 1.1 2018/04/08 19:30:11 jasper Exp $
error: invalid operands to binary expression ('std::__1::basic_istream<char>' and 'nullptr_t')
Index: src/libannotate/addArcs.cpp
--- src/libannotate/addArcs.cpp.orig
+++ src/libannotate/addArcs.cpp
@@ -258,7 +258,7 @@ addArcs(PlanetProperties *planetProperties, Planet *pl
{
ifstream inFile(arcFile.c_str());
char *line = new char[MAX_LINE_LENGTH];
- while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (inFile.getline (line, MAX_LINE_LENGTH, '\n'))
readArcFile(line, planet, view, projection,
planetProperties, annotationMap);
@@ -292,7 +292,7 @@ addArcs(View *view, multimap<double, Annotation *> &an
{
ifstream inFile(arcFile.c_str());
char *line = new char[256];
- while (inFile.getline (line, 256, '\n') != NULL)
+ while (inFile.getline (line, 256, '\n'))
readArcFile(line, NULL, view, NULL, NULL, annotationMap);
inFile.close();

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-src_libannotate_addMarkers_cpp,v 1.1 2018/04/08 19:30:11 jasper Exp $
error: invalid operands to binary expression ('std::__1::basic_istream<char>' and 'nullptr_t')
Index: src/libannotate/addMarkers.cpp
--- src/libannotate/addMarkers.cpp.orig
+++ src/libannotate/addMarkers.cpp
@@ -423,7 +423,7 @@ addMarkers(PlanetProperties *planetProperties, Planet
{
ifstream inFile(markerFile.c_str());
char *line = new char[MAX_LINE_LENGTH];
- while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (inFile.getline (line, MAX_LINE_LENGTH, '\n'))
{
unsigned char color[3];
memcpy(color, planetProperties->MarkerColor(), 3);
@@ -469,7 +469,7 @@ addMarkers(View *view, const int width, const int heig
{
ifstream inFile(markerFile.c_str());
char *line = new char[MAX_LINE_LENGTH];
- while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (inFile.getline (line, MAX_LINE_LENGTH, '\n'))
{
unsigned char color[3];
memcpy(color, options->Color(), 3);

View File

@ -0,0 +1,30 @@
$OpenBSD: patch-src_libannotate_addSatellites_cpp,v 1.1 2018/04/08 19:30:11 jasper Exp $
error: invalid operands to binary expression ('std::__1::basic_istream<char>' and 'nullptr_t')
Index: src/libannotate/addSatellites.cpp
--- src/libannotate/addSatellites.cpp.orig
+++ src/libannotate/addSatellites.cpp
@@ -488,10 +488,10 @@ loadSatelliteVector(PlanetProperties *planetProperties
{
ifstream inFile(tleFile.c_str());
char lines[3][80];
- while (inFile.getline(lines[0], 80) != NULL)
+ while (inFile.getline(lines[0], 80))
{
- if ((inFile.getline(lines[1], 80) == NULL)
- || (inFile.getline(lines[2], 80) == NULL))
+ if ((!inFile.getline(lines[1], 80))
+ || (!inFile.getline(lines[2], 80)))
{
ostringstream errStr;
errStr << "Malformed TLE file (" << tleFile << ")?\n";
@@ -542,7 +542,7 @@ addSatellites(PlanetProperties *planetProperties, Plan
{
ifstream inFile(satFile.c_str());
char *line = new char[MAX_LINE_LENGTH];
- while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (inFile.getline (line, MAX_LINE_LENGTH, '\n'))
readSatelliteFile(line, planet, view, projection,
planetProperties, annotationMap);

View File

@ -0,0 +1,34 @@
$OpenBSD: patch-src_libmultiple_RayleighScattering_cpp,v 1.1 2018/04/08 19:30:11 jasper Exp $
error: invalid operands to binary expression ('std::__1::basic_istream<char>' and 'nullptr_t')
Index: src/libmultiple/RayleighScattering.cpp
--- src/libmultiple/RayleighScattering.cpp.orig
+++ src/libmultiple/RayleighScattering.cpp
@@ -369,7 +369,7 @@ RayleighScattering::readConfigFile(string configFile)
diskTemplate_.clear();
limbTemplate_.clear();
- while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (inFile.getline(line, MAX_LINE_LENGTH, '\n'))
{
int i = 0;
while (isDelimiter(line[i]))
@@ -439,7 +439,7 @@ RayleighScattering::readBlock(ifstream &inFile,
values.clear();
char line[MAX_LINE_LENGTH];
- while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (inFile.getline(line, MAX_LINE_LENGTH, '\n'))
{
int i = 0;
while (isDelimiter(line[i]))
@@ -470,7 +470,7 @@ RayleighScattering::readValue(ifstream &inFile,
double &value)
{
char line[MAX_LINE_LENGTH];
- while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (inFile.getline(line, MAX_LINE_LENGTH, '\n'))
{
int i = 0;
while (isDelimiter(line[i]))

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-src_libmultiple_drawStars_cpp,v 1.1 2018/04/08 19:30:11 jasper Exp $
error: invalid operands to binary expression ('std::__1::basic_istream<char>' and 'nullptr_t')
Index: src/libmultiple/drawStars.cpp
--- src/libmultiple/drawStars.cpp.orig
+++ src/libmultiple/drawStars.cpp
@@ -41,7 +41,7 @@ drawStars(DisplayBase *display, View *view)
ifstream inFile(starMap.c_str());
char line[MAX_LINE_LENGTH];
- while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+ while (inFile.getline(line, MAX_LINE_LENGTH, '\n'))
{
if (line[0] == '#') continue;

View File

@ -0,0 +1,80 @@
$OpenBSD: patch-src_readConfig_cpp,v 1.1 2018/04/08 19:30:11 jasper Exp $
- error: invalid operands to binary expression ('std::__1::basic_istream<char>' and 'nullptr_t')
- error: non-constant-expression cannot be narrowed from type 'int' to 'unsigned char' in initializer list
Index: src/readConfig.cpp
--- src/readConfig.cpp.orig
+++ src/readConfig.cpp
@@ -20,6 +20,8 @@ using namespace std;
static PlanetProperties *defaultProperties;
static PlanetProperties *currentProperties;
+static inline unsigned char i2b( int x ) { return static_cast<unsigned int>(x) & 0xffU; }
+
static void
readConfig(const char *line, PlanetProperties *planetProperties[])
{
@@ -49,7 +51,7 @@ readConfig(const char *line, PlanetProperties *planetP
int r, g, b;
if (sscanf(returnString, "%d,%d,%d", &r, &g, &b) == 3)
{
- unsigned char color[3] = { r & 0xff, g & 0xff, b & 0xff };
+ unsigned char color[3] = { i2b(r), i2b(g), i2b(b) };
currentProperties->ArcColor(color);
}
else
@@ -179,7 +181,7 @@ readConfig(const char *line, PlanetProperties *planetP
int r, g, b;
if (sscanf(returnString, "%d,%d,%d", &r, &g, &b) == 3)
{
- unsigned char color[3] = { r & 0xff, g & 0xff, b & 0xff };
+ unsigned char color[3] = { i2b(r), i2b(g), i2b(b) };
currentProperties->Color(color);
}
else
@@ -244,7 +246,7 @@ readConfig(const char *line, PlanetProperties *planetP
int r, g, b;
if (sscanf(returnString, "%d,%d,%d", &r, &g, &b) == 3)
{
- unsigned char color[3] = { r & 0xff, g & 0xff, b & 0xff };
+ unsigned char color[3] = { i2b(r), i2b(g), i2b(b) };
currentProperties->GridColor(color);
}
else
@@ -296,7 +298,7 @@ readConfig(const char *line, PlanetProperties *planetP
int r, g, b;
if (sscanf(returnString, "%d,%d,%d", &r, &g, &b) == 3)
{
- unsigned char color[3] = { r & 0xff, g & 0xff, b & 0xff };
+ unsigned char color[3] = { i2b(r), i2b(g), i2b(b) };
currentProperties->MarkerColor(color);
}
else
@@ -403,7 +405,7 @@ readConfig(const char *line, PlanetProperties *planetP
int r, g, b;
if (sscanf(returnString, "%d,%d,%d", &r, &g, &b) == 3)
{
- unsigned char color[3] = { r & 0xff, g & 0xff, b & 0xff };
+ unsigned char color[3] = { i2b(r), i2b(g), i2b(b) };
currentProperties->OrbitColor(color);
}
else
@@ -473,7 +475,7 @@ readConfig(const char *line, PlanetProperties *planetP
int r, g, b;
if (sscanf(returnString, "%d,%d,%d", &r, &g, &b) == 3)
{
- unsigned char color[3] = { r & 0xff, g & 0xff, b & 0xff };
+ unsigned char color[3] = { i2b(r), i2b(g), i2b(b) };
currentProperties->TextColor(color);
}
else
@@ -550,7 +552,7 @@ readConfigFile(string configFile, PlanetProperties *pl
ifstream inFile(configFile.c_str());
char *line = new char[256];
- while (inFile.getline(line, 256, '\n') != NULL)
+ while (inFile.getline(line, 256, '\n'))
readConfig(line, planetProperties);
// This condition will only be true if [default] is the only