Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: dd3fe363bd2d648adf54df432899ee669eecff1a
Ticket: 218751ffffffffffffffffffffffffffffffffff
Updated string command, take 2
User & Date: nobody on 2000-10-26 01:04:56
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 1992 RFE
    Version: 8.1
    SubmitDate: '1999-05-05'
    LastModified: '1999-05-07'
    Severity: LOW
    Status: Released
    Submitter: pat
    ChangedBy: stanton
    OS: Solaris
    OSVersion: 2.5.1
    Machine: Other
    FixedDate: '1999-05-07'
    FixedInVersion: 8.1.1
    ClosedDate: '2000-10-25'
    
    
    Name:
    Jeffrey Hobbs
    
    Comments:
    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:
    This is related to the previous feature request for an updated string
        command, with one new method (string is) and patched against 8.1.0.
        
        To cover it all again, I have made the following mods:
        
        * 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 is <class> ?-strict? ?-failindex varname? string
            The following are valid classes:
        alnum, alpha, ascii, boolean, digit, double, false,
        integer, lower, space, true, upper, wordchar
            Most of the correspond to the std is*() C functions.  Those
            that are missing (like iscntrl()) are due to a lack of
            Tcl_UniCharIs*() equivalent, but could be added.  I chose
            not to mess with adding them, as that means going in and
            setting things in the stub tables and such.  However, they
            are not complicated (zB, *IsControl() is a one liner).
        
            Those that do not correspond to is*() (like boolean, int,
            ...) are intelligently handled to return the correct value,
            but the command is written such that no type conversion of
            the passed object occurs (a good thing, I believe).  For
            integer and double, this was tricky, but the test suite is
            full, and the C code is well-commented with the purpose.
        
            With the exception of int/double, which are inherently in
            Tcl not unicode safe (still calls to strto*), all of these
            are unicode safe (with tests).
        
        * added [string repeat string count]
            Repeats given string <count> number of times
        
        * added string replace, quasi 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 100KB with full doc and test suite changes
    against the Tcl 8.1.0 sources.
    http://www.hobbs.wservice.com/tcl/capp/Tcl81-string.txt
    
    PatchFiles:
    C: tclUtil.c && tclCmdMZ.c
        doc: string.n
        tests: string.test cmd*.test l*.test error.test
    
    
    
    
    
  4. foundin changed to: "obsolete: 8.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to: "Updated string command, take 2"
  11. type changed to: "RFE"