Tcl Source Code

Check-in [add6ea1397]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Move CYGWIN-specific stuff from tclPort.h to tclUnixPort.h, where it belongs
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: add6ea13976b7c891bec7653ccab6d3b9acd9eac
User & Date: jan.nijtmans 2012-04-27 14:37:37
Context
2012-04-28
17:09
IMPLEMENTATION OF TIP#398 : Quickly Exit with Non-Blocking Blocked Channels check-in: efc6bbd2cb user: ferrieux tags: trunk, potential incompatibility
2012-04-27
14:37
Move CYGWIN-specific stuff from tclPort.h to tclUnixPort.h, where it belongs check-in: add6ea1397 user: jan.nijtmans tags: trunk
14:30
Move CYGWIN-specific stuff from tclPort.h to tclUnixPort.h, where it belongs check-in: 533c11d007 user: jan.nijtmans tags: core-8-5-branch
08:51
Make 'auto_execok START' do the Right Thing check-in: b8ffe55b40 user: dkf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.








1
2
3
4
5
6
7







2012-04-27  Donal K. Fellows  <[email protected]>

	* library/init.tcl (auto_execok): Allow shell builtins to be detected
	even if they are upper-cased.

2012-04-26  Jan Nijtmans  <[email protected]>

>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
2012-04-27  Jan Nijtmans  <[email protected]>

	* generic/tclPort.h:    Move CYGWIN-specific stuff from tclPort.h to
	* generic/tclEnv.c:     tclUnixPort.h, where it belongs.
	* unix/tclUnixPort.h:
	* unix/tclUnixFile.c:

2012-04-27  Donal K. Fellows  <[email protected]>

	* library/init.tcl (auto_execok): Allow shell builtins to be detected
	even if they are upper-cased.

2012-04-26  Jan Nijtmans  <[email protected]>

Changes to generic/tclEnv.c.

694
695
696
697
698
699
700

701
702
703
704
705
706
707

/*
 * When using cygwin, when an environment variable changes, we need to synch
 * with both the cygwin environment (in case the application C code calls
 * fork) and the Windows environment (in case the application TCL code calls
 * exec, which calls the Windows CreateProcess function).
 */


