Also try to get help for engine options
[xboard.git] / dialogs.c
index ece6c40..d57b576 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -2467,8 +2467,8 @@ GetHelpText (FILE *f, char *name)
     while(buf[--len] == ' ') buf[len] = NULLCHAR;
     snprintf(title, MSG_SIZ, "Help on '%s'", buf+3);
     while((line = ReadLine(f))) {
-       if(!strncmp(line, buf, len) && (strncmp(line, ".SS ", 4) || strncmp(line+4, buf+3, len-3))) {
-           while((line = ReadLine(f)) && (cnt == 0 || strncmp(line, ".B ", 3))) {
+       if(!strncmp(line, buf, len) || !strncmp(line, ".SS ", 4) && !strncmp(line+4, buf+3, len-3)) {
+           while((line = ReadLine(f)) && (cnt == 0 || strncmp(line, ".B ", 3) && strncmp(line, ".SS ", 4))) {
                if(!*line) { *p++ = '\n'; *p++ = '\n'; q = p; continue; }
                if(*line == '.') continue;
                *p++ = ' '; cnt++;
@@ -2491,8 +2491,14 @@ GetHelpText (FILE *f, char *name)
 void
 DisplayHelp (char *name)
 {
-    char *manFile = DATADIR "/../../man/man6/xboard.6";
-    FILE *f = fopen(manFile, "r");
+    char buf[MSG_SIZ], *manFile = MANDIR "/man6/xboard.6";
+    FILE *f;
+    if(currentCps) snprintf(manFile = buf, MSG_SIZ, "/usr/share/man/man6/%s.6", currentCps->program);
+    f = fopen(manFile, "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");
+    }
     if(f) {
        GetHelpText(f, name);
        fclose(f);