diff options
author | ericm <ericm@noemail.net> | 2000-03-31 19:39:40 (GMT) |
---|---|---|
committer | ericm <ericm@noemail.net> | 2000-03-31 19:39:40 (GMT) |
commit | fc921deac89ed9f6bb647030b22a4df2fb427ad7 (patch) | |
tree | 2d64c5f88a5d280114bdb5ec4b8455753a3a5384 /unix | |
parent | 81b94d11359675d289a7493c128e5511c9f18815 (diff) | |
download | tcl-fc921deac89ed9f6bb647030b22a4df2fb427ad7.zip tcl-fc921deac89ed9f6bb647030b22a4df2fb427ad7.tar.gz tcl-fc921deac89ed9f6bb647030b22a4df2fb427ad7.tar.bz2 |
* generic/tclGet.c (Tcl_GetDouble): Added additional conditions to
error test (previously only errno was checked, but the return
value of strtod() should be checked as well). [Bug: 4118].
* tests/exec.test: Added test for proper conversion of UTF data
when used with "<< $dataWithUTF" on exec's.
* unix/tclUnixPipe.c (TclpCreateTempFile): Added
Tcl_UtfToExternalDString call, so that if there is UTF content in
the string it will be properly converted to the system encoding
before being written [Bug: 4030].
(TclpCreateTempFile): Added a check on the return value of tmpnam;
some systems (Linux, for example) will start to return NULL after
tmpnam has been called TMP_MAX times; not checking for this can
have bad results (overwriting temp files, core dumps, etc.)
FossilOrigin-Name: 27f457dd13bd11383a15651c5e9c2bcbc947599b
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tclUnixPipe.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index 91c497d..d234245 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixPipe.c,v 1.8 2000/03/27 18:34:32 ericm Exp $ + * RCS: @(#) $Id: tclUnixPipe.c,v 1.9 2000/03/31 19:39:42 ericm Exp $ */ #include "tclInt.h" @@ -182,10 +182,13 @@ TclFile TclpCreateTempFile(contents) CONST char *contents; /* String to write into temp file, or NULL. */ { - char fileName[L_tmpnam]; + char fileName[L_tmpnam], *native; + Tcl_DString dstring; int fd; - tmpnam(fileName); /* INTL: Native. */ + if (tmpnam(fileName) == NULL) { /* INTL: Native. */ + return NULL; + } fd = open(fileName, O_RDWR|O_CREAT|O_TRUNC, 0666); /* INTL: Native. */ if (fd == -1) { return NULL; @@ -194,10 +197,13 @@ TclpCreateTempFile(contents) unlink(fileName); /* INTL: Native. */ if (contents != NULL) { - if (write(fd, contents, strlen(contents)) == -1) { + native = Tcl_UtfToExternalDString(NULL, contents, -1, &dstring); + if (write(fd, native, strlen(native)) == -1) { close(fd); + Tcl_DStringFree(&dstring); return NULL; } + Tcl_DStringFree(&dstring); lseek(fd, (off_t) 0, SEEK_SET); } return MakeFile(fd); |