Use dataDir/manDir variables always
[xboard.git] / dialogs.c
index 084d9f4..430f179 100644 (file)
--- 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 --------------------------------------------
 
@@ -2296,7 +2297,7 @@ ErrorPopDown ()
     if (errorExitStatus != -1) ExitEvent(errorExitStatus);
 }
 
-static int
+int
 ErrorOK (int n)
 {
     dialogError = errorUp = False;
@@ -2491,13 +2492,16 @@ GetHelpText (FILE *f, char *name)
 void
 DisplayHelp (char *name)
 {
-    char buf[MSG_SIZ], *manFile = MANDIR "/man6/xboard.6";
+    char buf[MSG_SIZ], tidy[MSG_SIZ];
     FILE *f;
-    if(currentCps) snprintf(manFile = buf, MSG_SIZ, "/usr/share/man/man6/%s.6", currentCps->program);
-    f = fopen(manFile, "r");
+    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);
+    f = fopen(buf, "r");
     if(!f && currentCps) { // engine manual could be in two places
-       snprintf(buf, MSG_SIZ, "/usr/man/man6/%s.6", currentCps->program);
-       f= fopen(buf, "r");
+       snprintf(buf, MSG_SIZ, "/usr/share/man/man6/%s.6", tidy);
+       f = fopen(buf, "r");
     }
     if(f) {
        GetHelpText(f, name);