Tcl Source Code

Check-in [2759df9850]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:*BACKPORT* [3600057]: Filled out missing parts of implementation of [string is double].

DGP - I'm pretty sure this patch is the Wrong Thing (TM) to do. Push over to a branch until we can mutually examine it.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-3600057-85
Files: files | file ages | folders
SHA1: 2759df9850fbbeccc227364f786258ab8cafa15d
User & Date: dkf 2013-09-08 14:59:41
Original Comment: *BACKPORT* [3600057]: Filled out missing parts of implementation of [string is double].
Context
2013-09-08
15:02
merge mark Closed-Leaf check-in: 4a60c3ee74 user: dkf tags: bug-3600057
14:59
*BACKPORT* [3600057]: Filled out missing parts of implementation of [string is double].

DGP - I'm... Closed-Leaf check-in: 2759df9850 user: dkf tags: bug-3600057-85

2013-09-07
21:36
[86ceb4e2b6] Improve reaction when multiple *tm files purport to offer the same version of the same ... check-in: f55d921665 user: dgp tags: core-8-5-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.






1
2
3
4
5
6
7





2013-08-01  Harald Oehlmann  <[email protected]>

	* tclUnixNotify.c Tcl_InitNotifier: Bug [a0bc856dcd]
	  Start notifier thread again if we were forked, to solve Rivet bug
	  55153.

2013-07-05  Kevin B. Kenny  <[email protected]>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2013-09-08  Donal Fellows  <[email protected]>

	* generic/tclCmdMZ.c (StringIsCmd): [Bug 3600057]: Filled out missing
	parts of implementation of [string is double].

2013-08-01  Harald Oehlmann  <[email protected]>

	* tclUnixNotify.c Tcl_InitNotifier: Bug [a0bc856dcd]
	  Start notifier thread again if we were forked, to solve Rivet bug
	  55153.

2013-07-05  Kevin B. Kenny  <[email protected]>

Changes to generic/tclCmdMZ.c.

1508
1509
1510
1511
1512
1513
1514
1515
1516
1517

1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
	break;
    case STR_IS_CONTROL:
	chcomp = Tcl_UniCharIsControl;
	break;
    case STR_IS_DIGIT:
	chcomp = Tcl_UniCharIsDigit;
	break;
    case STR_IS_DOUBLE: {
	/* TODO */
	if ((objPtr->typePtr == &tclDoubleType) ||

		(objPtr->typePtr == &tclIntType) ||
#ifndef NO_WIDE_TYPE
		(objPtr->typePtr == &tclWideIntType) ||
#endif
		(objPtr->typePtr == &tclBignumType)) {
	    break;
	}
	string1 = TclGetStringFromObj(objPtr, &length1);
	if (length1 == 0) {
	    if (strict) {
		result = 0;
	    }
	    goto str_is_done;
	}
	end = string1 + length1;
	if (TclParseNumber(NULL, objPtr, NULL, NULL, -1,
		(const char **) &stop, 0) != TCL_OK) {
	    result = 0;
	    failat = 0;
	} else {
	    failat = stop - string1;
	    if (stop < end) {
		result = 0;
		TclFreeIntRep(objPtr);
		objPtr->typePtr = NULL;
	    }
	}
	break;
    }
    case STR_IS_GRAPH:
	chcomp = Tcl_UniCharIsGraph;
	break;
    case STR_IS_INT:
	if (TCL_OK == TclGetIntFromObj(NULL, objPtr, &i)) {
	    break;
	}







|
<

>
|



|











|











<







1508
1509
1510
1511
1512
1513
1514
1515

1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545

1546
1547
1548
1549
1550
1551
1552
	break;
    case STR_IS_CONTROL:
	chcomp = Tcl_UniCharIsControl;
	break;
    case STR_IS_DIGIT:
	chcomp = Tcl_UniCharIsDigit;
	break;
    case STR_IS_DOUBLE:

	if ((objPtr->typePtr == &tclDoubleType) ||
		(objPtr->bytes == NULL &&
		((objPtr->typePtr == &tclIntType) ||
#ifndef NO_WIDE_TYPE
		(objPtr->typePtr == &tclWideIntType) ||
#endif
		(objPtr->typePtr == &tclBignumType)))) {
	    break;
	}
	string1 = TclGetStringFromObj(objPtr, &length1);
	if (length1 == 0) {
	    if (strict) {
		result = 0;
	    }
	    goto str_is_done;
	}
	end = string1 + length1;
	if (TclParseNumber(NULL, objPtr, NULL, NULL, -1,
		(const char **) &stop, TCL_PARSE_DECIMAL_ONLY) != TCL_OK) {
	    result = 0;
	    failat = 0;
	} else {
	    failat = stop - string1;
	    if (stop < end) {
		result = 0;
		TclFreeIntRep(objPtr);
		objPtr->typePtr = NULL;
	    }
	}
	break;

    case STR_IS_GRAPH:
	chcomp = Tcl_UniCharIsGraph;
	break;
    case STR_IS_INT:
	if (TCL_OK == TclGetIntFromObj(NULL, objPtr, &i)) {
	    break;
	}

