Skip to content

Commit

Permalink
Improve error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Aug 29, 2015
1 parent 6d5b6b2 commit 139ca8d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2415,8 +2415,10 @@ namespace Sass {
{
int max_len = 14;
const char* pos = peek < optional_spaces >();
// backup position to last significant char
while (!*pos || Prelexer::is_space(*pos)) -- pos;
bool ellipsis_left = false;
const char* pos_left(pos - 1);
const char* pos_left(pos + 1);
if (pos_left < source) pos_left = source;
while (*pos_left && pos_left > source) {
if (pos - pos_left > max_len) {
Expand All @@ -2426,23 +2428,21 @@ namespace Sass {
const char* prev = pos_left - 1;
if (*prev == '\r') break;
if (*prev == '\n') break;
if (*prev == 10) break;
pos_left = prev;
}
bool ellipsis_right = false;
const char* pos_right(pos);
const char* pos_right(pos + 1);
while (*pos_right && pos_right <= end) {
if (pos_right - pos > max_len) {
ellipsis_right = true;
break;
}
if (*pos_right == '\r') break;
if (*pos_right == '\n') break;
if (*pos_left == 10) break;
++ pos_right;
}
std::string left(pos_left, pos);
std::string right(pos, pos_right);
std::string left(pos_left, pos + 1);
std::string right(pos + 1, pos_right);
if (ellipsis_left) left = ellipsis + left;
if (ellipsis_right) right = right + ellipsis;
// now pass new message to the more generic error function
Expand Down

0 comments on commit 139ca8d

Please sign in to comment.