Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Extend cases where string rep generation can be prevented. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3f07499767ad13abb24031f450ce1a01 |
User & Date: | dgp 2017-06-16 12:56:03 |
Context
2017-06-16
| ||
14:43 | Rework the logic. Equivalent function. check-in: aa9699939f user: dgp tags: trunk | |
12:56 | Extend cases where string rep generation can be prevented. check-in: 3f07499767 user: dgp tags: trunk | |
11:47 | Better define the meaning of "first" and "last". check-in: a1eb17546f user: dgp tags: trunk | |
Changes
Changes to generic/tclStringObj.c.
︙ | ︙ | |||
2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 | last = objc - oc; first = last; pendingPtr = objPtr; } else { Tcl_GetStringFromObj(objPtr, &numBytes); /* PANIC? */ if (numBytes == 0) { continue; } last = objc - oc; if (pendingPtr) { Tcl_GetStringFromObj(pendingPtr, &length); /* PANIC? */ pendingPtr = NULL; } if (length == 0) { first = last; } else if (numBytes > INT_MAX - length) { | > > > > > > > > > > > > > > > > | 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 | last = objc - oc; first = last; pendingPtr = objPtr; } else { Tcl_GetStringFromObj(objPtr, &numBytes); /* PANIC? */ if (numBytes == 0) { if (pendingPtr && pendingPtr->bytes) { /* * Generating string rep of objPtr also * generated string rep of pendingPtr. */ if (pendingPtr->length) { /* Can this happen? */ goto foo; } else { /* string-29.14 */ first = objc - 1; last = 0; pendingPtr = NULL; } } continue; } last = objc - oc; foo: if (pendingPtr) { Tcl_GetStringFromObj(pendingPtr, &length); /* PANIC? */ pendingPtr = NULL; } if (length == 0) { first = last; } else if (numBytes > INT_MAX - length) { |
︙ | ︙ |
Changes to tests/string.test.
︙ | ︙ | |||
2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 | tcl::unsupported::representation \ [string cat [encoding convertto utf-8 {}] [list x]] } -match glob -result {*, string representation "x"} test string-29.13 {string cat, efficiency} -body { tcl::unsupported::representation [string cat \ [encoding convertto utf-8 {}] [encoding convertto utf-8 {}] [list x]] } -match glob -result {*, string representation "x"} # cleanup rename MemStress {} catch {rename foo {}} ::tcltest::cleanupTests | > > > > > > > > > > > > > > > | 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 | tcl::unsupported::representation \ [string cat [encoding convertto utf-8 {}] [list x]] } -match glob -result {*, string representation "x"} test string-29.13 {string cat, efficiency} -body { tcl::unsupported::representation [string cat \ [encoding convertto utf-8 {}] [encoding convertto utf-8 {}] [list x]] } -match glob -result {*, string representation "x"} test string-29.14 {string cat, efficiency} -setup { set e [encoding convertto utf-8 {}] } -cleanup { unset e } -body { tcl::unsupported::representation [string cat $e $e [list x]] } -match glob -result {*no string representation} test string-29.15 {string cat, efficiency} -setup { set e [encoding convertto utf-8 {}] set f [encoding convertto utf-8 {}] } -cleanup { unset e f } -body { tcl::unsupported::representation [string cat $e $f $e $f [list x]] } -match glob -result {*no string representation} # cleanup rename MemStress {} catch {rename foo {}} ::tcltest::cleanupTests |
︙ | ︙ |