Changes to tests/string.test.

12
13
14
15
16
17
18















19
20
21
22
23


24
25
26
27
28
29
30
31
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import -force ::tcltest::*
}
















# Some tests require the testobj command

testConstraint testobj [expr {[info commands testobj] != {}}]
testConstraint testindexobj [expr {[info commands testindexobj] != {}}]



test string-1.1 {error conditions} {
    list [catch {string gorp a b} msg] $msg
} {1 {unknown or ambiguous subcommand "gorp": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}}
test string-1.2 {error conditions} {
    list [catch {string} msg] $msg
} {1 {wrong # args: should be "string subcommand ?argument ...?"}}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





>
>
|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import -force ::tcltest::*
}

proc testIEEE {} {
    binary scan [binary format dd -1.0 1.0] c* c
    switch -exact -- $c {
	{0 0 0 0 0 0 -16 -65 0 0 0 0 0 0 -16 63} {
	    return 1
	}
	{-65 -16 0 0 0 0 0 0 63 -16 0 0 0 0 0 0} {
	    return 1
	}
	default {
	    return 0
	}
    }
}

# Some tests require the testobj command

testConstraint testobj [expr {[info commands testobj] != {}}]
testConstraint testindexobj [expr {[info commands testindexobj] != {}}]
# Some tests require full IEEE floating point value support
testConstraint ieeeFloatingPoint [testIEEE]

test string-1.1 {error conditions} {
    list [catch {string gorp a b} msg] $msg
} {1 {unknown or ambiguous subcommand "gorp": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}}
test string-1.2 {error conditions} {
    list [catch {string} msg] $msg
} {1 {wrong # args: should be "string subcommand ?argument ...?"}}

671
672
673
674
675
676
677



































678
679
680
681
682
683
684
    set x 2turtledoves
    string is double $x
    string is double $x
} 0
test string-6.109 {string is double, Bug 1360532} {
    string is double 1\u00a0
} 0




































catch {rename largest_int {}}

test string-7.1 {string last, too few args} {
    list [catch {string last a} msg] $msg
} {1 {wrong # args: should be "string last needleString haystackString ?startIndex?"}}
test string-7.2 {string last, bad args} {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
    set x 2turtledoves
    string is double $x
    string is double $x
} 0
test string-6.109 {string is double, Bug 1360532} {
    string is double 1\u00a0
} 0
test string-6.132 {string is double, false on hex} {
    string is double [format "0%c5" [scan x %c]]
} 0
test string-6.133 {string is double, false on hex} -setup {
    set var unset
} -body {
    list [string is double -fail var [format "0%c5" [scan x %c]]] $var
} -result {0 1}
test string-6.134 {string is double, false on hex} {
    # Force the presence of an integer representation
    set val 0x5; expr {$val + 1}
    list [string is int $val] [string is double $val]
} {1 0}
test string-6.135 {string is double, false on new octal} {
    string is double [format "0%c5" [scan o %c]]
} 0
test string-6.136 {string is double, false on new octal} -setup {
    set var unset
} -body {
    list [string is double -fail var [format "0%c5" [scan o %c]]] $var
} -result {0 1}
test string-6.137 {string is double, false on hex} {
    # Force the presence of an integer representation
    set val 0o5; expr {$val + 1}
    list [string is int $val] [string is double $val]
} {1 0}
test string-6.138 {string is double, true on inf} ieeeFloatingPoint {
    string is double Inf
} 1
test string-6.139 {string is double, true on -inf} ieeeFloatingPoint {
    string is double -Inf
} 1
test string-6.140 {string is double, true on NaN} ieeeFloatingPoint {
    string is double NaN
} 1

catch {rename largest_int {}}

test string-7.1 {string last, too few args} {
    list [catch {string last a} msg] $msg
} {1 {wrong # args: should be "string last needleString haystackString ?startIndex?"}}
test string-7.2 {string last, bad args} {
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
    set x {}
    list [string is list -failindex x {  {b c}d e}] $x
} {0 2}
test string-25.14 {string is list} {
    set x {}
    list [string is list -failindex x "\uabcd {b c}d e"] $x
} {0 2}

# cleanup
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End:







|







1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
    set x {}
    list [string is list -failindex x {  {b c}d e}] $x
} {0 2}
test string-25.14 {string is list} {
    set x {}
    list [string is list -failindex x "\uabcd {b c}d e"] $x
} {0 2}

# cleanup
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End: