summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorericm <ericm>2000-04-10 21:08:26 (GMT)
committerericm <ericm>2000-04-10 21:08:26 (GMT)
commit1ca8b9ee3d089e20d6e8603c3b6ce33bac188d6d (patch)
tree969dd778b3f00ae92ec0793ad12d2fb87496794c /win
parenta44349c8166358f92b65f61682ea4a484df881b4 (diff)
downloadtcl-1ca8b9ee3d089e20d6e8603c3b6ce33bac188d6d.zip
tcl-1ca8b9ee3d089e20d6e8603c3b6ce33bac188d6d.tar.gz
tcl-1ca8b9ee3d089e20d6e8603c3b6ce33bac188d6d.tar.bz2
* win/tclWinPipe.c (TclpCreateTempFile): Added conversion of
contents string from UTF to native encoding [Bug: 4030]. * tests/regexp.test: Added tests for infinite looping in [regexp -all]. * generic/tclCmdMZ.c: Fixed infinite loop bug with [regexp -all] [Bug: 4981].
Diffstat (limited to 'win')
-rw-r--r--win/tclWinPipe.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index 5c4b137..21f15c4 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -9,7 +9,7 @@
* 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.9 1999/12/09 14:44:11 hobbs Exp $
+ * RCS: @(#) $Id: tclWinPipe.c,v 1.10 2000/04/10 21:08:27 ericm Exp $
*/
#include "tclWinInt.h"
@@ -692,6 +692,8 @@ TclpCreateTempFile(contents)
CONST char *contents; /* String to write into temp file, or NULL. */
{
WCHAR name[MAX_PATH];
+ char *native;
+ Tcl_DString dstring;
HANDLE handle;
if (TempFileName(name) == 0) {
@@ -712,27 +714,33 @@ TclpCreateTempFile(contents)
if (contents != NULL) {
DWORD result, length;
CONST char *p;
+
+ /*
+ * Convert the contents from UTF to native encoding
+ */
+ native = Tcl_UtfToExternalDString(NULL, contents, -1, &dstring);
- for (p = contents; *p != '\0'; p++) {
+ for (p = native; *p != '\0'; p++) {
if (*p == '\n') {
- length = p - contents;
+ length = p - native;
if (length > 0) {
- if (!WriteFile(handle, contents, length, &result, NULL)) {
+ if (!WriteFile(handle, native, length, &result, NULL)) {
goto error;
}
}
if (!WriteFile(handle, "\r\n", 2, &result, NULL)) {
goto error;
}
- contents = p+1;
+ native = p+1;
}
}
- length = p - contents;
+ length = p - native;
if (length > 0) {
- if (!WriteFile(handle, contents, length, &result, NULL)) {
+ if (!WriteFile(handle, native, length, &result, NULL)) {
goto error;
}
}
+ Tcl_DStringFree(&dstring);
if (SetFilePointer(handle, 0, NULL, FILE_BEGIN) == 0xFFFFFFFF) {
goto error;
}
@@ -741,6 +749,11 @@ TclpCreateTempFile(contents)
return TclWinMakeFile(handle);
error:
+ /* Free the native representation of the contents if necessary */
+ if (contents != NULL) {
+ Tcl_DStringFree(&dstring);
+ }
+
TclWinConvertError(GetLastError());
CloseHandle(handle);
(*tclWinProcs->deleteFileProc)((TCHAR *) name);