Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update c_parser.py to fix string concatenation error #547

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Llewyllen
Copy link

@Llewyllen Llewyllen commented Jul 3, 2024

Do not remove consecutive double quotes, as it might result in a different string in case of an escaped octal or hexadecimal value at the end of the first string AND a numeric character at the beginning of the second string

e.g. "\07""7" must not be merged in "\077"

Do not remove consecutive double quotes, as it might result in a different string in case of an escaped octal or hexadecimal value at the end of the first string AND a numeric character at the beginning of the second string
@@ -1674,7 +1674,7 @@ def test_unified_string_literals(self):
self.assertEqual(d1, ['Constant', 'string', '"hello"'])

d2 = self.get_decl_init('char* s = "hello" " world";')
self.assertEqual(d2, ['Constant', 'string', '"hello world"'])
self.assertEqual(d2, ['Constant', 'string', '"hello"" world"'])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this makes no sense in the general case - it goes against language semantics (see the discussion on the issue)

Copy link
Author

@Llewyllen Llewyllen Jul 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly the general case is wrong in particular cases and cannot be extended to cover these. And keeping the double quotes only when required would be way too complicated (would need to check if the last character of the first string is an escaped hexa/octal character that might wrongly merge with the first character of the second string)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants