Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit bd98ba3

Browse files
author
Aaron Leung
committed
Working on better url scanning.
1 parent 952868e commit bd98ba3

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

prelexer.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,5 +383,32 @@ namespace Sass {
383383
const char* folders(const char* src) {
384384
return zero_plus< folder >(src);
385385
}
386+
387+
const char* chunk(const char* src) {
388+
char inside_str = 0;
389+
const char* p = src;
390+
size_t depth = 0;
391+
while (true) {
392+
if (!*p) {
393+
return 0;
394+
}
395+
else if (!inside_str && (*p == '"' || *p == '\'')) {
396+
inside_str = *p;
397+
}
398+
else if (*p == inside_str && *(p-1) != '\\') {
399+
inside_str = 0;
400+
}
401+
else if (*p == '(' && !inside_str) {
402+
++depth;
403+
}
404+
else if (*p == ')' && !inside_str) {
405+
if (depth == 0) return p;
406+
else --depth;
407+
}
408+
++p;
409+
}
410+
// unreachable
411+
return 0;
412+
}
386413
}
387414
}

prelexer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,5 +447,7 @@ namespace Sass {
447447
}
448448
return counter;
449449
}
450+
451+
const char* chunk(const char* src);
450452
}
451453
}

0 commit comments

Comments
 (0)