Here are some small fixes for the src/main/macosx/SDLMain.m source
file used by Mac OS X apps:
-
setupWorkingDirectory() called chdir() within an assert(), which
gets compiled out in non-debug builds. -
When some of gcc’s optional warnings are enabled, it complains
about some implicit casts and the use of #import in SDLMain.m.
chris
— original/SDLMain.m 2008-04-05 19:26:04.000000000 -0700
+++ patched/SDLMain.m 2008-04-05 19:27:26.000000000 -0700
@@ -5,10 +5,10 @@
Feel free to customize this file to suit your needs
*/
-#import “SDL.h”
+#include “SDL/SDL.h”
#include “SDLMain.h”
-#import <sys/param.h> /* for MAXPATHLEN /
-#import <unistd.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”];
@@ -89,8 +89,8 @@
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 */
-
if (CFURLGetFileSystemRepresentation(url2, (int) 1, (UInt8
*)parentdir, MAXPATHLEN)) {
-
chdir(parentdir); /* chdir to the binary app's parent */ } CFRelease(url); CFRelease(url2);
@@ -227,7 +227,7 @@
/* Start the main event loop */
[NSApp run];-
-
[sdlMain release];
[pool release];
}
@@ -319,7 +319,7 @@
NSString *result;bufferSize = selfLen + aStringLen - aRange.length;
- buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
-
buffer = (unichar )NSAllocateMemoryPages(bufferSizesizeof(unichar));
/* Get first part into buffer */
localRange.location = 0;
@@ -381,4 +381,3 @@
#endif
return 0;
}