[comp.windows.x] rtl patches

Richard.Draves@RPD.CAMELOT.CS.CMU.EDU (06/30/88)

These patches fix several problems I had compiling rtl.  Using these patches,
I have compiled versions for Suns, Vaxen, and RTs running Mach.

In gravity.c, I undefine NULL before including stdio.h to avoid a warning.

In userwin.define.h, I changed the definitions of some constants to exactly
match the standard X11R2 definitions, to avoid more warnings.

input.c and input-alt.c store the result of getopt in a char; this breaks
on machines which have unsigned chars (like RTs).

Most of the patches fix the casts-used-as-lvalue bugs others have mentioned.
You'll probably want to redo these more elegantly.

I think the Sun and Vax versions I have work OK, but the RT version I have my
doubts about.  I haven't played with it much, but it seems to place icons
differently than the other two (given the same preferences, of course).  The
rtl sources found bugs in both the RT compilers I have, so I used a mixed
strategy and compiled different files with different compilers.  There might
still be compiler problems that aren't obvious.

Rich

*** gravity.c.~1~	Wed Jun 22 14:36:03 1988
--- gravity.c	Sat Jun 25 02:10:34 1988
***************
*** 306,311 ****
--- 306,312 ----
      return(abs(diff));
  }
  #ifdef WM_DEBUG
+ #undef	NULL
  #include <stdio.h>
  
  void 