static void
TclCygwinPutenv(
    char *str)
{
    char *name, *value;








>







694
695
696
697
698
699
700
701
702
703
704
705
706
707
708

/*
 * When using cygwin, when an environment variable changes, we need to synch
 * with both the cygwin environment (in case the application C code calls
 * fork) and the Windows environment (in case the application TCL code calls
 * exec, which calls the Windows CreateProcess function).
 */
DLLIMPORT extern void __stdcall SetEnvironmentVariableA(const char*, const char *);

static void
TclCygwinPutenv(
    char *str)
{
    char *name, *value;

Changes to generic/tclPort.h.

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#   include "tclWinPort.h"
#endif
#include "tcl.h"
#if !defined(_WIN32)
#   include "tclUnixPort.h"
#endif

#if defined(__CYGWIN__)
#   define USE_PUTENV 1
#   define USE_PUTENV_FOR_UNSET 1
/* On Cygwin, the environment is imported from the Cygwin DLL. */
#   define environ __cygwin_environ
#   define timezone _timezone
    DLLIMPORT extern char **__cygwin_environ;
    DLLIMPORT extern int cygwin_conv_to_win32_path(const char *, char *);
    DLLIMPORT extern int cygwin_posix_to_win32_path_list_buf_size(char *value);
    DLLIMPORT extern void cygwin_posix_to_win32_path_list(char *buf, char *value);
    //DLLIMPORT extern void __stdcall SetEnvironmentVariableA(const char*, const char *);
#endif

#if !defined(LLONG_MIN)
#   ifdef TCL_WIDE_INT_IS_LONG
#      define LLONG_MIN LONG_MIN
#   else
#      ifdef LLONG_BIT
#         define LLONG_MIN ((Tcl_WideInt)(Tcl_LongAsWide(1)<<(LLONG_BIT-1)))
#      else







<
<
<
<
<
<
<
<
<
<
<
<
<







21
22
23
24
25
26
27













28
29
30
31
32
33
34
#   include "tclWinPort.h"
#endif
#include "tcl.h"
#if !defined(_WIN32)
#   include "tclUnixPort.h"
#endif














#if !defined(LLONG_MIN)
#   ifdef TCL_WIDE_INT_IS_LONG
#      define LLONG_MIN LONG_MIN
#   else
#      ifdef LLONG_BIT
#         define LLONG_MIN ((Tcl_WideInt)(Tcl_LongAsWide(1)<<(LLONG_BIT-1)))
#      else

Changes to unix/tclUnixFile.c.

35
36
37
38
39
40
41

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
69
70
71
72
73
74
75
 */

void
TclpFindExecutable(
    const char *argv0)		/* The value of the application's argv[0]
				 * (native). */
{

#ifdef __CYGWIN__
    int length;
    char buf[PATH_MAX * TCL_UTF_MAX + 1];
    char name[PATH_MAX * TCL_UTF_MAX + 1];

    /* Make some symbols available without including <windows.h> */
#   define CP_UTF8 65001
    extern int cygwin_conv_to_full_posix_path(const char *, char *);
    extern __stdcall int GetModuleFileNameW(void *, const char *, int);
    extern __stdcall int WideCharToMultiByte(int, int, const char *, int,
		const char *, int, const char *, const char *);

    GetModuleFileNameW(NULL, name, PATH_MAX);
    WideCharToMultiByte(CP_UTF8, 0, name, -1, buf, PATH_MAX, NULL, NULL);
    cygwin_conv_to_full_posix_path(buf, name);
    length = strlen(name);
    if ((length > 4) && !strcasecmp(name + length - 4, ".exe")) {
	/* Strip '.exe' part. */
	length -= 4;
    }

	TclSetObjNameOfExecutable(
		Tcl_NewStringObj(name, length), Tcl_GetEncoding(NULL, NULL));
#else
    const char *name, *p;
    Tcl_StatBuf statBuf;
    Tcl_DString buffer, nameString, cwd, utfName;
    Tcl_Encoding encoding;

    if (argv0 == NULL) {
	return;
    }
    Tcl_DStringInit(&buffer);

    name = argv0;







>







|
|
|










>

|




<







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

70
71
72
73
74
75
76
 */

void
TclpFindExecutable(
    const char *argv0)		/* The value of the application's argv[0]
				 * (native). */
{
    Tcl_Encoding encoding;
#ifdef __CYGWIN__
    int length;
    char buf[PATH_MAX * TCL_UTF_MAX + 1];
    char name[PATH_MAX * TCL_UTF_MAX + 1];

    /* Make some symbols available without including <windows.h> */
#   define CP_UTF8 65001
    DLLIMPORT extern int cygwin_conv_to_full_posix_path(const char *, char *);
    DLLIMPORT extern __stdcall int GetModuleFileNameW(void *, const char *, int);
    DLLIMPORT extern __stdcall int WideCharToMultiByte(int, int, const char *, int,
		const char *, int, const char *, const char *);

    GetModuleFileNameW(NULL, name, PATH_MAX);
    WideCharToMultiByte(CP_UTF8, 0, name, -1, buf, PATH_MAX, NULL, NULL);
    cygwin_conv_to_full_posix_path(buf, name);
    length = strlen(name);
    if ((length > 4) && !strcasecmp(name + length - 4, ".exe")) {
	/* Strip '.exe' part. */
	length -= 4;
    }
	encoding = Tcl_GetEncoding(NULL, NULL);
	TclSetObjNameOfExecutable(
		Tcl_NewStringObj(name, length), encoding);
#else
    const char *name, *p;
    Tcl_StatBuf statBuf;
    Tcl_DString buffer, nameString, cwd, utfName;


    if (argv0 == NULL) {
	return;
    }
    Tcl_DStringInit(&buffer);

    name = argv0;

Changes to unix/tclUnixPort.h.

75
76
77
78
79
80
81









82
83
84
85
86
87
88
89
90
#else
typedef off_t		Tcl_SeekOffset;
#   define TclOSseek		lseek
#   define TclOSopen		open
#endif

#ifdef __CYGWIN__









MODULE_SCOPE int TclOSstat(const char *name, Tcl_StatBuf *statBuf);
MODULE_SCOPE int TclOSlstat(const char *name, Tcl_StatBuf *statBuf);
#elif defined(HAVE_STRUCT_STAT64)
#   define TclOSstat		stat64
#   define TclOSlstat		lstat64
#else
#   define TclOSstat		stat
#   define TclOSlstat		lstat
#endif







>
>
>
>
>
>
>
>
>
|
|







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#else
typedef off_t		Tcl_SeekOffset;
#   define TclOSseek		lseek
#   define TclOSopen		open
#endif

#ifdef __CYGWIN__
#   define USE_PUTENV 1
#   define USE_PUTENV_FOR_UNSET 1
/* On Cygwin, the environment is imported from the Cygwin DLL. */
#   define environ __cygwin_environ
#   define timezone _timezone
    DLLIMPORT extern char **__cygwin_environ;
    DLLIMPORT extern int cygwin_conv_to_win32_path(const char *, char *);
    DLLIMPORT extern int cygwin_posix_to_win32_path_list_buf_size(char *value);
    DLLIMPORT extern void cygwin_posix_to_win32_path_list(char *buf, char *value);
    MODULE_SCOPE int TclOSstat(const char *name, Tcl_StatBuf *statBuf);
    MODULE_SCOPE int TclOSlstat(const char *name, Tcl_StatBuf *statBuf);
#elif defined(HAVE_STRUCT_STAT64)
#   define TclOSstat		stat64
#   define TclOSlstat		lstat64
#else
#   define TclOSstat		stat
#   define TclOSlstat		lstat
#endif

Changes to win/tclWinInit.c.

284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299

	/*
	 * The lstrcmpi() will work even if pathv[pathc-1] is random UTF-8
	 * chars because I know shortlib is ascii.
	 */

	if ((pathc > 0) && (lstrcmpiA(shortlib, pathv[pathc - 1]) != 0)) {
	    const char *str;

	    /*
	     * TCL_LIBRARY is set but refers to a different tcl installation
	     * than the current version. Try fiddling with the specified
	     * directory to make it refer to this installation by removing the
	     * old "tclX.Y" and substituting the current version string.
	     */








<
<







284
285
286
287
288
289
290


291
292
293
294
295
296
297

	/*
	 * The lstrcmpi() will work even if pathv[pathc-1] is random UTF-8
	 * chars because I know shortlib is ascii.
	 */

	if ((pathc > 0) && (lstrcmpiA(shortlib, pathv[pathc - 1]) != 0)) {


	    /*
	     * TCL_LIBRARY is set but refers to a different tcl installation
	     * than the current version. Try fiddling with the specified
	     * directory to make it refer to this installation by removing the
	     * old "tclX.Y" and substituting the current version string.
	     */