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

#include "..." parses the file name incorrectly. It is **not** a string literal. #89

Open
mrolle45 opened this issue Jan 5, 2024 · 1 comment
Labels

Comments

@mrolle45
Copy link

mrolle45 commented Jan 5, 2024

The difference between a string literal in C and a quoted header name is that the latter is " q-char-sequence " in the Standard (section 6.10.2). This is indeed also a valid string literal, but not vice versa.
A string literal can include an encoding prefix (such as L) and escape sequences.
pcpp looks for a string literal following #include. It uses the characters in the token's value as the file name. Instead, it should look for " q-char-sequence ".
Examples:

#include L"test.h"

This will try to open "test.h" but with wide characters in the string, which is not what is intended. Instead, this should be a syntax error (assuming L is not a macro).

#include "..\test.h"`

The intention is to open "test.h" in the parent directory (on Windows systems). The \ is just an ordinary character in the file name. pcpp will try to open "..\test.h" in the current directory, with ]t` being a tab character.

The fix
Use similar code to that used for #include < h-char-sequence >. Note (Standard section A.1.8), an h-char is any character other than > or \n.

@ned14 ned14 added the bug label Jan 7, 2024
@ned14
Copy link
Owner

ned14 commented Jan 7, 2024

Seems reasonable.

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

No branches or pull requests

2 participants