Overview
| Artifact ID: | 0e584d19ea33851d19c79f94d3ca2cc3158c70dc |
|---|---|
| Ticket: | 218721ffffffffffffffffffffffffffffffffff
Updated string command |
| User & Date: | nobody on 2000-10-26 01:04:33 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 1845 RFE Version: 8.1b3 SubmitDate: '1999-04-16' LastModified: '1999-08-06' Severity: LOW Status: Released Submitter: pat ChangedBy: hobbs OS: Other Machine: NA FixedDate: '1999-08-06' FixedInVersion: 8.1.1 ClosedDate: '2000-10-25' Name: Jeffrey Hobbs CustomShell: This is the core mod, baby! Comments: I think this fully tested patch would make a great addition to 8.1, but realizing that that is close to final, they should definitely be folded into 8.2. If you need good examples of where this saves times or improves logic for common tasks. you're not coding enough Tcl :^). The implementations were done to maintain 100% backwards compatibility with working code (changing the options to an arg can obviously change what error strings arise), and reduce any loss of speed (the only method that actually attained a speed loss was string index, as I throw a Tcl_NumUtfChars call in to support end-1 like indices, and that is not major). DesiredBehavior: There is some basic functionality missing in Tcl that causes commonly required functions to need multiple Tcl calls. I have upgraded the core string command (with some minor list indexing benefits) to give better core functionality for string manipulation in Tcl. These functions are fully tested (test suite included in patch, with all mods necessary to other tests) and documented. I made the following modifications: * string compare now takes optional length arg (for strncmp behavior) * added string equal (just a few lines of code blended in with string compare) * added string icompare/iequal for case-insensitive comparisons * string index's index can now be ?end[+-]?expression I made this change in the private TclGetIntForIndex, which means that the list commands also benefit, as well as string range, et al. * added [string repeat string count] Repeats given string <count> number of times * added string replace, string equiv to lreplace (quasi opposite of string range): string replace first last ?string? Example of use, replacing end of string with ... should the string be more than 16 chars long: string replace $string 16 end "..." This just returns the string len < 16, so it will only affect the long strings. * added optional first and last args to string to* This allows you to just affect certain regions of a string with the command (like just capping the first letter). I found the original totitle to be too draconian to be useful. * added [string map charMap string] where charMap is a {from to from to} list that equates to what one might get from [array get]. Each <from> and <to> can be multiple chars (or none at all). For Tcl/CGI users, this is a MAJOR speed booster. Patch: The patch comes to 64KB with full doc and test suite changes against the tcl8.1b3 sources. http://www.hobbs.wservice.com/tcl/capp/newstring.txt PatchFiles: C: tclUtil.c && tclCmdMZ.c doc: string.n tests: string.test cmd*.test l*.test error.test Added to 8.1.1. -- 08/06/1999 hobbs - foundin changed to: "obsolete: 8.1b3"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "69. Other"
- title changed to: "Updated string command"
- type changed to: "RFE"