SN port to Win32, temporary hacks

Kai Ruottu kai.ruottu@luukku.com
Mon Jul 17 05:44:00 GMT 2000


>On Sun, 16 Jul 2000, Mike Davies wrote:
> 
>> I have just installed the latest cygwin, and apart from creating a HOME
>> variable and some directories (/build, /build/src, /build/build, /home,
>> home/mike, home/mike/install) it is completely as it came out of the box
>> (well,  the net).
>> 
>> I untarred the SN451.tar.gz to /build/src.  Then ran
>> "../src/configure --prefix=/home/mike/install" from /build/build which all
>> seemed to go OK.  When I ran make in /build/build I got this error at the
>> end :

On Sun, 16 Jul 2000, Mo DeJong wrote:
>
> Keep in mind that building sourcenav under Cygwin is
> still "on the cutting edge", so you should expect to
> have some problems. The build process is well tested
> under Linux, not so much under Cygwin.

 Yes, I hadn't much problems with the native/target libc5 (SuSE 5.2) and
libc2.1 (Mandrake7) based Linux systems. But I build for the Cygwin and
Mingw targets also under Linux and all the problems aren't just problems
with the Cygwin build system (may however be very common with the Cygwin
environment;-). The Cygwin and Mingw runtime hosts have now the majority
of problems...

 But there was at least the problem with the 'cygpath' tried to be used when
building the 'hyper.exe' (compiling 'winMain.c'), related to a non-Win32
build environment... I just edited it away from the Makefile...

> Try setting CFLAGS="-g -mno-cygwin" and then rerun
> ./configure. That should get rid of the #include
> problems, but it is likely there are others
> lurking in there, so you might need to do a bit of hacking.
> The build support under Cygwin will be much improved
> in the first development snapshot for 5.0.

 This is the Mingw target, and I haven't had much more progress with it
either, I used my plain-vanilla i386-mingw32 target toolset (for
CRTDLL.DLL) though, not the '-mno-cygwin' with a Cygwin-targeted cross-
compiler.

The SN4.51 sources seem to be 'ported' for some b20 ... 1.1.2 snapshot
of Cygwin...

