19
19
static int isatty (int ) { return 0 ; }
20
20
#endif
21
21
22
+ #include < util/unicode.h>
23
+
22
24
#include " c_types.h"
23
25
#include " preprocessor_line.h"
24
26
#include " string_constant.h"
@@ -27,6 +29,7 @@ static int isatty(int) { return 0; }
27
29
#include " literals/convert_integer_literal.h"
28
30
#include " literals/convert_character_literal.h"
29
31
#include " literals/convert_string_literal.h"
32
+ #include " literals/unescape_string.h"
30
33
31
34
#define PARSER ansi_c_parser
32
35
#define YYSTYPE unsigned
@@ -45,9 +48,34 @@ extern int yyansi_cdebug;
45
48
int make_identifier ()
46
49
{
47
50
loc ();
48
-
51
+
52
+ // deal with universal identifiers
53
+ std::string final_identifier;
54
+ final_identifier.reserve (yyleng);
55
+
56
+ for (const char *p=yytext; *p!=0 ; p++)
57
+ {
58
+ if (p[0 ]==' \\ ' && (p[1 ]==' u' || p[1 ]==' U' ))
59
+ {
60
+ p++;
61
+ unsigned digits=(*p==' u' )?4 :8 ;
62
+ p++;
63
+ unsigned letter=hex_to_unsigned (p, digits);
64
+ for (; *p!=0 && digits>0 ; digits--, p++);
65
+
66
+ std::basic_string<unsigned > utf32;
67
+ utf32+=letter;
68
+
69
+ // turn into utf-8
70
+ std::string utf8_value=utf32_to_utf8 (utf32);
71
+ final_identifier+=utf8_value;
72
+ }
73
+ else
74
+ final_identifier+=*p;
75
+ }
76
+
49
77
// this hashes the identifier
50
- irep_idt base_name=yytext ;
78
+ irep_idt base_name=final_identifier ;
51
79
52
80
if (PARSER.cpp98 )
53
81
{
0 commit comments