Tcl Source Code

Check-in [078f98cdb5]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Eliminate tclWinProcs->useWide everywhere, since the value is always "1" on platforms >win95
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | dogeen-assembler-split
Files: files | file ages | folders
SHA1: 078f98cdb594569fe3219a052b66b20f813f9771
User & Date: nijtmans 2010-09-20 14:28:13
Context
2010-09-21
20:22
Fix declaration after statement. Add -Wdeclaration-after-statement, so this mistake cannot happen ag... check-in: 057c64e70b user: nijtmans tags: trunk
19:32
initial commit of Ozgur Dogan Ugurlu's (SF user:dogeen) assembler for the Tcl bytecode language check-in: ddc9909aaa user: kennykb tags: dogeen-assembler-branch
2010-09-20
14:28
Eliminate tclWinProcs->useWide everywhere, since the value is always "1" on platforms >win95 check-in: 078f98cdb5 user: nijtmans tags: trunk, dogeen-assembler-split
2010-09-18
23:14
* doc/file.n (file readlink): [Bug 3070580]: Typofix.
check-in: c634721862 user: dkf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.







1
2
3
4
5
6
7





2010-09-19  Donal K. Fellows  <[email protected]>

	* doc/file.n (file readlink): [Bug 3070580]: Typofix.

2010-09-18  Jan Nijtmans  <[email protected]>

	* win/tclWinFCmd.c [Bug 3069278]: Breakage on head Windows triggered
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
2010-09-20  Jan Nijtmans  <[email protected]>

	* win/tclWinFCmd.c: Eliminate tclWinProcs->useWide everywhere, since
	* win/tclWinFile.c: the value is always "1" on platforms >win95
	* win/tclWinPipe.c:

2010-09-19  Donal K. Fellows  <[email protected]>

	* doc/file.n (file readlink): [Bug 3070580]: Typofix.

2010-09-18  Jan Nijtmans  <[email protected]>

	* win/tclWinFCmd.c [Bug 3069278]: Breakage on head Windows triggered

Changes to win/tclWinFCmd.c.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
....
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
....
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
....
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
 *	subcommands of the "file" command.
 *
 * Copyright (c) 1996-1998 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinFCmd.c,v 1.66 2010/09/18 05:42:26 nijtmans Exp $
 */

/* TODO: This file does not compile in UNICODE mode.
 * See [Freq 2965056]: Windows build with -DUNICODE
 * and
 * [Bug 3069278]: breakage on head Windows triggered by install-tzdata
 */
