From 35f89898c92a8709618e2db77b11cbedfd7fc48c Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sat, 4 Jan 2014 12:18:30 +0100 Subject: [PATCH] Set ~~ to bundle path for OS X DATADIR is now #defined in WinBoard as "~~" to make the expansion a no-op there. For OS X it is redefined as a variable, obtained from GTK-OSX. --- args.h | 4 +--- gtk/xboard.c | 6 +++++- winboard/winboard.c | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/args.h b/args.h index 48371ad..23c166a 100644 --- a/args.h +++ b/args.h @@ -1147,14 +1147,12 @@ ParseArgs(GetFunc get, void *cl) case ArgString: case ArgFilename: -#ifdef DATADIR if(argValue[0] == '~' && argValue[1] == '~') { char buf[4*MSG_SIZ]; // expand ~~ - snprintf(buf, 4*MSG_SIZ, DATADIR "%s", argValue+2); + snprintf(buf, 4*MSG_SIZ, "%s%s", DATADIR, argValue+2); ASSIGN(*(char **) ad->argLoc, buf); break; } -#endif ASSIGN(*(char **) ad->argLoc, argValue); break; diff --git a/gtk/xboard.c b/gtk/xboard.c index 442b936..0546a3a 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -169,14 +169,17 @@ extern char *getenv(); #ifdef OSX # include "gtkmacintegration/gtkosxapplication.h" - // prevent pathname of positional file argument provided by OSx being be mistaken for option name + // prevent pathname of positional file argument provided by OS X being be mistaken for option name // (price is that we won't recognize Windows option format anymore). # define SLASH '-' // redefine some defaults # undef ICS_LOGON # undef SYSCONFDIR +# undef DATADIR # define ICS_LOGON "Library/Preferences/XboardICS.conf" # define SYSCONFDIR "../etc" +# define DATADIR dataDir + char *dataDir; // for expanding ~~ #else # define SLASH '/' #endif @@ -773,6 +776,7 @@ main (int argc, char **argv) #ifdef OSX { // prepare to catch OX OpenFile signal, which will tell us the clicked file GtkosxApplication *theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL); + dataDir = gtkosx_application_get_bundle_path(); g_signal_connect(theApp, "NSApplicationOpenFile", G_CALLBACK(StartNewXBoard), NULL); // we must call application ready before we can get the signal, // and supply a (dummy) menu bar before that, to avoid problems with dual apples in it diff --git a/winboard/winboard.c b/winboard/winboard.c index 60d92db..917a532 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -93,6 +93,7 @@ #include "wsnap.h" #define SLASH '/' +#define DATADIR "~~" //void InitEngineUCI( const char * iniDir, ChessProgramState * cps ); @@ -7673,6 +7674,7 @@ DoWriteFile(HANDLE hFile, char *buf, int count, DWORD *outCount, else err = GetLastError(); } + } return err; } -- 1.7.0.4