Skip to content

Commit

Permalink
Don't depend on unspecified ordering.
Browse files Browse the repository at this point in the history
Thanks to Matthew O'Connor for reporting this bug.
  • Loading branch information
ianh committed Dec 4, 2021
1 parent 01087f1 commit 0622ab1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/1-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -888,23 +888,26 @@ static size_t finish_token(uint32_t rule, size_t next_sibling, void *info) {
if (offset == 0)
abort();
write_tree(tree, offset);
tree->next_identifier_token_offset = offset - read_tree(&offset, tree);
tree->next_identifier_token_offset = offset;
tree->next_identifier_token_offset -= read_tree(&offset, tree);
break;
}
case 14: {
size_t offset = tree->next_string_token_offset;
if (offset == 0)
abort();
write_tree(tree, offset);
tree->next_string_token_offset = offset - read_tree(&offset, tree);
tree->next_string_token_offset = offset;
tree->next_string_token_offset -= read_tree(&offset, tree);
break;
}
case 15: {
size_t offset = tree->next_integer_token_offset;
if (offset == 0)
abort();
write_tree(tree, offset);
tree->next_integer_token_offset = offset - read_tree(&offset, tree);
tree->next_integer_token_offset = offset;
tree->next_integer_token_offset -= read_tree(&offset, tree);
break;
}
default:
Expand Down
3 changes: 2 additions & 1 deletion src/6a-generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ void generate(struct generator *gen)
output_line(out, " if (offset == 0)");
output_line(out, " abort();");
output_line(out, " write_tree(tree, offset);");
output_line(out, " tree->next_%%rule_token_offset = offset - read_tree(&offset, tree);");
output_line(out, " tree->next_%%rule_token_offset = offset;");
output_line(out, " tree->next_%%rule_token_offset -= read_tree(&offset, tree);");
output_line(out, " break;");
output_line(out, " }");
}
Expand Down

0 comments on commit 0622ab1

Please sign in to comment.