sassc 2.0.1 → 2.1.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.gitmodules +1 -1
- data/.travis.yml +7 -3
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +1 -1
- data/Rakefile +23 -8
- data/ext/extconf.rb +39 -0
- data/ext/libsass/.gitignore +1 -0
- data/ext/libsass/GNUmakefile.am +23 -39
- data/ext/libsass/Makefile +56 -91
- data/ext/libsass/Makefile.conf +16 -2
- data/ext/libsass/configure.ac +8 -12
- data/ext/libsass/include/sass/base.h +1 -0
- data/ext/libsass/include/sass/context.h +1 -1
- data/ext/libsass/src/GNUmakefile.am +1 -5
- data/ext/libsass/src/ast.cpp +747 -2010
- data/ext/libsass/src/ast.hpp +239 -2383
- data/ext/libsass/src/{to_c.cpp → ast2c.cpp} +22 -16
- data/ext/libsass/src/ast2c.hpp +39 -0
- data/ext/libsass/src/ast_def_macros.hpp +62 -10
- data/ext/libsass/src/ast_fwd_decl.cpp +1 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +43 -165
- data/ext/libsass/src/ast_sel_cmp.cpp +909 -0
- data/ext/libsass/src/ast_sel_unify.cpp +280 -0
- data/ext/libsass/src/ast_selectors.cpp +1475 -0
- data/ext/libsass/src/ast_selectors.hpp +568 -0
- data/ext/libsass/src/ast_supports.cpp +130 -0
- data/ext/libsass/src/ast_supports.hpp +121 -0
- data/ext/libsass/src/ast_values.cpp +967 -0
- data/ext/libsass/src/ast_values.hpp +489 -0
- data/ext/libsass/src/backtrace.cpp +4 -0
- data/ext/libsass/src/base64vlq.cpp +3 -0
- data/ext/libsass/src/bind.cpp +18 -17
- data/ext/libsass/src/bind.hpp +3 -1
- data/ext/libsass/src/c2ast.cpp +64 -0
- data/ext/libsass/src/c2ast.hpp +14 -0
- data/ext/libsass/src/cencode.c +2 -2
- data/ext/libsass/src/check_nesting.cpp +52 -56
- data/ext/libsass/src/check_nesting.hpp +35 -34
- data/ext/libsass/src/color_maps.cpp +156 -153
- data/ext/libsass/src/color_maps.hpp +152 -152
- data/ext/libsass/src/constants.cpp +15 -0
- data/ext/libsass/src/constants.hpp +13 -0
- data/ext/libsass/src/context.cpp +24 -14
- data/ext/libsass/src/context.hpp +6 -6
- data/ext/libsass/src/cssize.cpp +69 -71
- data/ext/libsass/src/cssize.hpp +50 -50
- data/ext/libsass/src/debugger.hpp +117 -110
- data/ext/libsass/src/emitter.cpp +13 -12
- data/ext/libsass/src/emitter.hpp +13 -9
- data/ext/libsass/src/environment.cpp +15 -1
- data/ext/libsass/src/environment.hpp +6 -0
- data/ext/libsass/src/error_handling.cpp +36 -59
- data/ext/libsass/src/error_handling.hpp +29 -16
- data/ext/libsass/src/eval.cpp +302 -323
- data/ext/libsass/src/eval.hpp +64 -55
- data/ext/libsass/src/expand.cpp +94 -88
- data/ext/libsass/src/expand.hpp +33 -37
- data/ext/libsass/src/extend.cpp +38 -36
- data/ext/libsass/src/extend.hpp +15 -15
- data/ext/libsass/src/file.cpp +34 -2
- data/ext/libsass/src/fn_colors.cpp +594 -0
- data/ext/libsass/src/fn_colors.hpp +85 -0
- data/ext/libsass/src/fn_lists.cpp +284 -0
- data/ext/libsass/src/fn_lists.hpp +34 -0
- data/ext/libsass/src/fn_maps.cpp +94 -0
- data/ext/libsass/src/fn_maps.hpp +30 -0
- data/ext/libsass/src/fn_miscs.cpp +256 -0
- data/ext/libsass/src/fn_miscs.hpp +40 -0
- data/ext/libsass/src/fn_numbers.cpp +220 -0
- data/ext/libsass/src/fn_numbers.hpp +45 -0
- data/ext/libsass/src/fn_selectors.cpp +235 -0
- data/ext/libsass/src/fn_selectors.hpp +35 -0
- data/ext/libsass/src/fn_strings.cpp +254 -0
- data/ext/libsass/src/fn_strings.hpp +34 -0
- data/ext/libsass/src/fn_utils.cpp +156 -0
- data/ext/libsass/src/fn_utils.hpp +56 -0
- data/ext/libsass/src/inspect.cpp +101 -152
- data/ext/libsass/src/inspect.hpp +69 -73
- data/ext/libsass/src/json.cpp +2 -2
- data/ext/libsass/src/lexer.cpp +6 -3
- data/ext/libsass/src/listize.cpp +9 -11
- data/ext/libsass/src/listize.hpp +11 -7
- data/ext/libsass/src/memory/SharedPtr.cpp +2 -83
- data/ext/libsass/src/memory/SharedPtr.hpp +127 -143
- data/ext/libsass/src/node.cpp +13 -10
- data/ext/libsass/src/node.hpp +3 -3
- data/ext/libsass/src/operation.hpp +184 -144
- data/ext/libsass/src/operators.cpp +43 -17
- data/ext/libsass/src/operators.hpp +5 -5
- data/ext/libsass/src/output.cpp +21 -18
- data/ext/libsass/src/output.hpp +14 -21
- data/ext/libsass/src/parser.cpp +215 -183
- data/ext/libsass/src/parser.hpp +28 -24
- data/ext/libsass/src/plugins.cpp +5 -1
- data/ext/libsass/src/position.cpp +3 -0
- data/ext/libsass/src/prelexer.cpp +9 -3
- data/ext/libsass/src/prelexer.hpp +9 -9
- data/ext/libsass/src/remove_placeholders.cpp +14 -11
- data/ext/libsass/src/remove_placeholders.hpp +8 -9
- data/ext/libsass/src/sass.cpp +9 -3
- data/ext/libsass/src/sass.hpp +12 -9
- data/ext/libsass/src/sass2scss.cpp +45 -14
- data/ext/libsass/src/sass_context.cpp +18 -15
- data/ext/libsass/src/sass_functions.cpp +6 -3
- data/ext/libsass/src/sass_functions.hpp +1 -1
- data/ext/libsass/src/sass_util.cpp +3 -0
- data/ext/libsass/src/sass_values.cpp +21 -13
- data/ext/libsass/src/source_map.cpp +5 -2
- data/ext/libsass/src/source_map.hpp +2 -2
- data/ext/libsass/src/subset_map.cpp +4 -1
- data/ext/libsass/src/to_value.cpp +23 -21
- data/ext/libsass/src/to_value.hpp +18 -22
- data/ext/libsass/src/units.cpp +4 -0
- data/ext/libsass/src/units.hpp +1 -0
- data/ext/libsass/src/utf8/checked.h +12 -10
- data/ext/libsass/src/utf8/core.h +3 -0
- data/ext/libsass/src/utf8_string.cpp +3 -0
- data/ext/libsass/src/util.cpp +67 -75
- data/ext/libsass/src/util.hpp +64 -19
- data/ext/libsass/src/util_string.cpp +75 -0
- data/ext/libsass/src/util_string.hpp +19 -0
- data/ext/libsass/src/values.cpp +22 -13
- data/ext/libsass/src/values.hpp +2 -2
- data/ext/libsass/win/libsass.targets +30 -4
- data/ext/libsass/win/libsass.vcxproj.filters +82 -4
- data/lib/sassc.rb +24 -0
- data/lib/sassc/engine.rb +2 -2
- data/lib/sassc/native.rb +8 -1
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +19 -11
- data/test/engine_test.rb +26 -1
- data/test/native_test.rb +1 -1
- metadata +66 -72
- data/ext/Rakefile +0 -3
- data/ext/libsass/.github/CONTRIBUTING.md +0 -65
- data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
- data/ext/libsass/.travis.yml +0 -64
- data/ext/libsass/Readme.md +0 -104
- data/ext/libsass/SECURITY.md +0 -10
- data/ext/libsass/appveyor.yml +0 -91
- data/ext/libsass/docs/README.md +0 -20
- data/ext/libsass/docs/api-context-example.md +0 -45
- data/ext/libsass/docs/api-context-internal.md +0 -163
- data/ext/libsass/docs/api-context.md +0 -295
- data/ext/libsass/docs/api-doc.md +0 -215
- data/ext/libsass/docs/api-function-example.md +0 -67
- data/ext/libsass/docs/api-function-internal.md +0 -8
- data/ext/libsass/docs/api-function.md +0 -74
- data/ext/libsass/docs/api-importer-example.md +0 -112
- data/ext/libsass/docs/api-importer-internal.md +0 -20
- data/ext/libsass/docs/api-importer.md +0 -86
- data/ext/libsass/docs/api-value-example.md +0 -55
- data/ext/libsass/docs/api-value-internal.md +0 -76
- data/ext/libsass/docs/api-value.md +0 -154
- data/ext/libsass/docs/build-on-darwin.md +0 -27
- data/ext/libsass/docs/build-on-gentoo.md +0 -55
- data/ext/libsass/docs/build-on-windows.md +0 -139
- data/ext/libsass/docs/build-shared-library.md +0 -35
- data/ext/libsass/docs/build-with-autotools.md +0 -78
- data/ext/libsass/docs/build-with-makefiles.md +0 -68
- data/ext/libsass/docs/build-with-mingw.md +0 -107
- data/ext/libsass/docs/build-with-visual-studio.md +0 -90
- data/ext/libsass/docs/build.md +0 -97
- data/ext/libsass/docs/compatibility-plan.md +0 -48
- data/ext/libsass/docs/contributing.md +0 -17
- data/ext/libsass/docs/custom-functions-internal.md +0 -122
- data/ext/libsass/docs/dev-ast-memory.md +0 -223
- data/ext/libsass/docs/implementations.md +0 -56
- data/ext/libsass/docs/plugins.md +0 -47
- data/ext/libsass/docs/setup-environment.md +0 -68
- data/ext/libsass/docs/source-map-internals.md +0 -51
- data/ext/libsass/docs/trace.md +0 -26
- data/ext/libsass/docs/triage.md +0 -17
- data/ext/libsass/docs/unicode.md +0 -39
- data/ext/libsass/extconf.rb +0 -6
- data/ext/libsass/script/bootstrap +0 -13
- data/ext/libsass/script/branding +0 -10
- data/ext/libsass/script/ci-build-libsass +0 -134
- data/ext/libsass/script/ci-build-plugin +0 -62
- data/ext/libsass/script/ci-install-compiler +0 -6
- data/ext/libsass/script/ci-install-deps +0 -20
- data/ext/libsass/script/ci-report-coverage +0 -42
- data/ext/libsass/script/spec +0 -5
- data/ext/libsass/script/tap-driver +0 -652
- data/ext/libsass/script/tap-runner +0 -1
- data/ext/libsass/script/test-leaks.pl +0 -103
- data/ext/libsass/src/functions.cpp +0 -2234
- data/ext/libsass/src/functions.hpp +0 -198
- data/ext/libsass/src/to_c.hpp +0 -39
- data/ext/libsass/test/test_node.cpp +0 -94
- data/ext/libsass/test/test_paths.cpp +0 -28
- data/ext/libsass/test/test_selector_difference.cpp +0 -25
- data/ext/libsass/test/test_specificity.cpp +0 -25
- data/ext/libsass/test/test_subset_map.cpp +0 -472
- data/ext/libsass/test/test_superselector.cpp +0 -69
- data/ext/libsass/test/test_unification.cpp +0 -31
- data/lib/tasks/libsass.rb +0 -33
data/ext/libsass/src/parser.hpp
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#ifndef SASS_PARSER_H
|
2
2
|
#define SASS_PARSER_H
|
3
3
|
|
4
|
+
#include "sass.hpp"
|
5
|
+
|
4
6
|
#include <string>
|
5
7
|
#include <vector>
|
6
8
|
|
@@ -38,7 +40,7 @@ namespace Sass {
|
|
38
40
|
Context& ctx;
|
39
41
|
std::vector<Block_Obj> block_stack;
|
40
42
|
std::vector<Scope> stack;
|
41
|
-
|
43
|
+
Media_Block* last_media_block;
|
42
44
|
const char* source;
|
43
45
|
const char* position;
|
44
46
|
const char* end;
|
@@ -48,23 +50,24 @@ namespace Sass {
|
|
48
50
|
Backtraces traces;
|
49
51
|
size_t indentation;
|
50
52
|
size_t nestings;
|
53
|
+
bool allow_parent;
|
51
54
|
|
52
55
|
Token lexed;
|
53
56
|
|
54
|
-
Parser(Context& ctx, const ParserState& pstate, Backtraces traces)
|
57
|
+
Parser(Context& ctx, const ParserState& pstate, Backtraces traces, bool allow_parent = true)
|
55
58
|
: ParserState(pstate), ctx(ctx), block_stack(), stack(0), last_media_block(),
|
56
59
|
source(0), position(0), end(0), before_token(pstate), after_token(pstate),
|
57
|
-
pstate(pstate), traces(traces), indentation(0), nestings(0)
|
58
|
-
{
|
60
|
+
pstate(pstate), traces(traces), indentation(0), nestings(0), allow_parent(allow_parent)
|
61
|
+
{
|
59
62
|
stack.push_back(Scope::Root);
|
60
63
|
}
|
61
64
|
|
62
65
|
// static Parser from_string(const std::string& src, Context& ctx, ParserState pstate = ParserState("[STRING]"));
|
63
|
-
static Parser from_c_str(const char* src, Context& ctx, Backtraces, ParserState pstate = ParserState("[CSTRING]"), const char* source =
|
64
|
-
static Parser from_c_str(const char* beg, const char* end, Context& ctx, Backtraces, ParserState pstate = ParserState("[CSTRING]"), const char* source =
|
65
|
-
static Parser from_token(Token t, Context& ctx, Backtraces, ParserState pstate = ParserState("[TOKEN]"), const char* source =
|
66
|
+
static Parser from_c_str(const char* src, Context& ctx, Backtraces, ParserState pstate = ParserState("[CSTRING]"), const char* source = nullptr, bool allow_parent = true);
|
67
|
+
static Parser from_c_str(const char* beg, const char* end, Context& ctx, Backtraces, ParserState pstate = ParserState("[CSTRING]"), const char* source = nullptr, bool allow_parent = true);
|
68
|
+
static Parser from_token(Token t, Context& ctx, Backtraces, ParserState pstate = ParserState("[TOKEN]"), const char* source = nullptr);
|
66
69
|
// special static parsers to convert strings into certain selectors
|
67
|
-
static Selector_List_Obj parse_selector(const char* src, Context& ctx, Backtraces, ParserState pstate = ParserState("[SELECTOR]"), const char* source =
|
70
|
+
static Selector_List_Obj parse_selector(const char* src, Context& ctx, Backtraces, ParserState pstate = ParserState("[SELECTOR]"), const char* source = nullptr, bool allow_parent = true);
|
68
71
|
|
69
72
|
#ifdef __clang__
|
70
73
|
|
@@ -285,14 +288,13 @@ namespace Sass {
|
|
285
288
|
Expression_Obj parse_value();
|
286
289
|
Function_Call_Obj parse_calc_function();
|
287
290
|
Function_Call_Obj parse_function_call();
|
288
|
-
|
291
|
+
Function_Call_Obj parse_function_call_schema();
|
289
292
|
String_Obj parse_url_function_string();
|
290
293
|
String_Obj parse_url_function_argument();
|
291
294
|
String_Obj parse_interpolated_chunk(Token, bool constant = false, bool css = true);
|
292
295
|
String_Obj parse_string();
|
293
|
-
|
294
|
-
String_Schema_Obj parse_css_variable_value(
|
295
|
-
String_Schema_Obj parse_css_variable_value_token(bool top_level = true);
|
296
|
+
Value_Obj parse_static_value();
|
297
|
+
String_Schema_Obj parse_css_variable_value();
|
296
298
|
String_Obj parse_ie_property();
|
297
299
|
String_Obj parse_ie_keyword_arg();
|
298
300
|
String_Schema_Obj parse_value_schema(const char* stop);
|
@@ -309,12 +311,12 @@ namespace Sass {
|
|
309
311
|
Media_Query_Obj parse_media_query();
|
310
312
|
Media_Query_Expression_Obj parse_media_expression();
|
311
313
|
Supports_Block_Obj parse_supports_directive();
|
312
|
-
Supports_Condition_Obj parse_supports_condition();
|
314
|
+
Supports_Condition_Obj parse_supports_condition(bool top_level);
|
313
315
|
Supports_Condition_Obj parse_supports_negation();
|
314
|
-
Supports_Condition_Obj parse_supports_operator();
|
316
|
+
Supports_Condition_Obj parse_supports_operator(bool top_level);
|
315
317
|
Supports_Condition_Obj parse_supports_interpolation();
|
316
318
|
Supports_Condition_Obj parse_supports_declaration();
|
317
|
-
Supports_Condition_Obj parse_supports_condition_in_parens();
|
319
|
+
Supports_Condition_Obj parse_supports_condition_in_parens(bool parens_required);
|
318
320
|
At_Root_Block_Obj parse_at_root_block();
|
319
321
|
At_Root_Query_Obj parse_at_root_query();
|
320
322
|
String_Schema_Obj parse_almost_any_value();
|
@@ -325,6 +327,8 @@ namespace Sass {
|
|
325
327
|
Error_Obj parse_error();
|
326
328
|
Debug_Obj parse_debug();
|
327
329
|
|
330
|
+
Value* color_or_string(const std::string& lexed) const;
|
331
|
+
|
328
332
|
// be more like ruby sass
|
329
333
|
Expression_Obj lex_almost_any_value_token();
|
330
334
|
Expression_Obj lex_almost_any_value_chars();
|
@@ -373,19 +377,19 @@ namespace Sass {
|
|
373
377
|
return SASS_MEMORY_NEW(String_Constant, pstate, lexed);
|
374
378
|
}
|
375
379
|
}
|
376
|
-
return
|
380
|
+
return {};
|
377
381
|
}
|
378
382
|
|
379
383
|
public:
|
380
|
-
static
|
381
|
-
static
|
382
|
-
static
|
383
|
-
static
|
384
|
+
static Number* lexed_number(const ParserState& pstate, const std::string& parsed);
|
385
|
+
static Number* lexed_dimension(const ParserState& pstate, const std::string& parsed);
|
386
|
+
static Number* lexed_percentage(const ParserState& pstate, const std::string& parsed);
|
387
|
+
static Value* lexed_hex_color(const ParserState& pstate, const std::string& parsed);
|
384
388
|
private:
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
+
Number* lexed_number(const std::string& parsed) { return lexed_number(pstate, parsed); };
|
390
|
+
Number* lexed_dimension(const std::string& parsed) { return lexed_dimension(pstate, parsed); };
|
391
|
+
Number* lexed_percentage(const std::string& parsed) { return lexed_percentage(pstate, parsed); };
|
392
|
+
Value* lexed_hex_color(const std::string& parsed) { return lexed_hex_color(pstate, parsed); };
|
389
393
|
|
390
394
|
static const char* re_attr_sensitive_close(const char* src);
|
391
395
|
static const char* re_attr_insensitive_close(const char* src);
|
data/ext/libsass/src/plugins.cpp
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
1
3
|
#include "sass.hpp"
|
4
|
+
|
2
5
|
#include <iostream>
|
3
6
|
#include "output.hpp"
|
4
7
|
#include "plugins.hpp"
|
8
|
+
#include "util.hpp"
|
5
9
|
|
6
10
|
#ifdef _WIN32
|
7
11
|
#include <windows.h>
|
@@ -154,7 +158,7 @@ namespace Sass {
|
|
154
158
|
}
|
155
159
|
}
|
156
160
|
}
|
157
|
-
catch (utf8::invalid_utf8)
|
161
|
+
catch (utf8::invalid_utf8&)
|
158
162
|
{
|
159
163
|
// report the error to the console (should not happen)
|
160
164
|
// implementors should make sure to provide valid utf8
|
@@ -1,4 +1,7 @@
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
1
3
|
#include "sass.hpp"
|
4
|
+
|
2
5
|
#include <cctype>
|
3
6
|
#include <iostream>
|
4
7
|
#include <iomanip>
|
@@ -260,7 +263,7 @@ namespace Sass {
|
|
260
263
|
>(src);
|
261
264
|
}
|
262
265
|
|
263
|
-
// Match a line comment (/.*?(?=\n|\r\n?|\Z)/.
|
266
|
+
// Match a line comment (/.*?(?=\n|\r\n?|\f|\Z)/.
|
264
267
|
const char* line_comment(const char* src)
|
265
268
|
{
|
266
269
|
return sequence<
|
@@ -1260,6 +1263,9 @@ namespace Sass {
|
|
1260
1263
|
const char* kwd_lte(const char* src) {
|
1261
1264
|
return exactly<lte>(src);
|
1262
1265
|
}
|
1266
|
+
const char* kwd_using(const char* src) {
|
1267
|
+
return keyword<using_kwd>(src);
|
1268
|
+
}
|
1263
1269
|
|
1264
1270
|
// match specific IE syntax
|
1265
1271
|
const char* ie_progid(const char* src) {
|
@@ -1394,7 +1400,7 @@ namespace Sass {
|
|
1394
1400
|
}*/
|
1395
1401
|
|
1396
1402
|
const char* H(const char* src) {
|
1397
|
-
return std::isxdigit(*src) ? src+1 : 0;
|
1403
|
+
return std::isxdigit(static_cast<unsigned char>(*src)) ? src+1 : 0;
|
1398
1404
|
}
|
1399
1405
|
|
1400
1406
|
const char* W(const char* src) {
|
@@ -1606,7 +1612,7 @@ namespace Sass {
|
|
1606
1612
|
>(src);
|
1607
1613
|
}
|
1608
1614
|
|
1609
|
-
extern const char css_variable_url_top_level_negates[] = "()[]{}\"'
|
1615
|
+
extern const char css_variable_url_top_level_negates[] = "()[]{}\"'#/;";
|
1610
1616
|
const char* css_variable_top_level_value(const char* src) {
|
1611
1617
|
return sequence<
|
1612
1618
|
alternatives<
|
@@ -25,6 +25,7 @@ namespace Sass {
|
|
25
25
|
const char* kwd_gte(const char* src);
|
26
26
|
const char* kwd_lt(const char* src);
|
27
27
|
const char* kwd_lte(const char* src);
|
28
|
+
const char* kwd_using(const char* src);
|
28
29
|
|
29
30
|
// Match standard control chars
|
30
31
|
const char* kwd_at(const char* src);
|
@@ -64,16 +65,15 @@ namespace Sass {
|
|
64
65
|
size_t level = 0;
|
65
66
|
bool in_squote = false;
|
66
67
|
bool in_dquote = false;
|
67
|
-
|
68
|
-
|
69
|
-
while (*src) {
|
70
|
-
|
71
|
-
// check for abort condition
|
72
|
-
if (end && src >= end) break;
|
68
|
+
bool in_backslash_escape = false;
|
73
69
|
|
70
|
+
while ((end == nullptr || src < end) && *src != '\0') {
|
74
71
|
// has escaped sequence?
|
75
|
-
if (
|
76
|
-
|
72
|
+
if (in_backslash_escape) {
|
73
|
+
in_backslash_escape = false;
|
74
|
+
}
|
75
|
+
else if (*src == '\\') {
|
76
|
+
in_backslash_escape = true;
|
77
77
|
}
|
78
78
|
else if (*src == '"') {
|
79
79
|
in_dquote = ! in_dquote;
|
@@ -119,7 +119,7 @@ namespace Sass {
|
|
119
119
|
// first start/opener must be consumed already!
|
120
120
|
template<prelexer start, prelexer stop>
|
121
121
|
const char* skip_over_scopes(const char* src) {
|
122
|
-
return skip_over_scopes<start, stop>(src,
|
122
|
+
return skip_over_scopes<start, stop>(src, nullptr);
|
123
123
|
}
|
124
124
|
|
125
125
|
// Match a sequence of characters delimited by the supplied chars.
|
@@ -1,4 +1,7 @@
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
1
3
|
#include "sass.hpp"
|
4
|
+
|
2
5
|
#include "remove_placeholders.hpp"
|
3
6
|
#include "context.hpp"
|
4
7
|
#include "inspect.hpp"
|
@@ -9,16 +12,16 @@ namespace Sass {
|
|
9
12
|
Remove_Placeholders::Remove_Placeholders()
|
10
13
|
{ }
|
11
14
|
|
12
|
-
void Remove_Placeholders::operator()(
|
15
|
+
void Remove_Placeholders::operator()(Block* b) {
|
13
16
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
14
|
-
|
17
|
+
Statement* st = b->at(i);
|
15
18
|
st->perform(this);
|
16
19
|
}
|
17
20
|
}
|
18
21
|
|
19
|
-
|
22
|
+
Selector_List* Remove_Placeholders::remove_placeholders(Selector_List* sl)
|
20
23
|
{
|
21
|
-
|
24
|
+
Selector_List* new_sl = SASS_MEMORY_NEW(Selector_List, sl->pstate());
|
22
25
|
|
23
26
|
for (size_t i = 0, L = sl->length(); i < L; ++i) {
|
24
27
|
if (!sl->at(i)->contains_placeholder()) {
|
@@ -31,7 +34,7 @@ namespace Sass {
|
|
31
34
|
}
|
32
35
|
|
33
36
|
|
34
|
-
void Remove_Placeholders::operator()(
|
37
|
+
void Remove_Placeholders::operator()(Ruleset* r) {
|
35
38
|
// Create a new selector group without placeholders
|
36
39
|
Selector_List_Obj sl = Cast<Selector_List>(r->selector());
|
37
40
|
|
@@ -43,9 +46,9 @@ namespace Sass {
|
|
43
46
|
while (cs) {
|
44
47
|
if (cs->head()) {
|
45
48
|
for (Simple_Selector_Obj& ss : cs->head()->elements()) {
|
46
|
-
if (
|
47
|
-
if (
|
48
|
-
|
49
|
+
if (Wrapped_Selector* ws = Cast<Wrapped_Selector>(ss)) {
|
50
|
+
if (Selector_List* wsl = Cast<Selector_List>(ws->selector())) {
|
51
|
+
Selector_List* clean = remove_placeholders(wsl);
|
49
52
|
// also clean superflous parent selectors
|
50
53
|
// probably not really the correct place
|
51
54
|
clean->remove_parent_selectors();
|
@@ -70,14 +73,14 @@ namespace Sass {
|
|
70
73
|
}
|
71
74
|
}
|
72
75
|
|
73
|
-
void Remove_Placeholders::operator()(
|
76
|
+
void Remove_Placeholders::operator()(Media_Block* m) {
|
74
77
|
operator()(m->block());
|
75
78
|
}
|
76
|
-
void Remove_Placeholders::operator()(
|
79
|
+
void Remove_Placeholders::operator()(Supports_Block* m) {
|
77
80
|
operator()(m->block());
|
78
81
|
}
|
79
82
|
|
80
|
-
void Remove_Placeholders::operator()(
|
83
|
+
void Remove_Placeholders::operator()(Directive* a) {
|
81
84
|
if (a->block()) a->block()->perform(this);
|
82
85
|
}
|
83
86
|
|
@@ -11,23 +11,22 @@ namespace Sass {
|
|
11
11
|
|
12
12
|
class Remove_Placeholders : public Operation_CRTP<void, Remove_Placeholders> {
|
13
13
|
|
14
|
-
void fallback_impl(AST_Node_Ptr n) {}
|
15
|
-
|
16
14
|
public:
|
17
|
-
|
15
|
+
Selector_List* remove_placeholders(Selector_List*);
|
18
16
|
|
19
17
|
public:
|
20
18
|
Remove_Placeholders();
|
21
19
|
~Remove_Placeholders() { }
|
22
20
|
|
23
|
-
void operator()(
|
24
|
-
void operator()(
|
25
|
-
void operator()(
|
26
|
-
void operator()(
|
27
|
-
void operator()(
|
21
|
+
void operator()(Block*);
|
22
|
+
void operator()(Ruleset*);
|
23
|
+
void operator()(Media_Block*);
|
24
|
+
void operator()(Supports_Block*);
|
25
|
+
void operator()(Directive*);
|
28
26
|
|
27
|
+
// ignore missed types
|
29
28
|
template <typename U>
|
30
|
-
|
29
|
+
void fallback(U x) {}
|
31
30
|
};
|
32
31
|
|
33
32
|
}
|
data/ext/libsass/src/sass.cpp
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
1
3
|
#include "sass.hpp"
|
4
|
+
|
2
5
|
#include <cstdlib>
|
3
6
|
#include <cstring>
|
4
7
|
#include <vector>
|
@@ -7,6 +10,7 @@
|
|
7
10
|
#include "sass.h"
|
8
11
|
#include "file.hpp"
|
9
12
|
#include "util.hpp"
|
13
|
+
#include "context.hpp"
|
10
14
|
#include "sass_context.hpp"
|
11
15
|
#include "sass_functions.hpp"
|
12
16
|
|
@@ -33,8 +37,10 @@ extern "C" {
|
|
33
37
|
void* ADDCALL sass_alloc_memory(size_t size)
|
34
38
|
{
|
35
39
|
void* ptr = malloc(size);
|
36
|
-
if (ptr == NULL)
|
37
|
-
|
40
|
+
if (ptr == NULL) {
|
41
|
+
std::cerr << "Out of memory.\n";
|
42
|
+
exit(EXIT_FAILURE);
|
43
|
+
}
|
38
44
|
return ptr;
|
39
45
|
}
|
40
46
|
|
@@ -146,4 +152,4 @@ namespace Sass {
|
|
146
152
|
return sass_copy_c_string(str.c_str());
|
147
153
|
}
|
148
154
|
|
149
|
-
}
|
155
|
+
}
|
data/ext/libsass/src/sass.hpp
CHANGED
@@ -14,11 +14,17 @@
|
|
14
14
|
// aplies to MSVC and MinGW
|
15
15
|
#ifdef _WIN32
|
16
16
|
// we do not want the ERROR macro
|
17
|
-
#
|
17
|
+
# ifndef NOGDI
|
18
|
+
# define NOGDI
|
19
|
+
# endif
|
18
20
|
// we do not want the min/max macro
|
19
|
-
#
|
21
|
+
# ifndef NOMINMAX
|
22
|
+
# define NOMINMAX
|
23
|
+
# endif
|
20
24
|
// we do not want the IN/OUT macro
|
21
|
-
#
|
25
|
+
# ifndef _NO_W32_PSEUDO_MODIFIERS
|
26
|
+
# define _NO_W32_PSEUDO_MODIFIERS
|
27
|
+
# endif
|
22
28
|
#endif
|
23
29
|
|
24
30
|
|
@@ -90,13 +96,10 @@ struct Sass_Inspect_Options {
|
|
90
96
|
// Precision for fractional numbers
|
91
97
|
int precision;
|
92
98
|
|
93
|
-
// Do not compress colors in selectors
|
94
|
-
bool in_selector;
|
95
|
-
|
96
99
|
// initialization list (constructor with defaults)
|
97
100
|
Sass_Inspect_Options(Sass_Output_Style style = Sass::NESTED,
|
98
|
-
int precision =
|
99
|
-
: output_style(style), precision(precision)
|
101
|
+
int precision = 10)
|
102
|
+
: output_style(style), precision(precision)
|
100
103
|
{ }
|
101
104
|
|
102
105
|
};
|
@@ -125,7 +128,7 @@ struct Sass_Output_Options : Sass_Inspect_Options {
|
|
125
128
|
|
126
129
|
// initialization list (constructor with defaults)
|
127
130
|
Sass_Output_Options(Sass_Output_Style style = Sass::NESTED,
|
128
|
-
int precision =
|
131
|
+
int precision = 10,
|
129
132
|
const char* indent = " ",
|
130
133
|
const char* linefeed = "\n",
|
131
134
|
bool source_comments = false)
|
@@ -154,6 +154,21 @@ namespace Sass
|
|
154
154
|
|
155
155
|
}
|
156
156
|
|
157
|
+
static size_t findFirstCharacter (std::string& sass, size_t pos)
|
158
|
+
{
|
159
|
+
return sass.find_first_not_of(SASS2SCSS_FIND_WHITESPACE, pos);
|
160
|
+
}
|
161
|
+
|
162
|
+
static size_t findLastCharacter (std::string& sass, size_t pos)
|
163
|
+
{
|
164
|
+
return sass.find_last_not_of(SASS2SCSS_FIND_WHITESPACE, pos);
|
165
|
+
}
|
166
|
+
|
167
|
+
static bool isUrl (std::string& sass, size_t pos)
|
168
|
+
{
|
169
|
+
return sass[pos] == 'u' && sass[pos+1] == 'r' && sass[pos+2] == 'l' && sass[pos+3] == '(';
|
170
|
+
}
|
171
|
+
|
157
172
|
// check if there is some char data
|
158
173
|
// will ignore everything in comments
|
159
174
|
static bool hasCharData (std::string& sass)
|
@@ -587,6 +602,7 @@ namespace Sass
|
|
587
602
|
sass.substr(pos_left, 5) == "@warn" ||
|
588
603
|
sass.substr(pos_left, 6) == "@debug" ||
|
589
604
|
sass.substr(pos_left, 6) == "@error" ||
|
605
|
+
sass.substr(pos_left, 6) == "@value" ||
|
590
606
|
sass.substr(pos_left, 8) == "@charset" ||
|
591
607
|
sass.substr(pos_left, 10) == "@namespace"
|
592
608
|
) { sass = indent + sass.substr(pos_left); }
|
@@ -606,23 +622,38 @@ namespace Sass
|
|
606
622
|
{
|
607
623
|
// get positions for the actual import url
|
608
624
|
size_t pos_import = sass.find_first_of(SASS2SCSS_FIND_WHITESPACE, pos_left + 7);
|
609
|
-
size_t
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
{
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
625
|
+
size_t pos = sass.find_first_not_of(SASS2SCSS_FIND_WHITESPACE, pos_import);
|
626
|
+
size_t start = pos;
|
627
|
+
bool in_dqstr = false;
|
628
|
+
bool in_sqstr = false;
|
629
|
+
bool is_escaped = false;
|
630
|
+
do {
|
631
|
+
if (is_escaped) {
|
632
|
+
is_escaped = false;
|
633
|
+
}
|
634
|
+
else if (sass[pos] == '\\') {
|
635
|
+
is_escaped = true;
|
636
|
+
}
|
637
|
+
else if (sass[pos] == '"') {
|
638
|
+
if (!in_sqstr) in_dqstr = ! in_dqstr;
|
639
|
+
}
|
640
|
+
else if (sass[pos] == '\'') {
|
641
|
+
if (!in_dqstr) in_sqstr = ! in_sqstr;
|
642
|
+
}
|
643
|
+
else if (in_dqstr || in_sqstr) {
|
644
|
+
// skip over quoted stuff
|
645
|
+
}
|
646
|
+
else if (sass[pos] == ',' || sass[pos] == 0) {
|
647
|
+
if (sass[start] != '"' && sass[start] != '\'' && !isUrl(sass, start)) {
|
648
|
+
size_t end = findLastCharacter(sass, pos - 1) + 1;
|
649
|
+
sass = sass.replace(end, 0, "\"");
|
650
|
+
sass = sass.replace(start, 0, "\"");
|
651
|
+
pos += 2;
|
623
652
|
}
|
653
|
+
start = findFirstCharacter(sass, pos + 1);
|
624
654
|
}
|
625
655
|
}
|
656
|
+
while (sass[pos++] != 0);
|
626
657
|
|
627
658
|
}
|
628
659
|
else if (
|