[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Gzipped man pages



Here is a quick fix to the bug with gzipped man pages found by Ronald
Holzloehner.  It also incorporates a fix for searches for "curs_util(3X)".
The patch is rather large as it contains a lot of formating changes.
The CATMAN stuff is still in it as well.

Dennis Payne
payned@rpi.edu


--- ../xwpe-1.5.7a/we_fl_unix.c	Sun Apr  5 15:44:26 1998
+++ we_fl_unix.c	Sat Apr 11 23:23:26 1998
@@ -27,16 +27,14 @@
 #include <unistd.h>
 #endif
 
-int e_file_first(sw, cn, dirct)
-     int sw;
-     ECNT *cn;
-     char *dirct;
+int e_file_first(int sw, ECNT *cn, char *dirct)
 {
    extern char *e_hlp_str[];
    extern WOPT *fblst, *rblst, *wblst, *xblst, *sblst, *ablst;
    FENSTER *f;
    int i, j;
    FLBFFR *b;
+
    if(cn->mxedt >= MAXEDT)
    {  e_error(e_msg[ERR_MAXWINS], 0, cn->fb);
       return(-1);
@@ -125,8 +123,7 @@
    return(0);
 }
 
-int e_file_schirm(f)
-     FENSTER *f;
+int e_file_schirm(FENSTER *f)
 {
    FLBFFR *b = (FLBFFR *)f->b;
    int i, j;
@@ -240,18 +237,16 @@
 
 /*    Aufruf des Datei-Managers    */
 
-int e_manager_first(f)
-     FENSTER *f;
+int e_manager_first(FENSTER *f)
 {
    return(e_file_first(0, f->ed, ""));
 }
 
-int e_file_again(sw, f)
-     int sw;
-     FENSTER *f;
+int e_file_again(int sw, FENSTER *f)
 {
    int i;
    FLBFFR *b;
+
    for(i = f->ed->mxedt; i > 0; i--)
    if(f->ed->f[i]->dtmd == 'F')
    {  b = (FLBFFR *)f->ed->f[i]->b;
@@ -270,36 +265,31 @@
    return(0);
 }
 
-int e_manager(f)
-     FENSTER *f;
+int e_manager(FENSTER *f)
 {
-   return(e_file_again(0, f));
+ return(e_file_again(0, f));
 }
 
-int e_ed_manager(sw, f)
-     int sw;
-     FENSTER *f;
+int e_ed_manager(int sw, FENSTER *f)
 {
-   return(e_file_first(sw, f->ed, ""));
+ return(e_file_first(sw, f->ed, ""));
 }
 
-int e_execute(f)
-     FENSTER *f;
+int e_execute(FENSTER *f)
 {
-   return(e_file_again(3, f));
+ return(e_file_again(3, f));
 }
 
-int e_saveas(f)
-     FENSTER *f;
+int e_saveas(FENSTER *f)
 {
-   return(e_file_first(4, f->ed, ""));
+ return(e_file_first(4, f->ed, ""));
 }
 
-int e_shell(f)
-     FENSTER *f;
+int e_shell(FENSTER *f)
 {
    PIC *outp = NULL;
    int g[4];
+
 #ifndef DJGPP
    if(!WpeIsXwin())
 #endif
@@ -338,8 +328,7 @@
 
 /*    Datei-Manager     */
 
-int e_file_eingabe(cn)
-     ECNT *cn;
+int e_file_eingabe(ECNT *cn)
 {
    extern struct EXT h_error;
    FENSTER *f = cn->f[cn->mxedt], *fe = NULL;
@@ -970,19 +959,18 @@
    return(0);
 }
 
-struct dirfile *e_dfnull(df)
-     struct dirfile *df;
+struct dirfile *e_dfnull(struct dirfile *df)
 {
-   freedf(df);
-   df = MALLOC(sizeof(struct dirfile));
-   if(df) df->anz = 0;
-   return(df);
+ freedf(df);
+ df = MALLOC(sizeof(struct dirfile));
+ if (df)
+ {
+  df->anz = 0;
+ }
+ return(df);
 }
 
-int e_grep_file(file, string, sw)
-     char *file;
-     char *string;
-     int sw;
+int e_grep_file(char *file, char *string, int sw)
 {
    FILE *fp = fopen(file, "r");
    char str[256];
@@ -1011,17 +999,14 @@
    return(0);
 }
 
-struct dirfile *e_search_files(dirct, file, string, df, sw)
-     char *dirct;
-     char *file;
-     char *string;
-     struct dirfile *df;
-     int sw;
+struct dirfile *e_search_files(char *dirct, char *file, char *string,
+  struct dirfile *df, int sw)
 {
    struct dirfile *dd;
    char **tname, *tp, *tmp, *tmp2;
    int i;
    static int rec = 0;
+
    if(rec > MAXREC) return(df);
 #ifdef DJGPP
    if(*dirct != DIRC && (dirct[1] != ':' || dirct[2] != DIRC))
@@ -1116,11 +1101,11 @@
 /*   Datei drucken    */
 
 #ifndef NOPRINTER
-int e_drucke_datei(f)
-     FENSTER *f;
+int e_drucke_datei(FENSTER *f)
 {
    char str[256], *dp;
    int c, sins = f->ins;
+
    for(c = f->ed->mxedt; c > 0 && f->ed->f[c]->dtmd <= 'Z'; c--);
    if(c <= 0) return(0);
    f = f->ed->f[c];
@@ -1142,16 +1127,15 @@
 #else
 int e_drucke_datei(FENSTER *f)
 {
-   return(e_error(e_msg[ERR_NOPRINT], 0, f->fb));
+ return(e_error(e_msg[ERR_NOPRINT], 0, f->fb));
 }
 #endif
 
-char *e_ret_wastefile(file, path)
-     char *file;
-     char *path;
+char *e_ret_wastefile(char *file, char *path)
 {
    static char *wastebasket = NULL;
    int i;
+
    if(!wastebasket)
    {  char tmp[256], tmp2[256];
 #ifdef DJGPP
@@ -1178,11 +1162,7 @@
    return(path);
 }
 
-int e_remove_dir(dirct, file, f, rec)
-     char *dirct;
-     char *file;
-     FENSTER *f;
-     int rec;
+int e_remove_dir(char *dirct, char *file, FENSTER *f, int rec)
 {
    PIC *pic = NULL;
    char *tmp;
@@ -1249,95 +1229,100 @@
    return(0);
 }
 
-int e_remove(file, f)
-     char *file;
-     FENSTER *f;
+int e_remove(char *file, FENSTER *f)
 {
-   struct stat buf[1];
-   char tmp[256];
-   int ret;
+ struct stat buf[1];
+ char tmp[256];
+ int ret;
 
-   WpeMouseChangeShape(WpeWorkingShape);
-   stat(file, buf);
+ WpeMouseChangeShape(WpeWorkingShape);
+ stat(file, buf);
 #ifndef DJGPP
-   if(!(buf->st_mode & 040000) || (ret = readlink(file, tmp, 256)) >= 0)
+ if (!(buf->st_mode & 040000) || (ret = readlink(file, tmp, 256)) >= 0)
 #else
-   if(!(buf->st_mode & 040000))
+ if (!(buf->st_mode & 040000))
 #endif
-   {  if((f->ed->flopt & FM_REMOVE_INTO_WB))
-      {  e_ret_wastefile(file, tmp);
-	 ret = strlen(tmp);
-	 if(strncmp(tmp, file, ret))
-	 {  e_rename(file, tmp, f);  }
-      }
-      else
-      {
-         if(f->ed->flopt & FM_REMOVE_PROMPT)
-         {  sprintf(tmp, "Remove File:\n%s", file);
-	    ret = e_message(1, tmp, f);
-         }
-         else ret = 'Y';
-         if(ret == 'Y') remove(file);
-      }
+ {
+  if ((f->ed->flopt & FM_REMOVE_INTO_WB))
+  {
+   e_ret_wastefile(file, tmp);
+   ret = strlen(tmp);
+   if (strncmp(tmp, file, ret))
+   {
+    e_rename(file, tmp, f);
    }
-   else e_remove_dir(file, f->ed->fd.file, f, 0);
-   WpeMouseRestoreShape();
-   return(0);
+  }
+  else
+  {
+   if (f->ed->flopt & FM_REMOVE_PROMPT)
+   {
+    sprintf(tmp, "Remove File:\n%s", file);
+    ret = e_message(1, tmp, f);
+   }
+   else
+    ret = 'Y';
+   if (ret == 'Y')
+    remove(file);
+  }
+ }
+ else
+  e_remove_dir(file, f->ed->fd.file, f, 0);
+ WpeMouseRestoreShape();
+ return(0);
 }
 
 #define E_C_BUFFERSIZE 524288   /*   1/2  Mega Byte   */
 
-int fk_copy(old, new)
-     char *old;
-     char *new;
+int fk_copy(char *old, char *new)
 {
-   struct stat buf[1];
-   int ret;
-   char *buffer;
-   FILE *fpo, *fpn;
-   if(!(fpo = fopen(old, "rb"))) return(-1);
-   if(!(fpn = fopen(new, "wb"))) return(-2);
-   if(!(buffer = malloc(E_C_BUFFERSIZE))) return(-3);
-   do
-   {  ret = fread(buffer, 1, E_C_BUFFERSIZE, fpo);
-      if(fwrite(buffer, 1, ret, fpn) != ret)
-      {  fclose(fpo);  fclose(fpn);  free(buffer);   return(-4);  }
-   } while(ret == E_C_BUFFERSIZE);
+ struct stat buf[1];
+ int ret;
+ char *buffer;
+ FILE *fpo, *fpn;
+
+ if (!(fpo = fopen(old, "rb")))
+  return(-1);
+ if (!(fpn = fopen(new, "wb")))
+  return(-2);
+ if (!(buffer = malloc(E_C_BUFFERSIZE)))
+  return(-3);
+ do
+ {
+  ret = fread(buffer, 1, E_C_BUFFERSIZE, fpo);
+  if (fwrite(buffer, 1, ret, fpn) != ret)
+  {
    fclose(fpo);
    fclose(fpn);
    free(buffer);
-   stat(old, buf);
-   chmod(new, buf->st_mode);
-   return(0);
+   return(-4);
+  }
+ } while (ret == E_C_BUFFERSIZE);
+ fclose(fpo);
+ fclose(fpn);
+ free(buffer);
+ stat(old, buf);
+ chmod(new, buf->st_mode);
+ return(0);
 }
 
 #ifndef DJGPP
 /* #define fk_rename(o, n) rename(o, n)  */
 #define fk_rename rename
 #ifndef NOSYMLINKS
-int fk_link(fl, ln, sw)
-     char *fl;
-     char *ln;
-     int sw;
+int fk_link(char *fl, char *ln, int sw)
 {
-   return((sw || link(fl, ln)) ? symlink(fl, ln) : 0);
+ return((sw || link(fl, ln)) ? symlink(fl, ln) : 0);
 }
 
-int fk_ren_link(old, ln, fl)
-     char *old;
-     char *ln;
-     char *fl;
+int fk_ren_link(char *old, char *ln, char *fl)
 {
-   return(symlink(fl, ln) ? -1 : remove(old));
+ return(symlink(fl, ln) ? -1 : remove(old));
 }
 #endif
 
-int e_link(file, newname, f)
-     char *file;
-     char *newname;
-     FENSTER *f;
+int e_link(char *file, char *newname, FENSTER *f)
 {
-   return(e_renocpy(file, newname, f, 2));
+ return(e_renocpy(file, newname, f, 2));
 }
 #else
 int fk_rename(char *old, char *new)
@@ -1358,32 +1343,19 @@
 }
 #endif
 
-int e_copy(file, newname, f)
-     char *file;
-     char *newname;
-     FENSTER *f;
+int e_copy(char *file, char *newname, FENSTER *f)
 {
-   return(e_renocpy(file, newname, f, 1));
+ return(e_renocpy(file, newname, f, 1));
 }
 
-int e_rename_dir(dirct, file, newname, f, rec)
-     char *dirct;
-     char *file;
-     char *newname;
-     FENSTER *f;
-     int rec;
+int e_rename_dir(char *dirct, char *file, char *newname, FENSTER *f, int rec)
 {
-   return(e_renocpy_dir(dirct, file, newname, f, rec, 0));
+ return(e_renocpy_dir(dirct, file, newname, f, rec, 0));
 }
 
 
-int e_renocpy_dir(dirct, file, newname, f, rec, sw)
-     char *dirct;
-     char *file;
-     char *newname;
-     FENSTER *f;
-     int rec;
-     int sw;
+int e_renocpy_dir(char *dirct, char *file, char *newname, FENSTER *f,
+  int rec, int sw)
 {
    char tmp[256], ntmp[256], mtmp[512];
    int i, ret, mode;
@@ -1456,19 +1428,12 @@
    return(0);
 }
 
-int e_rename(file, newname, f)
-     char *file;
-     char *newname;
-     FENSTER *f;
-{
-   return(e_renocpy(file, newname, f, 0));
+int e_rename(char *file, char *newname, FENSTER *f)
+{
+ return(e_renocpy(file, newname, f, 0));
 }
 
-int e_renocpy(file, newname, f, sw)
-     char *file;
-     char *newname;
-     FENSTER *f;
-     int sw;
+int e_renocpy(char *file, char *newname, FENSTER *f, int sw)
 {
    struct stat buf[1];
    char tmp[256], tmpl[256];
@@ -1519,47 +1484,52 @@
    WpeMouseRestoreShape();
    return(0);
 }
+
 #ifndef DJGPP
-int e_duplicate(file, f)
-     char *file;
-     FENSTER *f;
+int e_duplicate(char *file, FENSTER *f)
 {
-   char dupl[256];
-   int ret;
-   WpeMouseChangeShape(WpeWorkingShape);
-   sprintf(dupl, "%s.dup", file);
-   ret = e_renocpy(file, dupl, f, 1);
-   WpeMouseRestoreShape();
-   return(ret);
+ char dupl[256];
+ int ret;
+
+ WpeMouseChangeShape(WpeWorkingShape);
+ sprintf(dupl, "%s.dup", file);
+ ret = e_renocpy(file, dupl, f, 1);
+ WpeMouseRestoreShape();
+ return(ret);
 }
 #else
 int e_duplicate(char *file, FENSTER *f)
 {
-   char dupl[128];
-   int i, len = strlen(file);
-   strcpy(dupl, file);
-   for(i = len - 1; i >= 0 && dupl[i] != '.'  && dupl[i] != ':'
-		&& dupl[i] != '/'  && dupl[i] != '\\'; i--);
-   if(i < 0 || dupl[i] != '.')  strcat(dupl, ".~");
-   else  dupl[len-1] = '~';
-   return(e_renocpy(file, dupl, f, 1));
-}
-#endif
-int e_mk_newdir(f)
-     FENSTER *f;
-{
-   char dirct[256];
-   int msk, mode;
-   umask(msk = umask(077));
-   mode = 0777 & ~msk;
-   if(f->dirct[strlen(f->dirct)-1] != DIRC)
-   sprintf(dirct, "%s/new.dir" , f->dirct);
-   else sprintf(dirct, "%snew.dir" , f->dirct);
-   return(mkdir(dirct, mode));
+ char dupl[128];
+ int i, len = strlen(file);
+ strcpy(dupl, file);
+ for(i = len - 1;
+   i >= 0 && dupl[i] != '.'  && dupl[i] != ':' && dupl[i] != '/'  &&
+     dupl[i] != '\\';
+   i--);
+ if (i < 0 || dupl[i] != '.')
+  strcat(dupl, ".~");
+ else
+  dupl[len-1] = '~';
+ return(e_renocpy(file, dupl, f, 1));
+}
+#endif
+
+int e_mk_newdir(FENSTER *f)
+{
+ char dirct[256];
+ int msk, mode;
+
+ umask(msk = umask(077));
+ mode = 0777 & ~msk;
+ if (f->dirct[strlen(f->dirct)-1] != DIRC)
+  sprintf(dirct, "%s/new.dir" , f->dirct);
+ else
+  sprintf(dirct, "%snew.dir" , f->dirct);
+ return(mkdir(dirct, mode));
 }
 
-int e_fl_mng_options(f)
-     FENSTER *f;
+int e_fl_mng_options(FENSTER *f)
 {
    int ret;
    W_OPTSTR *o = e_init_opt_kst(f);
@@ -1620,9 +1590,7 @@
    return(0);
 }
 
-int e_attributes(filen, f)
-     char *filen;
-     FENSTER *f;
+int e_attributes(char *filen, FENSTER *f)
 {
    struct stat buf[1];
    int mode, ret;
@@ -1662,49 +1630,50 @@
    return(0);
 }
 
-int e_dir_del_options(f)
-     FENSTER *f;
-{
-   int ret;
-   W_OPTSTR *o = e_init_opt_kst(f);
-   if(!o) return(-1);
-   o->xa = 19;  o->ya = 11;  o->xe = 53;  o->ye = 19;
-   o->bgsw = AltO;
-   o->name = "Message";
-   o->crsw = AltO;
-   e_add_txtstr(4, 2, "Delete Directory:", o);
-   e_add_pswstr(0, 5, 3, 0, AltD, 0, "Delete without Prompt", o);
-   e_add_pswstr(0, 5, 4, 0, AltP, 1, "Prompt for Files     ", o);
-   e_add_bttstr(7, 6, 1, AltO, " Ok ", NULL, o);
-   e_add_bttstr(22, 6, -1, ESC, "Cancel", NULL, o);
-   ret = e_opt_kst(o);
-   ret = (ret == ESC) ? -1 : o->pstr[0]->num;
-   freeostr(o);
-   return(ret);
-}
-
-int e_sh_wastebasket(f)
-     FENSTER *f;
+int e_dir_del_options(FENSTER *f)
 {
-   return(e_file_again(6, f));
-}
+ int ret;
+ W_OPTSTR *o = e_init_opt_kst(f);
 
-int e_del_wastebasket(f)
-     FENSTER *f;
-{
-   char tmp[256];
-   int ret, mode = f->ed->flopt;
-   WpeMouseChangeShape(WpeWorkingShape);
-   f->ed->flopt = FM_SHOW_HIDDEN_FILES & FM_SHOW_HIDDEN_DIRS & 
-                  FM_MOVE_OVERWRITE & FM_REKURSIVE_ACTIONS;
-   ret = e_remove_dir(e_ret_wastefile("", tmp), "*", f, 0);
-   f->ed->flopt = mode;
-   WpeMouseRestoreShape();
-   return(ret);
+ if (!o) return(-1);
+ o->xa = 19;
+ o->ya = 11;
+ o->xe = 53;
+ o->ye = 19;
+ o->bgsw = AltO;
+ o->name = "Message";
+ o->crsw = AltO;
+ e_add_txtstr(4, 2, "Delete Directory:", o);
+ e_add_pswstr(0, 5, 3, 0, AltD, 0, "Delete without Prompt", o);
+ e_add_pswstr(0, 5, 4, 0, AltP, 1, "Prompt for Files     ", o);
+ e_add_bttstr(7, 6, 1, AltO, " Ok ", NULL, o);
+ e_add_bttstr(22, 6, -1, ESC, "Cancel", NULL, o);
+ ret = e_opt_kst(o);
+ ret = (ret == ESC) ? -1 : o->pstr[0]->num;
+ freeostr(o);
+ return(ret);
+}
+
+int e_sh_wastebasket(FENSTER *f)
+{
+ return(e_file_again(6, f));
+}
+
+int e_del_wastebasket(FENSTER *f)
+{
+ char tmp[256];
+ int ret, mode = f->ed->flopt;
+
+ WpeMouseChangeShape(WpeWorkingShape);
+ f->ed->flopt = FM_SHOW_HIDDEN_FILES & FM_SHOW_HIDDEN_DIRS & 
+   FM_MOVE_OVERWRITE & FM_REKURSIVE_ACTIONS;
+ ret = e_remove_dir(e_ret_wastefile("", tmp), "*", f, 0);
+ f->ed->flopt = mode;
+ WpeMouseRestoreShape();
+ return(ret);
 }
 
-int e_quit_wastebasket(f)
-     FENSTER *f;
+int e_quit_wastebasket(FENSTER *f)
 {
    char tmp[256];
    int ret = 0, mode = f->ed->flopt;
@@ -1731,8 +1700,7 @@
 
 /*  Struktur bis zur Arbeits-Directory erstellen  */
 
-struct dirfile *e_mk_cur_dir(sw)
-     int sw;
+struct dirfile *e_mk_cur_dir(int sw)
 {
    struct dirfile *df = MALLOC(sizeof(struct dirfile));
    char buf[256];
@@ -1795,189 +1763,246 @@
    return(df);
 }
 
-int e_ed_man(str, f)
-     char *str;
-     FENSTER *f;
-{
-   char command[256], tstr[120];
-   char cc, hstr[80], nstr[10];
-   int mdsv = f->ed->dtmd, bg, i, j = 0;
-   BUFFER *b;
-   if(!str) return(0);
-   while(isspace(*str++));
-   if(!*--str) return(0);
-   for(i = f->ed->mxedt; i >= 0; i--)
-   {  if(!strcmp(f->ed->f[i]->datnam, str))
-      {  e_switch_window(f->ed->edt[i], f);  return(0);  }
-   }
-   WpeMouseChangeShape(WpeWorkingShape);
-   sprintf(tstr, "%s/%s", e_tmp_dir, str);
-   for(i=0; (hstr[i] = str[i]) && str[i] != '(' && str[i] != ')'; i++);
-   hstr[i] = '\0';
-   if(str[i] == '(')
-   for(++i; (nstr[j] = str[i]) && str[i] != ')'
-					&& str[i] != '('; i++, j++);
-   nstr[j] = '\0';
-   while(1)
-#ifdef MAN_S_OPT
-   {  if(!nstr[0])
-         sprintf(command, " man %s > \'%s\' 2> /dev/null", hstr, tstr);
-      else
-         sprintf(command, " man -s %s %s > \'%s\' 2> /dev/null", nstr, hstr, tstr);
-#else
-   {  sprintf(command, " man %s %s > \'%s\' 2> /dev/null", nstr, hstr, tstr);
-#endif
-      system(command);
-      chmod(tstr, 0400);
-      f->ed->dtmd = 'h';
-      e_edit(f->ed, tstr);
-      f->ed->dtmd = mdsv;
-      f = f->ed->f[f->ed->mxedt];
-      b = f->b;
-      if(b->mxlines > 1 || !nstr[1]) break;
-      nstr[1] = '\0';
-      chmod(tstr, 0600);
-      remove(tstr);
-      e_close_window(f);
-   }
-   if(b->mxlines == 1 && b->bf[0].len == 0)
-   {  e_ins_nchar(f->b, f->s, "No manual entry for ", 0, 0, 20);
-      e_ins_nchar(f->b, f->s, hstr, b->b.x, b->b.y, strlen(hstr));
-      e_ins_nchar(f->b, f->s, ".", b->b.x, b->b.y, 1);
-   }
-   for(i = 0; i < b->mxlines; i++)
-   if(b->bf[i].len == 0 && (i == 0 || b->bf[i-1].len == 0))
-   {  e_del_line(i, b, f->s);  i--;  }
-   for(bg = 0; bg < b->bf[0].len && isspace(b->bf[0].s[bg]); bg++);
-   if(bg == b->bf[0].len) bg = 0;
-   for(i = 0;
-     i < b->mxlines &&
-       WpeStrnccmp(b->bf[i].s+bg, "\017SEE\005 \017ALSO\005", 12) &&
-       WpeStrnccmp(b->bf[i].s+bg, "SEE ALSO", 8);
-     i++);
-   if(i < b->mxlines)
-   for(bg = 0, i++; i < b->mxlines && b->bf[i].len > 0 && bg >= 0; i++)
-   {  bg = 0;
-      while(b->bf[i].s[bg])
-	 {  for(; isspace(b->bf[i].s[bg]); bg++);
-	    if(!b->bf[i].s[bg]) continue;
-	    for(j = bg+1; b->bf[i].s[j] && b->bf[i].s[j] != ',' && b->bf[i].s[j] != '.'
-			&& b->bf[i].s[j] != ' ' && b->bf[i].s[j] != '('; j++);
-	    if(b->bf[i].s[j] != '(') {  bg = -1;  break;  }
-            if (b->bf[i].s[j-1] == 5) e_del_nchar(b, f->s, j-1, i, 1);
-	    for(j++; b->bf[i].s[j] && b->bf[i].s[j] != ',' 
-							&& b->bf[i].s[j] != '.'; j++);
-	    if (b->bf[i].s[bg] == 15) b->bf[i].s[bg] = HFB;
-            else
-            {
-             cc = HFB;
-             e_ins_nchar(b, f->s, &cc, bg, i, 1);
-             j++;
-            }
-	    cc = HED;
-	    e_ins_nchar(b, f->s, &cc, j, i, 1);
-            j++;
-	    if(b->bf[i].s[j]) j++;
-	    bg = j;
-	 }
-   }
-   b->b.x = b->b.y = 0;
-   chmod(tstr, 0600);
-   remove(tstr);
-   WpeMouseRestoreShape();
-   e_schirm(f, 1);
-   return(0);
-}
-
-int e_funct(f)
-     FENSTER *f;
+int e_ed_man(char *str, FENSTER *f)
 {
-   char str[80];
-   if(f->ed->hdf && f->ed->hdf->anz > 0) strcpy(str, f->ed->hdf->name[0]);
-   else str[0] = '\0';
-   if(e_add_arguments(str, "Function", f, 0, AltF, &f->ed->hdf))
-   {  f->ed->hdf = e_add_df(str, f->ed->hdf);
-      e_ed_man(str, f);
-   }
+ char command[256], tstr[120];
+ char cc, hstr[80], nstr[10];
+ int mdsv = f->ed->dtmd, bg, i, j = 0;
+ BUFFER *b;
+
+ if (!str)
+  return(0);
+ while (isspace(*str++));
+ if (!*--str) return(0);
+ for(i = f->ed->mxedt; i >= 0; i--)
+ {
+  if(!strcmp(f->ed->f[i]->datnam, str))
+  {
+   e_switch_window(f->ed->edt[i], f);
    return(0);
-}
+  }
+ }
+ WpeMouseChangeShape(WpeWorkingShape);
+ sprintf(tstr, "%s/%s", e_tmp_dir, str);
+ for (i=0; (hstr[i] = str[i]) && str[i] != '(' && str[i] != ')'; i++);
+ hstr[i] = '\0';
+ if (str[i] == '(')
+ {
+  for(++i; (nstr[j] = str[i]) && str[i] != ')' && str[i] != '('; i++, j++);
+
+  /* Some SEE ALSO's are list as "foobar(3X)" but are in section 3 not 3X.
+     This is a quick hack to fix the problem.  -- Dennis */
+  if (isdigit(nstr[0]))
+  j = 1;
+ }
+ nstr[j] = '\0';
 
-struct dirfile *e_make_funct(man)
-     char *man;
-{
-   struct dirfile *df = NULL, *dout = MALLOC(sizeof(struct dirfile));
-   char sustr[250], subpath[250], manpath[250];
-   int ret = 0, n, i = 0, j, k, l = 0;
+ while(1)
+ {
+#ifdef MAN_S_OPT
+  if (!nstr[0])
+   sprintf(command, " man %s > \'%s\' 2> /dev/null", hstr, tstr);
+  else
+   sprintf(command, " man -s %s %s > \'%s\' 2> /dev/null", nstr, hstr, tstr);
+#else
+  sprintf(command, " man %s %s > \'%s\' 2> /dev/null", nstr, hstr, tstr);
+#endif
+  system(command);
+  chmod(tstr, 0400);
+  f->ed->dtmd = 'h';
+  e_edit(f->ed, tstr);
+  f->ed->dtmd = mdsv;
+  f = f->ed->f[f->ed->mxedt];
+  b = f->b;
+  if (b->mxlines > 1 || !nstr[1])
+   break;
+  nstr[1] = '\0';
+  chmod(tstr, 0600);
+  remove(tstr);
+  e_close_window(f);
+ }
+ if (b->mxlines == 1 && b->bf[0].len == 0)
+ {
+  e_ins_nchar(f->b, f->s, "No manual entry for ", 0, 0, 20);
+  e_ins_nchar(f->b, f->s, hstr, b->b.x, b->b.y, strlen(hstr));
+  e_ins_nchar(f->b, f->s, ".", b->b.x, b->b.y, 1);
+ }
+ for (i = 0; i < b->mxlines; i++)
+  if(b->bf[i].len == 0 && (i == 0 || b->bf[i-1].len == 0))
+  {
+   e_del_line(i, b, f->s);
+   i--;
+  }
+ for (bg = 0; bg < b->bf[0].len && isspace(b->bf[0].s[bg]); bg++);
+ if (bg == b->bf[0].len)
+  bg = 0;
+ for (i = 0;
+   i < b->mxlines &&
+     WpeStrnccmp(b->bf[i].s+bg, "\017SEE\005 \017ALSO\005", 12) &&
+     WpeStrnccmp(b->bf[i].s+bg, "SEE ALSO", 8);
+   i++);
+ if (i < b->mxlines)
+  for (bg = 0, i++; i < b->mxlines && b->bf[i].len > 0 && bg >= 0; i++)
+  {
+   bg = 0;
+   while(b->bf[i].s[bg])
+   {
+    for(; isspace(b->bf[i].s[bg]); bg++);
+    if (!b->bf[i].s[bg]) continue;
+    for (j = bg+1;
+      b->bf[i].s[j] && b->bf[i].s[j] != ',' && b->bf[i].s[j] != '.' &&
+        b->bf[i].s[j] != ' ' && b->bf[i].s[j] != '(';
+      j++);
+    if (b->bf[i].s[j] != '(')
+    {
+     bg = -1;
+     break;
+    }
+    if (b->bf[i].s[j-1] == 5)
+     e_del_nchar(b, f->s, j-1, i, 1);
+    for (j++; b->bf[i].s[j] && b->bf[i].s[j] != ',' && b->bf[i].s[j] != '.';
+      j++);
+    if (b->bf[i].s[bg] == 15)
+     b->bf[i].s[bg] = HFB;
+    else
+    {
+     cc = HFB;
+     e_ins_nchar(b, f->s, &cc, bg, i, 1);
+     j++;
+    }
+    cc = HED;
+    e_ins_nchar(b, f->s, &cc, j, i, 1);
+    j++;
+    if (b->bf[i].s[j])
+     j++;
+    bg = j;
+   }
+  }
+ b->b.x = b->b.y = 0;
+ chmod(tstr, 0600);
+ remove(tstr);
+ WpeMouseRestoreShape();
+ e_schirm(f, 1);
+ return(0);
+}
+
+int e_funct(FENSTER *f)
+{
+ char str[80];
+
+ if (f->ed->hdf && f->ed->hdf->anz > 0)
+  strcpy(str, f->ed->hdf->name[0]);
+ else
+  str[0] = '\0';
+ if (e_add_arguments(str, "Function", f, 0, AltF, &f->ed->hdf))
+ {
+  f->ed->hdf = e_add_df(str, f->ed->hdf);
+  e_ed_man(str, f);
+ }
+ return(0);
+}
+
+struct dirfile *e_make_funct(char *man)
+{
+ struct dirfile *df = NULL, *dout = MALLOC(sizeof(struct dirfile));
+ char sustr[250], subpath[250], manpath[250];
+ int ret = 0, n, i = 0, j, k, l = 0;
 #ifdef CATMAN
-   struct dirfile *dd = NULL;
-   int m;
+ struct dirfile *dd = NULL;
+ int m;
 #endif
-   WpeMouseChangeShape(WpeWorkingShape);
-   dout->anz = 0;
-   dout->name = NULL;
+
+ WpeMouseChangeShape(WpeWorkingShape);
+ dout->anz = 0;
+ dout->name = NULL;
 #ifdef CATMAN
-   if(getenv("CATMAN")) strcpy(manpath, getenv("CATMAN"));
-   else manpath[0] = '\0';
+ if (getenv("CATMAN")) strcpy(manpath, getenv("CATMAN"));
+ else manpath[0] = '\0';
 #else
-   manpath[0] = '\0';
-   if(getenv("MANPATH")) strcpy(manpath, getenv("MANPATH"));
-   if(manpath[0] == '\0') strcpy(manpath, "/usr/man:/usr/local/man");
-#endif
-   while(manpath[i])
-   {  for(n = 0; (subpath[n] = manpath[i]) && manpath[i] != PTHD; i++, n++);
-      subpath[n] = '\0';
-      if(manpath[i]) i++;
+ manpath[0] = '\0';
+ if (getenv("MANPATH")) strcpy(manpath, getenv("MANPATH"));
+ if (manpath[0] == '\0') strcpy(manpath, "/usr/man:/usr/local/man");
+#endif
+ while (manpath[i])
+ {
+  for (n = 0; (subpath[n] = manpath[i]) && manpath[i] != PTHD; i++, n++);
+  subpath[n] = '\0';
+  if (manpath[i])
+   i++;
 #ifdef CATMAN
-      sprintf(sustr, "%s/C/*_man", subpath);
-      dd = e_find_dir(sustr);
-      for(m = 0; m < dd->anz; m++)  {
-	 sprintf(sustr, "%s/C/%s/cat%s/*", subpath, dd->name[m], man);
-#else
-      sprintf(sustr, "%s/man%s/*", subpath, man);
-#endif
-      df = e_find_files(sustr, 0);
-      if(!df->anz) {  freedf(df);  continue;  }
-      for(j = 0; j < df->anz; j++)
-      {  for(k = strlen(df->name[j]) - 1; k >= 0 && *(df->name[j]+k) != '.'; k--);
-	 if(k >= 0 /**(df->name[j]+k)*/)
-	 {  df->name[j] = REALLOC(df->name[j],
-				(l = strlen(df->name[j])+2)*sizeof(char));
-	    *(df->name[j]+k) = '(';
-	    *(df->name[j]+l-2) = ')';
-	    *(df->name[j]+l-1) = '\0';
-	 }
-      }
-      if(!dout->name) dout->name = MALLOC(df->anz * sizeof(char *));
-      else dout->name = REALLOC(dout->name,
-				(df->anz+dout->anz)*sizeof(char *));
-      for(j = 0; j < df->anz; j++)
-      {  for(k = 0; k < dout->anz; k++)
-	 {  if(!(ret = strcmp(df->name[j], dout->name[k])))
-	    {  FREE(df->name[j]);  break;  }
-	    else if(ret < 0) break;
-	 }
-	 if(!ret && dout->anz) continue;
-	 for(l = dout->anz; l > k; l--) dout->name[l] = dout->name[l-1];
-	 dout->name[k] = df->name[j];
-	 dout->anz++;
-      }
-      FREE(df);
+  sprintf(sustr, "%s/C/*_man", subpath);
+  dd = e_find_dir(sustr);
+  for (m = 0; m < dd->anz; m++)
+  {
+   sprintf(sustr, "%s/C/%s/cat%s/*", subpath, dd->name[m], man);
+#else
+   sprintf(sustr, "%s/man%s/*", subpath, man);
+#endif
+   df = e_find_files(sustr, 0);
+   if (!df->anz)
+   {
+    freedf(df);
+    continue;
+   }
+   for (j = 0; j < df->anz; j++)
+   {
+    k = strlen(df->name[j]) - 1;
+
+    /* If the file is gzipped strip the .gz ending. */
+    if ((k > 2) && (strcmp(df->name[j] + k - 2, ".gz") == 0))
+    {
+     k -= 3;
+     *(df->name[j] + k + 1) = '\0';
+    }
+   
+    for (k = strlen(df->name[j]) - 1; k >= 0 && *(df->name[j]+k) != '.'; k--);
+    if (k >= 0 /**(df->name[j]+k)*/)
+    {
+     df->name[j] = REALLOC(df->name[j],
+       (l = strlen(df->name[j])+2)*sizeof(char));
+     *(df->name[j]+k) = '(';
+     *(df->name[j]+l-2) = ')';
+     *(df->name[j]+l-1) = '\0';
+    }
+   }
+   if (!dout->name)
+    dout->name = MALLOC(df->anz * sizeof(char *));
+   else
+    dout->name = REALLOC(dout->name,(df->anz+dout->anz)*sizeof(char *));
+   for (j = 0; j < df->anz; j++)
+   {
+    for (k = 0; k < dout->anz; k++)
+    {
+     if (!(ret = strcmp(df->name[j], dout->name[k])))
+     {
+      FREE(df->name[j]);
+      break;
+     }
+     else if (ret < 0)
+      break;
+    }
+    if (!ret && dout->anz)
+     continue;
+    for (l = dout->anz; l > k; l--)
+     dout->name[l] = dout->name[l-1];
+    dout->name[k] = df->name[j];
+    dout->anz++;
+   }
+   FREE(df);
 #ifdef CATMAN
-   }   freedf(dd);
+  }
+  freedf(dd);
 #endif
-}
-WpeMouseRestoreShape();
-return(dout);
+ }
+ WpeMouseRestoreShape();
+ return(dout);
 }
 
 #ifdef PROG
 extern struct dirfile **e_p_df;
 #endif
 
-int e_data_first(sw, cn, nstr)
-     int sw;
-     ECNT *cn;
-     char *nstr;
+int e_data_first(int sw, ECNT *cn, char *nstr)
 {
     extern char *e_hlp_str[];
     extern WOPT *gblst, *oblst;
@@ -2072,8 +2097,7 @@
     return(0);
 }
 
-int e_data_schirm(f)
-     FENSTER *f;
+int e_data_schirm(FENSTER *f)
 {
     int i, j;
     FLWND *fw = (FLWND *) f->b;
@@ -2118,8 +2142,7 @@
     return(0);
 }
 
-int e_data_eingabe(cn)
-     ECNT *cn;
+int e_data_eingabe(ECNT *cn)
 {
     FENSTER *f = cn->f[cn->mxedt];
     FLWND *fw = (FLWND *) f->b;
@@ -2186,38 +2209,37 @@
     return((f->ed->edopt & 1) ? CF4 : AF3);
 }
 
-int e_get_funct_in(nstr, f)
-     char *nstr;
-     FENSTER *f;
+int e_get_funct_in(char *nstr, FENSTER *f)
 {
-    return(e_data_first(1, f->ed, nstr));
+ return(e_data_first(1, f->ed, nstr));
 }
 
 
-int e_funct_in(f)
-     FENSTER *f;
+int e_funct_in(FENSTER *f)
 {
-    int n, xa = 37, ya = 2, num = 8;
-    OPTK *opt = MALLOC(num * sizeof(OPTK));
-    char nstr[2];
+ int n, xa = 37, ya = 2, num = 8;
+ OPTK *opt = MALLOC(num * sizeof(OPTK));
+ char nstr[2];
 
-    opt[0].t = "User Commands";       opt[0].x = 0;  opt[0].o = 'U';
-    opt[1].t = "System Calls";        opt[1].x = 0;  opt[1].o = 'S';
-    opt[2].t = "C-Lib.-Functions";    opt[2].x = 0;  opt[2].o = 'C';
-    opt[3].t = "Devices & Netw. I.";  opt[3].x = 0;  opt[3].o = 'D';
-    opt[4].t = "File Formats";        opt[4].x = 0;  opt[4].o = 'F';
-    opt[5].t = "Games & Demos";       opt[5].x = 0;  opt[5].o = 'G';
-    opt[6].t = "Environment, ...";    opt[6].x = 0;  opt[6].o = 'E';
-    opt[7].t = "Maintenance Com.";    opt[7].x = 0;  opt[7].o = 'M';
+ opt[0].t = "User Commands";       opt[0].x = 0;  opt[0].o = 'U';
+ opt[1].t = "System Calls";        opt[1].x = 0;  opt[1].o = 'S';
+ opt[2].t = "C-Lib.-Functions";    opt[2].x = 0;  opt[2].o = 'C';
+ opt[3].t = "Devices & Netw. I.";  opt[3].x = 0;  opt[3].o = 'D';
+ opt[4].t = "File Formats";        opt[4].x = 0;  opt[4].o = 'F';
+ opt[5].t = "Games & Demos";       opt[5].x = 0;  opt[5].o = 'G';
+ opt[6].t = "Environment, ...";    opt[6].x = 0;  opt[6].o = 'E';
+ opt[7].t = "Maintenance Com.";    opt[7].x = 0;  opt[7].o = 'M';
 
-    n = e_opt_sec_box(xa, ya, num, opt, f, 1);
+ n = e_opt_sec_box(xa, ya, num, opt, f, 1);
 
-    FREE(opt);
-    if(n < 0) return(ESC);
+ FREE(opt);
+ if (n < 0)
+  return(ESC);
 
-    nstr[0] = '1' + n;  nstr[1] = '\0';
-    return(e_get_funct_in(nstr, f));
+ nstr[0] = '1' + n;
+ nstr[1] = '\0';
+ return(e_get_funct_in(nstr, f));
 }
 
-
 #endif
+