>> I tried that,  but it makes things worse - this time db and grep didn't
>> build.
>>
>> gcc -DHAVE_CONFIG_H -I. -I../../../src/db/PORT -I..
>> -I../../../src/db/PORT/../include -I../../../src/db/PORT/include
>> -D__DBINTERFACE_PRIVATE -DWIN32 -g -mno-cygwin -c
>> -I../../../src/db/PORT/../btree
>> ../../../src/db/PORT/../btree/bt_close.c
>> In file included from ../../../src/db/PORT/../btree/bt_close.c:50:
>> ../../../src/db/PORT/../btree/btree.h:347: parse error before `caddr_t'
>> ../../../src/db/PORT/../btree/btree.h:347: warning: no semicolon at end of
>> struct or union

 The Mingw target needs its own patches, currently not at all included into
the SN4.51 sources. Anyway my portings for Cygwin and Mingw stopped quite in
the same stage...

- the Cygwin binaries don't work on Win2k at all, but run under Win98.
  On Win2k they just give the famous "Can' find a usable init.tcl in ...",
  reported many times for Insight/Cygwin recently... (the 20000714 DLL
  didn't help...). With the Mingw-host the problems seem to be same on all
  Windows variations.

 The following is related to Mingw and Cygwin on Win98. 

- cygwish81.exe (Cygwin-host) and wish81.exe (Mingw-host) seem to work.
  Initially they both crashed when exited, but some patches adapted from
  tcl-8.1.1 sources into 'tcl8.1/generic/tclParse.c' seemed to get it to
  behave more stable... (No crashes any more when exiting)

- cygtix4181.exe and tix4181.exe both crash when starting...

- 'hyper.exe' crashes when started by 'snavigator.exe'

 I have tried to track these with GDB, currently it says that something
bad happens with the 'tixFileJoin' procedure, called from 'tclParse.c',
on line 277... (the tix4181.exe and hyper.exe crash with the same error...)

> Ok, no more Cygwin build advice for me. If you don't want to hack it
> yourself then you will just have to wait until we post a release
> that builds under Cygwin out of the box. As always, the answer
> to the question of "when will it be available" is "soon" or
> "when it is ready".

 Mike, here are some hints for starting the hacking while waiting the
snapshots :

* Those '#include <direct.h>' and '#include <tchar.h>' can be wrapped away
  using '#ifndef __CYGWIN32__' / '#endif', or empty stubs for these can be
  added to the Cygwin headers. Don't know what would be the 'right' way...

* There is a difference between the Cygwin-related things in the sources,
  the name '__imp_reent_data' is now '_imp__reent_data' with Cygwin-1.1.2.
  And the '__imp___cygwin_environ' is now '_imp____cygwin_environ'. Files
  like 'tcl8.1/win/tclWin32Dll.c' and the tk-equivalent use these... You'll
  find them from the errors about unresolved symbols when linking the DLLs.

 My patches for the 'tcl8.1/generic/tclParse.c' follows, but there are
patches for other files too, the given hints, some common C-practice
(sometimes done something with C...) etc. should take you much longer.
Just ask more specific questions when problems arise... Anyway I'm
trying to get SN to work under Mingw and Cygwin... But perhaps letting
the Cygwin/Redhat folks to do the job would be easier, so waiting for the
snapshots could be better...

 BTW, the patches for 'tclParse.c' was taken because GDB said that
'tcl81.dll' crashed in these points, or they just seemed 'sane' when
looking at the diffs to the tcl-8.1.1 version of 'tclParse.c'...

Cheers, Kai

----------------- clip --------------------------------------
*** tclParse.c	Mon Oct 19 21:33:56 1998
--- /home2/src/cygnus/source-navigator/tcl8.1a2/generic/tclParse.c	Wed Jul  5 14:35:04 2000
***************
*** 55,61 ****
  #define TYPE_CLOSE_BRACK	0x20
  #define TYPE_BRACE		0x40
  
! #define CHAR_TYPE(c) (typeTable+128)[c]
  
  char typeTable[] = {
      /*
--- 55,61 ----
  #define TYPE_CLOSE_BRACK	0x20
  #define TYPE_BRACE		0x40
  
! #define CHAR_TYPE(c) (typeTable+128)[(int)(c)]
  
  char typeTable[] = {
      /*
***************
*** 273,280 ****
       */
  
      savedChar = string[numBytes];
!     string[numBytes] = 0;
! 
      /*
       * Parse any leading space and comments before the first word of the
       * command.
--- 273,282 ----
       */
  
      savedChar = string[numBytes];
!     if (savedChar != 0) {
! 	string[numBytes] = 0;
!     }
!   
      /*
       * Parse any leading space and comments before the first word of the
       * command.
***************
*** 305,311 ****
  	}
  	while (1) {
  	    if (src == parsePtr->end) {
! 		parsePtr->incomplete = 1;
  		parsePtr->commentSize = src - parsePtr->commentStart;
  		break;
  	    } else if (*src == '\\') {
--- 307,315 ----
  	}
  	while (1) {
  	    if (src == parsePtr->end) {
! 		if (nested) {
! 		    parsePtr->incomplete = nested;
! 		}
  		parsePtr->commentSize = src - parsePtr->commentStart;
  		break;
  	    } else if (*src == '\\') {
***************
*** 467,480 ****
  
  
      parsePtr->commandSize = src - parsePtr->commandStart;
!     string[numBytes] = (char) savedChar;
      return TCL_OK;
  
      error:
!     string[numBytes] = (char) savedChar;
!     if (parsePtr->tokenPtr != parsePtr->staticTokens) {
! 	ckfree((char *) parsePtr->tokenPtr);
      }
      if (parsePtr->commandStart == NULL) {
  	parsePtr->commandStart = string;
      }
--- 471,486 ----
  
  
      parsePtr->commandSize = src - parsePtr->commandStart;
!     if (savedChar != 0) {
! 	string[numBytes] = (char) savedChar;
!     }
      return TCL_OK;
  
      error:
!     if (savedChar != 0) {
! 	string[numBytes] = (char) savedChar;
      }
+     Tcl_FreeParse(parsePtr);
      if (parsePtr->commandStart == NULL) {
  	parsePtr->commandStart = string;
      }
***************
*** 690,695 ****
--- 696,702 ----
  {
      if (parsePtr->tokenPtr != parsePtr->staticTokens) {
  	ckfree((char *) parsePtr->tokenPtr);
+ 	parsePtr->tokenPtr = parsePtr->staticTokens;
      }
  }
  
 
***************
*** 859,864 ****
--- 866,874 ----
       * Call trace procedures if needed.
       */
  
+     argv = NULL;
+     commandCopy = command;
+ 
      for (tracePtr = iPtr->tracePtr; tracePtr != NULL; tracePtr = nextPtr) {
  	nextPtr = tracePtr->nextPtr;
  	if (iPtr->numLevels > tracePtr->level) {
***************
*** 867,891 ****
  
  	/*
  	 * This is a bit messy because we have to emulate the old trace
! 	 * interface, which uses strings for everything.  This can lose
! 	 * information if some of the words contain null characters.
  	 */
  
! 	argv = (char **) ckalloc((unsigned) (objc + 1) * sizeof(char *));
! 	for (i = 0; i < objc; i++) {
! 	    argv[i] = Tcl_GetString(objv[i]);
! 	}
! 	argv[objc] = 0;
! 	if (length < 0) {
! 	    length = strlen(command);
! 	}
! 	commandCopy = (char *) ckalloc((unsigned) (length + 1));
! 	strncpy(commandCopy, command, (size_t) length);
! 	commandCopy[length] = 0;
  	(*tracePtr->proc)(tracePtr->clientData, interp, iPtr->numLevels,
  			  commandCopy, cmdPtr->proc, cmdPtr->clientData,
  			  objc, argv);
  	ckfree((char *) argv);
  	ckfree((char *) commandCopy);
      }
      
--- 877,908 ----
  
  	/*
  	 * This is a bit messy because we have to emulate the old trace
! 	 * interface, which uses strings for everything.
  	 */
  
! 	if (argv == NULL) {
! 	    argv = (char **) ckalloc((unsigned) (objc + 1) * sizeof(char *));
! 	    for (i = 0; i < objc; i++) {
! 		argv[i] = Tcl_GetString(objv[i]);
! 	    }
! 	    argv[objc] = 0;
! 
! 	    if (length < 0) {
! 		length = strlen(command);
! 	    } else if ((size_t)length < strlen(command)) {
! 		commandCopy = (char *) ckalloc((unsigned) (length + 1));
! 		strncpy(commandCopy, command, (size_t) length);
! 		commandCopy[length] = 0;
! 	    }
! 	}
  	(*tracePtr->proc)(tracePtr->clientData, interp, iPtr->numLevels,
  			  commandCopy, cmdPtr->proc, cmdPtr->clientData,
  			  objc, argv);
+     }
+     if (argv != NULL) {
  	ckfree((char *) argv);
+     }
+     if (commandCopy != command) {
  	ckfree((char *) commandCopy);
      }
      
***************
*** 1537,1543 ****
  	while (src != end) {
  	    offset = Tcl_UtfToUniChar(src, &ch);
  	    c = UCHAR(ch);
! 	    if (isalnum(c) || (c == '_')) { /* INTL: ISO only. */
  		src += offset;
  		continue;
  	    }
--- 1554,1560 ----
  	while (src != end) {
  	    offset = Tcl_UtfToUniChar(src, &ch);
  	    c = UCHAR(ch);
! 	    if (isalnum(c) || (c == '_')) { /* INTL: ISO only, UCHAR. */
  		src += offset;
  		continue;
  	    }
***************
*** 1597,1605 ****
      return TCL_OK;
  
      error:
!     if (parsePtr->tokenPtr != parsePtr->staticTokens) {
! 	ckfree((char *) parsePtr->tokenPtr);
!     }
      return TCL_ERROR;
  }
  
 
--- 1614,1620 ----
      return TCL_OK;
  
      error:
!     Tcl_FreeParse(parsePtr);
      return TCL_ERROR;
  }
  
 
***************
*** 1836,1844 ****
      return TCL_OK;
  
      error:
!     if (parsePtr->tokenPtr != parsePtr->staticTokens) {
! 	ckfree((char *) parsePtr->tokenPtr);
!     }
      return TCL_ERROR;
  }
  
 
--- 1851,1857 ----
      return TCL_OK;
  
      error:
!     Tcl_FreeParse(parsePtr);
      return TCL_ERROR;
  }
  
 
***************
*** 1927,1935 ****
      return TCL_OK;
  
      error:
!     if (parsePtr->tokenPtr != parsePtr->staticTokens) {
! 	ckfree((char *) parsePtr->tokenPtr);
!     }
      return TCL_ERROR;
  }
  
 
--- 1940,1946 ----
      return TCL_OK;
  
      error:
!     Tcl_FreeParse(parsePtr);
      return TCL_ERROR;
  }
  
 
***************
*** 1960,1965 ****
--- 1971,1977 ----
  {
      Tcl_Parse parse;
      char *p, *end;
+     int result;
  
      p = script;
      end = p + length;
***************
*** 1969,1979 ****
  	if (*p == 0) {
  	    break;
  	}
      }
      if (parse.incomplete) {
! 	return 0;
      }
!     return 1;
  }
  
 
  /*
--- 1981,1995 ----
  	if (*p == 0) {
  	    break;
  	}
+ 	Tcl_FreeParse(&parse);
      }
      if (parse.incomplete) {
! 	result = 0;
!     } else {
! 	result = 1;
      }
!     Tcl_FreeParse(&parse);
!     return result;
  }
  
 
  /*
----------------- clip --------------------------------------



More information about the Sourcenav mailing list