[comp.windows.x] xman bug + fixes

strike@convexs.uucp (Professor Fate) (11/30/88)

VERSION:
    R3

CLIENT MACHINE and OPERATING SYSTEM:
    CONVEX C120 running CONVEX UNIX V6.2 (but applies to all systems
    regardless of hardware/OS)

DISPLAY:
    Any display 

AREA:
    xman (and contrib/clients/xmore since it is derived from xman)

SYNOPSIS:
    xman does not use the X Tookit structure XtResource correctly - it uses
    addresses of variables rather than offsets of fields in a structure.
    This makes xman unportable because it depends on addresses being positive
    to work correctly with the resource manager.

DESCRIPTION:
    In xman's main.c the array "my_resources" defines a set of resources of 
    type XtResource. The field resource_offset is set to an address of a 
    variable.  
    
    On our machine, address values have the high bit set and this 
    confuses Xlib - Xlib does not compile the resource list when it should 
    because it looks like the structure has already been compiled in place 
    (Xlib looks to see if resource_offset is less than zero; if it is, then 
    this implies that the structure has been compiled. On our machine, 
    addresses look like negative values and the resource array in xman is
    never compiled.)

    The Xt include file Intrinsic.h says that the offset field of
    the structure should be the byte offset of the field from the base of a 
    structure to put the resource value. Most clients create a large structure
    with all the resource variables contained within. Then, the resource_offset
    field of the XtResource structure is filled in using XtOffset. As an 
    example of the correct way to do it, look at xterm and the way it creates
    its resource array. 

    xman has to be changed to use XtResource correctly by creating a large
    structure with the resource values included and using XtOffset to
    initialize the my_resources array. In this way, resource_offset will be a 
    small positive integer and will not depend on addresses being positive.

REPEAT BY:
    I built xman on the CONVEX and ran it - it core dumped with "(null) to 
    (null) conversion" errors.

SAMPLE FIX:
    Change directory to clients/xman and apply the following diffs:

*** buttons.c.orig	Tue Nov 29 19:27:17 1988
--- buttons.c	Wed Nov 23 17:11:47 1988
***************
*** 136,142
  
  /* Initialize the number of screens that will be shown */
  
!   man_globals->both_shown = both_shown_initial;
  
    for ( i = 0 ; i < sections ; i++) 
      man_globals->manpagewidgets.box[i] = NULL;

--- 136,142 -----
  
  /* Initialize the number of screens that will be shown */
  
!   man_globals->both_shown = resource.both_shown_initial;
  
    for ( i = 0 ; i < sections ; i++) 
      man_globals->manpagewidgets.box[i] = NULL;
***************
*** 223,230
  
  /* Create Manpage */
  
!   font_height = (fonts.normal->max_bounds.ascent + 
! 		   fonts.normal->max_bounds.descent);
  
    num_args = 0;
    XtSetArg(arglist[num_args], XtNallowVert, TRUE);

--- 223,230 -----
  
  /* Create Manpage */
  
!   font_height = (resource.normal->max_bounds.ascent + 
! 		   resource.normal->max_bounds.descent);
  
    num_args = 0;
    XtSetArg(arglist[num_args], XtNallowVert, TRUE);
***************
*** 285,291
      if (man_globals->both_shown) {
        XtManageChild(dir);
        man_globals->dir_shown = TRUE;
!       XtPanedSetMinMax(dir, directory_height, directory_height);
        XtSetSensitive(man_globals->put_up_manpage,FALSE);
        XtSetSensitive(man_globals->put_up_directory,FALSE);
        ChangeLabel(man_globals->both_shown_button, SHOW_ONE);

--- 285,292 -----
      if (man_globals->both_shown) {
        XtManageChild(dir);
        man_globals->dir_shown = TRUE;
!       XtPanedSetMinMax(dir, resource.directory_height, 
! 		       resource.directory_height);
        XtSetSensitive(man_globals->put_up_manpage,FALSE);
        XtSetSensitive(man_globals->put_up_directory,FALSE);
        ChangeLabel(man_globals->both_shown_button, SHOW_ONE);
***************
*** 320,326
   */
  
    XtRealizeWidget(  man_globals->This_Manpage );
!   AddCursor( man_globals->This_Manpage, cursors.manpage);
    XtPanedSetMinMax(dir, 1, 10000); 
  }
  

--- 321,327 -----
   */
  
    XtRealizeWidget(  man_globals->This_Manpage );
!   AddCursor( man_globals->This_Manpage, resource.manpage);
    XtPanedSetMinMax(dir, 1, 10000); 
  }
  
***************
*** 467,473
    MakeLong((Widget) pupwidget);
  
    XtRealizeWidget(popup_shell);	/* Realize it and change its cursor. */
