Fix popdown of Error/Help dialog through window-close button
[xboard.git] / dialogs.c
index 6ecdcaf..759830b 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -1259,7 +1259,7 @@ NewTagsPopup (char *text, char *msg, char *ttl)
     if(tagsText) free(tagsText); tagsText = strdup(text);
     tagsOptions[0].name = msg;
     MarkMenu("View.Tags", TagsDlg);
-    GenericPopUp(tagsOptions, title, TagsDlg, BoardWindow, NONMODAL, appData.topLevel);
+    GenericPopUp(tagsOptions + (msg == NULL), title, TagsDlg, BoardWindow, NONMODAL, appData.topLevel);
 }
 
 void
@@ -2296,7 +2296,7 @@ ErrorPopDown ()
     if (errorExitStatus != -1) ExitEvent(errorExitStatus);
 }
 
-static int
+int
 ErrorOK (int n)
 {
     dialogError = errorUp = False;
@@ -2491,8 +2491,17 @@ GetHelpText (FILE *f, char *name)
 void
 DisplayHelp (char *name)
 {
-    char *manFile = MANDIR "/man6/xboard.6";
-    FILE *f = fopen(manFile, "r");
+    char buf[MSG_SIZ], tidy[MSG_SIZ];
+    FILE *f;
+    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/share/man/man6/%s.6", tidy);
+       f = fopen(buf, "r");
+    }
     if(f) {
        GetHelpText(f, name);
        fclose(f);