................................................................................
		if ((size == 0) || (size > MAX_PATH) || (nativeRest == NULL)) {
		    return TCL_ERROR;
		}
		nativeTmp = (TCHAR *) tempBuf;
		nativeRest[0] = '\0';

		result = TCL_ERROR;
		nativePrefix = (tclWinProcs->useWide)
			? (TCHAR *) L"tclr" : (TCHAR *) "tclr";
		if (tclWinProcs->getTempFileNameProc(nativeTmp, nativePrefix,
			0, tempBuf) != 0) {
		    /*
		     * Strictly speaking, need the following DeleteFile and
		     * MoveFile to be joined as an atomic operation so no
		     * other app comes along in the meantime and creates the
		     * same temp file.
................................................................................
	/*
	 * Process the regular file
	 */

	return traverseProc(nativeSource, nativeTarget, DOTREE_F, errorPtr);
    }

    if (tclWinProcs->useWide) {
	Tcl_DStringAppend(sourcePtr, (char *) L"\\*.*", 4 * sizeof(WCHAR) + 1);
	Tcl_DStringSetLength(sourcePtr, Tcl_DStringLength(sourcePtr) - 1);
    } else {
	Tcl_DStringAppend(sourcePtr, "\\*.*", 4);
    }

    nativeSource = (TCHAR *) Tcl_DStringValue(sourcePtr);
    handle = tclWinProcs->findFirstFileProc(nativeSource, &data);
    if (handle == INVALID_HANDLE_VALUE) {
	/*
	 * Can't read directory.
	 */
................................................................................
    result = traverseProc(nativeSource, nativeTarget, DOTREE_PRED,
	    errorPtr);
    if (result != TCL_OK) {
	FindClose(handle);
	return result;
    }

    sourceLen = oldSourceLen;

    if (tclWinProcs->useWide) {
	sourceLen += sizeof(WCHAR);
	Tcl_DStringAppend(sourcePtr, (char *) L"\\", sizeof(WCHAR) + 1);
	Tcl_DStringSetLength(sourcePtr, sourceLen);
    } else {
	sourceLen += 1;
	Tcl_DStringAppend(sourcePtr, "\\", 1);
    }
    if (targetPtr != NULL) {
	oldTargetLen = Tcl_DStringLength(targetPtr);

	targetLen = oldTargetLen;
	if (tclWinProcs->useWide) {
	    targetLen += sizeof(WCHAR);
	    Tcl_DStringAppend(targetPtr, (char *) L"\\", sizeof(WCHAR) + 1);
	    Tcl_DStringSetLength(targetPtr, targetLen);
	} else {
	    targetLen += 1;
	    Tcl_DStringAppend(targetPtr, "\\", 1);
	}
    }

    found = 1;
    for (; found; found = tclWinProcs->findNextFileProc(handle, &data)) {
	TCHAR *nativeName;
	int len;

	if (tclWinProcs->useWide) {
	    WCHAR *wp;

	    wp = data.w.cFileName;
	    if (*wp == '.') {
		wp++;
		if (*wp == '.') {
		    wp++;
		}
		if (*wp == '\0') {
		    continue;
		}
	    }
	    nativeName = (TCHAR *) data.w.cFileName;
	    len = wcslen(data.w.cFileName) * sizeof(WCHAR);
	} else {
	    if ((strcmp(data.a.cFileName, ".") == 0)
		    || (strcmp(data.a.cFileName, "..") == 0)) {
		continue;
	    }
	    nativeName = (TCHAR *) data.a.cFileName;
	    len = strlen(data.a.cFileName);
	}

	/*
	 * Append name after slash, and recurse on the file.
	 */

	Tcl_DStringAppend(sourcePtr, (char *) nativeName, len + 1);
	Tcl_DStringSetLength(sourcePtr, Tcl_DStringLength(sourcePtr) - 1);
................................................................................
	    if (handle == INVALID_HANDLE_VALUE) {
		Tcl_DStringFree(&ds);
		if (interp != NULL) {
		    StatError(interp, fileName);
		}
		goto cleanup;
	    }
	    if (tclWinProcs->useWide) {
		nativeName = (TCHAR *) data.w.cAlternateFileName;
		if (longShort) {
		    if (data.w.cFileName[0] != '\0') {
			nativeName = (TCHAR *) data.w.cFileName;
		    }
		} else {
		    if (data.w.cAlternateFileName[0] == '\0') {
			nativeName = (TCHAR *) data.w.cFileName;
		    }
		}
	    } else {
		nativeName = (TCHAR *) data.a.cAlternateFileName;
		if (longShort) {
		    if (data.a.cFileName[0] != '\0') {
			nativeName = (TCHAR *) data.a.cFileName;
		    }
		} else {
		    if (data.a.cAlternateFileName[0] == '\0') {
			nativeName = (TCHAR *) data.a.cFileName;
		    }
		}
	    }

	    /*
	     * Purify reports a extraneous UMR in Tcl_WinTCharToUtf() trying
	     * to dereference nativeName as a Unicode string. I have proven to
	     * myself that purify is wrong by running the following example






|







 







<
|







 







<
|
|
<
<
<







 







|
<
<
<
|
|
<
<
<
<




<
|
|
|
<
<
<
<







<
<
<
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<
<
<
<
<







 







<
|
|
|
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
483
484
485
486
487
488
489

490
491
492
493
494
495
496
497
....
1285
1286
1287
1288
1289
1290
1291

1292
1293



1294
1295
1296
1297
1298
1299
1300
....
1309
1310
1311
1312
1313
1314
1315
1316



1317
1318




1319
1320
1321
1322

1323
1324
1325




1326
1327
1328
1329
1330
1331
1332



1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344








1345
1346
1347
1348
1349
1350
1351
....
1744
1745
1746
1747
1748
1749
1750

1751
1752
1753
1754
1755
1756
1757
1758












1759
1760
1761
1762
1763
1764
1765
 *	subcommands of the "file" command.
 *
 * Copyright (c) 1996-1998 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinFCmd.c,v 1.67 2010/09/20 14:28:15 nijtmans Exp $
 */

/* TODO: This file does not compile in UNICODE mode.
 * See [Freq 2965056]: Windows build with -DUNICODE
 * and
 * [Bug 3069278]: breakage on head Windows triggered by install-tzdata
 */
................................................................................
		if ((size == 0) || (size > MAX_PATH) || (nativeRest == NULL)) {
		    return TCL_ERROR;
		}
		nativeTmp = (TCHAR *) tempBuf;
		nativeRest[0] = '\0';

		result = TCL_ERROR;

		nativePrefix = (TCHAR *) L"tclr";
		if (tclWinProcs->getTempFileNameProc(nativeTmp, nativePrefix,
			0, tempBuf) != 0) {
		    /*
		     * Strictly speaking, need the following DeleteFile and
		     * MoveFile to be joined as an atomic operation so no
		     * other app comes along in the meantime and creates the
		     * same temp file.
................................................................................
	/*
	 * Process the regular file
	 */

	return traverseProc(nativeSource, nativeTarget, DOTREE_F, errorPtr);
    }


    Tcl_DStringAppend(sourcePtr, (char *) L"\\*.*", 4 * sizeof(WCHAR) + 1);
    Tcl_DStringSetLength(sourcePtr, Tcl_DStringLength(sourcePtr) - 1);




    nativeSource = (TCHAR *) Tcl_DStringValue(sourcePtr);
    handle = tclWinProcs->findFirstFileProc(nativeSource, &data);
    if (handle == INVALID_HANDLE_VALUE) {
	/*
	 * Can't read directory.
	 */
................................................................................
    result = traverseProc(nativeSource, nativeTarget, DOTREE_PRED,
	    errorPtr);
    if (result != TCL_OK) {
	FindClose(handle);
	return result;
    }

    sourceLen = oldSourceLen + sizeof(WCHAR);



    Tcl_DStringAppend(sourcePtr, (char *) L"\\", sizeof(WCHAR) + 1);
    Tcl_DStringSetLength(sourcePtr, sourceLen);




    if (targetPtr != NULL) {
	oldTargetLen = Tcl_DStringLength(targetPtr);

	targetLen = oldTargetLen;

	targetLen += sizeof(WCHAR);
	Tcl_DStringAppend(targetPtr, (char *) L"\\", sizeof(WCHAR) + 1);
	Tcl_DStringSetLength(targetPtr, targetLen);




    }

    found = 1;
    for (; found; found = tclWinProcs->findNextFileProc(handle, &data)) {
	TCHAR *nativeName;
	int len;




	WCHAR *wp = data.w.cFileName;
	if (*wp == '.') {
	    wp++;
	    if (*wp == '.') {
		wp++;
	    }
	    if (*wp == '\0') {
		continue;
	    }
	}
	nativeName = (TCHAR *) data.w.cFileName;
	len = wcslen(data.w.cFileName) * sizeof(WCHAR);









	/*
	 * Append name after slash, and recurse on the file.
	 */

	Tcl_DStringAppend(sourcePtr, (char *) nativeName, len + 1);
	Tcl_DStringSetLength(sourcePtr, Tcl_DStringLength(sourcePtr) - 1);
................................................................................
	    if (handle == INVALID_HANDLE_VALUE) {
		Tcl_DStringFree(&ds);
		if (interp != NULL) {
		    StatError(interp, fileName);
		}
		goto cleanup;
	    }

	    nativeName = (TCHAR *) data.w.cAlternateFileName;
	    if (longShort) {
		if (data.w.cFileName[0] != '\0') {
		    nativeName = (TCHAR *) data.w.cFileName;
		}
	    } else {
		if (data.w.cAlternateFileName[0] == '\0') {
		    nativeName = (TCHAR *) data.w.cFileName;












		}
	    }

	    /*
	     * Purify reports a extraneous UMR in Tcl_WinTCharToUtf() trying
	     * to dereference nativeName as a Unicode string. I have proven to
	     * myself that purify is wrong by running the following example

Changes to win/tclWinFile.c.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
....
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
....
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
....
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
....
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
....
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
....
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
 *	interfaces.
 *
 * Copyright (c) 1995-1998 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinFile.c,v 1.111 2010/09/18 05:56:17 nijtmans Exp $
 */

#include "tclWinInt.h"
#include "tclFileSystem.h"
#include <winioctl.h>
#include <sys/stat.h>
#include <shlobj.h>
................................................................................
	 */

	do {
	    const char *utfname;
	    int checkDrive = 0, isDrive;
	    DWORD attr;

	    if (tclWinProcs->useWide) {
		native = (const TCHAR *) data.w.cFileName;
		attr = data.w.dwFileAttributes;
	    } else {
		native = (const TCHAR *) data.a.cFileName;
		attr = data.a.dwFileAttributes;
	    }

	    utfname = tclWinProcs->tchar2utf(native, -1, &ds);

	    if (!matchSpecialDots) {
		/*
		 * If it is exactly '.' or '..' then we ignore it.
		 */

................................................................................
 *	1 = executable, 0 = not.
 *
 *----------------------------------------------------------------------
 */

static int
NativeIsExec(
    const TCHAR *nativePath)
{
    if (tclWinProcs->useWide) {
	const WCHAR *path = (const WCHAR *) nativePath;
	int len = wcslen(path);

	if (len < 5) {
	    return 0;
	}

	if (path[len-4] != L'.') {
	    return 0;
	}

	/*
	 * Use wide-char case-insensitive comparison
	 */

	if ((_wcsicmp(path+len-3, L"exe") == 0)
		|| (_wcsicmp(path+len-3, L"com") == 0)
		|| (_wcsicmp(path+len-3, L"bat") == 0)) {
	    return 1;
	}
    } else {
	const char *p;

	/*
	 * We are only looking for pure ascii.
	 */

	p = strrchr((const char *) nativePath, '.');
	if (p != NULL) {
	    p++;

	    /*
	     * Note: in the old code, stat considered '.pif' files as
	     * executable, whereas access did not.
	     */

	    if ((strcasecmp(p, "exe") == 0)
		    || (strcasecmp(p, "com") == 0)
		    || (strcasecmp(p, "bat") == 0)) {
		/*
		 * File that ends with .exe, .com, or .bat is executable.
		 */

		return 1;
	    }
	}
    }
    return 0;
}
 
/*
 *----------------------------------------------------------------------
 *
................................................................................
	return NULL;
    }

    /*
     * Watch for the weird Windows c:\\UNC syntax.
     */

    if (tclWinProcs->useWide) {
	WCHAR *native = (WCHAR *) buffer;
	if ((native[0] != '\0') && (native[1] == ':')
		&& (native[2] == '\\') && (native[3] == '\\')) {
	    native += 2;
	}
	tclWinProcs->tchar2utf((TCHAR *) native, -1, bufferPtr);
    } else {
	char *native = (char *) buffer;
	if ((native[0] != '\0') && (native[1] == ':')
		&& (native[2] == '\\') && (native[3] == '\\')) {
	    native += 2;
	}
	tclWinProcs->tchar2utf((TCHAR *) native, -1, bufferPtr);
    }

    /*
     * Convert to forward slashes for easier use in scripts.
     */

    for (p = Tcl_DStringValue(bufferPtr); *p != '\0'; p++) {
	if (*p == '\\') {
................................................................................

    if (tclWinProcs->getCurrentDirectoryProc(MAX_PATH, buffer) == 0) {
	TclWinConvertError(GetLastError());
	return NULL;
    }

    if (clientData != NULL) {
	if (tclWinProcs->useWide) {
	    /*
	     * Unicode representation when running on NT/2K/XP.
	     */

	    if (wcscmp((const WCHAR*)clientData, (const WCHAR*)buffer) == 0) {
		return clientData;
	    }
	} else {
	    /*
	     * ANSI representation when running on 95/98/ME.
	     */

	    if (strcmp((const char*) clientData, (const char*) buffer) == 0) {
		return clientData;
	    }
	}
    }

    return TclNativeDupInternalRep(buffer);
}
 
int
................................................................................
	for (p = str; p && *p; ++p) {
	    if (*p == '/') {
		*p = '\\';
	    }
	}
    }
    tclWinProcs->utf2tchar(str, len, &ds);
    if (tclWinProcs->useWide) {
	len = Tcl_DStringLength(&ds) + sizeof(WCHAR);
    } else {
	len = Tcl_DStringLength(&ds) + sizeof(char);
    }
    Tcl_DecrRefCount(validPathPtr);
    nativePathPtr = ckalloc((unsigned) len);
    memcpy(nativePathPtr, Tcl_DStringValue(&ds), (size_t) len);

    Tcl_DStringFree(&ds);
    return nativePathPtr;
}
................................................................................
    char *copy;
    size_t len;

    if (clientData == NULL) {
	return NULL;
    }

    if (tclWinProcs->useWide) {
	/*
	 * Unicode representation when running on NT/2K/XP.
	 */

	len = sizeof(WCHAR) * (wcslen((const WCHAR *) clientData) + 1);
    } else {
	/*
	 * ANSI representation when running on 95/98/ME.
	 */

	len = sizeof(char) * (strlen((const char *) clientData) + 1);
    }

    copy = (char *) ckalloc(len);
    memcpy(copy, clientData, len);
    return copy;
}
 
/*






|







 







<
|
|
<
<
<
<
<







 







|

<
<
|

|
|
|

|
|
|

<
<
<
<
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
|
|
|
|
|
|
<
<
<
<
<
<
<
<







 







<
<
<
<
<
|
|
<
<
<
<
<
<
<
<
<







 







<
|
<
<
<







 







<
<
<
<
<
|
<
<
<
<
<
<
<







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
....
1047
1048
1049
1050
1051
1052
1053

1054
1055





1056
1057
1058
1059
1060
1061
1062
....
1735
1736
1737
1738
1739
1740
1741
1742
1743


1744
1745
1746
1747
1748
1749
1750
1751
1752
1753




1754
1755
1756
1757



























1758
1759
1760
1761
1762
1763
1764
....
1895
1896
1897
1898
1899
1900
1901

1902
1903
1904
1905
1906
1907








1908
1909
1910
1911
1912
1913
1914
....
2299
2300
2301
2302
2303
2304
2305





2306
2307









2308
2309
2310
2311
2312
2313
2314
....
3155
3156
3157
3158
3159
3160
3161

3162



3163
3164
3165
3166
3167
3168
3169
....
3192
3193
3194
3195
3196
3197
3198





3199







3200
3201
3202
3203
3204
3205
3206
 *	interfaces.
 *
 * Copyright (c) 1995-1998 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinFile.c,v 1.112 2010/09/20 14:28:13 nijtmans Exp $
 */

#include "tclWinInt.h"
#include "tclFileSystem.h"
#include <winioctl.h>
#include <sys/stat.h>
#include <shlobj.h>
................................................................................
	 */

	do {
	    const char *utfname;
	    int checkDrive = 0, isDrive;
	    DWORD attr;


	    native = (const TCHAR *) data.w.cFileName;
	    attr = data.w.dwFileAttributes;





	    utfname = tclWinProcs->tchar2utf(native, -1, &ds);

	    if (!matchSpecialDots) {
		/*
		 * If it is exactly '.' or '..' then we ignore it.
		 */

................................................................................
 *	1 = executable, 0 = not.
 *
 *----------------------------------------------------------------------
 */

static int
NativeIsExec(
    const TCHAR *path)
{


    int len = wcslen(path);

    if (len < 5) {
	return 0;
    }

    if (path[len-4] != L'.') {
	return 0;
    }





    if ((_wcsicmp(path+len-3, L"exe") == 0)
	    || (_wcsicmp(path+len-3, L"com") == 0)
	    || (_wcsicmp(path+len-3, L"bat") == 0)) {
	return 1;



























    }
    return 0;
}
 
/*
 *----------------------------------------------------------------------
 *
................................................................................
	return NULL;
    }

    /*
     * Watch for the weird Windows c:\\UNC syntax.
     */


    WCHAR *native = (WCHAR *) buffer;
    if ((native[0] != '\0') && (native[1] == ':')
	    && (native[2] == '\\') && (native[3] == '\\')) {
	native += 2;
    }
    tclWinProcs->tchar2utf((TCHAR *) native, -1, bufferPtr);









    /*
     * Convert to forward slashes for easier use in scripts.
     */

    for (p = Tcl_DStringValue(bufferPtr); *p != '\0'; p++) {
	if (*p == '\\') {
................................................................................

    if (tclWinProcs->getCurrentDirectoryProc(MAX_PATH, buffer) == 0) {
	TclWinConvertError(GetLastError());
	return NULL;
    }

    if (clientData != NULL) {





	if (wcscmp((const WCHAR*)clientData, (const WCHAR*)buffer) == 0) {
	    return clientData;









	}
    }

    return TclNativeDupInternalRep(buffer);
}
 
int
................................................................................
	for (p = str; p && *p; ++p) {
	    if (*p == '/') {
		*p = '\\';
	    }
	}
    }
    tclWinProcs->utf2tchar(str, len, &ds);

    len = Tcl_DStringLength(&ds) + sizeof(WCHAR);



    Tcl_DecrRefCount(validPathPtr);
    nativePathPtr = ckalloc((unsigned) len);
    memcpy(nativePathPtr, Tcl_DStringValue(&ds), (size_t) len);

    Tcl_DStringFree(&ds);
    return nativePathPtr;
}
................................................................................
    char *copy;
    size_t len;

    if (clientData == NULL) {
	return NULL;
    }






    len = sizeof(TCHAR) * (_tcslen((const WCHAR *) clientData) + 1);








    copy = (char *) ckalloc(len);
    memcpy(copy, clientData, len);
    return copy;
}
 
/*

Changes to win/tclWinPipe.c.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
....
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
....
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
 *	"pipe" channel driver, and the "pid" Tcl command.
 *
 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinPipe.c,v 1.82 2010/09/09 14:30:20 nijtmans Exp $
 */

#include "tclWinInt.h"

#include <sys/stat.h>

/*
................................................................................
 */

static int
TempFileName(
    TCHAR name[MAX_PATH])	/* Buffer in which name for temporary file
				 * gets stored. */
{
    TCHAR *prefix;

    prefix = (tclWinProcs->useWide) ? (TCHAR *) L"TCL" : (TCHAR *) "TCL";
    if (tclWinProcs->getTempPathProc(MAX_PATH, name) != 0) {
	if (tclWinProcs->getTempFileNameProc(name, prefix, 0, name) != 0) {
	    return 1;
	}
    }
    if (tclWinProcs->useWide) {
	((WCHAR *) name)[0] = '.';
	((WCHAR *) name)[1] = '\0';
    } else {
	((char *) name)[0] = '.';
	((char *) name)[1] = '\0';
    }
    return tclWinProcs->getTempFileNameProc(name, prefix, 0, name);
}
 
/*
 *----------------------------------------------------------------------
 *
 * TclpMakeFile --
................................................................................
    }

    namePtr = (char *) name;
    length = tclWinProcs->getTempPathProc(MAX_PATH, name);
    if (length == 0) {
	goto gotError;
    }
    if (tclWinProcs->useWide) {
	namePtr += length * sizeof(WCHAR);
    } else {
	namePtr += length;
    }
    if (basenameObj) {
	const char *string = Tcl_GetStringFromObj(basenameObj, &length);

	tclWinProcs->utf2tchar(string, length, &buf);
	memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf));
	namePtr += Tcl_DStringLength(&buf);
	Tcl_DStringFree(&buf);
    } else {
	TCHAR *baseStr = tclWinProcs->useWide ?
		(TCHAR *) L"TCL" : (TCHAR *) "TCL";
	int length = tclWinProcs->useWide ? 3*sizeof(WCHAR) : 3;

	memcpy(namePtr, baseStr, length);
	namePtr += length;
    }
    counter = TclpGetClicks() % 65533;
    counter2 = 1024;			/* Only try this many times! Prevents
					 * an infinite loop. */
................................................................................
    do {
	char number[TCL_INTEGER_SPACE + 4];

	sprintf(number, "%d.TMP", counter);
	counter = (unsigned short) (counter + 1);
	tclWinProcs->utf2tchar(number, strlen(number), &buf);
	memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf));
	if (tclWinProcs->useWide) {
	    *(WCHAR *)(namePtr + Tcl_DStringLength(&buf) + 1) = '\0';
	} else {
	    namePtr[Tcl_DStringLength(&buf) + 1] = '\0';
	}
	Tcl_DStringFree(&buf);

	handle = tclWinProcs->createFileProc((TCHAR *) name,
		GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_NEW, flags, NULL);
    } while (handle == INVALID_HANDLE_VALUE
	    && --counter2 > 0
	    && GetLastError() == ERROR_FILE_EXISTS);






|







 







|
<
<





<
<
<
<
|
|
<







 







<
|
<
<
<








|
|
<







 







<
|
<
<
<







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
473
474
475
476
477
478
479
480


481
482
483
484
485




486
487

488
489
490
491
492
493
494
....
3104
3105
3106
3107
3108
3109
3110

3111



3112
3113
3114
3115
3116
3117
3118
3119
3120
3121

3122
3123
3124
3125
3126
3127
3128
....
3130
3131
3132
3133
3134
3135
3136

3137



3138
3139
3140
3141
3142
3143
3144
 *	"pipe" channel driver, and the "pid" Tcl command.
 *
 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclWinPipe.c,v 1.83 2010/09/20 14:28:15 nijtmans Exp $
 */

#include "tclWinInt.h"

#include <sys/stat.h>

/*
................................................................................
 */

static int
TempFileName(
    TCHAR name[MAX_PATH])	/* Buffer in which name for temporary file
				 * gets stored. */
{
    TCHAR *prefix = TEXT("TCL");


    if (tclWinProcs->getTempPathProc(MAX_PATH, name) != 0) {
	if (tclWinProcs->getTempFileNameProc(name, prefix, 0, name) != 0) {
	    return 1;
	}
    }




    name[0] = '.';
    name[1] = '\0';

    return tclWinProcs->getTempFileNameProc(name, prefix, 0, name);
}
 
/*
 *----------------------------------------------------------------------
 *
 * TclpMakeFile --
................................................................................
    }

    namePtr = (char *) name;
    length = tclWinProcs->getTempPathProc(MAX_PATH, name);
    if (length == 0) {
	goto gotError;
    }

    namePtr += length * sizeof(TCHAR);



    if (basenameObj) {
	const char *string = Tcl_GetStringFromObj(basenameObj, &length);

	tclWinProcs->utf2tchar(string, length, &buf);
	memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf));
	namePtr += Tcl_DStringLength(&buf);
	Tcl_DStringFree(&buf);
    } else {
	TCHAR *baseStr = TEXT("TCL");
	int length = 3 * sizeof(TCHAR);


	memcpy(namePtr, baseStr, length);
	namePtr += length;
    }
    counter = TclpGetClicks() % 65533;
    counter2 = 1024;			/* Only try this many times! Prevents
					 * an infinite loop. */
................................................................................
    do {
	char number[TCL_INTEGER_SPACE + 4];

	sprintf(number, "%d.TMP", counter);
	counter = (unsigned short) (counter + 1);
	tclWinProcs->utf2tchar(number, strlen(number), &buf);
	memcpy(namePtr, Tcl_DStringValue(&buf), Tcl_DStringLength(&buf));

	*(WCHAR *)(namePtr + Tcl_DStringLength(&buf) + 1) = '\0';



	Tcl_DStringFree(&buf);

	handle = tclWinProcs->createFileProc((TCHAR *) name,
		GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_NEW, flags, NULL);
    } while (handle == INVALID_HANDLE_VALUE
	    && --counter2 > 0
	    && GetLastError() == ERROR_FILE_EXISTS);