!   AddCursor(popup_shell,cursors.top);
  }
  
  /*	Function Name: MakeDirPopUpWidget

--- 468,474 -----
    MakeLong((Widget) pupwidget);
  
    XtRealizeWidget(popup_shell);	/* Realize it and change its cursor. */
!   AddCursor(popup_shell,resource.top);
  }
  
  /*	Function Name: MakeDirPopUpWidget
***************
*** 529,535
    XtManageChild(pupwidget);
    (void) MakeLong(pupwidget);
    XtRealizeWidget(popup_shell);
!   AddCursor(popup_shell,cursors.top);
  }
  
  /*	Function Name: CreateManpageName

--- 530,536 -----
    XtManageChild(pupwidget);
    (void) MakeLong(pupwidget);
    XtRealizeWidget(popup_shell);
!   AddCursor(popup_shell,resource.top);
  }
  
  /*	Function Name: CreateManpageName
***************
*** 618,624
    num_args++;
    XtSetArg(arglist[num_args], XtNborderWidth, 0);
    num_args++;
!   XtSetArg(arglist[num_args], XtNfont, fonts.directory);
    num_args++;
    
    *dir_disp = XtCreateWidget(DIRECTORY_NAME, listWidgetClass, parent,

--- 619,625 -----
    num_args++;
    XtSetArg(arglist[num_args], XtNborderWidth, 0);
    num_args++;
!   XtSetArg(arglist[num_args], XtNfont, resource.directory);
    num_args++;
    
    *dir_disp = XtCreateWidget(DIRECTORY_NAME, listWidgetClass, parent,
***************
*** 669,675
  						arglist,num_args);
    XtManageChild(box);
    XtRealizeWidget(shell);
!   AddCursor(shell,cursors.top);
  
    num_args = 0;
    shell = XtCreatePopupShell("likeToSave",transientShellWidgetClass,

--- 670,676 -----
  						arglist,num_args);
    XtManageChild(box);
    XtRealizeWidget(shell);
!   AddCursor(shell,resource.top);
  
    num_args = 0;
    shell = XtCreatePopupShell("likeToSave",transientShellWidgetClass,
***************
*** 727,731
  
    XtManageChild(box);
    XtRealizeWidget(shell);
!   AddCursor(shell,cursors.top);
  }

--- 728,732 -----
  
    XtManageChild(box);
    XtRealizeWidget(shell);
!   AddCursor(shell,resource.top);
  }
*** globals.c.orig	Tue Nov 29 19:27:18 1988
--- globals.c	Wed Nov 23 16:52:06 1988
***************
*** 26,41
  #include "man.h"
  
  /* Resource manager sets these. */
! 
! XmanFonts fonts;		/* The fonts used for the man pages. */
! XmanCursors cursors;		/* The cursors for xman. */
! Boolean both_shown_initial;	/* The initial state of the manual pages
! 				   show two screens or only one. */
! Boolean top_box_active;	        /* Put up the Top Box. */
! int directory_height;	        /* The default height of directory in 
! 				   both_shown mode. */
! char * help_file;		/* The name of the help file. */
! 
  Widget help_widget;		/* The help widget. */
  
  /* bookkeeping global variables. */

--- 26,32 -----
  #include "man.h"
  
  /* Resource manager sets these. */
! struct _resource resource;	/* all resources  - see globals.h */
  Widget help_widget;		/* The help widget. */
  
  /* bookkeeping global variables. */
*** handler.c.orig	Tue Nov 29 19:27:18 1988
--- handler.c	Wed Nov 23 16:43:35 1988
***************
*** 98,104
        Widget dir = man_globals->manpagewidgets.directory;
  
        label_str = SHOW_ONE;
!       XtPanedSetMinMax(dir,directory_height,directory_height);
        if (!man_globals->dir_shown) {
  	XtUnmanageChild(manpage);
  	XtManageChild(dir);

--- 98,106 -----
        Widget dir = man_globals->manpagewidgets.directory;
  
        label_str = SHOW_ONE;
!       XtPanedSetMinMax(dir, 
! 		       resource.directory_height,
! 		       resource.directory_height);
        if (!man_globals->dir_shown) {
  	XtUnmanageChild(manpage);
  	XtManageChild(dir);
*** help.c.orig	Tue Nov 29 19:27:18 1988
--- help.c	Wed Nov 23 17:13:32 1988
***************
*** 55,61
  
    XtManageChild( man_globals->manpagewidgets.manpage );
    XtRealizeWidget(  help_widget );
!   AddCursor( help_widget, cursors.manpage);
  
    return(TRUE);
  }

--- 55,61 -----
  
    XtManageChild( man_globals->manpagewidgets.manpage );
    XtRealizeWidget(  help_widget );
!   AddCursor( help_widget, resource.manpage);
  
    return(TRUE);
  }
