changeset 4145:f00b6b19d57e SDL-1.2

Date: Sat, 5 Apr 2008 19:54:28 -0700 From: "Chris Peterson" To: sdl@lists.libsdl.org Subject: [SDL] [PATCH] SDLMain.m: fix a bug and some warnings for Mac OS X Here are some small fixes for the src/main/macosx/SDLMain.m source file used by Mac OS X apps: 1. setupWorkingDirectory() called chdir() within an assert(), which gets compiled out in non-debug builds. 2. When some of gcc's optional warnings are enabled, it complains about some implicit casts and the use of #import in SDLMain.m.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 13 Apr 2008 04:50:17 +0000
parents 904defc0792e
children dc726b233f5f
files src/main/macosx/SDLMain.m
diffstat 1 files changed, 15 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/macosx/SDLMain.m	Mon Mar 31 05:27:21 2008 +0000
+++ b/src/main/macosx/SDLMain.m	Sun Apr 13 04:50:17 2008 +0000
@@ -5,10 +5,10 @@
     Feel free to customize this file to suit your needs
 */
 
-#import "SDL.h"
-#import "SDLMain.h"
-#import <sys/param.h> /* for MAXPATHLEN */
-#import <unistd.h>
+#include "SDL.h"
+#include "SDLMain.h"
+#include <sys/param.h> /* for MAXPATHLEN */
+#include <unistd.h>
 
 /* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
  but the method still is there and works. To avoid warnings, we declare
@@ -43,11 +43,11 @@
 
 static NSString *getApplicationName(void)
 {
-    NSDictionary *dict;
+    const NSDictionary *dict;
     NSString *appName = 0;
 
     /* Determine the application name */
-    dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
+    dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
     if (dict)
         appName = [dict objectForKey: @"CFBundleName"];
     
@@ -87,15 +87,14 @@
     if (shouldChdir)
     {
         char parentdir[MAXPATHLEN];
-		CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
-		CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
-		if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) {
-	        assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's parent */
-		}
-		CFRelease(url);
-		CFRelease(url2);
-	}
-
+        CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
+        CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
+        if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
+            chdir(parentdir);   /* chdir to the binary app's parent */
+        }
+        CFRelease(url);
+        CFRelease(url2);
+    }
 }
 
 #if SDL_USE_NIB_FILE
@@ -319,7 +318,7 @@
     NSString *result;
 
     bufferSize = selfLen + aStringLen - aRange.length;
-    buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
+    buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
     
     /* Get first part into buffer */
     localRange.location = 0;