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

fix: don't log NUL characters #3037

Merged
merged 1 commit into from Feb 17, 2024
Merged

Conversation

amaanq
Copy link
Member

@amaanq amaanq commented Feb 17, 2024

Graphviz dot will fail with this character present

Closes #709

Graphviz dot will fail with this character present
@amaanq amaanq merged commit caa451f into tree-sitter:master Feb 17, 2024
12 of 13 checks passed
@@ -997,7 +997,7 @@ void ts_subtree__print_dot_graph(const Subtree *self, uint32_t start_offset,
ts_subtree_lookahead_bytes(*self)
);

if (ts_subtree_is_error(*self) && ts_subtree_child_count(*self) == 0) {
if (ts_subtree_is_error(*self) && ts_subtree_child_count(*self) == 0 && self->ptr->lookahead_char != 0) {
fprintf(f, "\ncharacter: '%c'", self->ptr->lookahead_char);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we a print a replacement character here e.g.NUL or \0

Copy link
Member Author

@amaanq amaanq Feb 17, 2024

Choose a reason for hiding this comment

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

Yeah maybe, well \0 itself wouldn't work but escaping it like \\0 would if that's what you mean. I initially just thought about the EOF case but there's also some languages where the nul byte is valid in certain spots as well.

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.

Graphviz generation sometimes fails with syntax error for dot
2 participants