From: H.G.Muller Date: Sun, 13 Mar 2016 22:25:11 +0000 (+0100) Subject: Use dataDir/manDir variables always X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=2655364624f87e757fa8719d3510bdf02ccf850c Use dataDir/manDir variables always The DATADIR and MANDIR string constants obtained from the configure process are now stored in variables, which are then used everywhere instead of them. The OSX App overwrites these variables, so the directory location can be made dynamic. --- diff --git a/dialogs.c b/dialogs.c index 759830b..430f179 100644 --- a/dialogs.c +++ b/dialogs.c @@ -66,6 +66,7 @@ extern char *getenv(); int values[MAX_OPTIONS]; ChessProgramState *currentCps; +char dataDir[MSG_SIZ] = DATADIR, manDir[MSG_SIZ] = MANDIR; //----------------------------Generic dialog -------------------------------------------- @@ -2496,7 +2497,7 @@ DisplayHelp (char *name) if(currentCps) { TidyProgramName(currentCps == &first ? appData.firstChessProgram : appData.secondChessProgram, "localhost", tidy); snprintf(buf, MSG_SIZ, "/usr/local/share/man/man6/%s.6", tidy); - } else snprintf(buf, MSG_SIZ, "%s/man6/xboard.6", MANDIR); + } else snprintf(buf, MSG_SIZ, "%s/man6/xboard.6", manDir); f = fopen(buf, "r"); if(!f && currentCps) { // engine manual could be in two places snprintf(buf, MSG_SIZ, "/usr/share/man/man6/%s.6", tidy); diff --git a/frontend.h b/frontend.h index bd0f071..bf79c67 100644 --- a/frontend.h +++ b/frontend.h @@ -167,6 +167,7 @@ void CmailSigHandlerCallBack P((InputSourceRef isr, VOIDSTAR closure, extern ProcRef cmailPR; extern int shiftKey, controlKey; +extern char dataDir[], manDir[]; /* in xgamelist.c or winboard.c */ void GLT_ClearList(); diff --git a/gtk/xboard.c b/gtk/xboard.c index 62de768..89d8058 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -175,18 +175,12 @@ extern char *getenv(); # define IMG ".png" // redefine some defaults # undef ICS_LOGON -# undef DATADIR -# undef MANDIR # undef LOCALEDIR # undef SETTINGS_FILE # define ICS_LOGON "Library/Preferences/XboardICS.conf" -# define DATADIR dataDir -# define MANDIR manDir # define LOCALEDIR localeDir # define SETTINGS_FILE masterSettings # define SYNC_MENUBAR gtkosx_application_sync_menubar(theApp) - char dataDir[MSG_SIZ]; // for expanding ~~ - char manDir[MSG_SIZ]; char localeDir[MSG_SIZ]; char masterSettings[MSG_SIZ]; #else @@ -920,6 +914,7 @@ main (int argc, char **argv) typedef struct {char *name, *value; } Config; static Config configList[] = { { "Datadir", DATADIR }, + { "Mandir", MANDIR }, { "Sysconfdir", SYSCONFDIR }, { NULL } }; @@ -964,7 +959,7 @@ main (int argc, char **argv) { // [HGM] initstring: kludge to fix bad bug. expand '\n' characters in init string and computer string. static char buf[MSG_SIZ]; - snprintf(buf, MSG_SIZ, appData.sysOpen, DATADIR); + snprintf(buf, MSG_SIZ, appData.sysOpen, dataDir); ASSIGN(appData.sysOpen, buf); // expand %s in -openCommand to DATADIR (usefull for OS X configuring) EscapeExpand(buf, appData.firstInitString); appData.firstInitString = strdup(buf); diff --git a/usystem.c b/usystem.c index 77efb60..23ba305 100644 --- a/usystem.c +++ b/usystem.c @@ -347,7 +347,7 @@ ExpandPathName (char *path) if (*s == '~') { if(s[1] == '~') { // use ~~ for XBoard's private data directory - snprintf(d, 4*MSG_SIZ, DATADIR "%s", s+2); + snprintf(d, 4*MSG_SIZ, "%s%s", dataDir, s+2); } else if (*(s+1) == '/') { safeStrCpy(d, getpwuid(getuid())->pw_dir, 4*MSG_SIZ );