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

Correct syntax error printing in case of end of file #4350

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions jerry-main/main-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,18 @@ main_print_unhandled_exception (jerry_value_t error_value) /**< error value */
pos++;
}

uint32_t char_count = 0;
uint8_t ch;

do
/* Print character if:
* - The max line length is not reached.
* - The current position is valid (it is not the end of the source).
* - The current character is not a newline.
**/
for (uint32_t char_count = 0;
(char_count < SYNTAX_ERROR_MAX_LINE_LENGTH) && (pos < source_size) && (source_p[pos] != '\n');
char_count++, pos++)
{
ch = source_p[pos++];
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "%c", ch);
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "%c", source_p[pos]);
}
while (ch != '\n' && char_count++ < SYNTAX_ERROR_MAX_LINE_LENGTH);
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "\n");

jerry_port_release_source (source_p);

Expand Down