From: Simon Marchi <simark@simark.ca>
To: 張俊芝 <zjz@zjz.name>, gdb-patches@sourceware.org
Subject: Re: support C/C++ identifiers named with non-ASCII characters
Date: Mon, 21 May 2018 14:21:00 -0000 [thread overview]
Message-ID: <8c8af079-dbb8-207b-5edf-86b99e9f5db8@simark.ca> (raw)
In-Reply-To: <9418d4f0-f22a-c587-cc34-2fa67afbd028@zjz.name>
On 2018-05-21 04:52 AM, å¼µä¿è wrote:
> Hello, team.
>
> This patch fixes the bug at
> https://sourceware.org/bugzilla/show_bug.cgi?id=22973 .
>
> Here is how to test the patch:
>
> Step 1. If you are using Clang or any other C compilers that have
> implemented
> support for Unicode identifiers, then create a C file with the
> following
> content:
>
> int main(int åé, char* å[])
> {
> struct é
> {
> int æ¸[3];
> } é = {100, 200, 300};
> int åº = 2;
> return 0;
> }
>
> Or if you are using GCC, create a C file with the following content as a
> workaround(GCC still doesn't actually support Unicode identifiers in
> 2018, which
> is a pity):
>
> int main(int \u53C3\u91CF, char* \u53C3[])
> {
> struct \u96C6
> {
> int \u6578[3];
> } \u96C6 = {100, 200, 300};
> int \u5E8F = 2;
> return 0;
> }
>
> Step 2. Compile the C file.
>
> Step 3. Run GDB for the compiled executable, add a breakpoint in "return 0".
>
> Step 4. Run until the breakpoint.
>
> Step 5. Test the following commands to see if they work:
> p åé
> p å
> p é
> p é.æ¸
> p é.æ¸[åº]
>
> Thanks for your review.
>
Hi Zhang,
Thanks for the patch, I tested it quickly, it seems to work as expected.
Could you please write a small test case in testsuite/gdb.base with the example
you gave, so we make sure this doesn't get broken later? If you can write it
in such a way that both clang and gcc understand it would be better, because
most people run the testuite using gcc to compile test programs.
I am not a specialist in lexing and parsing C, so can you explain quickly why
you think this is a good solution? Quickly, I understand that you change the
identifier recognition algorithm to a blacklist of characters rather than
a whitelist, so bytes that are not recognized (such as those that compose
the utf-8 encoded characters) are not rejected.
Given unlimited time, would the right solution be to use a lib to parse the
string as utf-8, and reject strings that are not valid utf-8?
Here are some not and formatting comments:
> +static bool is_identifier_separator (char);
You don't have to forward declare the function if it's not necessary.
> + /* '<' should not be a token separator, because it can be an open angle
> + bracket followed by a nested template identifier in C++. */
Please use two spaces after the final period (...C++. */).
> + if (is_identifier_separator(c))
Please use a space before the parentheses:
is_identifier_separator (c)
> + for (c = tokstart[namelen]; !is_identifier_separator(c);)
Here too.
Thanks!
Simon
next prev parent reply other threads:[~2018-05-21 14:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 9:54 張俊芝
2018-05-21 14:21 ` Simon Marchi [this message]
2018-05-21 15:27 ` Paul.Koning
2018-05-21 16:16 ` Eli Zaretskii
2018-05-21 18:34 ` Paul.Koning
[not found] ` <83tvr0ev0p.fsf@gnu.org>
2018-05-21 19:25 ` Paul.Koning
2018-05-21 20:43 ` Joseph Myers
2018-05-22 10:31 ` 張俊芝
2018-05-22 8:34 ` 張俊芝
[not found] ` <1b915196-3e97-4892-7426-be4211fe7889@zjz.name>
2018-05-21 18:00 ` 張俊芝
2018-05-21 18:03 ` 張俊芝
2018-05-21 18:14 ` Matt Rice
2018-05-22 7:06 ` 張俊芝
2018-05-22 14:39 ` Pedro Alves
2018-05-22 14:39 ` 張俊芝
2018-05-22 15:17 ` Pedro Alves
2018-05-22 16:42 ` Pedro Alves
2018-05-22 17:31 ` 張俊芝
2018-05-22 17:38 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8c8af079-dbb8-207b-5edf-86b99e9f5db8@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=zjz@zjz.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox