Переглянути джерело

Android Studio build fixes 2of2 -- Fix dStrstr and other build errors

Torque's `strstr` variant wasn't standard library compliant and has been fixed for all platforms that Torque 2D compiles for and runs on. Was explicitly corrected for Android Studio because current compiler refuses to allow old/incorrect usages.
Fixed pointer comparison to integer error, another thing not allowed by current compiler.
Fixed `free` and `malloc` undeclared function warnings.
delegateSignal.h's `_SIGNAL_H_` header guard collided with Unix signal.h's header guard, changed to `_DELEGATESIGNAL_H_`.
dottools 7 роки тому
батько
коміт
fbccd86f49

+ 1 - 1
engine/source/console/consoleDoc.cc

@@ -278,7 +278,7 @@ void Namespace::printNamespaceEntries(Namespace * g, bool dumpScript, bool dumpE
          }
 
          // Finally, see if they did it foo(*) style.
-         char* func_pos = dStrstr(use, funcName);
+         const char* func_pos = dStrstr(use, funcName);
          if((func_pos) && (func_pos < bgn) && (end > bgn))
          {
             U32 len = (U32)(end - bgn - 1);

+ 1 - 1
engine/source/console/output_ScriptBinding.h

@@ -181,7 +181,7 @@ ConsoleFunctionWithDocs(quitWithErrorMessage, ConsoleVoid, 2, 2, (msg string))
 ConsoleFunctionWithDocs( gotoWebPage, ConsoleVoid, 2, 2, ( address ))
 {
    TORQUE_UNUSED( argc );
-   char* protocolSep = dStrstr(argv[1],"://");
+   const char* protocolSep = dStrstr(argv[1],"://");
 
    if( protocolSep != NULL )
    {

+ 3 - 3
engine/source/delegates/delegateSignal.h

@@ -20,8 +20,8 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#ifndef _SIGNAL_H_
-#define _SIGNAL_H_
+#ifndef _DELEGATESIGNAL_H_
+#define _DELEGATESIGNAL_H_
 
 #ifndef _UTIL_DELEGATE_H_
 #include "delegates/delegate.h"
@@ -663,4 +663,4 @@ class Signal<void(A,B,C,D,E,F,G,H,I,J)> : public SignalBaseT<void(A,B,C,D,E,F,G,
       }
 };
 
-#endif // _SIGNAL_H_
+#endif // _DELEGATESIGNAL_H_

+ 2 - 2
engine/source/graphics/dgl_ScriptBinding.h

@@ -95,7 +95,7 @@ ConsoleFunctionWithDocs(png2jpg, ConsoleInt, 2, 3, ( pngFilename, [quality ]? ))
    {
       char * buf = new char[dStrlen(bmpname)+32];
       dStrcpy(buf,bmpname);
-      char * pos = dStrstr((const char*)buf,".png");
+      char * pos = dStrstr(buf,".png");
       if (!pos)
          pos = buf + dStrlen(buf);
       dStrcpy(pos,".jpg");
@@ -105,7 +105,7 @@ ConsoleFunctionWithDocs(png2jpg, ConsoleInt, 2, 3, ( pngFilename, [quality ]? ))
    {
       char * buf = new char[dStrlen(bmpname)+32];
       dStrcpy(buf,bmpname);
-      char * pos = dStrstr((const char*)buf,".png");
+      char * pos = dStrstr(buf,".png");
       if (!pos)
          pos = buf + dStrlen(buf);
       dStrcpy(pos,".alpha.jpg");

+ 2 - 2
engine/source/platform/platformNet.cpp

@@ -259,7 +259,7 @@ namespace PlatformNetState
 
    struct addrinfo* pickAddressByProtocol(struct addrinfo* addr, int protocol)
    {
-      for (addr; addr != NULL; addr = addr->ai_next)
+      for (; addr != NULL; addr = addr->ai_next)
       {
          if (addr->ai_family == protocol)
             return addr;
@@ -1686,7 +1686,7 @@ Net::Error Net::send(NetSocket handleFd, const U8 *buffer, S32 bufferSize, S32 *
 
    if (outBytesWritten)
    {
-      *outBytesWritten = outBytesWritten < 0 ? 0 : bytesWritten;
+      *outBytesWritten = outBytesWritten < (void *)0 ? 0 : bytesWritten;
    }
 
    return PlatformNetState::getLastError();

+ 2 - 2
engine/source/platform/platformString.h

@@ -63,8 +63,8 @@ extern char* dStrrchr(char *str, int c);
 extern const char* dStrrchr(const char *str, int c);
 extern U32 dStrspn(const char *str, const char *set);
 extern U32 dStrcspn(const char *str, const char *set);
-extern char* dStrstr(char *str1, char *str2);
-extern char* dStrstr(const char *str1, const char *str2);
+extern char* dStrstr(char *str1, const char *str2);
+extern const char* dStrstr(const char *str1, const char *str2);
 
 extern char* dStrtok(char *str, const char *sep);
 

+ 2 - 2
engine/source/platformAndroid/AndroidStrings.cpp

@@ -258,12 +258,12 @@ U32 dStrcspn(const char *str, const char *set)
 }   
 
 
-char* dStrstr(char *str1, char *str2)
+char* dStrstr(char *str1, const char *str2)
 {
    return strstr(str1,str2);
 }
 
-char* dStrstr(const char *str1, const char *str2)
+const char* dStrstr(const char *str1, const char *str2)
 {
    return strstr(str1,str2);
 }   

+ 2 - 0
engine/source/platformAndroid/android_native_app_glue.c

@@ -17,11 +17,13 @@
 
 #include <jni.h>
 
+#include <stdlib.h>
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
 #include <sys/resource.h>
 
+
 #include "android_native_app_glue.h"
 #include <android/log.h>
 

+ 2 - 2
engine/source/platformEmscripten/EmscriptenStrings.cpp

@@ -249,12 +249,12 @@ dsize_t dStrcspn(const char *str, const char *set)
 }   
 
 
-char* dStrstr(char *str1, char *str2)
+char* dStrstr(char *str1, const char *str2)
 {
    return strstr(str1,str2);
 }
 
-char* dStrstr(const char *str1, const char *str2)
+const char* dStrstr(const char *str1, const char *str2)
 {
    return strstr(str1,str2);
 }   

+ 2 - 2
engine/source/platformOSX/osxString.mm

@@ -319,14 +319,14 @@ U32 dStrcspn(const char *str, const char *set)
 
 //-----------------------------------------------------------------------------
 
-char* dStrstr(char *str1, char *str2)
+char* dStrstr(char *str1, const char *str2)
 {
     return strstr(str1, str2);
 }
 
 //-----------------------------------------------------------------------------
 
-char* dStrstr(const char *str1, const char *str2)
+const char* dStrstr(const char *str1, const char *str2)
 {
     return strstr(str1, str2);
 }

+ 2 - 2
engine/source/platformWin32/winStrings.cc

@@ -247,12 +247,12 @@ U32 dStrcspn(const char *str, const char *set)
 }
 
 
-char* dStrstr(char *str1, char *str2)
+char* dStrstr(char *str1, const char *str2)
 {
    return strstr(str1,str2);
 }
 
-char* dStrstr(const char *str1, const char *str2)
+const char* dStrstr(const char *str1, const char *str2)
 {
    return strstr((char *)str1,str2);
 }

+ 2 - 2
engine/source/platformX86UNIX/x86UNIXStrings.cc

@@ -295,12 +295,12 @@ U32 dStrcspn(const char *str, const char *set)
 }   
 
 
-char* dStrstr(char *str1, char *str2)
+char* dStrstr(char *str1, const char *str2)
 {
    return strstr(str1,str2);
 }
 
-char* dStrstr(const char *str1, const char *str2)
+const char* dStrstr(const char *str1, const char *str2)
 {
    return strstr((char *)str1,str2);
 }

+ 2 - 2
engine/source/platformiOS/iOSStrings.mm

@@ -259,12 +259,12 @@ U32 dStrcspn(const char *str, const char *set)
 }   
 
 
-char* dStrstr(char *str1, char *str2)
+char* dStrstr(char *str1, const char *str2)
 {
    return strstr(str1,str2);
 }
 
-char* dStrstr(const char *str1, const char *str2)
+const char* dStrstr(const char *str1, const char *str2)
 {
    return strstr(str1,str2);
 }