*** input-alt.c.~1~	Wed Jun 22 14:34:07 1988
--- input-alt.c	Tue Jun 28 00:38:27 1988
***************
*** 694,700 ****
  {
      int use_startup_file = 0;
      int finish_layout = 0;
!     char c;
      extern void Wsys_Startup();
      
      Input_Setup();
--- 694,700 ----
  {
      int use_startup_file = 0;
      int finish_layout = 0;
!     int c;
      extern void Wsys_Startup();
      
      Input_Setup();
*** input.c.~1~	Wed Jun 22 15:05:53 1988
--- input.c	Tue Jun 28 00:38:32 1988
***************
*** 697,703 ****
      int use_startup_file = 0;
      int finish_layout = 0;
      int ignore_layout_file = 0;
!     char c;
      extern void Wsys_Startup();
      
      while((c = getopt(argc, argv, "sfi")) != EOF)
--- 697,703 ----
      int use_startup_file = 0;
      int finish_layout = 0;
      int ignore_layout_file = 0;
!     int c;
      extern void Wsys_Startup();
      
      while((c = getopt(argc, argv, "sfi")) != EOF)
*** menu.c.~1~	Wed Jun 22 14:34:09 1988
--- menu.c	Sat Jun 25 02:29:57 1988
***************
*** 125,132 ****
      ItemText(menuitem) = NULL;
      ItemTextLength(menuitem) = 0;
      
!     for(next = &MenuItems(menu) ;
! 	*next; next = &ItemNext(*next));
      
      *next = menuitem;
  
--- 125,132 ----
      ItemText(menuitem) = NULL;
      ItemTextLength(menuitem) = 0;
      
!     for(next = (RTLMenuItem *) &((Menu *)menu)->menuItems ;
! 	*next; next = (RTLMenuItem *) &((MenuItem *)*next)->nextItem);
      
      *next = menuitem;
  
***************
*** 150,162 ****
      
      if (MenuIsNull(menu) || ItemIsNull(item))
  	return(FALSE);
!     next = &MenuItems(menu);
      do 
      {
  	if(ItemIsNull(*next))
  	    return(FALSE);
  	last = next;
! 	next = &ItemNext(*next);
      }
      while((*last != item) && !ItemIsNull(*next));
      menuitem = *last;
--- 150,162 ----
      
      if (MenuIsNull(menu) || ItemIsNull(item))
  	return(FALSE);
!     next = (RTLMenuItem *) &((Menu *)menu)->menuItems;
      do 
      {
  	if(ItemIsNull(*next))
  	    return(FALSE);
  	last = next;
! 	next = (RTLMenuItem *) &((MenuItem *)*next)->nextItem;
      }
      while((*last != item) && !ItemIsNull(*next));
      menuitem = *last;
***************
*** 396,402 ****
      if (MenuIsNull(menu))
  	return(FALSE);
  	
!     MenuParent(menu) = parent;
  
      if (MenuIsNull(parent))
  	MenuNested(menu) = 0;
--- 396,402 ----
      if (MenuIsNull(menu))
  	return(FALSE);
  	
!     ((Menu *)menu)->parentMenu = (Menu *) parent;
  
      if (MenuIsNull(parent))
  	MenuNested(menu) = 0;
***************
*** 427,433 ****
      if (MenuIsNull(menu))
  	return;
  
!     MenuParent(menu) = NULLMENU;
      MenuNested(menu) = 0;
      
      UnmapMenu(menu);
--- 427,433 ----
      if (MenuIsNull(menu))
  	return;
  
!     ((Menu *)menu)->parentMenu = (Menu *) NULLMENU;
      MenuNested(menu) = 0;
      
      UnmapMenu(menu);
***************
*** 616,622 ****
      RTLMenu menu;
  {
      if (! TestMenuFlag(menu, menuMapped))
! 	MenuItemHighlighted(menu) = NULLITEM;
      if (TestOptionFlag(menu,savebits))
      {
  	if ((MenuSavedPixmap(menu) == (Pixmap) 0) ||
--- 616,622 ----
      RTLMenu menu;
  {
      if (! TestMenuFlag(menu, menuMapped))
! 	ResetHighlightItem(menu);
      if (TestOptionFlag(menu,savebits))
      {
  	if ((MenuSavedPixmap(menu) == (Pixmap) 0) ||
***************
*** 956,962 ****
  			       valuemask, &attributes)
  		 ) == (Window) 0)
  		return FALSE;
! 	     ItemMenu(item) = menu;
  	     XMakeAssoc(MenuDisplay(menu), item_table, ItemWindow(item),
  		       (char *) item);
  	     XDefineCursor(MenuDisplay(menu), ItemWindow(item),
--- 956,962 ----
  			       valuemask, &attributes)
  		 ) == (Window) 0)
  		return FALSE;
! 	     ((MenuItem *)item)->itemMenu = (Menu *) menu;
  	     XMakeAssoc(MenuDisplay(menu), item_table, ItemWindow(item),
  		       (char *) item);
  	     XDefineCursor(MenuDisplay(menu), ItemWindow(item),
*** rtlmenu.c.~1~	Wed Jun 22 14:34:10 1988
--- rtlmenu.c	Sat Jun 25 02:27:52 1988
***************
*** 193,199 ****
      {
  	if (SetItemText(menu, item, str) == FALSE)
  	    return(NULLITEM);
! 	ItemSubmenu(item) = submenu;
      }
      return (RTLMenuItem)item;
  }
--- 193,199 ----
      {
  	if (SetItemText(menu, item, str) == FALSE)
  	    return(NULLITEM);
! 	((MenuItem *)item)->itemSubmenu = (Menu *) submenu;
      }
      return (RTLMenuItem)item;
  }
*** rtlmenu.define.h.~1~	Wed Jun 22 14:29:29 1988
--- rtlmenu.define.h	Sat Jun 25 02:14:55 1988
***************
*** 76,83 ****
  #define MenuHasInitialItem(menu) (MenuInitialItemText(menu) != (char *) NULL)
  
  /* Menu modifiers */
! #define SetHighlightItem(menu, item) (MenuItemHighlighted(menu) = item)
! #define ResetHighlightItem(menu)   (MenuItemHighlighted(menu) = NULLITEM)
  #define SetMenuFlag(menu, flag)     MenuFlags(menu) |= flag
  #define ResetMenuFlag(menu,flag)    MenuFlags(menu) &= ~flag
  #define TestMenuFlag(menu,flag)     (MenuFlags(menu) & flag)
--- 76,83 ----
  #define MenuHasInitialItem(menu) (MenuInitialItemText(menu) != (char *) NULL)
  
  /* Menu modifiers */
! #define SetHighlightItem(menu, item) (((Menu *)(menu))->highlightedItem = (MenuItem *)(item))
! #define ResetHighlightItem(menu)   (((Menu *)(menu))->highlightedItem = (MenuItem *) NULLITEM)
  #define SetMenuFlag(menu, flag)     MenuFlags(menu) |= flag
  #define ResetMenuFlag(menu,flag)    MenuFlags(menu) &= ~flag
  #define TestMenuFlag(menu,flag)     (MenuFlags(menu) & flag)
*** tilwin_dump.c.~1~	Wed Jun 22 14:36:05 1988
--- tilwin_dump.c	Sat Jun 25 02:10:32 1988
***************
*** 62,71 ****
  		/* this assumes null pointers are == to NULL_TILE
  		 * (a valid "sentinel" tile)
  		 */
! 		(int) bl_stitch(dumper) = Tile_Get_Name(bl_stitch(a_tile));
! 		(int) lb_stitch(dumper) = Tile_Get_Name(lb_stitch(a_tile));
! 		(int) tr_stitch(dumper) = Tile_Get_Name(tr_stitch(a_tile));
! 		(int) rt_stitch(dumper) = Tile_Get_Name(rt_stitch(a_tile));
  
  		(void) fwrite((char *) dumper, sizeof(Tile), 1, dump_file);
  	}
--- 62,71 ----
  		/* this assumes null pointers are == to NULL_TILE
  		 * (a valid "sentinel" tile)
  		 */
! 		bl_stitch(dumper) = (Tile *) Tile_Get_Name(bl_stitch(a_tile));
! 		lb_stitch(dumper) = (Tile *) Tile_Get_Name(lb_stitch(a_tile));
! 		tr_stitch(dumper) = (Tile *) Tile_Get_Name(tr_stitch(a_tile));
! 		rt_stitch(dumper) = (Tile *) Tile_Get_Name(rt_stitch(a_tile));
  
  		(void) fwrite((char *) dumper, sizeof(Tile), 1, dump_file);
  	}
*** userwin.define.h.~1~	Wed Jun 22 14:30:51 1988
--- userwin.define.h	Sat Jun 25 02:10:29 1988
***************
*** 46,56 ****
  #define GroupState -3
  #define NeverState -2
  #define NoState -1
! #define DontCareState 0
! #define NormalState 1
  #define ClientIconState 2
! #define IconicState 3
! #define InactiveState 4
  #define IgnoreState 5
  
  #define Userwin_Allocate \
--- 46,57 ----
  #define GroupState -3
  #define NeverState -2
  #define NoState -1
! #define DontCareState 0	/* don't know or care */
! #define NormalState 1	/* most applications want to start this way */
  #define ClientIconState 2
! #define IconicState 3	/* application wants to start as an icon */
! #define InactiveState 4	/* application believes it is seldom used; some
!     			   wm's may put it on inactive menu */
  #define IgnoreState 5
  
  #define Userwin_Allocate \