diff options
author | Pedro Alves <palves@redhat.com> | 2018-05-22 17:35:38 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2018-05-22 17:35:38 +0100 |
commit | b1b60145aedb8adcb0b9dcf43a5ae735c2f03b51 (patch) | |
tree | 777bdbeaa10580f6d5a404ad2d9b86abf11da683 /gdb/c-lang.c | |
parent | 0ec848ad25bb77edd9c9c3c097c3dd5b8874a6c0 (diff) | |
download | gdb-b1b60145aedb8adcb0b9dcf43a5ae735c2f03b51.zip gdb-b1b60145aedb8adcb0b9dcf43a5ae735c2f03b51.tar.gz gdb-b1b60145aedb8adcb0b9dcf43a5ae735c2f03b51.tar.bz2 |
Support UTF-8 identifiers in C/C++ expressions (PR gdb/22973)
Factor out cp_ident_is_alpha/cp_ident_is_alnum out of
gdb/cp-name-parser.y and use it in the C/C++ expression parser too.
New test included.
gdb/ChangeLog:
2018-05-22 Pedro Alves <palves@redhat.com>
張俊芝 <zjz@zjz.name>
PR gdb/22973
* c-exp.y: Include "c-support.h".
(parse_number, c_parse_escape, lex_one_token): Use TOLOWER instead
of tolower. Use c_ident_is_alpha to scan names.
* c-lang.c: Include "c-support.h".
(convert_ucn, convert_octal, convert_hex, convert_escape): Use
ISXDIGIT instead of isxdigit and ISDIGIT instead of isdigit.
* c-support.h: New file, with bits factored out from ...
* cp-name-parser.y: ... this file.
Include "c-support.h".
(cp_ident_is_alpha, cp_ident_is_alnum): Deleted, moved to
c-support.h and renamed.
(symbol_end, yylex): Adjust.
gdb/testsuite/ChangeLog:
2018-05-22 Pedro Alves <palves@redhat.com>
PR gdb/22973
* gdb.base/utf8-identifiers.c: New file.
* gdb.base/utf8-identifiers.exp: New file.
Diffstat (limited to 'gdb/c-lang.c')
-rw-r--r-- | gdb/c-lang.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 15e633f..6bbb470 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -25,6 +25,7 @@ #include "language.h" #include "varobj.h" #include "c-lang.h" +#include "c-support.h" #include "valprint.h" #include "macroscope.h" #include "charset.h" @@ -382,7 +383,7 @@ convert_ucn (char *p, char *limit, const char *dest_charset, gdb_byte data[4]; int i; - for (i = 0; i < length && p < limit && isxdigit (*p); ++i, ++p) + for (i = 0; i < length && p < limit && ISXDIGIT (*p); ++i, ++p) result = (result << 4) + host_hex_value (*p); for (i = 3; i >= 0; --i) @@ -424,7 +425,7 @@ convert_octal (struct type *type, char *p, unsigned long value = 0; for (i = 0; - i < 3 && p < limit && isdigit (*p) && *p != '8' && *p != '9'; + i < 3 && p < limit && ISDIGIT (*p) && *p != '8' && *p != '9'; ++i) { value = 8 * value + host_hex_value (*p); @@ -447,7 +448,7 @@ convert_hex (struct type *type, char *p, { unsigned long value = 0; - while (p < limit && isxdigit (*p)) + while (p < limit && ISXDIGIT (*p)) { value = 16 * value + host_hex_value (*p); ++p; @@ -488,7 +489,7 @@ convert_escape (struct type *type, const char *dest_charset, case 'x': ADVANCE; - if (!isxdigit (*p)) + if (!ISXDIGIT (*p)) error (_("\\x used with no following hex digits.")); p = convert_hex (type, p, limit, output); break; @@ -510,7 +511,7 @@ convert_escape (struct type *type, const char *dest_charset, int length = *p == 'u' ? 4 : 8; ADVANCE; - if (!isxdigit (*p)) + if (!ISXDIGIT (*p)) error (_("\\u used with no following hex digits")); p = convert_ucn (p, limit, dest_charset, output, length); } |