]> granicus.if.org Git - nethack/commitdiff
MacOSX/Qt system tweaks
authorwarwick <warwick>
Thu, 24 Jan 2002 05:49:04 +0000 (05:49 +0000)
committerwarwick <warwick>
Thu, 24 Jan 2002 05:49:04 +0000 (05:49 +0000)
These changes clean up build warnings and allow the resulting "NetHack"
Application icons to be dragged around freely in the Finder, as is expected
for Mac apps.

include/config.h
src/hacklib.c
sys/unix/unixmain.c
win/Qt/qt_win.cpp

index b12ac77cb94aeb19a2e76e7d9345cc4090e5a1c7..4e3a0e2c770fcf1e1270b7eeed869c2af8e6f295 100644 (file)
  * otherwise it will be the current directory.
  */
 # ifndef HACKDIR
-#  define HACKDIR "/usr/games/lib/nethackdir"  /* nethack directory */
+#  ifdef __APPLE__
+#    define HACKDIR "nethackdir"       /* nethack directory */
+#  else
+#    define HACKDIR "/usr/games/lib/nethackdir"
+#  endif
 # endif
 
 /*
index dc074ec21623d07a5e1d3cd8278bcac4c6952770..768dfbc6e0fb8aa0a6a763f3800ab6ea47e642c4 100644 (file)
@@ -452,7 +452,7 @@ setrandom()
 #ifdef RANDOM  /* srandom() from sys/share/random.c */
        srandom((unsigned int) time((time_t *)0));
 #else
-# if defined(BSD) || defined(ULTRIX) || defined(CYGWIN32) /* system srandom() */
+# if defined(__APPLE__) || defined(BSD) || defined(ULTRIX) || defined(CYGWIN32) /* system srandom() */
 #  ifdef BSD
 #   if defined(SUNOS4)
        (void)
index 9208448c464beb2fde35df40af3f7ad4aa98ba9d..a5b0a0dccfc92538cb01c2385f8ca4226e06050e 100644 (file)
@@ -60,7 +60,7 @@ char *argv[];
           running from finder --sam */
 #define MAC_PATH_VALUE ".app/Contents/MacOS/"
        char mac_cwd[1024], *mac_exe = argv[0], *mac_tmp;
-       int arg0_len = strlen(mac_exe), mac_tmp_len;
+       int arg0_len = strlen(mac_exe), mac_tmp_len, mac_lhs_len=0;
        getcwd(mac_cwd, 1024);
        if(mac_exe[0] == '/' && !strcmp(mac_cwd, "/")) {
            if((mac_exe = strrchr(mac_exe, '/')))
@@ -72,10 +72,11 @@ char *argv[];
                mac_tmp = malloc(mac_tmp_len + 1);
                sprintf(mac_tmp, "%s%s%s", mac_exe, MAC_PATH_VALUE, mac_exe);
                if(!strcmp(argv[0] + (arg0_len - mac_tmp_len), mac_tmp)) {
-                   if(arg0_len - mac_tmp_len > mac_tmp_len - 1)
-                       mac_tmp = realloc(mac_tmp, arg0_len - mac_tmp_len);
-                   strncpy(mac_tmp, argv[0], arg0_len - mac_tmp_len);
-                   mac_tmp[arg0_len - mac_tmp_len] = '\0';
+                   mac_lhs_len = (arg0_len - mac_tmp_len) + strlen(mac_exe) + 5;
+                   if(mac_lhs_len > mac_tmp_len - 1)
+                       mac_tmp = realloc(mac_tmp, mac_lhs_len);
+                   strncpy(mac_tmp, argv[0], mac_lhs_len);
+                   mac_tmp[mac_lhs_len] = '\0';
                    chdir(mac_tmp);
                }
                free(mac_tmp);
index 89d9235d4593a9823d45fef7013be6195f1128fe..1705720db0dad643a50da5ab35dc37ac6f0c185b 100644 (file)
@@ -99,7 +99,11 @@ extern "C" {
 #include "qt_xpms.h"
 
 #include <dirent.h>
-#include <malloc.h>
+#ifdef Q_WS_MACX
+#  include <sys/malloc.h>
+#else
+#  include <malloc.h>
+#endif
 
 #ifdef _WS_X11_
 // For userid control