Commit f4270729 authored by Sam Lantinga's avatar Sam Lantinga

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.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402750
parent 78de16e6
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
Feel free to customize this file to suit your needs Feel free to customize this file to suit your needs
*/ */
#import "SDL.h" #include "SDL.h"
#import "SDLMain.h" #include "SDLMain.h"
#import <sys/param.h> /* for MAXPATHLEN */ #include <sys/param.h> /* for MAXPATHLEN */
#import <unistd.h> #include <unistd.h>
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4, /* 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 but the method still is there and works. To avoid warnings, we declare
...@@ -43,11 +43,11 @@ static BOOL gCalledAppMainline = FALSE; ...@@ -43,11 +43,11 @@ static BOOL gCalledAppMainline = FALSE;
static NSString *getApplicationName(void) static NSString *getApplicationName(void)
{ {
NSDictionary *dict; const NSDictionary *dict;
NSString *appName = 0; NSString *appName = 0;
/* Determine the application name */ /* Determine the application name */
dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle()); dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
if (dict) if (dict)
appName = [dict objectForKey: @"CFBundleName"]; appName = [dict objectForKey: @"CFBundleName"];
...@@ -87,15 +87,14 @@ static NSString *getApplicationName(void) ...@@ -87,15 +87,14 @@ static NSString *getApplicationName(void)
if (shouldChdir) if (shouldChdir)
{ {
char parentdir[MAXPATHLEN]; char parentdir[MAXPATHLEN];
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) { if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */ chdir(parentdir); /* chdir to the binary app's parent */
} }
CFRelease(url); CFRelease(url);
CFRelease(url2); CFRelease(url2);
} }
} }
#if SDL_USE_NIB_FILE #if SDL_USE_NIB_FILE
...@@ -319,7 +318,7 @@ static void CustomApplicationMain (int argc, char **argv) ...@@ -319,7 +318,7 @@ static void CustomApplicationMain (int argc, char **argv)
NSString *result; NSString *result;
bufferSize = selfLen + aStringLen - aRange.length; bufferSize = selfLen + aStringLen - aRange.length;
buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar)); buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
/* Get first part into buffer */ /* Get first part into buffer */
localRange.location = 0; localRange.location = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment