Overview
| Artifact ID: | 2e09c20fb8a2320f4d303da15779004095cbe010 |
|---|---|
| Ticket: | 218973ffffffffffffffffffffffffffffffffff
[expr {" "}] inconsistentcy on Tru64 |
| User & Date: | nobody on 2000-10-26 01:08:50 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 3378 Bug Version: 8.2.1 SubmitDate: '1999-11-05' LastModified: '2000-01-12' Severity: SER Status: Released Submitter: techsupp ChangedBy: hobbs OS: Digital Unix OSVersion: Compaq Tru64 Unix 5.0 FixedDate: '2000-01-12' FixedInVersion: 8.3b2 ClosedDate: '2000-10-25' Name: Don Porter Comments: The root of the problem is an inconsistency in the implementation of strtod() on Tru64 Unix 5.0. strtod(" ") returns 0.0 instead of an indication that the conversion could not be performed. I'd argue that this is a bug. The ANSI C spec says leading whitespace should be ignored by strtod(), but the Tru64 implementation gives a different result for strtod("") and strtod(" "). The fix just adds a check for this bug to the configure script and links in the compat/strtod.o to replace the buggy system one. A test is added to the test suite to catch this problem. ObservedBehavior: On Linux, Solaris, Windows, ... % puts ->[expr {" "}]<- -> <- % puts ->[expr {"\n"}]<- -> <- % expr { " " == "\n" } 0 BUT, on Compaq's Tru64 Unix 5.0.... % puts ->[expr {" "}]<- 0.0 % puts ->[expr {"\n"}]<- 0.0 % expr { " " == "\n" } 1 The last one is especially bad for any programmers who are using "==" when they mean to use [string equal]. DesiredBehavior: Consistent [expr] results on all platforms Patch: Index: tests/expr.test =================================================================== RCS file: /cvsroot/tcl/tests/expr.test,v retrieving revision 1.5.4.1 diff -c -r1.5.4.1 expr.test *** expr.test 1999/09/22 04:12:57 1.5.4.1 --- expr.test 1999/10/14 21:28:27 *************** *** 647,652 **** --- 647,655 ---- catch {expr int($x)} expr {$x} } 11 + test expr-18.2 {whitespace strings should not be == 0 (buggy strtod)} { + expr {" "} + } { } # Check "expr" and interpreter result object resetting before appending # an error msg during evaluation of exprs not in {}s Index: unix/configure.in =================================================================== RCS file: /cvsroot/tcl/unix/configure.in,v retrieving revision 1.48.2.1 diff -c -r1.48.2.1 configure.in *** configure.in 1999/09/30 21:27:05 1.48.2.1 --- configure.in 1999/10/14 21:28:29 *************** *** 248,253 **** --- 248,283 ---- fi #-------------------------------------------------------------------- + # Check for buggy strtod function. On Compaq's Tru64 Unix 5.0, + # strtod(" ") returns 0.0 instead of a failure to convert. + #-------------------------------------------------------------------- + + AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0) + if test "$tcl_strtod" = 1; then + AC_MSG_CHECKING([for Tru64 strtod bug]) + AC_TRY_RUN([ + extern double strtod(); + int main() + { + char *string = " "; + char *term; + double value; + value = strtod(string, &term); + if (term == (string+1)) { + exit(1); + } + exit(0); + }], tcl_ok=1, tcl_ok=0, tcl_ok=0) + if test "$tcl_ok" = 1; then + AC_MSG_RESULT(ok) + else + AC_MSG_RESULT(buggy) + test -n "$verbose" && echo " Adding strtod.o." + LIBOBJS="$LIBOBJS strtod.o" + fi + fi + + #-------------------------------------------------------------------- # Under Solaris 2.4, strtod returns the wrong value for the # terminating character under some conditions. Check for this # and if the problem exists use a substitute procedure PatchFiles: tests/expr.test unix/configure.in These are folded in to the existing strtod checks, for both Tcl and Tk. -- 01/12/2000 hobbs - foundin changed to: "obsolete: 8.2.1"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "75. Tutorial"
- title changed to: "[expr {" "}] inconsistentcy on Tru64"
- type changed to: "Bug"