403Webshell
Server IP : 82.208.35.60  /  Your IP : 216.73.216.238
Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31
System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64
User : studiokobylisy_cz ( 1008)
PHP Version : 7.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/ports/astro/xplanet/files/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/ports/astro/xplanet/files/patch-src_readConfig.cpp
The later chunks (using i2b) are compile fixes on aarch64 (presumably with
clang6 as well). Typical error message reads

    readConfig.cpp:407:54: error: non-constant-expression cannot be narrowed 
    from type 'int' to 'unsigned char' in initializer list [-Wc++11-narrowing]
        unsigned char color[3] = { r & 0xff, g & 0xff, b & 0xff };
                                   ^~~~~~~~
    readConfig.cpp:407:54: note: insert an explicit cast to silence this issue
        unsigned char color[3] = { r & 0xff, g & 0xff, b & 0xff };
                                   ^~~~~~~~
                                   static_cast<unsigned char>( )

Since it happens in a half-dozen places, introduce a trivial helper function.

--- src/readConfig.cpp.orig	2018-01-21 16:58:09 UTC
+++ src/readConfig.cpp
@@ -4,6 +4,7 @@
 #include <fstream>
 #include <sstream>
 #include <string>
+#include <clocale>
 using namespace std;
 
 #include "body.h"
@@ -20,6 +21,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 +52,7 @@ readConfig(const char *line, PlanetPrope
             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 +182,7 @@ readConfig(const char *line, PlanetPrope
             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 +247,7 @@ readConfig(const char *line, PlanetPrope
             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 +299,7 @@ readConfig(const char *line, PlanetPrope
             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 +406,7 @@ readConfig(const char *line, PlanetPrope
             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 +476,7 @@ readConfig(const char *line, PlanetPrope
             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

Youez - 2016 - github.com/yon3zu
LinuXploit