Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tip-342 Excluding Merge-Ins
This is equivalent to a diff from 2a6c012bff to f500eaf0ba
2019-04-16
| ||
13:25 | Implement TIP 342 check-in: 1417ed9dbf user: dkf tags: core-8-branch | |
2019-04-15
| ||
19:57 | Add [dict getdef] alias Closed-Leaf check-in: f500eaf0ba user: dkf tags: tip-342 | |
2019-04-14
| ||
14:15 | Implement TIP 160 check-in: 42f24469aa user: dkf tags: core-8-branch | |
2019-04-12
| ||
20:16 | merge 8.7 Closed-Leaf check-in: c8c10b1df8 user: dgp tags: dgp-string-insert | |
20:15 | merge 8.7 Closed-Leaf check-in: a92f73b21e user: dgp tags: tip-367 | |
19:44 | merge 8.7 check-in: 959bd9e05d user: dgp tags: tip-342 | |
19:21 | merge 8.7 check-in: 77b29afa6b user: dgp tags: tip-312-new | |
19:12 | merge 8.7 Closed-Leaf check-in: 325ddbd682 user: dgp tags: tip-224 | |
2019-04-11
| ||
20:38 | Merge 8.7 check-in: c8a7a0b2d8 user: jan.nijtmans tags: trunk | |
20:37 | Merge 8.6 check-in: 2a6c012bff user: jan.nijtmans tags: core-8-branch | |
20:09 | Only use special mp_sqrt() code when double format/tommath format are exactly what's expected. Other... check-in: 3f35b52355 user: jan.nijtmans tags: core-8-6-branch | |
09:52 | merge 8.6 (conflicts resolved, changes on tests/cmdMZ.test in [4cb9044dfa] reverted - timerate is su... check-in: 1803c5e40f user: sebres tags: core-8-branch | |
Changes to doc/dict.n.
︙ | |||
115 116 117 118 119 120 121 122 123 124 125 126 127 128 | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | + + + + + + + + + + + + + + + + | elements in a manner similar to \fBarray get\fR. That is, the first element of each pair would be the key and the second element would be the value for that key. .PP It is an error to attempt to retrieve a value for a key that is not present in the dictionary. .RE .TP \fBdict getdef \fIdictionaryValue \fR?\fIkey ...\fR? \fIkey default\fR .TP \fBdict getwithdefault \fIdictionaryValue \fR?\fIkey ...\fR? \fIkey default\fR .VS "8.7, TIP342" This behaves the same as \fBdict get\fR (with at least one \fIkey\fR argument), returning the value that the key path maps to in the dictionary \fIdictionaryValue\fR, except that instead of producing an error because the \fIkey\fR (or one of the \fIkey\fRs on the key path) is absent, it returns the \fIdefault\fR argument instead. .RS .PP Note that there must always be at least one \fIkey\fR provided, and that \fBdict getdef\fR and \fBdict getwithdefault\fR are aliases for each other. .RE .VE "8.7, TIP342" .TP \fBdict incr \fIdictionaryVariable key \fR?\fIincrement\fR? . This adds the given increment value (an integer that defaults to 1 if not specified) to the value that the given key maps to in the dictionary value contained in the given variable, writing the resulting dictionary value back to that variable. Non-existent keys |
︙ |
Changes to generic/tclDictObj.c.
︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | + + | int objc, Tcl_Obj *const *objv); static int DictExistsCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); static int DictFilterCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); static int DictGetCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); static int DictGetDefCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); static int DictIncrCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); static int DictInfoCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); static int DictKeysCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); static int DictLappendCmd(ClientData dummy, Tcl_Interp *interp, |
︙ | |||
85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | + + | static const EnsembleImplMap implementationMap[] = { {"append", DictAppendCmd, TclCompileDictAppendCmd, NULL, NULL, 0 }, {"create", DictCreateCmd, TclCompileDictCreateCmd, NULL, NULL, 0 }, {"exists", DictExistsCmd, TclCompileDictExistsCmd, NULL, NULL, 0 }, {"filter", DictFilterCmd, NULL, NULL, NULL, 0 }, {"for", NULL, TclCompileDictForCmd, DictForNRCmd, NULL, 0 }, {"get", DictGetCmd, TclCompileDictGetCmd, NULL, NULL, 0 }, {"getdef", DictGetDefCmd, NULL, NULL, NULL, 0 }, {"getwithdefault", DictGetDefCmd, NULL, NULL, NULL, 0 }, {"incr", DictIncrCmd, TclCompileDictIncrCmd, NULL, NULL, 0 }, {"info", DictInfoCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0 }, {"keys", DictKeysCmd, TclCompileBasic1Or2ArgCmd, NULL, NULL, 0 }, {"lappend", DictLappendCmd, TclCompileDictLappendCmd, NULL, NULL, 0 }, {"map", NULL, TclCompileDictMapCmd, DictMapNRCmd, NULL, 0 }, {"merge", DictMergeCmd, TclCompileDictMergeCmd, NULL, NULL, 0 }, {"remove", DictRemoveCmd, TclCompileBasicMin1ArgCmd, NULL, NULL, 0 }, |
︙ | |||
1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 | 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "DICT", TclGetString(objv[objc-1]), NULL); return TCL_ERROR; } Tcl_SetObjResult(interp, valuePtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * DictGetDefCmd -- * * This function implements the "dict getdef" and "dict getwithdefault" * Tcl commands. See the user documentation for details on what it does, * and TIP#342 for the formal specification. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ static int DictGetDefCmd( ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) { Tcl_Obj *dictPtr, *keyPtr, *valuePtr, *defaultPtr; Tcl_Obj *const *keyPath; int numKeys; if (objc < 4) { Tcl_WrongNumArgs(interp, 1, objv, "dictionary ?key ...? key default"); return TCL_ERROR; } /* * Give the bits of arguments names for clarity. */ dictPtr = objv[1]; keyPath = &objv[2]; numKeys = objc - 4; /* Number of keys in keyPath; there's always * one extra key afterwards too. */ keyPtr = objv[objc - 2]; defaultPtr = objv[objc - 1]; /* * Implement the getting-with-default operation. */ dictPtr = TclTraceDictPath(interp, dictPtr, numKeys, keyPath, DICT_PATH_EXISTS); if (dictPtr == NULL) { return TCL_ERROR; } else if (dictPtr == DICT_PATH_NON_EXISTENT) { Tcl_SetObjResult(interp, defaultPtr); } else if (Tcl_DictObjGet(interp, dictPtr, keyPtr, &valuePtr) != TCL_OK) { return TCL_ERROR; } else if (valuePtr == NULL) { Tcl_SetObjResult(interp, defaultPtr); } else { Tcl_SetObjResult(interp, valuePtr); } return TCL_OK; } /* *---------------------------------------------------------------------- * * DictReplaceCmd -- * * This function implements the "dict replace" Tcl command. See the user |
︙ |
Changes to tests/dict.test.
︙ | |||
2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 | 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | test dict-25.1 {compiled dict update with low-refcount values [Bug d553228d9f]} { # Test crashes on failure apply {{} { lassign {} item dict update item item item two two {} }} } {} test dict-26.1 {dict getdef command} -body { dict getdef {a b} a c } -result b test dict-26.2 {dict getdef command} -body { dict getdef {a b} b c } -result c test dict-26.3 {dict getdef command} -body { dict getdef {a {b c}} a b d } -result c test dict-26.4 {dict getdef command} -body { dict getdef {a {b c}} a c d } -result d test dict-26.5 {dict getdef command} -body { dict getdef {a {b c}} b c d } -result d test dict-26.6 {dict getdef command} -returnCodes error -body { dict getdef {a {b c d}} a b d } -result {missing value to go with key} test dict-26.7 {dict getdef command} -returnCodes error -body { dict getdef } -result {wrong # args: should be "dict getdef dictionary ?key ...? key default"} test dict-26.8 {dict getdef command} -returnCodes error -body { dict getdef {} } -result {wrong # args: should be "dict getdef dictionary ?key ...? key default"} test dict-26.9 {dict getdef command} -returnCodes error -body { dict getdef {} {} } -result {wrong # args: should be "dict getdef dictionary ?key ...? key default"} test dict-27.1 {dict getwithdefault command} -body { dict getwithdefault {a b} a c } -result b test dict-27.2 {dict getwithdefault command} -body { dict getwithdefault {a b} b c } -result c test dict-27.3 {dict getwithdefault command} -body { dict getwithdefault {a {b c}} a b d } -result c test dict-27.4 {dict getwithdefault command} -body { dict getwithdefault {a {b c}} a c d } -result d test dict-27.5 {dict getwithdefault command} -body { dict getwithdefault {a {b c}} b c d } -result d test dict-27.6 {dict getwithdefault command} -returnCodes error -body { dict getwithdefault {a {b c d}} a b d } -result {missing value to go with key} test dict-27.7 {dict getwithdefault command} -returnCodes error -body { dict getwithdefault } -result {wrong # args: should be "dict getwithdefault dictionary ?key ...? key default"} test dict-27.8 {dict getwithdefault command} -returnCodes error -body { dict getwithdefault {} } -result {wrong # args: should be "dict getwithdefault dictionary ?key ...? key default"} test dict-27.9 {dict getwithdefault command} -returnCodes error -body { dict getwithdefault {} {} } -result {wrong # args: should be "dict getwithdefault dictionary ?key ...? key default"} # cleanup ::tcltest::cleanupTests return # Local Variables: # mode: tcl # End: |