8000 #include "..." parses the file name incorrectly. It is **not** a string literal. · Issue #89 · ned14/pcpp · GitHub
[go: up one dir, main page]

Skip to content

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

@mrolle45

Description

@mrolle45

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0