***************
*** 85,91
  {
    FILE * help_file_ptr;
  
!   if( (help_file_ptr = fopen(help_file, "r")) == NULL ) {
      PrintWarning("Could not open help file, NO HELP WILL BE AVALIABLE.");
      return(FALSE);
    }

--- 85,91 -----
  {
    FILE * help_file_ptr;
  
!   if( (help_file_ptr = fopen(resource.help_file, "r")) == NULL ) {
      PrintWarning("Could not open help file, NO HELP WILL BE AVALIABLE.");
      return(FALSE);
    }
*** main.c.orig	Tue Nov 29 19:27:19 1988
--- main.c	Wed Nov 23 17:24:28 1988
***************
*** 23,28
    static char rcs_version[] = "$Athena: main.c,v 4.0 88/08/31 22:12:26 kit Exp $";
  #endif
  
  #include "globals.h"
  
  #if ( !defined(lint) && !defined(SABER)) /* Version can be retrieve */

--- 23,29 -----
    static char rcs_version[] = "$Athena: main.c,v 4.0 88/08/31 22:12:26 kit Exp $";
  #endif
  
+ #include <X11/Intrinsic.h>
  #include "globals.h"
  
  #if ( !defined(lint) && !defined(SABER)) /* Version can be retrieve */
***************
*** 31,37
  
  static void ArgError();
  
! /* XtOffset() hack for ibmrt BandAidCompiler */
  
  static XtResource my_resources[] = {
    {"manualFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),

--- 32,38 -----
  
  static void ArgError();
  
! #define offset(field)	XtOffset(struct _resource *, field)
  
  static XtResource my_resources[] = {
    {"manualFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
***************
*** 35,41
  
  static XtResource my_resources[] = {
    {"manualFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
!      (Cardinal) &(fonts.normal), XtRString, MANPAGE_NORMAL},
    {"manualFontBold", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       (Cardinal) &(fonts.bold), XtRString, MANPAGE_BOLD},
    {"manualFontItalic", XtCFont, XtRFontStruct, sizeof(XFontStruct *),

--- 36,42 -----
  
  static XtResource my_resources[] = {
    {"manualFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
!      offset(normal), XtRString, MANPAGE_NORMAL},
    {"manualFontBold", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       offset(bold), XtRString, MANPAGE_BOLD},
    {"manualFontItalic", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
***************
*** 37,43
    {"manualFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       (Cardinal) &(fonts.normal), XtRString, MANPAGE_NORMAL},
    {"manualFontBold", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
!      (Cardinal) &(fonts.bold), XtRString, MANPAGE_BOLD},
    {"manualFontItalic", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       (Cardinal) &(fonts.italic), XtRString, MANPAGE_ITALIC},
    {"directoryFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),

--- 38,44 -----
    {"manualFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       offset(normal), XtRString, MANPAGE_NORMAL},
    {"manualFontBold", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
!      offset(bold), XtRString, MANPAGE_BOLD},
    {"manualFontItalic", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       offset(italic), XtRString, MANPAGE_ITALIC},
    {"directoryFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
***************
*** 39,45
    {"manualFontBold", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       (Cardinal) &(fonts.bold), XtRString, MANPAGE_BOLD},
    {"manualFontItalic", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
!      (Cardinal) &(fonts.italic), XtRString, MANPAGE_ITALIC},
    {"directoryFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       (Cardinal) &(fonts.directory), XtRString, DIRECTORY_NORMAL},
    {"bothShown", XtCBoolean, XtRBoolean, sizeof(Boolean),

--- 40,46 -----
    {"manualFontBold", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       offset(bold), XtRString, MANPAGE_BOLD},
    {"manualFontItalic", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
!      offset(italic), XtRString, MANPAGE_ITALIC},
    {"directoryFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       offset(directory), XtRString, DIRECTORY_NORMAL},
    {"bothShown", XtCBoolean, XtRBoolean, sizeof(Boolean),
***************
*** 41,47
    {"manualFontItalic", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       (Cardinal) &(fonts.italic), XtRString, MANPAGE_ITALIC},
    {"directoryFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
!      (Cardinal) &(fonts.directory), XtRString, DIRECTORY_NORMAL},
    {"bothShown", XtCBoolean, XtRBoolean, sizeof(Boolean),
       (Cardinal) &both_shown_initial, XtRString, "False"},
    {"directoryHeight", "DirectoryHeight", XtRInt, sizeof(int),

--- 42,48 -----
    {"manualFontItalic", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       offset(italic), XtRString, MANPAGE_ITALIC},
    {"directoryFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
!      offset(directory), XtRString, DIRECTORY_NORMAL},
    {"bothShown", XtCBoolean, XtRBoolean, sizeof(Boolean),
       offset(both_shown_initial), XtRString, "False"},
    {"directoryHeight", "DirectoryHeight", XtRInt, sizeof(int),
***************
*** 43,49
    {"directoryFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       (Cardinal) &(fonts.directory), XtRString, DIRECTORY_NORMAL},
    {"bothShown", XtCBoolean, XtRBoolean, sizeof(Boolean),
!      (Cardinal) &both_shown_initial, XtRString, "False"},
    {"directoryHeight", "DirectoryHeight", XtRInt, sizeof(int),
       (Cardinal) &directory_height, XtRString, "150"},  
    {"topCursor", XtCCursor, XtRCursor, sizeof(Cursor), 

--- 44,50 -----
    {"directoryFontNormal", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       offset(directory), XtRString, DIRECTORY_NORMAL},
    {"bothShown", XtCBoolean, XtRBoolean, sizeof(Boolean),
!      offset(both_shown_initial), XtRString, "False"},
    {"directoryHeight", "DirectoryHeight", XtRInt, sizeof(int),
       offset(directory_height), XtRString, "150"},  
    {"topCursor", XtCCursor, XtRCursor, sizeof(Cursor), 
***************
*** 45,51
    {"bothShown", XtCBoolean, XtRBoolean, sizeof(Boolean),
       (Cardinal) &both_shown_initial, XtRString, "False"},
    {"directoryHeight", "DirectoryHeight", XtRInt, sizeof(int),
!      (Cardinal) &directory_height, XtRString, "150"},  
    {"topCursor", XtCCursor, XtRCursor, sizeof(Cursor), 
       (Cardinal) &(cursors.top), XtRString, XMAN_CURSOR},
    {"helpCursor", XtCCursor, XtRCursor, sizeof(Cursor),

--- 46,52 -----
    {"bothShown", XtCBoolean, XtRBoolean, sizeof(Boolean),
       offset(both_shown_initial), XtRString, "False"},
    {"directoryHeight", "DirectoryHeight", XtRInt, sizeof(int),
!      offset(directory_height), XtRString, "150"},  
    {"topCursor", XtCCursor, XtRCursor, sizeof(Cursor), 
       offset(top), XtRString, XMAN_CURSOR},
    {"helpCursor", XtCCursor, XtRCursor, sizeof(Cursor),
***************
*** 47,53
    {"directoryHeight", "DirectoryHeight", XtRInt, sizeof(int),
       (Cardinal) &directory_height, XtRString, "150"},  
    {"topCursor", XtCCursor, XtRCursor, sizeof(Cursor), 
!      (Cardinal) &(cursors.top), XtRString, XMAN_CURSOR},
    {"helpCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       (Cardinal) &(cursors.help), XtRString, HELP_CURSOR},
    {"manpageCursor", XtCCursor, XtRCursor, sizeof(Cursor),

--- 48,54 -----
    {"directoryHeight", "DirectoryHeight", XtRInt, sizeof(int),
       offset(directory_height), XtRString, "150"},  
    {"topCursor", XtCCursor, XtRCursor, sizeof(Cursor), 
!      offset(top), XtRString, XMAN_CURSOR},
    {"helpCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       offset(help), XtRString, HELP_CURSOR},
    {"manpageCursor", XtCCursor, XtRCursor, sizeof(Cursor),
***************
*** 49,55
    {"topCursor", XtCCursor, XtRCursor, sizeof(Cursor), 
       (Cardinal) &(cursors.top), XtRString, XMAN_CURSOR},
    {"helpCursor", XtCCursor, XtRCursor, sizeof(Cursor),
!      (Cardinal) &(cursors.help), XtRString, HELP_CURSOR},
    {"manpageCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       (Cardinal) &(cursors.manpage), XtRString, MANPAGE_CURSOR},
    {"searchEntryCursor", XtCCursor, XtRCursor, sizeof(Cursor),

--- 50,56 -----
    {"topCursor", XtCCursor, XtRCursor, sizeof(Cursor), 
       offset(top), XtRString, XMAN_CURSOR},
    {"helpCursor", XtCCursor, XtRCursor, sizeof(Cursor),
!      offset(help), XtRString, HELP_CURSOR},
    {"manpageCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       offset(manpage), XtRString, MANPAGE_CURSOR},
    {"searchEntryCursor", XtCCursor, XtRCursor, sizeof(Cursor),
***************
*** 51,57
    {"helpCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       (Cardinal) &(cursors.help), XtRString, HELP_CURSOR},
    {"manpageCursor", XtCCursor, XtRCursor, sizeof(Cursor),
!      (Cardinal) &(cursors.manpage), XtRString, MANPAGE_CURSOR},
    {"searchEntryCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       (Cardinal) &(cursors.search_entry), XtRString, SEARCH_ENTRY_CURSOR},
    {"helpFile", XtCFile, XtRString, sizeof(char *),

--- 52,58 -----
    {"helpCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       offset(help), XtRString, HELP_CURSOR},
    {"manpageCursor", XtCCursor, XtRCursor, sizeof(Cursor),
!      offset(manpage), XtRString, MANPAGE_CURSOR},
    {"searchEntryCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       offset(search_entry), XtRString, SEARCH_ENTRY_CURSOR},
    {"helpFile", XtCFile, XtRString, sizeof(char *),
***************
*** 53,59
    {"manpageCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       (Cardinal) &(cursors.manpage), XtRString, MANPAGE_CURSOR},
    {"searchEntryCursor", XtCCursor, XtRCursor, sizeof(Cursor),
!      (Cardinal) &(cursors.search_entry), XtRString, SEARCH_ENTRY_CURSOR},
    {"helpFile", XtCFile, XtRString, sizeof(char *),
       (Cardinal) &(help_file), XtRString, HELPFILE},
    {"topBox", XtCBoolean, XtRBoolean, sizeof(Boolean),

--- 54,60 -----
    {"manpageCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       offset(manpage), XtRString, MANPAGE_CURSOR},
    {"searchEntryCursor", XtCCursor, XtRCursor, sizeof(Cursor),
!      offset(search_entry), XtRString, SEARCH_ENTRY_CURSOR},
    {"helpFile", XtCFile, XtRString, sizeof(char *),
       offset(help_file), XtRString, HELPFILE},
    {"topBox", XtCBoolean, XtRBoolean, sizeof(Boolean),
***************
*** 55,61
    {"searchEntryCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       (Cardinal) &(cursors.search_entry), XtRString, SEARCH_ENTRY_CURSOR},
    {"helpFile", XtCFile, XtRString, sizeof(char *),
!      (Cardinal) &(help_file), XtRString, HELPFILE},
    {"topBox", XtCBoolean, XtRBoolean, sizeof(Boolean),
       (Cardinal) &top_box_active, XtRString, "True"},
  };

--- 56,62 -----
    {"searchEntryCursor", XtCCursor, XtRCursor, sizeof(Cursor),
       offset(search_entry), XtRString, SEARCH_ENTRY_CURSOR},
    {"helpFile", XtCFile, XtRString, sizeof(char *),
!      offset(help_file), XtRString, HELPFILE},
    {"topBox", XtCBoolean, XtRBoolean, sizeof(Boolean),
       offset(top_box_active), XtRString, "True"},
  };
***************
*** 57,63
    {"helpFile", XtCFile, XtRString, sizeof(char *),
       (Cardinal) &(help_file), XtRString, HELPFILE},
    {"topBox", XtCBoolean, XtRBoolean, sizeof(Boolean),
!      (Cardinal) &top_box_active, XtRString, "True"},
  };
  
  /*

--- 58,64 -----
    {"helpFile", XtCFile, XtRString, sizeof(char *),
       offset(help_file), XtRString, HELPFILE},
    {"topBox", XtCBoolean, XtRBoolean, sizeof(Boolean),
!      offset(top_box_active), XtRString, "True"},
  };
  
  /*
***************
*** 95,101
      exit(42);
    }
  
!   XtGetApplicationResources( (Widget) top_menu, (caddr_t) NULL, 
  			    my_resources, XtNumber(my_resources),
  			    NULL, (Cardinal) 0);
    if (!fonts.normal)

--- 96,102 -----
      exit(42);
    }
  
!   XtGetApplicationResources( (Widget) top_menu, &resource, 
  			    my_resources, XtNumber(my_resources),
  			    NULL, (Cardinal) 0);
    if (!resource.normal)
***************
*** 98,104
    XtGetApplicationResources( (Widget) top_menu, (caddr_t) NULL, 
  			    my_resources, XtNumber(my_resources),
  			    NULL, (Cardinal) 0);
!   if (!fonts.normal)
  	XtError("failed to get the manualFontNormal font");
    if (!fonts.bold)
  	fonts.bold = fonts.normal;

--- 99,105 -----
    XtGetApplicationResources( (Widget) top_menu, &resource, 
  			    my_resources, XtNumber(my_resources),
  			    NULL, (Cardinal) 0);
!   if (!resource.normal)
  	XtError("failed to get the manualFontNormal font");
    if (!resource.bold)
  	resource.bold = resource.normal;
***************
*** 100,111
  			    NULL, (Cardinal) 0);
    if (!fonts.normal)
  	XtError("failed to get the manualFontNormal font");
!   if (!fonts.bold)
! 	fonts.bold = fonts.normal;
!   if (!fonts.italic)
! 	fonts.italic = fonts.bold;
!   if (!fonts.directory)
! 	fonts.directory = fonts.normal;
  
  #ifdef DEBUG
    printf("debugging mode\n");

--- 101,112 -----
  			    NULL, (Cardinal) 0);
    if (!resource.normal)
  	XtError("failed to get the manualFontNormal font");
!   if (!resource.bold)
! 	resource.bold = resource.normal;
!   if (!resource.italic)
! 	resource.italic = resource.bold;
!   if (!resource.directory)
! 	resource.directory = resource.normal;
  
  #ifdef DEBUG
    printf("debugging mode\n");
***************
*** 126,132
  
    MakeTopMenuWidget(top_menu);	
  
!   if (top_box_active) {
      XtRealizeWidget(top_menu);
      AddCursor(top_menu,cursors.top);
    }

--- 127,133 -----
  
    MakeTopMenuWidget(top_menu);	
  
!   if (resource.top_box_active) {
      XtRealizeWidget(top_menu);
      AddCursor(top_menu,resource.top);
    }
***************
*** 128,134
  
    if (top_box_active) {
      XtRealizeWidget(top_menu);
!     AddCursor(top_menu,cursors.top);
    }
    else
      CreateManpage();

--- 129,135 -----
  
    if (resource.top_box_active) {
      XtRealizeWidget(top_menu);
!     AddCursor(top_menu,resource.top);
    }
    else
      CreateManpage();
*** man.c.orig	Tue Nov 29 19:27:20 1988
--- man.c	Wed Nov 23 16:59:37 1988
***************
*** 332,339
   */
        if ((j = strlen(dp->d_name)) >= longest - 2) {
  	longest = j;
! 	if  ( (j = XTextWidth(fonts.directory,dp->d_name,strlen(dp->d_name))) >
! 	     lpixels)
  	lpixels = j;
        }
      }

--- 332,339 -----
   */
        if ((j = strlen(dp->d_name)) >= longest - 2) {
  	longest = j;
! 	if  ( (j = XTextWidth(resource.directory,
! 			      dp->d_name,strlen(dp->d_name))) > lpixels)
  	lpixels = j;
        }
      }
*** pages.c.orig	Tue Nov 29 19:27:21 1988
--- pages.c	Wed Nov 23 17:06:00 1988
***************
*** 237,244
   * export the font height.
   */
  
!   height = (fonts.normal->max_bounds.ascent + 
! 		   fonts.normal->max_bounds.descent); 
  
    bold_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,bold_gc,(unsigned long) fgcolor);

--- 237,244 -----
   * export the font height.
   */
  
!   height = (resource.normal->max_bounds.ascent + 
! 		   resource.normal->max_bounds.descent); 
  
    bold_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,bold_gc,(unsigned long) fgcolor);
***************
*** 242,248
  
    bold_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,bold_gc,(unsigned long) fgcolor);
!   XSetFont(disp,bold_gc,fonts.bold->fid);
  
    normal_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,normal_gc,(unsigned long) fgcolor);

--- 242,248 -----
  
    bold_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,bold_gc,(unsigned long) fgcolor);
!   XSetFont(disp,bold_gc,resource.bold->fid);
  
    normal_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,normal_gc,(unsigned long) fgcolor);
***************
*** 246,252
  
    normal_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,normal_gc,(unsigned long) fgcolor);
!   XSetFont(disp,normal_gc,fonts.normal->fid);
  
    italic_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,italic_gc,(unsigned long) fgcolor);

--- 246,252 -----
  
    normal_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,normal_gc,(unsigned long) fgcolor);
!   XSetFont(disp,normal_gc,resource.normal->fid);
  
    italic_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,italic_gc,(unsigned long) fgcolor);
***************
*** 250,256
  
    italic_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,italic_gc,(unsigned long) fgcolor);
!   XSetFont(disp,italic_gc,fonts.italic->fid);
  
    width =  XTextWidth(fonts.normal,"        ",8); /* Width of a tab stop. */
  

--- 250,256 -----
  
    italic_gc = XCreateGC(disp,window,0,NULL);
    XSetForeground(disp,italic_gc,(unsigned long) fgcolor);
!   XSetFont(disp,italic_gc,resource.italic->fid);
  
    width =  XTextWidth(resource.normal,"        ",8); /* Width of a tab stop. */
  
***************
*** 252,258
    XSetForeground(disp,italic_gc,(unsigned long) fgcolor);
    XSetFont(disp,italic_gc,fonts.italic->fid);
  
!   width =  XTextWidth(fonts.normal,"        ",8); /* Width of a tab stop. */
  
  /*
   * Because XDrawString uses the bottom of the text as a position

--- 252,258 -----
    XSetForeground(disp,italic_gc,(unsigned long) fgcolor);
    XSetFont(disp,italic_gc,resource.italic->fid);
  
!   width =  XTextWidth(resource.normal,"        ",8); /* Width of a tab stop. */
  
  /*
   * Because XDrawString uses the bottom of the text as a position
***************
*** 260,266
   * to the ScollByLine position reference.
   */
  
!   y_loc = scroll_info->location + fonts.normal->max_bounds.ascent;
  
  /*
   * Ok, here's the more than mildly heuristic man page formatter.

--- 260,266 -----
   * to the ScollByLine position reference.
   */
  
!   y_loc = scroll_info->location + resource.normal->max_bounds.ascent;
  
  /*
   * Ok, here's the more than mildly heuristic man page formatter.
***************
*** 336,342
  	XDrawString(disp,window,normal_gc,col,y_loc,buf,strlen(buf));
        bufp = buf; 
        italicflag = 0;
!       cur_pos = XTextWidth(fonts.normal,buf,strlen(buf)) + col;
        col = cur_pos - (cur_pos % width) + width;
        break;
  

--- 336,342 -----
  	XDrawString(disp,window,normal_gc,col,y_loc,buf,strlen(buf));
        bufp = buf; 
        italicflag = 0;
!       cur_pos = XTextWidth(resource.normal,buf,strlen(buf)) + col;
        col = cur_pos - (cur_pos % width) + width;
        break;
  
***************
*** 350,356
  	if (bufp > &buf[0]) {
  	    if (italicflag) {
  	       XDrawString(disp,window,italic_gc,col,y_loc,buf,strlen(buf));
! 	       col += XTextWidth(fonts.italic,buf,strlen(buf));
  	    }
  	    else {
  	       XDrawString(disp,window,normal_gc,col,y_loc,buf,strlen(buf));

--- 350,356 -----
  	if (bufp > &buf[0]) {
  	    if (italicflag) {
  	       XDrawString(disp,window,italic_gc,col,y_loc,buf,strlen(buf));
! 	       col += XTextWidth(resource.italic,buf,strlen(buf));
  	    }
  	    else {
  	       XDrawString(disp,window,normal_gc,col,y_loc,buf,strlen(buf));
***************
*** 354,360
  	    }
  	    else {
  	       XDrawString(disp,window,normal_gc,col,y_loc,buf,strlen(buf));
! 	       col += XTextWidth(fonts.normal,buf,strlen(buf));
  	    }
  	    bufp = buf;
  	}

--- 354,360 -----
  	    }
  	    else {
  	       XDrawString(disp,window,normal_gc,col,y_loc,buf,strlen(buf));
! 	       col += XTextWidth(resource.normal,buf,strlen(buf));
  	    }
  	    bufp = buf;
  	}
***************
*** 366,372
  	 */
  	 *bufp = c[1];
  	 XDrawString(disp,window,bold_gc,col,y_loc,bufp,1);
! 	 col += XTextWidth(fonts.bold,bufp,1);
  	 *bufp = '\0';
  
  	/*

--- 366,372 -----
  	 */
  	 *bufp = c[1];
  	 XDrawString(disp,window,bold_gc,col,y_loc,bufp,1);
! 	 col += XTextWidth(resource.bold,bufp,1);
  	 *bufp = '\0';
  
  	/*
***************
*** 404,410
  	  *bufp = '\0';
  	  XDrawString(disp,window,normal_gc,col,y_loc,
  		      buf,strlen(buf));
! 	  col += XTextWidth(fonts.normal,buf,strlen(buf));
  	  bufp = buf;
  	  *bufp = '\0';
  	  italicflag = 1;

--- 404,410 -----
  	  *bufp = '\0';
  	  XDrawString(disp,window,normal_gc,col,y_loc,
  		      buf,strlen(buf));
! 	  col += XTextWidth(resource.normal,buf,strlen(buf));
  	  bufp = buf;
  	  *bufp = '\0';
  	  italicflag = 1;
***************
*** 418,424
        if(italicflag) {			/* font change? */
  	*bufp = '\0';
  	XDrawString(disp,window,italic_gc,col,y_loc,buf,strlen(buf));
! 	col += XTextWidth(fonts.italic,buf,strlen(buf));	
  	bufp = buf;
  	*bufp = '\0';
  	italicflag = 0;

--- 418,424 -----
        if(italicflag) {			/* font change? */
  	*bufp = '\0';
  	XDrawString(disp,window,italic_gc,col,y_loc,buf,strlen(buf));
! 	col += XTextWidth(resource.italic,buf,strlen(buf));	
  	bufp = buf;
  	*bufp = '\0';
  	italicflag = 0;
*** search.c.orig	Tue Nov 29 19:27:22 1988
--- search.c	Wed Nov 23 17:16:09 1988
***************
*** 90,96
  
    XtSetArg(arglist[num_args], XtNlength, SEARCH_STRING_LENGTH);
    num_args++;
!   XtSetArg(arglist[num_args], XtNcursor, cursors.search_entry);
    num_args++;
  
    text = XtCreateWidget("textWidgetSearch",asciiStringWidgetClass,

--- 90,96 -----
  
    XtSetArg(arglist[num_args], XtNlength, SEARCH_STRING_LENGTH);
    num_args++;
!   XtSetArg(arglist[num_args], XtNcursor, resource.search_entry);
    num_args++;
  
    text = XtCreateWidget("textWidgetSearch",asciiStringWidgetClass,
***************
*** 166,172
  
    XtManageChild(box);
    XtRealizeWidget(popup_shell);
!   AddCursor(popup_shell,cursors.search_entry);
  }
  
  /*	Function Name: DoSearch

--- 166,172 -----
  
    XtManageChild(box);
    XtRealizeWidget(popup_shell);
!   AddCursor(popup_shell,resource.search_entry);
  }
  
  /*	Function Name: DoSearch
*** globals.h.orig	Tue Nov 29 19:27:18 1988
--- globals.h	Wed Nov 23 16:40:16 1988
***************
*** 24,38
  
  /* Resource manager sets these. */
  
! extern XmanFonts fonts;			/* The fonts used for the man pages. */
! extern XmanCursors cursors;		/* The cursors for xman. */
! extern Boolean both_shown_initial;      /* The initial state of the manual 
! 				         pages show two screens or only one. */
! extern Boolean top_box_active;	        /* Put up the Top Box. */
! extern int directory_height;	        /* The default height of directory in 
! 				            both_shown mode. */
! extern char * help_file;		/* The name of the help file. */
! 
  extern Widget help_widget;		/* The help widget. */
  
  /* bookkeeping global variables. */

--- 24,30 -----
  
  /* Resource manager sets these. */
  
! extern struct _resource resource;	/* all resources set by rm */
  extern Widget help_widget;		/* The help widget. */
  
  /* bookkeeping global variables. */
*** man.h.orig	Tue Nov 29 19:27:20 1988
--- man.h	Wed Nov 23 16:53:30 1988
***************
*** 60,80
  
  typedef void (*fcall)();	/* function pointer typedef */
  
- typedef struct _XmanFonts {
-   XFontStruct * bold,		/* The bold text for the man pages. */
-     * normal,			/* The normal text for the man pages. */
-     * italic,			/* The italic text for the man pages. */
-     * directory;		/* The font for the directory.  */
- } XmanFonts;
- 
- typedef struct _XmanCursors {
-   Cursor top,			/* The top Cursor, default for xman. */
-     help,			/* The top cursor for the help menu. */
-     manpage,			/* The cursor for the Manpage. */
-     search_entry;		/* The cursor for the text widget in the
- 				   search box.*/
- } XmanCursors;
- 
  typedef struct _ManPageWidgets {
    Widget manpage,		/* The manual page window (scrolled) */
      directory,			/* The widget in which all directories will

--- 60,65 -----
  
  typedef void (*fcall)();	/* function pointer typedef */
  
  typedef struct _ManPageWidgets {
    Widget manpage,		/* The manual page window (scrolled) */
      directory,			/* The widget in which all directories will
***************
*** 151,153
  				   this manpage. */
  
  } ManpageGlobals;

--- 136,160 -----
  				   this manpage. */
  
  } ManpageGlobals;
+ 
+ /*
+  * things set by the resource manager
+  */
+ struct _resource {
+ 	XFontStruct	*bold;		 /* the bold text for man pages */
+ 	XFontStruct	*normal;	 /* the normal text for man pages */
+ 	XFontStruct	*italic;	 /* the italic text for man pages */
+ 	XFontStruct	*directory;	 /* the font for the directory */
+ 	Boolean		both_shown_initial; /* the initial state of the manual
+ 					       pages - show two screens or
+ 					       one */
+ 	int		directory_height;/* the default height of directory in
+ 					    both_shown mode */
+ 	Cursor		top;		 /* the top cursor, default for xman */
+ 	Cursor		help;	 	 /* the top cursor for the help menu */
+ 	Cursor		manpage;	 /* the cursor for the man page */
+ 	Cursor		search_entry;	 /* the cursor for text widget in the
+ 					    search box */
+ 	char		*help_file;	 /* the name of the help file */
+ 	Boolean		top_box_active;  /* put up the top box */
+ };

Martin Streicher
Software Development Engineer
CONVEX Computer Corporation
{uunet, purdue, sun}!convex!strike




Finally then, I will read you your rights... You have the right to remain 
silent. You are warned that anything you say can and will be taken down and 
used as evidence against you.  Listen to this. Run.
					-The Clash "Know Your Rights"