Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 26, 2023
1 parent 04c7a3c commit 515cd87
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/json5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,16 @@ class parser5
public:
std::string exceptionDetailInfo()
{
size_t start_point = _col;
auto len = _print_len;
auto current_line = _line_begin_cur;
std::stringstream ss;
ss << "at line " << _line << ", column " << _col + 1 << '\n';

while (read() != '\n' && _cur != _end && (_col - start_point) < 5)
;
ss << std::string(current_line, _cur) << '\n';
ss << std::setw(len) << '^' << '\n';
return ss.str();
}

Expand Down Expand Up @@ -771,6 +779,9 @@ inline typename parser5<StringT>::u8char parser5<StringT>::read()
if (len > 0) {
_print_len += (std::min)(len, 2_sz);
_cur += len;
if (_cur > _end) {
_cur = _end;
}
}
return _current_char;
}
Expand Down

0 comments on commit 515cd87

Please sign in to comment.