Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9b34d8e57345b9ccc919284b1571be0033d0138b
Ticket: 217987ffffffffffffffffffffffffffffffffff
Backslash substitution is broken with non-ASCII chars
User & Date: cc_benny on 2001-01-29 23:47:35
Changes

  1. icomment:
    The Problem still exists in 8.4 in CVS, and it doesn't seem to be fixed in the 8.3.2 branch either ??.
    
    I attach a patch against the main branch in CVS here:
    
    Index: tclUtf.c
    ===================================================================
    RCS file: /cvsroot/tcl/tcl/generic/tclUtf.c,v
    retrieving revision 1.14
    diff -c -r1.14 tclUtf.c
    *** tclUtf.c2000/06/05 23:36:211.14
    --- tclUtf.c2001/01/29 16:46:49
    ***************
    *** 781,787 ****
       * backslash sequence. */
      {
          register CONST char *p = src+1;
    !     int result, count, n;
          char buf[TCL_UTF_MAX];
      
          if (dst == NULL) {
    --- 781,787 ----
       * backslash sequence. */
      {
          register CONST char *p = src+1;
    !     int result, count, n, utfconvert;
          char buf[TCL_UTF_MAX];
      
          if (dst == NULL) {
    ***************
    *** 789,794 ****
    --- 789,795 ----
          }
      
          count = 2;
    +     utfconvert = 0; /*false*/
          switch (*p) {
      /*
               * Note: in the conversions below, use absolute values (e.g.,
    ***************
    *** 820,825 ****
    --- 821,827 ----
                  result = 0xb;
                  break;
              case 'x':
    +     utfconvert = 1; /*true*/
                  if (isxdigit(UCHAR(p[1]))) { /* INTL: digit */
                      char *end;
      
    ***************
    *** 831,836 ****
    --- 833,839 ----
                  }
                  break;
      case 'u':
    +     utfconvert = 1; /*true*/
          result = 0;
          for (count = 0; count < 4; count++) {
      p++;
    ***************
    *** 868,873 ****
    --- 871,877 ----
           * Check for an octal number \oo?o?
           */
          if (isdigit(UCHAR(*p)) && (UCHAR(*p) < '8')) { /* INTL: digit */
    +         utfconvert = 1; /*true*/
      result = (unsigned char)(*p - '0');
      p++;
      if (!isdigit(UCHAR(*p)) || (UCHAR(*p) >= '8')) { /* INTL: digit */
    ***************
    *** 891,897 ****
          if (readPtr != NULL) {
      *readPtr = count;
          }
    !     return Tcl_UniCharToUtf(result, dst);
      }
      
      /*
    --- 895,909 ----
          if (readPtr != NULL) {
      *readPtr = count;
          }
    !     if (!utfconvert)
    !     {
    ! *dst = (char)result;
    !         return 1;
    !     }
    !     else
    !     {
    ! return Tcl_UniCharToUtf(result, dst);
    !     }
      }
      
      /*
    
    
    
    
    
  2. login: "cc_benny"
  3. mimetype: "text/plain"
  4. username: "cc_benny"