@@ -17873,7 +17873,7 @@ pm_parser_errors_format_sort(const pm_list_t *error_list, const pm_newline_list_
17873
17873
if (start.line == end.line) {
17874
17874
column_end = (uint32_t) end.column;
17875
17875
} else {
17876
- column_end = (uint32_t) (newline_list->offsets[start.line + 1 ] - newline_list->offsets[start.line] - 1);
17876
+ column_end = (uint32_t) (newline_list->offsets[start.line] - newline_list->offsets[start.line - 1 ] - 1);
17877
17877
}
17878
17878
17879
17879
// Ensure we have at least one column of error.
@@ -17892,16 +17892,16 @@ pm_parser_errors_format_sort(const pm_list_t *error_list, const pm_newline_list_
17892
17892
17893
17893
static inline void
17894
17894
pm_parser_errors_format_line(const pm_parser_t *parser, const pm_newline_list_t *newline_list, const char *number_prefix, size_t line, pm_buffer_t *buffer) {
17895
- const uint8_t *start = &parser->start[newline_list->offsets[line]];
17895
+ const uint8_t *start = &parser->start[newline_list->offsets[line - 1 ]];
17896
17896
const uint8_t *end;
17897
17897
17898
- if (line + 1 >= newline_list->size) {
17898
+ if (line >= newline_list->size) {
17899
17899
end = parser->end;
17900
17900
} else {
17901
- end = &parser->start[newline_list->offsets[line + 1 ]];
17901
+ end = &parser->start[newline_list->offsets[line]];
17902
17902
}
17903
17903
17904
- pm_buffer_append_format(buffer, number_prefix, (uint32_t) ( line + 1) );
17904
+ pm_buffer_append_format(buffer, number_prefix, (uint32_t) line);
17905
17905
pm_buffer_append_string(buffer, (const char *) start, (size_t) (end - start));
17906
17906
17907
17907
if (end == parser->end && end[-1] != '\n') {
@@ -17926,7 +17926,7 @@ pm_parser_errors_format(const pm_parser_t *parser, pm_buffer_t *buffer, bool col
17926
17926
// blank lines based on the maximum number of digits in the line numbers
17927
17927
// that are going to be displayed.
17928
17928
pm_error_format_t error_format;
17929
- size_t max_line_number = errors[error_list->size - 1].line + 1 ;
17929
+ size_t max_line_number = errors[error_list->size - 1].line;
17930
17930
17931
17931
if (max_line_number < 10) {
17932
17932
if (colorize) {
@@ -18008,7 +18008,7 @@ pm_parser_errors_format(const pm_parser_t *parser, pm_buffer_t *buffer, bool col
18008
18008
// the source before the error to give some context. We'll be careful not to
18009
18009
// display the same line twice in case the errors are close enough in the
18010
18010
// source.
18011
- uint32_t last_line = (uint32_t) -1 ;
18011
+ uint32_t last_line = 0 ;
18012
18012
const pm_encoding_t *encoding = parser->encoding;
18013
18013
18014
18014
for (size_t index = 0; index < error_list->size; index++) {
@@ -18054,7 +18054,7 @@ pm_parser_errors_format(const pm_parser_t *parser, pm_buffer_t *buffer, bool col
18054
18054
pm_buffer_append_string(buffer, error_format.blank_prefix, error_format.blank_prefix_length);
18055
18055
18056
18056
size_t column = 0;
18057
- const uint8_t *start = &parser->start[newline_list->offsets[error->line]];
18057
+ const uint8_t *start = &parser->start[newline_list->offsets[error->line - 1 ]];
18058
18058
18059
18059
while (column < error->column_end) {
18060
18060
if (column < error->column_start) {
@@ -18078,7 +18078,7 @@ pm_parser_errors_format(const pm_parser_t *parser, pm_buffer_t *buffer, bool col
18078
18078
// Here we determine how many lines of padding to display after the
18079
18079
// error, depending on where the next error is in source.
18080
18080
last_line = error->line;
18081
- size_t next_line = (index == error_list->size - 1) ? newline_list->size - 1 : errors[index + 1].line;
18081
+ size_t next_line = (index == error_list->size - 1) ? newline_list->size : errors[index + 1].line;
18082
18082
18083
18083
if (next_line - last_line > 1) {
18084
18084
pm_buffer_append_string(buffer, " ", 2);
0 commit comments