# New Ticket Created by  Will Coleda 
# Please include the string:  [perl #35976]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=35976 >


The attached patch provides a (possibly naive) implementation of the remaining 
escape characters from:

http://www.tcl.tk/man/tcl8.5/TclCmd/Tcl.htm#M16

that were missing, namely

\ooo (octal)

\xhh (hex)

and

\uhhhh (unicode)

Supplied as a patch as I know someone's in the middle of working on the parser 
right now. 

For this to *really* work, we need to be able to append ascii and unicode 
strings together with impunity. (Which *might* already work.)
4c4
<  *     $Id: tclparser.pmc 7926 2005-04-25 16:17:41Z coke $
---
>  *     $Id: tclparser.pmc 8055 2005-05-10 21:14:59Z mdiep $
601c601
<     goto backslash_escape_octal;
---
>     goto backslash_escape_not;
606,683c606,607
< backslash_escape_octal:
<   /* Octal Escape (XXX: Too ASCII?) */
<   /* We can take one to three digits. */
<   if (I0 >= 48 && I0 <= 57) {
<      I0 -= 48;
<      I1 = string_index(INTERP, buffer, start_word+1);
<      if (I1 >=48 && I1 <=57) {
<        escape_length++; 
<        I0 = 8*I0 + I1-48;
<        I1 = string_index(INTERP, buffer, start_word+2);
<        if (I1 >=48 && I1 <=57) {
<            escape_length++; 
<            I0 = 8*I0 + I1 - 48;
<        }
<      } 
<      Parrot_call_method(INTERP, P1, word, ConcatChar, "vI", I0);
<      goto escape_done;
<   }
< 
< backslash_escape_hex:
<   /* 
<    * Hex Excape:
<    * Take as many hex digit as we can get, but only the last
<    * two are used to generate the character.
<    */
<   if (I0 == 120) {
<     /* loop, getting characters. Keep a running total in I0 */
<     I0 = 0;
<     while (1) {
<       I1 = string_index(INTERP, buffer, start_word + escape_length);
<       if (I1 >=48 && I1 <=57) {       /* 0-9 */
<         I0 = I0 * 16 + I1-48; 
<       } else if (I1>=65 && I1<=70) {  /* A-Z */
<         I0 = I0 * 16 + I1 - 65 + 10;
<       } else if (I1>=97 && I1<=102) { /* a-z */
<         I0 = I0 * 16 + I1 - 97 + 10;
<       } else {
<         break;
<       }
<       I0 = I0 % 256;  /* Toss away anything bigger than two digits. */
<       escape_length++;
<     }
<     if (escape_length == 1) {
<       Parrot_call_method(INTERP, P1, word, ConcatChar, "vI", 120);
<     } else {
<       Parrot_call_method(INTERP, P1, word, ConcatChar, "vI", I0);
<     }
<     goto escape_done;
<   }
< 
< backslash_escape_unicode:
<   /* 
<    * Unicode Excape:
<    * Take 1-4 hex digits.
<    */
<   if (I0 == 117) {
<     /* loop, getting characters. Keep a running total in I0 */
<     I0 = 0;
<     while (escape_length <= 4) {
<       I1 = string_index(INTERP, buffer, start_word + escape_length);
<       if (I1 >=48 && I1 <=57) {       /* 0-9 */
<         I0 = I0 * 16 + I1-48; 
<       } else if (I1>=65 && I1<=70) {  /* A-Z */
<         I0 = I0 * 16 + I1 - 65 + 10;
<       } else if (I1>=97 && I1<=102) { /* a-z */
<         I0 = I0 * 16 + I1 - 97 + 10;
<       } else {
<         break;
<       }
<       escape_length++;
<     }
<     if (escape_length == 1) {
<       Parrot_call_method(INTERP, P1, word, ConcatChar, "vI", 117);
<     } else {
<       Parrot_call_method(INTERP, P1, word, ConcatChar, "vI", I0);
<     }
<     goto escape_done;
<   }
---
> /* XXX - here is where the \o, \x, \u escapes will go, pending more
>    trans-charset joy */
685c609
<   /* A backslash that didn't have any special meaning */
---
> backslash_escape_not:
689c613
<   /* skip the escaped char(s)*/
---
>   /* skip the escaped char*/

Reply via email to