diff options
author | ericm <ericm@noemail.net> | 2000-04-10 21:08:25 (GMT) |
---|---|---|
committer | ericm <ericm@noemail.net> | 2000-04-10 21:08:25 (GMT) |
commit | ff0fab7b16e7b6e8afc6ac8e9412cbd899c3d23a (patch) | |
tree | 969dd778b3f00ae92ec0793ad12d2fb87496794c /win | |
parent | 827e24b3436dc0af025b4b369bb3993efc71c210 (diff) | |
download | tcl-ff0fab7b16e7b6e8afc6ac8e9412cbd899c3d23a.zip tcl-ff0fab7b16e7b6e8afc6ac8e9412cbd899c3d23a.tar.gz tcl-ff0fab7b16e7b6e8afc6ac8e9412cbd899c3d23a.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].
FossilOrigin-Name: 1908ebdc39b71cc7648c9ccca12713c005201b83
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinPipe.c | 27 |
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); |