mtr@mace.cc.purdue.edu (Miek Rowan) (11/23/88)
Here are some diffs for the R3 xman. I have added support for
compressed cat pages (as we use here) and made it use the
ButtonPressMask instead of EnterWindowMask. I also up'ed
the MAXENTRY size for SunOS 4.0 (does everyone one have >
1100 pages in section 3? ) - I used ifdefs for everything:
COMPRESSED_MANPAGES - define this if you have these
if you don't and you still
define this, you only loose
a little time (one system call)
USEENTERMASK define this if you want the
old behavior of using EnterWindowMask
SUNOS We define this in sys/param.h
if it is >= 40, MAXENTRY gets
bumped up to 1200
I have tested this stuff some, and all seems happy. The menu
could/should be done better, but I got sick of it popping up
everytime I entered the damn window!
Flames to /dev/null.
mtr
Feed me to patch from $X11R3/clients/xman!
*** /tmp/,RCSt1019374 Tue Nov 22 13:09:20 1988
--- buttons.c Tue Nov 22 12:52:32 1988
***************
*** 202,209 ****
XtPanedSetMinMax( man_globals->label, 2 ,
Height( man_globals->label ) );
! XtAddEventHandler(man_globals->label, (Cardinal) EnterWindowMask,
FALSE ,PopUpMenu, NULL);
/* Create Directory */
--- 202,214 ----
XtPanedSetMinMax( man_globals->label, 2 ,
Height( man_globals->label ) );
! #ifndef USEENTERMASK
! XtAddEventHandler(man_globals->label, (Cardinal) ButtonPressMask,
FALSE ,PopUpMenu, NULL);
+ #else /* use enter mask */
+ XtAddEventHandler(man_globals->label, (Cardinal) EnterWindowMask,
+ FALSE ,PopUpMenu, NULL);
+ #endif /* USEENTERMASK */
/* Create Directory */
*** /tmp/,RCSt1019405 Tue Nov 22 13:09:45 1988
--- handler.c Tue Nov 22 13:03:39 1988
***************
*** 24,29 ****
--- 24,32 ----
#endif
#include "globals.h"
+ #ifdef COMPRESSED_MANPAGES
+ #include <sys/wait.h>
+ #endif /* COMPRESSED_MANPAGES */
static void PutUpManpage();
***************
*** 429,434 ****
--- 432,440 ----
{
ManpageGlobals * man_globals;
char str[100];
+ #ifdef COMPRESSED_MANPAGES
+ struct wait StatusWait;
+ #endif /* COMPRESSED_MANPAGES */
man_globals = (ManpageGlobals *) global_pointer;
***************
*** 439,444 ****
--- 445,460 ----
if(system(str) != 0) /* execute copy. */
PrintError("Something went wrong trying to copy temp file to cat dir.");
+ #ifdef COMPRESSED_MANPAGES
+ if(0 == fork()) {
+ execl(COMPRESS,"compress",man_globals->filename,(char *)0);
+ exit(-1);
+ }
+ (void) wait(&StatusWait);
+ if(0 != StatusWait.w_retcode) {
+ PrintError("Couldn't compress the man page.");
+ }
+ #endif /* COMPRESSED_MANPAGES */
}
XtPopdown( XtParent(XtParent(w)) );
*** /tmp/,RCSt1019439 Tue Nov 22 13:09:58 1988
--- man.c Tue Nov 22 11:23:29 1988
***************
*** 24,29 ****
--- 24,30 ----
#endif
#include "globals.h"
+ #include <sys/param.h>
static void SetSectionNames();
static int GetSectNumber();
*** /tmp/,RCSt1019504 Tue Nov 22 13:10:30 1988
--- misc.c Tue Nov 22 13:04:59 1988
***************
*** 24,29 ****
--- 24,33 ----
#endif
#include "globals.h"
+ #ifdef COMPRESSED_MANPAGES
+ #include <sys/wait.h>
+ #include <sys/file.h>
+ #endif /* COMPRESSED_MANPAGES */
/*
* It would be very nice if these would pop up their own windows for
***************
*** 89,94 ****
--- 93,133 ----
if ( (file = fopen(man_globals->filename,"r")) != NULL)
return(file);
+ #ifdef COMPRESSED_MANPAGES
+ /*
+ * Check for a .Z extension, if it is, uncompress it and
+ * open the output.
+ */
+ sprintf(local_filename, "%s.Z", man_globals->filename);
+ if(-1 != access(local_filename, F_OK)) {
+ char *tempfile = mktemp("/tmp/xman_compressedXXXXXX");
+ int iFileno,
+ local_pid;
+ union wait WaitStatus;
+
+ if(0 == (local_pid = fork())) {
+ if(NULL == (file = fopen(tempfile,"w"))) {
+ exit(1);
+ }
+ /*
+ * set up our stdout - then exec
+ */
+ iFileno = fileno(stdout);
+ close( iFileno);
+ dup2(fileno(file), iFileno);
+ fclose(file);
+ execl(ZCAT,"zcat",local_filename, (char *)0);
+ exit(-1); /* error */
+ }
+ (void) wait(&WaitStatus);
+ if(0 == WaitStatus.w_retcode) {
+ if(NULL != (file = fopen(tempfile,"r"))) {
+ return file;
+ }
+ }
+ }
+ #endif /* COMPRESSED_MANPAGES */
+
/* If not then look for the unformatted man page, format it and
* write access is allowed to the cat directory, then ask if we
* want to save it.
***************
*** 182,188 ****
sprintf(catdir,"%s/%s%c",
entry->path,CAT, manual[current_box].sect[LCAT], entry->label);
!
if( (access(catdir,W_OK)) == 0) {
x = Width(man_globals->manpagewidgets.manpage)/2;
y = Height(man_globals->manpagewidgets.manpage)/2;
--- 221,227 ----
sprintf(catdir,"%s/%s%c",
entry->path,CAT, manual[current_box].sect[LCAT], entry->label);
!
if( (access(catdir,W_OK)) == 0) {
x = Width(man_globals->manpagewidgets.manpage)/2;
y = Height(man_globals->manpagewidgets.manpage)/2;
*** /tmp/,RCSt1019511 Tue Nov 22 13:10:45 1988
--- defs.h Tue Nov 22 11:37:57 1988
***************
*** 23,28 ****
--- 23,30 ----
#ifndef HELPFILE
#define HELPFILE "/usr/lib/X11/xman.help" /* name of the default helpfile. */
#endif
+ #define ZCAT "/usr/ucb/zcat"
+ #define COMPRESS "/usr/ucb/compress"
/* The default cursors */
***************
*** 92,99 ****
--- 94,105 ----
#define MAXSECT 25 /* The maximum number of sections. */
#define FIXEDSECT 11 /* The number of predefined sections.
0 - 8 and n, and l = 11. */
+ #if SUNOS>=40
+ #define MAXENTRY 1200
+ #else /* ! SUNOS4.0 */
#define MAXENTRY 800 /* The maximum number of entries in one
section. */
+ #endif /* SUNOS40 */
#define NLINES 66 /* This is the number of lines to wait until
we boldify the line again, this allows
me to bold the first line of each page.*/