diff options
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | generic/tclGet.c | 5 | ||||
-rw-r--r-- | tests/exec.test | 9 | ||||
-rw-r--r-- | unix/tclUnixPipe.c | 14 |
4 files changed, 39 insertions, 7 deletions
@@ -1,3 +1,21 @@ +2000-03-31 Eric Melski <ericm@scriptics.com> + + * 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.) + 2000-03-30 Jeff Hobbs <hobbs@scriptics.com> * generic/tclBasic.c (Tcl_DeleteCommandFromToken): Added comments diff --git a/generic/tclGet.c b/generic/tclGet.c index 69cf503..aa60799 100644 --- a/generic/tclGet.c +++ b/generic/tclGet.c @@ -11,11 +11,12 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclGet.c,v 1.5 1999/12/04 06:15:41 hobbs Exp $ + * RCS: @(#) $Id: tclGet.c,v 1.6 2000/03/31 19:39:42 ericm Exp $ */ #include "tclInt.h" #include "tclPort.h" +#include "tclMath.h" /* @@ -222,7 +223,7 @@ Tcl_GetDouble(interp, string, doublePtr) } return TCL_ERROR; } - if (errno != 0) { + if (errno != 0 && (d == HUGE_VAL || d == -HUGE_VAL || d == 0)) { if (interp != (Tcl_Interp *) NULL) { TclExprFloatError(interp, d); } diff --git a/tests/exec.test b/tests/exec.test index b142e9b..95010de 100644 --- a/tests/exec.test +++ b/tests/exec.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: exec.test,v 1.6 1999/08/27 21:45:17 jenn Exp $ +# RCS: @(#) $Id: exec.test,v 1.7 2000/03/31 19:39:42 ericm Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -141,6 +141,13 @@ test exec-2.4 {redirecting input from immediate source} {execCommandExists stdio test exec-2.5 {redirecting input from immediate source} {execCommandExists stdio} { exec $::tcltest::tcltest cat "<<Joined to arrows" } {Joined to arrows} +test exec-2.6 {redirecting input from immediate source, with UTF} {execCommandExists stdio} { + # If this fails, it may give back: + # "\uC3\uA9\uC3\uA0\uC3\uBC\uC3\uB1" + # If it does, this means that the UTF -> external conversion did not + # occur before writing out the temp file. + exec $::tcltest::tcltest cat << "\uE9\uE0\uFC\uF1" +} "\uE9\uE0\uFC\uF1" # I/O redirection: output to file. 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); |