stdwin temporary patch, and note

Guido van Rossum guido at cwi.nl
Tue Feb 26 03:02:28 AEST 1991


There is a small problem with the stdwin 0.9.4 that I put on wuarchive
(see announcement in alt.sources.d).  Programs called without any X
options would not find resources specified in your .Xresources file.
The diff below fixes this.

There is another problem with the distribution that is easier
explained than fixed by patches: all calls to winitnew() in the test
applications should really be calls to winitargs() with the same
arguments.  (This shows how much I test before putting out a
distribution. :-)

Finally, there is a section of code in window.c which doesn't compile
on X11R3: it references PWinGravity and win_gravity which aren't
defined in R3.  If this bites you, you can comment out this section
with no bad conseqences.

--
Guido van Rossum, CWI, Amsterdam <guido at cwi.nl>
Honary Member, Royal Society for Putting Things on Top of Other Things

Here is the patch (use patch -p!):

*** .../stdwin-dist/stdwin/Ports/x11/general.c	Tue Feb 19 10:47:59 1991
--- Ports/x11/general.c	Mon Feb 25 14:26:35 1991
***************
*** 173,179 ****
     You can also set the environment variable RESOURCE_NAME. */
  
  
! XrmDatabase db = NULL; /* Passed between wargs() and winit() */
  
  /* Part one of the initialization -- process command line arguments */
  
--- 173,180 ----
     You can also set the environment variable RESOURCE_NAME. */
  
  
! static XrmDatabase db = NULL; /* Passed between wargs() and winit() */
! static int wargs_called; /* Set when wargs is called */
  
  /* Part one of the initialization -- process command line arguments */
  
***************
*** 185,190 ****
--- 186,195 ----
  	char **argv= *pargv;
  	char *value;
  	
+ 	if (wargs_called)
+ 		_wfatal("wargs: called more than once");
+ 	wargs_called = 1;
+ 	
  	/* Get the program name (similar to basename(argv[0])) */
  	
  	if (*pargc > 0 && argv[0] != NULL && argv[0][0] != EOS) {
***************
*** 254,273 ****
  
  	/* Call wargs() with dummy arguments if not already called */
  
! 	if (db == NULL) {
  		static char* def_args[]= {"stdwin", (char*)NULL};
  		int argc= 1;
  		char **argv= def_args;
  		wargs(&argc, &argv);
! 	}
  	
  	/* Open the display, die if we can't */
  	
  	_wd= XOpenDisplay(_wdisplayname);
  	if (_wd == NULL) {
! 		_wfatal("winit: can't open display (%s)",
! 			_wdisplayname ? _wdisplayname :
! 			getenv("DISPLAY") ? getenv("DISPLAY") : "<none>");
  	}
  	
  #ifdef AMOEBA
--- 259,279 ----
  
  	/* Call wargs() with dummy arguments if not already called */
  
! 	if (!wargs_called) {
  		static char* def_args[]= {"stdwin", (char*)NULL};
  		int argc= 1;
  		char **argv= def_args;
+ 		_wdebug(0, "winit: wargs not called, faking argv[0]=stdwin");
  		wargs(&argc, &argv);
! 	      }
  	
  	/* Open the display, die if we can't */
  	
  	_wd= XOpenDisplay(_wdisplayname);
  	if (_wd == NULL) {
! 	  _wfatal("winit: can't open display (%s)",
! 		  _wdisplayname ? _wdisplayname :
! 		  getenv("DISPLAY") ? getenv("DISPLAY") : "<none>");
  	}
  	
  #ifdef AMOEBA
***************
*** 274,280 ****
  	/* Set the semaphore.  This must be done before doing anything
  	   else with the connection. */
  	if (_wsema != NULL)
! 		XamSetSema(_wd, _wsema);
  #endif
  	
  	/* Turn on synchronous mode if required.
--- 280,286 ----
  	/* Set the semaphore.  This must be done before doing anything
  	   else with the connection. */
  	if (_wsema != NULL)
! 	  XamSetSema(_wd, _wsema);
  #endif
  	
  	/* Turn on synchronous mode if required.
***************
*** 282,288 ****
  	   since some bugs disappear in synchronous mode! */
  	
  	if (getoption(db, "synchronous", "Synchronous") != NULL)
! 		XSynchronize(_wd, True);
  	
  	/* Call XGetDefault() once.  We don't use it to get our
  	   defaults, since it doesn't let the caller specify the class
--- 288,294 ----
  	   since some bugs disappear in synchronous mode! */
  	
  	if (getoption(db, "synchronous", "Synchronous") != NULL)
! 	  XSynchronize(_wd, True);
  	
  	/* Call XGetDefault() once.  We don't use it to get our
  	   defaults, since it doesn't let the caller specify the class
***************
*** 301,313 ****
  	
  	value= _wgetdefault("debugLevel", "DebugLevel");
  	if (value != 0) {
! 		int k= atoi(value);
! 		if (k > _wdebuglevel) {
! 			_wtracelevel= _wdebuglevel= k;
! 			_wdebug(1, "winit: new debuglevel %d (%s)",
! 				_wdebuglevel, value);
! 			XSynchronize(_wd, True);
! 		}
  	}
  	
  	/* Merge the command line options with the defaults database.
--- 307,319 ----
  	
  	value= _wgetdefault("debugLevel", "DebugLevel");
  	if (value != 0) {
! 	  int k= atoi(value);
! 	  if (k > _wdebuglevel) {
! 	    _wtracelevel= _wdebuglevel= k;
! 	    _wdebug(1, "winit: new debuglevel %d (%s)",
! 		    _wdebuglevel, value);
! 	    XSynchronize(_wd, True);
! 	  }
  	}
  	
  	/* Merge the command line options with the defaults database.



More information about the Alt.sources mailing list