* 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
/*
#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)
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, '/')))
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);