sassc 1.11.4 → 1.12.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 +5 -5
- data/.travis.yml +2 -2
- data/CODE_OF_CONDUCT.md +10 -0
- data/README.md +4 -1
- data/ext/libsass/.editorconfig +1 -1
- data/ext/libsass/.github/CONTRIBUTING.md +7 -7
- data/ext/libsass/.github/ISSUE_TEMPLATE.md +31 -6
- data/ext/libsass/.gitignore +3 -0
- data/ext/libsass/.travis.yml +37 -18
- data/ext/libsass/GNUmakefile.am +23 -37
- data/ext/libsass/Makefile +10 -6
- data/ext/libsass/Makefile.conf +3 -0
- data/ext/libsass/Readme.md +68 -63
- data/ext/libsass/appveyor.yml +7 -3
- data/ext/libsass/configure.ac +10 -14
- data/ext/libsass/docs/api-context-internal.md +29 -21
- data/ext/libsass/docs/api-context.md +26 -6
- data/ext/libsass/docs/api-doc.md +49 -16
- data/ext/libsass/docs/api-function-example.md +1 -1
- data/ext/libsass/docs/api-function.md +31 -7
- data/ext/libsass/docs/api-importer.md +19 -19
- data/ext/libsass/docs/api-value.md +4 -2
- data/ext/libsass/docs/build-on-windows.md +4 -4
- data/ext/libsass/docs/build-with-mingw.md +3 -3
- data/ext/libsass/docs/build.md +9 -9
- data/ext/libsass/docs/custom-functions-internal.md +10 -8
- data/ext/libsass/docs/implementations.md +20 -8
- data/ext/libsass/docs/unicode.md +16 -10
- data/ext/libsass/include/sass/base.h +0 -3
- data/ext/libsass/include/sass/context.h +20 -2
- data/ext/libsass/include/sass/functions.h +31 -0
- data/ext/libsass/include/sass/values.h +3 -1
- data/ext/libsass/include/sass/version.h +1 -1
- data/ext/libsass/include/sass/version.h.in +1 -1
- data/ext/libsass/include/sass2scss.h +1 -1
- data/ext/libsass/res/resource.rc +6 -6
- data/ext/libsass/script/ci-build-libsass +10 -5
- data/ext/libsass/script/ci-build-plugin +62 -0
- data/ext/libsass/script/ci-install-compiler +1 -1
- data/ext/libsass/script/ci-install-deps +4 -7
- data/ext/libsass/script/ci-report-coverage +13 -3
- data/ext/libsass/script/tap-driver +1 -1
- data/ext/libsass/script/tap-runner +1 -1
- data/ext/libsass/src/GNUmakefile.am +1 -1
- data/ext/libsass/src/ast.cpp +537 -762
- data/ext/libsass/src/ast.hpp +377 -419
- data/ext/libsass/src/ast_def_macros.hpp +26 -1
- data/ext/libsass/src/ast_fwd_decl.cpp +29 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +94 -21
- data/ext/libsass/src/b64/encode.h +3 -1
- data/ext/libsass/src/backtrace.cpp +46 -0
- data/ext/libsass/src/backtrace.hpp +7 -54
- data/ext/libsass/src/bind.cpp +72 -50
- data/ext/libsass/src/bind.hpp +0 -1
- data/ext/libsass/src/cencode.c +6 -0
- data/ext/libsass/src/check_nesting.cpp +157 -135
- data/ext/libsass/src/check_nesting.hpp +11 -10
- data/ext/libsass/src/color_maps.cpp +10 -6
- data/ext/libsass/src/color_maps.hpp +6 -8
- data/ext/libsass/src/constants.cpp +4 -3
- data/ext/libsass/src/constants.hpp +4 -3
- data/ext/libsass/src/context.cpp +110 -47
- data/ext/libsass/src/context.hpp +11 -1
- data/ext/libsass/src/cssize.cpp +105 -94
- data/ext/libsass/src/cssize.hpp +4 -5
- data/ext/libsass/src/debugger.hpp +247 -244
- data/ext/libsass/src/emitter.cpp +30 -6
- data/ext/libsass/src/emitter.hpp +7 -0
- data/ext/libsass/src/environment.cpp +67 -16
- data/ext/libsass/src/environment.hpp +28 -7
- data/ext/libsass/src/error_handling.cpp +92 -64
- data/ext/libsass/src/error_handling.hpp +64 -43
- data/ext/libsass/src/eval.cpp +494 -544
- data/ext/libsass/src/eval.hpp +17 -23
- data/ext/libsass/src/expand.cpp +182 -154
- data/ext/libsass/src/expand.hpp +4 -5
- data/ext/libsass/src/extend.cpp +299 -291
- data/ext/libsass/src/extend.hpp +46 -11
- data/ext/libsass/src/file.cpp +103 -36
- data/ext/libsass/src/file.hpp +21 -4
- data/ext/libsass/src/functions.cpp +561 -312
- data/ext/libsass/src/functions.hpp +8 -5
- data/ext/libsass/src/inspect.cpp +108 -53
- data/ext/libsass/src/inspect.hpp +5 -2
- data/ext/libsass/src/lexer.cpp +15 -7
- data/ext/libsass/src/lexer.hpp +13 -4
- data/ext/libsass/src/listize.cpp +3 -2
- data/ext/libsass/src/listize.hpp +0 -1
- data/ext/libsass/src/memory/SharedPtr.cpp +16 -18
- data/ext/libsass/src/memory/SharedPtr.hpp +47 -43
- data/ext/libsass/src/node.cpp +34 -38
- data/ext/libsass/src/node.hpp +6 -8
- data/ext/libsass/src/operation.hpp +2 -2
- data/ext/libsass/src/operators.cpp +240 -0
- data/ext/libsass/src/operators.hpp +30 -0
- data/ext/libsass/src/output.cpp +22 -20
- data/ext/libsass/src/parser.cpp +719 -358
- data/ext/libsass/src/parser.hpp +57 -22
- data/ext/libsass/src/plugins.cpp +28 -10
- data/ext/libsass/src/position.cpp +21 -3
- data/ext/libsass/src/position.hpp +2 -1
- data/ext/libsass/src/prelexer.cpp +104 -19
- data/ext/libsass/src/prelexer.hpp +10 -3
- data/ext/libsass/src/remove_placeholders.cpp +9 -10
- data/ext/libsass/src/remove_placeholders.hpp +1 -5
- data/ext/libsass/src/sass.cpp +62 -4
- data/ext/libsass/src/sass.hpp +5 -2
- data/ext/libsass/src/sass_context.cpp +96 -58
- data/ext/libsass/src/sass_context.hpp +7 -5
- data/ext/libsass/src/sass_functions.cpp +63 -1
- data/ext/libsass/src/sass_functions.hpp +19 -1
- data/ext/libsass/src/sass_util.cpp +3 -3
- data/ext/libsass/src/sass_util.hpp +4 -4
- data/ext/libsass/src/sass_values.cpp +42 -39
- data/ext/libsass/src/sass_values.hpp +2 -1
- data/ext/libsass/src/source_map.cpp +16 -18
- data/ext/libsass/src/subset_map.cpp +6 -8
- data/ext/libsass/src/subset_map.hpp +6 -6
- data/ext/libsass/src/to_c.cpp +2 -2
- data/ext/libsass/src/to_value.cpp +8 -3
- data/ext/libsass/src/to_value.hpp +1 -0
- data/ext/libsass/src/units.cpp +349 -45
- data/ext/libsass/src/units.hpp +39 -22
- data/ext/libsass/src/utf8/checked.h +7 -0
- data/ext/libsass/src/utf8/unchecked.h +7 -0
- data/ext/libsass/src/utf8_string.cpp +1 -1
- data/ext/libsass/src/util.cpp +139 -45
- data/ext/libsass/src/util.hpp +4 -7
- data/ext/libsass/src/values.cpp +15 -23
- data/ext/libsass/win/libsass.sln +13 -2
- data/ext/libsass/win/libsass.sln.DotSettings +9 -0
- data/ext/libsass/win/libsass.targets +3 -0
- data/ext/libsass/win/libsass.vcxproj.filters +9 -0
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +1 -1
- data/test/native_test.rb +1 -1
- metadata +11 -4
data/ext/libsass/src/units.hpp
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include <cmath>
|
|
5
5
|
#include <string>
|
|
6
6
|
#include <sstream>
|
|
7
|
+
#include <vector>
|
|
7
8
|
|
|
8
9
|
namespace Sass {
|
|
9
10
|
|
|
@@ -52,40 +53,56 @@ namespace Sass {
|
|
|
52
53
|
|
|
53
54
|
};
|
|
54
55
|
|
|
56
|
+
class Units {
|
|
57
|
+
public:
|
|
58
|
+
std::vector<std::string> numerators;
|
|
59
|
+
std::vector<std::string> denominators;
|
|
60
|
+
public:
|
|
61
|
+
// default constructor
|
|
62
|
+
Units() :
|
|
63
|
+
numerators(),
|
|
64
|
+
denominators()
|
|
65
|
+
{ }
|
|
66
|
+
// copy constructor
|
|
67
|
+
Units(const Units* ptr) :
|
|
68
|
+
numerators(ptr->numerators),
|
|
69
|
+
denominators(ptr->denominators)
|
|
70
|
+
{ }
|
|
71
|
+
// convert to string
|
|
72
|
+
std::string unit() const;
|
|
73
|
+
// get if units are empty
|
|
74
|
+
bool is_unitless() const;
|
|
75
|
+
// return if valid for css
|
|
76
|
+
bool is_valid_css_unit() const;
|
|
77
|
+
// reduce units for output
|
|
78
|
+
// returns conversion factor
|
|
79
|
+
double reduce();
|
|
80
|
+
// normalize units for compare
|
|
81
|
+
// returns conversion factor
|
|
82
|
+
double normalize();
|
|
83
|
+
// compare operations
|
|
84
|
+
bool operator< (const Units& rhs) const;
|
|
85
|
+
bool operator== (const Units& rhs) const;
|
|
86
|
+
// factor to convert into given units
|
|
87
|
+
double convert_factor(const Units&) const;
|
|
88
|
+
};
|
|
89
|
+
|
|
55
90
|
extern const double size_conversion_factors[6][6];
|
|
56
91
|
extern const double angle_conversion_factors[4][4];
|
|
57
92
|
extern const double time_conversion_factors[2][2];
|
|
58
93
|
extern const double frequency_conversion_factors[2][2];
|
|
59
94
|
extern const double resolution_conversion_factors[3][3];
|
|
60
95
|
|
|
96
|
+
UnitType get_main_unit(const UnitClass unit);
|
|
61
97
|
enum Sass::UnitType string_to_unit(const std::string&);
|
|
62
98
|
const char* unit_to_string(Sass::UnitType unit);
|
|
63
99
|
enum Sass::UnitClass get_unit_type(Sass::UnitType unit);
|
|
64
100
|
std::string get_unit_class(Sass::UnitType unit);
|
|
65
101
|
std::string unit_to_class(const std::string&);
|
|
66
102
|
// throws incompatibleUnits exceptions
|
|
67
|
-
double conversion_factor(const std::string&, const std::string
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
public:
|
|
72
|
-
const char* msg;
|
|
73
|
-
incompatibleUnits(Sass::UnitType a, Sass::UnitType b)
|
|
74
|
-
: exception()
|
|
75
|
-
{
|
|
76
|
-
std::stringstream ss;
|
|
77
|
-
ss << "Incompatible units: ";
|
|
78
|
-
ss << "'" << unit_to_string(a) << "' and ";
|
|
79
|
-
ss << "'" << unit_to_string(b) << "'";
|
|
80
|
-
// hold on to string on stack!
|
|
81
|
-
std::string str(ss.str());
|
|
82
|
-
msg = str.c_str();
|
|
83
|
-
}
|
|
84
|
-
virtual const char* what() const throw()
|
|
85
|
-
{
|
|
86
|
-
return msg;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
103
|
+
double conversion_factor(const std::string&, const std::string&);
|
|
104
|
+
double conversion_factor(UnitType, UnitType, UnitClass, UnitClass);
|
|
105
|
+
double convert_units(const std::string&, const std::string&, int&, int&);
|
|
89
106
|
|
|
90
107
|
}
|
|
91
108
|
|
|
@@ -193,6 +193,13 @@ namespace utf8
|
|
|
193
193
|
utf8::next(it, end);
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
template <typename octet_iterator, typename distance_type>
|
|
197
|
+
void retreat (octet_iterator& it, distance_type n, octet_iterator start)
|
|
198
|
+
{
|
|
199
|
+
for (distance_type i = 0; i < n; ++i)
|
|
200
|
+
utf8::prior(it, start);
|
|
201
|
+
}
|
|
202
|
+
|
|
196
203
|
template <typename octet_iterator>
|
|
197
204
|
typename std::iterator_traits<octet_iterator>::difference_type
|
|
198
205
|
distance (octet_iterator first, octet_iterator last)
|
|
@@ -116,6 +116,13 @@ namespace utf8
|
|
|
116
116
|
utf8::unchecked::next(it);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
template <typename octet_iterator, typename distance_type>
|
|
120
|
+
void retreat (octet_iterator& it, distance_type n)
|
|
121
|
+
{
|
|
122
|
+
for (distance_type i = 0; i < n; ++i)
|
|
123
|
+
utf8::unchecked::prior(it);
|
|
124
|
+
}
|
|
125
|
+
|
|
119
126
|
template <typename octet_iterator>
|
|
120
127
|
typename std::iterator_traits<octet_iterator>::difference_type
|
|
121
128
|
distance (octet_iterator first, octet_iterator last)
|
|
@@ -28,7 +28,7 @@ namespace Sass {
|
|
|
28
28
|
size_t offset_at_position(const string& str, size_t position) {
|
|
29
29
|
string::const_iterator it = str.begin();
|
|
30
30
|
utf8::advance(it, position, str.end());
|
|
31
|
-
return distance(str.begin(), it);
|
|
31
|
+
return std::distance(str.begin(), it);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// function that returns number of bytes in a character at offset
|
data/ext/libsass/src/util.cpp
CHANGED
|
@@ -9,11 +9,22 @@
|
|
|
9
9
|
|
|
10
10
|
#include <cmath>
|
|
11
11
|
#include <stdint.h>
|
|
12
|
+
#if defined(_MSC_VER) && _MSC_VER >= 1800 && _MSC_VER < 1900 && defined(_M_X64)
|
|
13
|
+
#include <mutex>
|
|
14
|
+
#endif
|
|
12
15
|
|
|
13
16
|
namespace Sass {
|
|
14
17
|
|
|
15
18
|
double round(double val, size_t precision)
|
|
16
19
|
{
|
|
20
|
+
// Disable FMA3-optimized implementation when compiling with VS2013 for x64 targets
|
|
21
|
+
// See https://github.com/sass/node-sass/issues/1854 for details
|
|
22
|
+
// FIXME: Remove this workaround when we switch to VS2015+
|
|
23
|
+
#if defined(_MSC_VER) && _MSC_VER >= 1800 && _MSC_VER < 1900 && defined(_M_X64)
|
|
24
|
+
static std::once_flag flag;
|
|
25
|
+
std::call_once(flag, []() { _set_FMA3_enable(0); });
|
|
26
|
+
#endif
|
|
27
|
+
|
|
17
28
|
// https://github.com/sass/sass/commit/4e3e1d5684cc29073a507578fc977434ff488c93
|
|
18
29
|
if (fmod(val, 1) - 0.5 > - std::pow(0.1, precision + 1)) return std::ceil(val);
|
|
19
30
|
else if (fmod(val, 1) - 0.5 > std::pow(0.1, precision)) return std::floor(val);
|
|
@@ -24,7 +35,7 @@ namespace Sass {
|
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
/* Locale unspecific atof function. */
|
|
27
|
-
double
|
|
38
|
+
double sass_strtod(const char *str)
|
|
28
39
|
{
|
|
29
40
|
char separator = *(localeconv()->decimal_point);
|
|
30
41
|
if(separator != '.'){
|
|
@@ -37,13 +48,13 @@ namespace Sass {
|
|
|
37
48
|
// of the string. This is slower but it is thread safe.
|
|
38
49
|
char *copy = sass_copy_c_string(str);
|
|
39
50
|
*(copy + (found - str)) = separator;
|
|
40
|
-
double res =
|
|
51
|
+
double res = strtod(copy, NULL);
|
|
41
52
|
free(copy);
|
|
42
53
|
return res;
|
|
43
54
|
}
|
|
44
55
|
}
|
|
45
56
|
|
|
46
|
-
return
|
|
57
|
+
return strtod(str, NULL);
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
// helper for safe access to c_ctx
|
|
@@ -85,8 +96,9 @@ namespace Sass {
|
|
|
85
96
|
}
|
|
86
97
|
|
|
87
98
|
// read css string (handle multiline DELIM)
|
|
88
|
-
std::string read_css_string(const std::string& str)
|
|
99
|
+
std::string read_css_string(const std::string& str, bool css)
|
|
89
100
|
{
|
|
101
|
+
if (!css) return str;
|
|
90
102
|
std::string out("");
|
|
91
103
|
bool esc = false;
|
|
92
104
|
for (auto i : str) {
|
|
@@ -169,6 +181,23 @@ namespace Sass {
|
|
|
169
181
|
return out;
|
|
170
182
|
}
|
|
171
183
|
|
|
184
|
+
std::string escape_string(const std::string& str)
|
|
185
|
+
{
|
|
186
|
+
std::string out("");
|
|
187
|
+
for (auto i : str) {
|
|
188
|
+
if (i == '\n') {
|
|
189
|
+
out += "\\n";
|
|
190
|
+
} else if (i == '\r') {
|
|
191
|
+
out += "\\r";
|
|
192
|
+
} else if (i == '\t') {
|
|
193
|
+
out += "\\t";
|
|
194
|
+
} else {
|
|
195
|
+
out += i;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
200
|
+
|
|
172
201
|
std::string comment_to_string(const std::string& text)
|
|
173
202
|
{
|
|
174
203
|
std::string str = "";
|
|
@@ -221,6 +250,75 @@ namespace Sass {
|
|
|
221
250
|
return quote_mark;
|
|
222
251
|
}
|
|
223
252
|
|
|
253
|
+
std::string read_hex_escapes(const std::string& s)
|
|
254
|
+
{
|
|
255
|
+
|
|
256
|
+
std::string result;
|
|
257
|
+
bool skipped = false;
|
|
258
|
+
|
|
259
|
+
for (size_t i = 0, L = s.length(); i < L; ++i) {
|
|
260
|
+
|
|
261
|
+
// implement the same strange ruby sass behavior
|
|
262
|
+
// an escape sequence can also mean a unicode char
|
|
263
|
+
if (s[i] == '\\' && !skipped) {
|
|
264
|
+
|
|
265
|
+
// remember
|
|
266
|
+
skipped = true;
|
|
267
|
+
|
|
268
|
+
// escape length
|
|
269
|
+
size_t len = 1;
|
|
270
|
+
|
|
271
|
+
// parse as many sequence chars as possible
|
|
272
|
+
// ToDo: Check if ruby aborts after possible max
|
|
273
|
+
while (i + len < L && s[i + len] && isxdigit(s[i + len])) ++ len;
|
|
274
|
+
|
|
275
|
+
if (len > 1) {
|
|
276
|
+
|
|
277
|
+
// convert the extracted hex string to code point value
|
|
278
|
+
// ToDo: Maybe we could do this without creating a substring
|
|
279
|
+
uint32_t cp = strtol(s.substr (i + 1, len - 1).c_str(), NULL, 16);
|
|
280
|
+
|
|
281
|
+
if (s[i + len] == ' ') ++ len;
|
|
282
|
+
|
|
283
|
+
// assert invalid code points
|
|
284
|
+
if (cp == 0) cp = 0xFFFD;
|
|
285
|
+
// replace bell character
|
|
286
|
+
// if (cp == '\n') cp = 32;
|
|
287
|
+
|
|
288
|
+
// use a very simple approach to convert via utf8 lib
|
|
289
|
+
// maybe there is a more elegant way; maybe we shoud
|
|
290
|
+
// convert the whole output from string to a stream!?
|
|
291
|
+
// allocate memory for utf8 char and convert to utf8
|
|
292
|
+
unsigned char u[5] = {0,0,0,0,0}; utf8::append(cp, u);
|
|
293
|
+
for(size_t m = 0; m < 5 && u[m]; m++) result.push_back(u[m]);
|
|
294
|
+
|
|
295
|
+
// skip some more chars?
|
|
296
|
+
i += len - 1; skipped = false;
|
|
297
|
+
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
else {
|
|
301
|
+
|
|
302
|
+
skipped = false;
|
|
303
|
+
|
|
304
|
+
result.push_back(s[i]);
|
|
305
|
+
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
else {
|
|
311
|
+
|
|
312
|
+
result.push_back(s[i]);
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return result;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
224
322
|
std::string unquote(const std::string& s, char* qd, bool keep_utf8_sequences, bool strict)
|
|
225
323
|
{
|
|
226
324
|
|
|
@@ -281,7 +379,7 @@ namespace Sass {
|
|
|
281
379
|
// convert the whole output from string to a stream!?
|
|
282
380
|
// allocate memory for utf8 char and convert to utf8
|
|
283
381
|
unsigned char u[5] = {0,0,0,0,0}; utf8::append(cp, u);
|
|
284
|
-
for(size_t m = 0;
|
|
382
|
+
for(size_t m = 0; m < 5 && u[m]; m++) unq.push_back(u[m]);
|
|
285
383
|
|
|
286
384
|
// skip some more chars?
|
|
287
385
|
i += len - 1; skipped = false;
|
|
@@ -445,7 +543,7 @@ namespace Sass {
|
|
|
445
543
|
|
|
446
544
|
Block_Obj b = r->block();
|
|
447
545
|
|
|
448
|
-
Selector_List_Ptr sl =
|
|
546
|
+
Selector_List_Ptr sl = Cast<Selector_List>(r->selector());
|
|
449
547
|
bool hasSelectors = sl ? sl->length() > 0 : false;
|
|
450
548
|
|
|
451
549
|
if (!hasSelectors) {
|
|
@@ -456,16 +554,16 @@ namespace Sass {
|
|
|
456
554
|
bool hasPrintableChildBlocks = false;
|
|
457
555
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
|
458
556
|
Statement_Obj stm = b->at(i);
|
|
459
|
-
if (
|
|
557
|
+
if (Cast<Directive>(stm)) {
|
|
460
558
|
return true;
|
|
461
|
-
} else if (Declaration_Ptr d =
|
|
559
|
+
} else if (Declaration_Ptr d = Cast<Declaration>(stm)) {
|
|
462
560
|
return isPrintable(d, style);
|
|
463
|
-
} else if (
|
|
464
|
-
Block_Obj pChildBlock =
|
|
465
|
-
if (isPrintable(
|
|
561
|
+
} else if (Has_Block_Ptr p = Cast<Has_Block>(stm)) {
|
|
562
|
+
Block_Obj pChildBlock = p->block();
|
|
563
|
+
if (isPrintable(pChildBlock, style)) {
|
|
466
564
|
hasPrintableChildBlocks = true;
|
|
467
565
|
}
|
|
468
|
-
} else if (Comment_Ptr c =
|
|
566
|
+
} else if (Comment_Ptr c = Cast<Comment>(stm)) {
|
|
469
567
|
// keep for uncompressed
|
|
470
568
|
if (style != COMPRESSED) {
|
|
471
569
|
hasDeclarations = true;
|
|
@@ -499,8 +597,8 @@ namespace Sass {
|
|
|
499
597
|
bool isPrintable(Declaration_Ptr d, Sass_Output_Style style)
|
|
500
598
|
{
|
|
501
599
|
Expression_Obj val = d->value();
|
|
502
|
-
if (String_Quoted_Obj sq =
|
|
503
|
-
if (String_Constant_Obj sc =
|
|
600
|
+
if (String_Quoted_Obj sq = Cast<String_Quoted>(val)) return isPrintable(sq.ptr(), style);
|
|
601
|
+
if (String_Constant_Obj sc = Cast<String_Constant>(val)) return isPrintable(sc.ptr(), style);
|
|
504
602
|
return true;
|
|
505
603
|
}
|
|
506
604
|
|
|
@@ -511,19 +609,19 @@ namespace Sass {
|
|
|
511
609
|
|
|
512
610
|
Block_Obj b = f->block();
|
|
513
611
|
|
|
514
|
-
// bool hasSelectors = f->selector() && static_cast<Selector_List_Ptr>(f->selector())->length() > 0;
|
|
515
|
-
|
|
516
612
|
bool hasDeclarations = false;
|
|
517
613
|
bool hasPrintableChildBlocks = false;
|
|
518
614
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
|
519
615
|
Statement_Obj stm = b->at(i);
|
|
520
|
-
if (
|
|
616
|
+
if (Cast<Declaration>(stm) || Cast<Directive>(stm)) {
|
|
521
617
|
hasDeclarations = true;
|
|
522
618
|
}
|
|
523
|
-
else if (
|
|
524
|
-
Block_Obj pChildBlock =
|
|
525
|
-
if (
|
|
526
|
-
|
|
619
|
+
else if (Has_Block_Ptr b = Cast<Has_Block>(stm)) {
|
|
620
|
+
Block_Obj pChildBlock = b->block();
|
|
621
|
+
if (!b->is_invisible()) {
|
|
622
|
+
if (isPrintable(pChildBlock, style)) {
|
|
623
|
+
hasPrintableChildBlocks = true;
|
|
624
|
+
}
|
|
527
625
|
}
|
|
528
626
|
}
|
|
529
627
|
|
|
@@ -542,34 +640,32 @@ namespace Sass {
|
|
|
542
640
|
if (b == 0) return false;
|
|
543
641
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
|
544
642
|
Statement_Obj stm = b->at(i);
|
|
545
|
-
if (
|
|
546
|
-
else if (
|
|
547
|
-
else if (
|
|
548
|
-
Comment_Ptr c = (Comment_Ptr) &stm;
|
|
643
|
+
if (Cast<Directive>(stm)) return true;
|
|
644
|
+
else if (Cast<Declaration>(stm)) return true;
|
|
645
|
+
else if (Comment_Ptr c = Cast<Comment>(stm)) {
|
|
549
646
|
if (isPrintable(c, style)) {
|
|
550
647
|
return true;
|
|
551
648
|
}
|
|
552
649
|
}
|
|
553
|
-
else if (
|
|
554
|
-
Ruleset_Ptr r = (Ruleset_Ptr) &stm;
|
|
650
|
+
else if (Ruleset_Ptr r = Cast<Ruleset>(stm)) {
|
|
555
651
|
if (isPrintable(r, style)) {
|
|
556
652
|
return true;
|
|
557
653
|
}
|
|
558
654
|
}
|
|
559
|
-
else if (
|
|
560
|
-
Supports_Block_Ptr f = (Supports_Block_Ptr) &stm;
|
|
655
|
+
else if (Supports_Block_Ptr f = Cast<Supports_Block>(stm)) {
|
|
561
656
|
if (isPrintable(f, style)) {
|
|
562
657
|
return true;
|
|
563
658
|
}
|
|
564
659
|
}
|
|
565
|
-
else if (
|
|
566
|
-
|
|
567
|
-
if (isPrintable(m, style)) {
|
|
660
|
+
else if (Media_Block_Ptr mb = Cast<Media_Block>(stm)) {
|
|
661
|
+
if (isPrintable(mb, style)) {
|
|
568
662
|
return true;
|
|
569
663
|
}
|
|
570
664
|
}
|
|
571
|
-
else if (
|
|
572
|
-
|
|
665
|
+
else if (Has_Block_Ptr b = Cast<Has_Block>(stm)) {
|
|
666
|
+
if (isPrintable(b->block(), style)) {
|
|
667
|
+
return true;
|
|
668
|
+
}
|
|
573
669
|
}
|
|
574
670
|
}
|
|
575
671
|
return false;
|
|
@@ -596,35 +692,33 @@ namespace Sass {
|
|
|
596
692
|
|
|
597
693
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
|
598
694
|
Statement_Obj stm = b->at(i);
|
|
599
|
-
if (
|
|
695
|
+
if (Cast<Declaration>(stm) || Cast<Directive>(stm)) {
|
|
600
696
|
return true;
|
|
601
697
|
}
|
|
602
|
-
else if (
|
|
603
|
-
Comment_Ptr c = (Comment_Ptr) &stm;
|
|
698
|
+
else if (Comment_Ptr c = Cast<Comment>(stm)) {
|
|
604
699
|
if (isPrintable(c, style)) {
|
|
605
700
|
return true;
|
|
606
701
|
}
|
|
607
702
|
}
|
|
608
|
-
else if (
|
|
609
|
-
Ruleset_Ptr r = (Ruleset_Ptr) &stm;
|
|
703
|
+
else if (Ruleset_Ptr r = Cast<Ruleset>(stm)) {
|
|
610
704
|
if (isPrintable(r, style)) {
|
|
611
705
|
return true;
|
|
612
706
|
}
|
|
613
707
|
}
|
|
614
|
-
else if (
|
|
615
|
-
Supports_Block_Ptr f = (Supports_Block_Ptr) &stm;
|
|
708
|
+
else if (Supports_Block_Ptr f = Cast<Supports_Block>(stm)) {
|
|
616
709
|
if (isPrintable(f, style)) {
|
|
617
710
|
return true;
|
|
618
711
|
}
|
|
619
712
|
}
|
|
620
|
-
else if (
|
|
621
|
-
Media_Block_Ptr m = (Media_Block_Ptr) &stm;
|
|
713
|
+
else if (Media_Block_Ptr m = Cast<Media_Block>(stm)) {
|
|
622
714
|
if (isPrintable(m, style)) {
|
|
623
715
|
return true;
|
|
624
716
|
}
|
|
625
717
|
}
|
|
626
|
-
else if (
|
|
627
|
-
|
|
718
|
+
else if (Has_Block_Ptr b = Cast<Has_Block>(stm)) {
|
|
719
|
+
if (isPrintable(b->block(), style)) {
|
|
720
|
+
return true;
|
|
721
|
+
}
|
|
628
722
|
}
|
|
629
723
|
}
|
|
630
724
|
|
data/ext/libsass/src/util.hpp
CHANGED
|
@@ -12,20 +12,17 @@
|
|
|
12
12
|
|
|
13
13
|
namespace Sass {
|
|
14
14
|
|
|
15
|
-
#define out_of_memory() do { \
|
|
16
|
-
std::cerr << "Out of memory.\n"; \
|
|
17
|
-
exit(EXIT_FAILURE); \
|
|
18
|
-
} while (0)
|
|
19
|
-
|
|
20
15
|
double round(double val, size_t precision = 0);
|
|
21
|
-
double
|
|
16
|
+
double sass_strtod(const char* str);
|
|
22
17
|
const char* safe_str(const char *, const char* = "");
|
|
23
18
|
void free_string_array(char **);
|
|
24
19
|
char **copy_strings(const std::vector<std::string>&, char ***, int = 0);
|
|
25
|
-
std::string read_css_string(const std::string& str);
|
|
20
|
+
std::string read_css_string(const std::string& str, bool css = true);
|
|
26
21
|
std::string evacuate_escapes(const std::string& str);
|
|
27
22
|
std::string string_to_output(const std::string& str);
|
|
28
23
|
std::string comment_to_string(const std::string& text);
|
|
24
|
+
std::string read_hex_escapes(const std::string& str);
|
|
25
|
+
std::string escape_string(const std::string& str);
|
|
29
26
|
void newline_to_space(std::string& str);
|
|
30
27
|
|
|
31
28
|
std::string quote(const std::string&, char q = 0);
|