Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e8d9931cd913d0765f3385ba25c8aaf1d3148669
Ticket: 769895ffffffffffffffffffffffffffffffffff
Tcl_UtfPrev not as documented ?
User & Date: dgp on 2003-07-11 21:43:11
Changes

  1. assignee changed to: "nijtmans"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    Docs for Tcl_UtfPrev(src, start) say:
    
         Given src, a pointer to some location  in  a 
    UTF-8  string,
         Tcl_UtfPrev  returns a pointer to the previous
    UTF-8 charac-
         ter in the string.  This function will  not  back
     up  to  a
         position  before  start,  the start of the UTF-8
    string.  If
         src was already at start, the return value will be
    start.
    
    The source code comments just before Tcl_UtfPrev
    also say:
    
     *      Given a pointer to some current location in a
    UTF-8 string,
     *      move backwards one character.  This works
    correctly when the
     *      pointer is in the middle of a UTF-8 character.
    
    So the claim is that the src argument can be a pointer
    to a trailing byte of a multi-byte character.
    
    However, that does not appear to be what the
    routine really does.  Instead, the routine starts
    a search at one byte before the src argument, and
    searches backward for the beginning of a UTF8
    character byte-sequence and returns that.
    
    So, for example, 
    
        CONST char *word="ab\303\521";
        Tcl_UtfPrev(word+3,word);
    
    will return word+2 (pointer to the é character in UTF8)
    and not word+1 (pointer to the 'b') as I would expect.
    
    One feature of the current Tcl_UtfPrev()
    implementation is that it is currently safe
    to pass in a 'src' argument, that points one
    byte past the end of the allocated buffer,
    which can be useful, even though it seems
    counter to the documentation.
    
    Either implementation or documentation
    ought to be changed to bring them into
    agreement.
    
    
    
  4. foundin changed to: "obsolete: 8.4.3"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "dgp"
  9. subsystem changed to: "44. UTF-8 Strings"
  10. title changed to: "Tcl_UtfPrev not as documented ?"
  11. type changed to: "Bug"