sassc 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +13 -0
- data/Rakefile +1 -3
- data/ext/extconf.rb +13 -5
- data/ext/libsass/VERSION +1 -1
- data/ext/libsass/include/sass/base.h +2 -1
- data/ext/libsass/include/sass/context.h +1 -0
- data/ext/libsass/src/ast.cpp +49 -59
- data/ext/libsass/src/ast.hpp +263 -102
- data/ext/libsass/src/ast_def_macros.hpp +8 -0
- data/ext/libsass/src/ast_fwd_decl.cpp +2 -1
- data/ext/libsass/src/ast_fwd_decl.hpp +40 -116
- data/ext/libsass/src/ast_helpers.hpp +292 -0
- data/ext/libsass/src/ast_sel_cmp.cpp +209 -722
- data/ext/libsass/src/ast_sel_super.cpp +539 -0
- data/ext/libsass/src/ast_sel_unify.cpp +207 -212
- data/ext/libsass/src/ast_sel_weave.cpp +616 -0
- data/ext/libsass/src/ast_selectors.cpp +559 -1001
- data/ext/libsass/src/ast_selectors.hpp +311 -367
- data/ext/libsass/src/ast_supports.cpp +1 -17
- data/ext/libsass/src/ast_values.cpp +216 -29
- data/ext/libsass/src/ast_values.hpp +42 -33
- data/ext/libsass/src/bind.cpp +1 -1
- data/ext/libsass/src/cencode.c +4 -6
- data/ext/libsass/src/check_nesting.cpp +5 -6
- data/ext/libsass/src/check_nesting.hpp +4 -0
- data/ext/libsass/src/color_maps.cpp +11 -10
- data/ext/libsass/src/color_maps.hpp +0 -8
- data/ext/libsass/src/constants.cpp +5 -0
- data/ext/libsass/src/constants.hpp +6 -0
- data/ext/libsass/src/context.cpp +30 -60
- data/ext/libsass/src/context.hpp +8 -20
- data/ext/libsass/src/cssize.cpp +36 -120
- data/ext/libsass/src/cssize.hpp +4 -10
- data/ext/libsass/src/dart_helpers.hpp +199 -0
- data/ext/libsass/src/debugger.hpp +364 -207
- data/ext/libsass/src/emitter.cpp +3 -4
- data/ext/libsass/src/emitter.hpp +0 -2
- data/ext/libsass/src/environment.hpp +5 -0
- data/ext/libsass/src/error_handling.cpp +21 -0
- data/ext/libsass/src/error_handling.hpp +25 -3
- data/ext/libsass/src/eval.cpp +33 -153
- data/ext/libsass/src/eval.hpp +11 -13
- data/ext/libsass/src/eval_selectors.cpp +75 -0
- data/ext/libsass/src/expand.cpp +214 -167
- data/ext/libsass/src/expand.hpp +26 -6
- data/ext/libsass/src/extender.cpp +1186 -0
- data/ext/libsass/src/extender.hpp +399 -0
- data/ext/libsass/src/extension.cpp +43 -0
- data/ext/libsass/src/extension.hpp +89 -0
- data/ext/libsass/src/file.cpp +15 -14
- data/ext/libsass/src/file.hpp +5 -12
- data/ext/libsass/src/fn_colors.cpp +12 -10
- data/ext/libsass/src/fn_lists.cpp +12 -11
- data/ext/libsass/src/fn_miscs.cpp +22 -34
- data/ext/libsass/src/fn_numbers.cpp +13 -6
- data/ext/libsass/src/fn_selectors.cpp +94 -124
- data/ext/libsass/src/fn_strings.cpp +16 -14
- data/ext/libsass/src/fn_utils.cpp +5 -6
- data/ext/libsass/src/fn_utils.hpp +9 -3
- data/ext/libsass/src/inspect.cpp +154 -117
- data/ext/libsass/src/inspect.hpp +10 -8
- data/ext/libsass/src/lexer.cpp +17 -81
- data/ext/libsass/src/lexer.hpp +5 -16
- data/ext/libsass/src/listize.cpp +22 -36
- data/ext/libsass/src/listize.hpp +8 -9
- data/ext/libsass/src/memory/SharedPtr.hpp +39 -5
- data/ext/libsass/src/operation.hpp +27 -17
- data/ext/libsass/src/operators.cpp +1 -0
- data/ext/libsass/src/ordered_map.hpp +112 -0
- data/ext/libsass/src/output.cpp +30 -49
- data/ext/libsass/src/output.hpp +1 -1
- data/ext/libsass/src/parser.cpp +211 -381
- data/ext/libsass/src/parser.hpp +17 -15
- data/ext/libsass/src/parser_selectors.cpp +189 -0
- data/ext/libsass/src/permutate.hpp +140 -0
- data/ext/libsass/src/position.hpp +1 -1
- data/ext/libsass/src/prelexer.cpp +6 -6
- data/ext/libsass/src/remove_placeholders.cpp +55 -56
- data/ext/libsass/src/remove_placeholders.hpp +21 -18
- data/ext/libsass/src/sass.hpp +1 -0
- data/ext/libsass/src/sass2scss.cpp +4 -4
- data/ext/libsass/src/sass_context.cpp +42 -91
- data/ext/libsass/src/sass_context.hpp +2 -2
- data/ext/libsass/src/sass_functions.cpp +1 -1
- data/ext/libsass/src/sass_values.cpp +0 -1
- data/ext/libsass/src/stylesheet.cpp +22 -0
- data/ext/libsass/src/stylesheet.hpp +57 -0
- data/ext/libsass/src/to_value.cpp +2 -2
- data/ext/libsass/src/to_value.hpp +1 -1
- data/ext/libsass/src/units.cpp +5 -3
- data/ext/libsass/src/util.cpp +10 -12
- data/ext/libsass/src/util.hpp +2 -3
- data/ext/libsass/src/util_string.cpp +111 -61
- data/ext/libsass/src/util_string.hpp +61 -8
- data/lib/sassc/engine.rb +5 -3
- data/lib/sassc/functions_handler.rb +8 -8
- data/lib/sassc/native.rb +1 -1
- data/lib/sassc/script.rb +4 -4
- data/lib/sassc/version.rb +1 -1
- data/test/functions_test.rb +18 -1
- data/test/native_test.rb +1 -1
- metadata +17 -12
- data/ext/libsass/src/extend.cpp +0 -2132
- data/ext/libsass/src/extend.hpp +0 -86
- data/ext/libsass/src/node.cpp +0 -322
- data/ext/libsass/src/node.hpp +0 -118
- data/ext/libsass/src/paths.hpp +0 -71
- data/ext/libsass/src/sass_util.cpp +0 -152
- data/ext/libsass/src/sass_util.hpp +0 -256
- data/ext/libsass/src/subset_map.cpp +0 -58
- data/ext/libsass/src/subset_map.hpp +0 -76
|
@@ -90,7 +90,7 @@ struct Sass_Context : Sass_Options
|
|
|
90
90
|
char* error_file;
|
|
91
91
|
size_t error_line;
|
|
92
92
|
size_t error_column;
|
|
93
|
-
|
|
93
|
+
char* error_src;
|
|
94
94
|
|
|
95
95
|
// report imported files
|
|
96
96
|
char** included_files;
|
|
@@ -126,4 +126,4 @@ struct Sass_Compiler {
|
|
|
126
126
|
Sass::Block_Obj root;
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
#endif
|
|
129
|
+
#endif
|
|
@@ -101,7 +101,7 @@ extern "C" {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// Creator for a single import entry returned by the custom importer inside the list
|
|
104
|
-
// We take ownership of the memory for source and srcmap (freed when context is
|
|
104
|
+
// We take ownership of the memory for source and srcmap (freed when context is destroyed)
|
|
105
105
|
Sass_Import_Entry ADDCALL sass_make_import(const char* imp_path, const char* abs_path, char* source, char* srcmap)
|
|
106
106
|
{
|
|
107
107
|
Sass_Import* v = (Sass_Import*) calloc(1, sizeof(Sass_Import));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
3
|
+
#include "sass.hpp"
|
|
4
|
+
|
|
5
|
+
#include "stylesheet.hpp"
|
|
6
|
+
|
|
7
|
+
namespace Sass {
|
|
8
|
+
|
|
9
|
+
// Constructor
|
|
10
|
+
Sass::StyleSheet::StyleSheet(const Resource& res, Block_Obj root) :
|
|
11
|
+
Resource(res),
|
|
12
|
+
root(root)
|
|
13
|
+
{
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
StyleSheet::StyleSheet(const StyleSheet& sheet) :
|
|
17
|
+
Resource(sheet),
|
|
18
|
+
root(sheet.root)
|
|
19
|
+
{
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#ifndef SASS_STYLESHEET_H
|
|
2
|
+
#define SASS_STYLESHEET_H
|
|
3
|
+
|
|
4
|
+
// sass.hpp must go before all system headers to get the
|
|
5
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
6
|
+
#include "sass.hpp"
|
|
7
|
+
|
|
8
|
+
#include "ast_fwd_decl.hpp"
|
|
9
|
+
#include "extender.hpp"
|
|
10
|
+
#include "file.hpp"
|
|
11
|
+
|
|
12
|
+
namespace Sass {
|
|
13
|
+
|
|
14
|
+
// parsed stylesheet from loaded resource
|
|
15
|
+
// this should be a `Module` for sass 4.0
|
|
16
|
+
class StyleSheet : public Resource {
|
|
17
|
+
public:
|
|
18
|
+
|
|
19
|
+
// The canonical URL for this module's source file. This may be `null`
|
|
20
|
+
// if the module was loaded from a string without a URL provided.
|
|
21
|
+
// Uri get url;
|
|
22
|
+
|
|
23
|
+
// Modules that this module uses.
|
|
24
|
+
// List<Module> get upstream;
|
|
25
|
+
|
|
26
|
+
// The module's variables.
|
|
27
|
+
// Map<String, Value> get variables;
|
|
28
|
+
|
|
29
|
+
// The module's functions. Implementations must ensure
|
|
30
|
+
// that each [Callable] is stored under its own name.
|
|
31
|
+
// Map<String, Callable> get functions;
|
|
32
|
+
|
|
33
|
+
// The module's mixins. Implementations must ensure that
|
|
34
|
+
// each [Callable] is stored under its own name.
|
|
35
|
+
// Map<String, Callable> get mixins;
|
|
36
|
+
|
|
37
|
+
// The extensions defined in this module, which is also able to update
|
|
38
|
+
// [css]'s style rules in-place based on downstream extensions.
|
|
39
|
+
// Extender extender;
|
|
40
|
+
|
|
41
|
+
// The module's CSS tree.
|
|
42
|
+
Block_Obj root;
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
|
|
46
|
+
// default argument constructor
|
|
47
|
+
StyleSheet(const Resource& res, Block_Obj root);
|
|
48
|
+
|
|
49
|
+
// Copy constructor
|
|
50
|
+
StyleSheet(const StyleSheet& res);
|
|
51
|
+
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#endif
|
|
@@ -95,8 +95,8 @@ namespace Sass {
|
|
|
95
95
|
return arg->value()->perform(this);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
//
|
|
99
|
-
Value* To_Value::operator()(
|
|
98
|
+
// SelectorList is converted to a string
|
|
99
|
+
Value* To_Value::operator()(SelectorList* s)
|
|
100
100
|
{
|
|
101
101
|
return SASS_MEMORY_NEW(String_Quoted,
|
|
102
102
|
s->pstate(),
|
data/ext/libsass/src/units.cpp
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#include "sass.hpp"
|
|
2
|
+
#include <map>
|
|
2
3
|
#include <stdexcept>
|
|
4
|
+
#include <algorithm>
|
|
3
5
|
#include "units.hpp"
|
|
4
6
|
#include "error_handling.hpp"
|
|
5
7
|
|
|
@@ -328,7 +330,7 @@ namespace Sass {
|
|
|
328
330
|
// has the advantage that they will be pre-sorted
|
|
329
331
|
std::map<std::string, int> exponents;
|
|
330
332
|
|
|
331
|
-
// initialize by summing up
|
|
333
|
+
// initialize by summing up occurrences in unit vectors
|
|
332
334
|
// this will already cancel out equivalent units (e.q. px/px)
|
|
333
335
|
for (size_t i = 0; i < iL; i ++) exponents[numerators[i]] += 1;
|
|
334
336
|
for (size_t n = 0; n < nL; n ++) exponents[denominators[n]] -= 1;
|
|
@@ -394,7 +396,7 @@ namespace Sass {
|
|
|
394
396
|
denominators.size() == 0;
|
|
395
397
|
}
|
|
396
398
|
|
|
397
|
-
// this does not cover all cases (multiple
|
|
399
|
+
// this does not cover all cases (multiple preferred units)
|
|
398
400
|
double Units::convert_factor(const Units& r) const
|
|
399
401
|
{
|
|
400
402
|
|
|
@@ -465,7 +467,7 @@ namespace Sass {
|
|
|
465
467
|
{
|
|
466
468
|
// get and increment afterwards
|
|
467
469
|
const std::string r_den = *(r_den_it);
|
|
468
|
-
// get possible
|
|
470
|
+
// get possible conversion factor for units
|
|
469
471
|
double conversion = conversion_factor(l_den, r_den);
|
|
470
472
|
// skip incompatible denominator
|
|
471
473
|
if (conversion == 0) {
|
data/ext/libsass/src/util.cpp
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include "sass.h"
|
|
3
3
|
#include "ast.hpp"
|
|
4
4
|
#include "util.hpp"
|
|
5
|
+
#include "util_string.hpp"
|
|
5
6
|
#include "lexer.hpp"
|
|
6
7
|
#include "prelexer.hpp"
|
|
7
8
|
#include "constants.hpp"
|
|
@@ -26,8 +27,8 @@ namespace Sass {
|
|
|
26
27
|
#endif
|
|
27
28
|
|
|
28
29
|
// https://github.com/sass/sass/commit/4e3e1d5684cc29073a507578fc977434ff488c93
|
|
29
|
-
if (fmod(val, 1) - 0.5 > - std::pow(0.1, precision + 1)) return std::ceil(val);
|
|
30
|
-
else if (fmod(val, 1) - 0.5 > std::pow(0.1, precision)) return std::floor(val);
|
|
30
|
+
if (std::fmod(val, 1) - 0.5 > - std::pow(0.1, precision + 1)) return std::ceil(val);
|
|
31
|
+
else if (std::fmod(val, 1) - 0.5 > std::pow(0.1, precision)) return std::floor(val);
|
|
31
32
|
// work around some compiler issue
|
|
32
33
|
// cygwin has it not defined in std
|
|
33
34
|
using namespace std;
|
|
@@ -289,7 +290,7 @@ namespace Sass {
|
|
|
289
290
|
|
|
290
291
|
// parse as many sequence chars as possible
|
|
291
292
|
// ToDo: Check if ruby aborts after possible max
|
|
292
|
-
while (i + len < L && s[i + len] &&
|
|
293
|
+
while (i + len < L && s[i + len] && Util::ascii_isxdigit(static_cast<unsigned char>(s[i + len]))) ++ len;
|
|
293
294
|
|
|
294
295
|
if (len > 1) {
|
|
295
296
|
|
|
@@ -375,7 +376,7 @@ namespace Sass {
|
|
|
375
376
|
|
|
376
377
|
// parse as many sequence chars as possible
|
|
377
378
|
// ToDo: Check if ruby aborts after possible max
|
|
378
|
-
while (i + len < L && s[i + len] &&
|
|
379
|
+
while (i + len < L && s[i + len] && Util::ascii_isxdigit(static_cast<unsigned char>(s[i + len]))) ++ len;
|
|
379
380
|
|
|
380
381
|
// hex string?
|
|
381
382
|
if (keep_utf8_sequences) {
|
|
@@ -535,7 +536,7 @@ namespace Sass {
|
|
|
535
536
|
|
|
536
537
|
Block_Obj b = r->block();
|
|
537
538
|
|
|
538
|
-
|
|
539
|
+
SelectorList* sl = r->selector();
|
|
539
540
|
bool hasSelectors = sl ? sl->length() > 0 : false;
|
|
540
541
|
|
|
541
542
|
if (!hasSelectors) {
|
|
@@ -625,11 +626,12 @@ namespace Sass {
|
|
|
625
626
|
return false;
|
|
626
627
|
}
|
|
627
628
|
|
|
628
|
-
bool isPrintable(
|
|
629
|
+
bool isPrintable(CssMediaRule* m, Sass_Output_Style style)
|
|
629
630
|
{
|
|
630
631
|
if (m == nullptr) return false;
|
|
631
632
|
Block_Obj b = m->block();
|
|
632
633
|
if (b == nullptr) return false;
|
|
634
|
+
if (m->empty()) return false;
|
|
633
635
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
|
634
636
|
Statement_Obj stm = b->at(i);
|
|
635
637
|
if (Cast<Directive>(stm)) return true;
|
|
@@ -649,7 +651,7 @@ namespace Sass {
|
|
|
649
651
|
return true;
|
|
650
652
|
}
|
|
651
653
|
}
|
|
652
|
-
else if (
|
|
654
|
+
else if (CssMediaRule* mb = Cast<CssMediaRule>(stm)) {
|
|
653
655
|
if (isPrintable(mb, style)) {
|
|
654
656
|
return true;
|
|
655
657
|
}
|
|
@@ -702,7 +704,7 @@ namespace Sass {
|
|
|
702
704
|
return true;
|
|
703
705
|
}
|
|
704
706
|
}
|
|
705
|
-
else if (
|
|
707
|
+
else if (CssMediaRule * m = Cast<CssMediaRule>(stm)) {
|
|
706
708
|
if (isPrintable(m, style)) {
|
|
707
709
|
return true;
|
|
708
710
|
}
|
|
@@ -717,9 +719,5 @@ namespace Sass {
|
|
|
717
719
|
return false;
|
|
718
720
|
}
|
|
719
721
|
|
|
720
|
-
bool isAscii(const char chr) {
|
|
721
|
-
return unsigned(chr) < 128;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
722
|
}
|
|
725
723
|
}
|
data/ext/libsass/src/util.hpp
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
#include "sass/base.h"
|
|
9
9
|
#include "ast_fwd_decl.hpp"
|
|
10
10
|
|
|
11
|
+
#include <cmath>
|
|
11
12
|
#include <cstring>
|
|
12
13
|
#include <vector>
|
|
13
14
|
#include <string>
|
|
14
15
|
#include <assert.h>
|
|
15
|
-
#include <math.h>
|
|
16
16
|
|
|
17
17
|
#define SASS_ASSERT(cond, msg) assert(cond && msg)
|
|
18
18
|
|
|
@@ -93,13 +93,12 @@ namespace Sass {
|
|
|
93
93
|
|
|
94
94
|
bool isPrintable(Ruleset* r, Sass_Output_Style style = NESTED);
|
|
95
95
|
bool isPrintable(Supports_Block* r, Sass_Output_Style style = NESTED);
|
|
96
|
-
bool isPrintable(
|
|
96
|
+
bool isPrintable(CssMediaRule* r, Sass_Output_Style style = NESTED);
|
|
97
97
|
bool isPrintable(Comment* b, Sass_Output_Style style = NESTED);
|
|
98
98
|
bool isPrintable(Block_Obj b, Sass_Output_Style style = NESTED);
|
|
99
99
|
bool isPrintable(String_Constant* s, Sass_Output_Style style = NESTED);
|
|
100
100
|
bool isPrintable(String_Quoted* s, Sass_Output_Style style = NESTED);
|
|
101
101
|
bool isPrintable(Declaration* d, Sass_Output_Style style = NESTED);
|
|
102
|
-
bool isAscii(const char chr);
|
|
103
102
|
|
|
104
103
|
}
|
|
105
104
|
}
|
|
@@ -1,75 +1,125 @@
|
|
|
1
1
|
#include "util_string.hpp"
|
|
2
2
|
|
|
3
|
+
#include <iostream>
|
|
3
4
|
#include <algorithm>
|
|
4
5
|
|
|
5
6
|
namespace Sass {
|
|
6
|
-
namespace Util {
|
|
7
|
+
namespace Util {
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
// ##########################################################################
|
|
10
|
+
// Special case insensitive string matcher. We can optimize
|
|
11
|
+
// the more general compare case quite a bit by requiring
|
|
12
|
+
// consumers to obey some rules (lowercase and no space).
|
|
13
|
+
// - `literal` must only contain lower case ascii characters
|
|
14
|
+
// there is one edge case where this could give false positives
|
|
15
|
+
// test could contain a (non-ascii) char exactly 32 below literal
|
|
16
|
+
// ##########################################################################
|
|
17
|
+
bool equalsLiteral(const char* lit, const std::string& test) {
|
|
18
|
+
// Work directly on characters
|
|
19
|
+
const char* src = test.c_str();
|
|
20
|
+
// There is a small chance that the search string
|
|
21
|
+
// Is longer than the rest of the string to look at
|
|
22
|
+
while (*lit && (*src == *lit || *src + 32 == *lit)) {
|
|
23
|
+
++src, ++lit;
|
|
24
|
+
}
|
|
25
|
+
// True if literal is at end
|
|
26
|
+
// If not test was too long
|
|
27
|
+
return *lit == 0;
|
|
28
|
+
}
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
while (true) {
|
|
24
|
-
const std::size_t newline = str.find_first_of("\n\f\r", pos);
|
|
25
|
-
if (newline == std::string::npos) break;
|
|
26
|
-
result.append(str, pos, newline - pos);
|
|
27
|
-
result += '\n';
|
|
28
|
-
if (str[newline] == '\r' && str[newline + 1] == '\n') {
|
|
29
|
-
pos = newline + 2;
|
|
30
|
-
} else {
|
|
31
|
-
pos = newline + 1;
|
|
30
|
+
void ascii_str_tolower(std::string* s) {
|
|
31
|
+
for (auto& ch : *s) {
|
|
32
|
+
ch = ascii_tolower(static_cast<unsigned char>(ch));
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
|
-
}
|
|
34
|
-
result.append(str, pos, std::string::npos);
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
36
|
+
void ascii_str_toupper(std::string* s) {
|
|
37
|
+
for (auto& ch : *s) {
|
|
38
|
+
ch = ascii_toupper(static_cast<unsigned char>(ch));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
43
41
|
|
|
44
|
-
std::string
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
normalized += str;
|
|
50
|
-
} else {
|
|
51
|
-
normalized = str;
|
|
52
|
-
}
|
|
53
|
-
return normalized;
|
|
54
|
-
}
|
|
42
|
+
std::string rtrim(std::string str) {
|
|
43
|
+
auto it = std::find_if_not(str.rbegin(), str.rend(), ascii_isspace);
|
|
44
|
+
str.erase(str.rend() - it);
|
|
45
|
+
return str;
|
|
46
|
+
}
|
|
55
47
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
// ###########################################################################
|
|
49
|
+
// Returns [name] without a vendor prefix.
|
|
50
|
+
// If [name] has no vendor prefix, it's returned as-is.
|
|
51
|
+
// ###########################################################################
|
|
52
|
+
std::string unvendor(const std::string& name)
|
|
53
|
+
{
|
|
54
|
+
if (name.size() < 2) return name;
|
|
55
|
+
if (name[0] != '-') return name;
|
|
56
|
+
if (name[1] == '-') return name;
|
|
57
|
+
for (size_t i = 2; i < name.size(); i++) {
|
|
58
|
+
if (name[i] == '-') return name.substr(i + 1);
|
|
59
|
+
}
|
|
60
|
+
return name;
|
|
61
|
+
}
|
|
62
|
+
// EO unvendor
|
|
63
|
+
|
|
64
|
+
std::string normalize_newlines(const std::string& str) {
|
|
65
|
+
std::string result;
|
|
66
|
+
result.reserve(str.size());
|
|
67
|
+
std::size_t pos = 0;
|
|
68
|
+
while (true) {
|
|
69
|
+
const std::size_t newline = str.find_first_of("\n\f\r", pos);
|
|
70
|
+
if (newline == std::string::npos) break;
|
|
71
|
+
result.append(str, pos, newline - pos);
|
|
72
|
+
result += '\n';
|
|
73
|
+
if (str[newline] == '\r' && str[newline + 1] == '\n') {
|
|
74
|
+
pos = newline + 2;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
pos = newline + 1;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
result.append(str, pos, std::string::npos);
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
std::string normalize_underscores(const std::string& str) {
|
|
85
|
+
std::string normalized = str;
|
|
86
|
+
std::replace(normalized.begin(), normalized.end(), '_', '-');
|
|
87
|
+
return normalized;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
std::string normalize_decimals(const std::string& str) {
|
|
91
|
+
std::string normalized;
|
|
92
|
+
if (!str.empty() && str[0] == '.') {
|
|
93
|
+
normalized.reserve(str.size() + 1);
|
|
94
|
+
normalized += '0';
|
|
95
|
+
normalized += str;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
normalized = str;
|
|
99
|
+
}
|
|
100
|
+
return normalized;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
char opening_bracket_for(char closing_bracket) {
|
|
104
|
+
switch (closing_bracket) {
|
|
105
|
+
case ')': return '(';
|
|
106
|
+
case ']': return '[';
|
|
107
|
+
case '}': return '{';
|
|
108
|
+
default: return '\0';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
char closing_bracket_for(char opening_bracket) {
|
|
113
|
+
switch (opening_bracket) {
|
|
114
|
+
case '(': return ')';
|
|
115
|
+
case '[': return ']';
|
|
116
|
+
case '{': return '}';
|
|
117
|
+
default: return '\0';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
64
120
|
|
|
65
|
-
char closing_bracket_for(char opening_bracket) {
|
|
66
|
-
switch (opening_bracket) {
|
|
67
|
-
case '(': return ')';
|
|
68
|
-
case '[': return ']';
|
|
69
|
-
case '{': return '}';
|
|
70
|
-
default: return '\0';
|
|
71
121
|
}
|
|
72
|
-
|
|
122
|
+
// namespace Util
|
|
73
123
|
|
|
74
|
-
}
|
|
75
|
-
|
|
124
|
+
}
|
|
125
|
+
// namespace Sass
|