On 2022-08-05 13:32:04 +0200, Samir Ribić via Tinycc-devel wrote: > Tcc supports \u escape sequence inside L"" but I have no idea how to > overcome this problem: > The code inside parse_escape_string function, in this part > > case 'x': > case 'u': > case 'U': > p++; > n = 0; > for(;;) { > c = *p; > if (c >= 'a' && c <= 'f') > c = c - 'a' + 10; > else if (c >= 'A' && c <= 'F') > c = c - 'A' + 10; > else if (isnum(c)) > c = c - '0'; > else > break; > n = n * 16 + c; > p++; > } [...]
Note that tccpp.c already has code that selects the right number of digits: case 'x': i = 0; goto parse_hex_or_ucn; case 'u': i = 4; goto parse_hex_or_ucn; case 'U': i = 8; goto parse_hex_or_ucn; parse_hex_or_ucn: p++; n = 0; do { c = *p; if (c >= 'a' && c <= 'f') c = c - 'a' + 10; else if (c >= 'A' && c <= 'F') c = c - 'A' + 10; else if (isnum(c)) c = c - '0'; else if (i > 0) expect("more hex digits in universal-character-name"); else { c = n; goto add_char_nonext; } n = n * 16 + c; p++; } while (--i); cstr_u8cat(outstr, n); continue; Perhaps some code could be shared, possibly via an inline function... -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel