Cleanse help texts of some common TeX escape codes
authorH.G.Muller <hgm@hgm-xboard.(none)>
Thu, 17 Mar 2016 21:13:28 +0000 (22:13 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 29 Mar 2016 14:51:33 +0000 (16:51 +0200)
The TeX escapes \s-1, \s0 around all-capital words, \*(L, \*(R for
distinguishing left/right quoting, a mysterious \& and a \ in general
(e.g. for \- as forced hyphen) occur quite often in the man-page text.
They now no longer clutter the help popups.

dialogs.c

index e9a1718..6db9c6e 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -2447,6 +2447,7 @@ DisplayTitle (char *text)
 }
 
 char *textPtr;
+char *texEscapes[] = { "s-1", "s0", "&", "*(L", "*(R", NULL };
 
 int
 GetNext(FILE *f)
@@ -2485,6 +2486,18 @@ GetHelpText (FILE *f, char *name)
                *p++ = ' '; cnt++;
                while(*line) {
                    if(*line < ' ') { line++; continue;}
+                   if(*line == '\\') {
+                       char **esc;
+                       line++;
+                       for(esc = texEscapes; *esc; esc++) {
+                           len = strlen(*esc);
+                           if(!strncmp(*esc, line, len)) {
+                               line += len;
+                               break;
+                           }
+                       }
+                       continue;
+                   }
                    if(*line == ' ' && p - q > 80) *line = '\n', q = p;
                    *p++ = *line++;
                }