sassc 1.8.3 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/ext/libsass/.editorconfig +1 -1
- data/ext/libsass/.gitignore +1 -0
- data/ext/libsass/LICENSE +1 -1
- data/ext/libsass/Makefile +20 -14
- data/ext/libsass/Makefile.conf +0 -1
- data/ext/libsass/Readme.md +3 -1
- data/ext/libsass/appveyor.yml +19 -11
- data/ext/libsass/docs/api-importer-example.md +2 -1235
- data/ext/libsass/docs/build-with-autotools.md +10 -0
- data/ext/libsass/docs/build-with-makefiles.md +18 -0
- data/ext/libsass/include/sass/base.h +4 -1
- data/ext/libsass/include/sass/values.h +2 -1
- data/ext/libsass/src/ast.cpp +279 -346
- data/ext/libsass/src/ast.hpp +234 -60
- data/ext/libsass/src/base64vlq.cpp +1 -0
- data/ext/libsass/src/bind.cpp +35 -45
- data/ext/libsass/src/bind.hpp +1 -0
- data/ext/libsass/src/color_maps.cpp +1 -0
- data/ext/libsass/src/constants.cpp +4 -1
- data/ext/libsass/src/constants.hpp +2 -1
- data/ext/libsass/src/context.cpp +41 -31
- data/ext/libsass/src/context.hpp +10 -10
- data/ext/libsass/src/cssize.cpp +7 -4
- data/ext/libsass/src/cssize.hpp +1 -3
- data/ext/libsass/src/debugger.hpp +73 -14
- data/ext/libsass/src/emitter.cpp +37 -25
- data/ext/libsass/src/emitter.hpp +10 -9
- data/ext/libsass/src/environment.cpp +16 -5
- data/ext/libsass/src/environment.hpp +5 -3
- data/ext/libsass/src/error_handling.cpp +91 -14
- data/ext/libsass/src/error_handling.hpp +105 -4
- data/ext/libsass/src/eval.cpp +519 -330
- data/ext/libsass/src/eval.hpp +12 -13
- data/ext/libsass/src/expand.cpp +92 -56
- data/ext/libsass/src/expand.hpp +5 -3
- data/ext/libsass/src/extend.cpp +60 -51
- data/ext/libsass/src/extend.hpp +1 -3
- data/ext/libsass/src/file.cpp +37 -27
- data/ext/libsass/src/functions.cpp +78 -62
- data/ext/libsass/src/functions.hpp +1 -0
- data/ext/libsass/src/inspect.cpp +293 -64
- data/ext/libsass/src/inspect.hpp +2 -0
- data/ext/libsass/src/lexer.cpp +1 -0
- data/ext/libsass/src/listize.cpp +14 -15
- data/ext/libsass/src/listize.hpp +3 -5
- data/ext/libsass/src/memory_manager.cpp +1 -0
- data/ext/libsass/src/node.cpp +2 -3
- data/ext/libsass/src/operation.hpp +70 -71
- data/ext/libsass/src/output.cpp +28 -32
- data/ext/libsass/src/output.hpp +1 -2
- data/ext/libsass/src/parser.cpp +402 -183
- data/ext/libsass/src/parser.hpp +19 -9
- data/ext/libsass/src/plugins.cpp +1 -0
- data/ext/libsass/src/position.cpp +1 -0
- data/ext/libsass/src/prelexer.cpp +134 -56
- data/ext/libsass/src/prelexer.hpp +51 -3
- data/ext/libsass/src/remove_placeholders.cpp +35 -9
- data/ext/libsass/src/remove_placeholders.hpp +4 -3
- data/ext/libsass/src/sass.cpp +1 -0
- data/ext/libsass/src/sass.hpp +129 -0
- data/ext/libsass/src/sass_context.cpp +31 -14
- data/ext/libsass/src/sass_context.hpp +2 -31
- data/ext/libsass/src/sass_functions.cpp +1 -0
- data/ext/libsass/src/sass_interface.cpp +5 -6
- data/ext/libsass/src/sass_util.cpp +1 -2
- data/ext/libsass/src/sass_util.hpp +5 -5
- data/ext/libsass/src/sass_values.cpp +13 -10
- data/ext/libsass/src/source_map.cpp +4 -3
- data/ext/libsass/src/source_map.hpp +2 -2
- data/ext/libsass/src/subset_map.hpp +0 -1
- data/ext/libsass/src/to_c.cpp +1 -0
- data/ext/libsass/src/to_c.hpp +1 -3
- data/ext/libsass/src/to_value.cpp +3 -5
- data/ext/libsass/src/to_value.hpp +1 -1
- data/ext/libsass/src/units.cpp +96 -59
- data/ext/libsass/src/units.hpp +10 -8
- data/ext/libsass/src/utf8_string.cpp +5 -0
- data/ext/libsass/src/util.cpp +23 -156
- data/ext/libsass/src/util.hpp +10 -14
- data/ext/libsass/src/values.cpp +1 -0
- data/ext/libsass/test/test_node.cpp +2 -6
- data/ext/libsass/test/test_selector_difference.cpp +1 -3
- data/ext/libsass/test/test_specificity.cpp +0 -2
- data/ext/libsass/test/test_superselector.cpp +0 -2
- data/ext/libsass/test/test_unification.cpp +1 -3
- data/ext/libsass/win/libsass.targets +18 -5
- data/ext/libsass/win/libsass.vcxproj +9 -7
- data/ext/libsass/win/libsass.vcxproj.filters +148 -106
- data/lib/sassc/version.rb +1 -1
- data/test/engine_test.rb +12 -0
- data/test/native_test.rb +1 -1
- metadata +3 -4
- data/ext/libsass/src/to_string.cpp +0 -48
- data/ext/libsass/src/to_string.hpp +0 -38
@@ -1,3 +1,4 @@
|
|
1
|
+
#include "sass.hpp"
|
1
2
|
#include <string>
|
2
3
|
#include <sstream>
|
3
4
|
#include <iostream>
|
@@ -16,7 +17,7 @@ namespace Sass {
|
|
16
17
|
|
17
18
|
std::string SourceMap::render_srcmap(Context &ctx) {
|
18
19
|
|
19
|
-
const bool include_sources = ctx.c_options
|
20
|
+
const bool include_sources = ctx.c_options.source_map_contents;
|
20
21
|
const std::vector<std::string> links = ctx.srcmap_links;
|
21
22
|
const std::vector<Resource>& sources(ctx.resources);
|
22
23
|
|
@@ -159,12 +160,12 @@ namespace Sass {
|
|
159
160
|
current_position += offset;
|
160
161
|
}
|
161
162
|
|
162
|
-
void SourceMap::add_open_mapping(AST_Node* node)
|
163
|
+
void SourceMap::add_open_mapping(const AST_Node* node)
|
163
164
|
{
|
164
165
|
mappings.push_back(Mapping(node->pstate(), current_position));
|
165
166
|
}
|
166
167
|
|
167
|
-
void SourceMap::add_close_mapping(AST_Node* node)
|
168
|
+
void SourceMap::add_close_mapping(const AST_Node* node)
|
168
169
|
{
|
169
170
|
mappings.push_back(Mapping(node->pstate() + node->pstate().offset, current_position));
|
170
171
|
}
|
@@ -28,8 +28,8 @@ namespace Sass {
|
|
28
28
|
void prepend(const Offset& offset);
|
29
29
|
void append(const OutputBuffer& out);
|
30
30
|
void prepend(const OutputBuffer& out);
|
31
|
-
void add_open_mapping(AST_Node* node);
|
32
|
-
void add_close_mapping(AST_Node* node);
|
31
|
+
void add_open_mapping(const AST_Node* node);
|
32
|
+
void add_close_mapping(const AST_Node* node);
|
33
33
|
|
34
34
|
std::string render_srcmap(Context &ctx);
|
35
35
|
ParserState remap(const ParserState& pstate);
|
data/ext/libsass/src/to_c.cpp
CHANGED
data/ext/libsass/src/to_c.hpp
CHANGED
@@ -8,15 +8,13 @@
|
|
8
8
|
namespace Sass {
|
9
9
|
|
10
10
|
class To_C : public Operation_CRTP<union Sass_Value*, To_C> {
|
11
|
-
// import all the class-specific methods and override as desired
|
12
|
-
using Operation<union Sass_Value*>::operator();
|
13
11
|
// override this to define a catch-all
|
14
12
|
union Sass_Value* fallback_impl(AST_Node* n);
|
15
13
|
|
16
14
|
public:
|
17
15
|
|
18
16
|
To_C() { }
|
19
|
-
|
17
|
+
~To_C() { }
|
20
18
|
|
21
19
|
union Sass_Value* operator()(Boolean*);
|
22
20
|
union Sass_Value* operator()(Number*);
|
@@ -1,6 +1,6 @@
|
|
1
|
+
#include "sass.hpp"
|
1
2
|
#include "ast.hpp"
|
2
3
|
#include "to_value.hpp"
|
3
|
-
#include "to_string.hpp"
|
4
4
|
|
5
5
|
namespace Sass {
|
6
6
|
|
@@ -91,19 +91,17 @@ namespace Sass {
|
|
91
91
|
// Selector_List is converted to a string
|
92
92
|
Value* To_Value::operator()(Selector_List* s)
|
93
93
|
{
|
94
|
-
To_String to_string(&ctx);
|
95
94
|
return SASS_MEMORY_NEW(mem, String_Quoted,
|
96
95
|
s->pstate(),
|
97
|
-
s->
|
96
|
+
s->to_string(ctx.c_options));
|
98
97
|
}
|
99
98
|
|
100
99
|
// Binary_Expression is converted to a string
|
101
100
|
Value* To_Value::operator()(Binary_Expression* s)
|
102
101
|
{
|
103
|
-
To_String to_string(&ctx);
|
104
102
|
return SASS_MEMORY_NEW(mem, String_Quoted,
|
105
103
|
s->pstate(),
|
106
|
-
s->
|
104
|
+
s->to_string(ctx.c_options));
|
107
105
|
}
|
108
106
|
|
109
107
|
};
|
data/ext/libsass/src/units.cpp
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
+
#include "sass.hpp"
|
1
2
|
#include <stdexcept>
|
2
3
|
#include "units.hpp"
|
3
4
|
|
4
|
-
#ifdef IN
|
5
|
-
#undef IN
|
6
|
-
#endif
|
7
|
-
|
8
5
|
namespace Sass {
|
9
6
|
|
10
7
|
/* the conversion matrix can be readed the following way */
|
@@ -52,88 +49,128 @@ namespace Sass {
|
|
52
49
|
/* dppx */ { 1/96.0, 2.54/96, 1 }
|
53
50
|
};
|
54
51
|
|
55
|
-
|
52
|
+
UnitClass get_unit_type(UnitType unit)
|
53
|
+
{
|
54
|
+
switch (unit & 0xFF00)
|
55
|
+
{
|
56
|
+
case UnitClass::LENGTH: return UnitClass::LENGTH; break;
|
57
|
+
case UnitClass::ANGLE: return UnitClass::ANGLE; break;
|
58
|
+
case UnitClass::TIME: return UnitClass::TIME; break;
|
59
|
+
case UnitClass::FREQUENCY: return UnitClass::FREQUENCY; break;
|
60
|
+
case UnitClass::RESOLUTION: return UnitClass::RESOLUTION; break;
|
61
|
+
default: return UnitClass::INCOMMENSURABLE; break;
|
62
|
+
}
|
63
|
+
};
|
64
|
+
|
65
|
+
std::string get_unit_class(UnitType unit)
|
56
66
|
{
|
57
67
|
switch (unit & 0xFF00)
|
58
68
|
{
|
59
|
-
case
|
60
|
-
case
|
61
|
-
case
|
62
|
-
case
|
63
|
-
case
|
64
|
-
default:
|
69
|
+
case UnitClass::LENGTH: return "LENGTH"; break;
|
70
|
+
case UnitClass::ANGLE: return "ANGLE"; break;
|
71
|
+
case UnitClass::TIME: return "TIME"; break;
|
72
|
+
case UnitClass::FREQUENCY: return "FREQUENCY"; break;
|
73
|
+
case UnitClass::RESOLUTION: return "RESOLUTION"; break;
|
74
|
+
default: return "INCOMMENSURABLE"; break;
|
65
75
|
}
|
66
76
|
};
|
67
77
|
|
68
|
-
|
78
|
+
UnitType string_to_unit(const std::string& s)
|
69
79
|
{
|
70
80
|
// size units
|
71
|
-
if (s == "px") return
|
72
|
-
else if (s == "pt") return
|
73
|
-
else if (s == "pc") return
|
74
|
-
else if (s == "mm") return
|
75
|
-
else if (s == "cm") return
|
76
|
-
else if (s == "in") return
|
81
|
+
if (s == "px") return UnitType::PX;
|
82
|
+
else if (s == "pt") return UnitType::PT;
|
83
|
+
else if (s == "pc") return UnitType::PC;
|
84
|
+
else if (s == "mm") return UnitType::MM;
|
85
|
+
else if (s == "cm") return UnitType::CM;
|
86
|
+
else if (s == "in") return UnitType::IN;
|
77
87
|
// angle units
|
78
|
-
else if (s == "deg") return
|
79
|
-
else if (s == "grad") return
|
80
|
-
else if (s == "rad") return
|
81
|
-
else if (s == "turn") return
|
88
|
+
else if (s == "deg") return UnitType::DEG;
|
89
|
+
else if (s == "grad") return UnitType::GRAD;
|
90
|
+
else if (s == "rad") return UnitType::RAD;
|
91
|
+
else if (s == "turn") return UnitType::TURN;
|
82
92
|
// time units
|
83
|
-
else if (s == "s") return
|
84
|
-
else if (s == "ms") return
|
93
|
+
else if (s == "s") return UnitType::SEC;
|
94
|
+
else if (s == "ms") return UnitType::MSEC;
|
85
95
|
// frequency units
|
86
|
-
else if (s == "Hz") return
|
87
|
-
else if (s == "kHz") return
|
96
|
+
else if (s == "Hz") return UnitType::HERTZ;
|
97
|
+
else if (s == "kHz") return UnitType::KHERTZ;
|
88
98
|
// resolutions units
|
89
|
-
else if (s == "dpi") return
|
90
|
-
else if (s == "dpcm") return
|
91
|
-
else if (s == "dppx") return
|
99
|
+
else if (s == "dpi") return UnitType::DPI;
|
100
|
+
else if (s == "dpcm") return UnitType::DPCM;
|
101
|
+
else if (s == "dppx") return UnitType::DPPX;
|
92
102
|
// for unknown units
|
93
|
-
else return
|
103
|
+
else return UnitType::UNKNOWN;
|
94
104
|
}
|
95
105
|
|
96
|
-
const char* unit_to_string(
|
106
|
+
const char* unit_to_string(UnitType unit)
|
97
107
|
{
|
98
108
|
switch (unit) {
|
99
109
|
// size units
|
100
|
-
case
|
101
|
-
case
|
102
|
-
case
|
103
|
-
case
|
104
|
-
case
|
105
|
-
case
|
110
|
+
case UnitType::PX: return "px"; break;
|
111
|
+
case UnitType::PT: return "pt"; break;
|
112
|
+
case UnitType::PC: return "pc"; break;
|
113
|
+
case UnitType::MM: return "mm"; break;
|
114
|
+
case UnitType::CM: return "cm"; break;
|
115
|
+
case UnitType::IN: return "in"; break;
|
106
116
|
// angle units
|
107
|
-
case
|
108
|
-
case
|
109
|
-
case
|
110
|
-
case
|
117
|
+
case UnitType::DEG: return "deg"; break;
|
118
|
+
case UnitType::GRAD: return "grad"; break;
|
119
|
+
case UnitType::RAD: return "rad"; break;
|
120
|
+
case UnitType::TURN: return "turn"; break;
|
111
121
|
// time units
|
112
|
-
case
|
113
|
-
case
|
122
|
+
case UnitType::SEC: return "s"; break;
|
123
|
+
case UnitType::MSEC: return "ms"; break;
|
114
124
|
// frequency units
|
115
|
-
case
|
116
|
-
case
|
125
|
+
case UnitType::HERTZ: return "Hz"; break;
|
126
|
+
case UnitType::KHERTZ: return "kHz"; break;
|
117
127
|
// resolutions units
|
118
|
-
case
|
119
|
-
case
|
120
|
-
case
|
128
|
+
case UnitType::DPI: return "dpi"; break;
|
129
|
+
case UnitType::DPCM: return "dpcm"; break;
|
130
|
+
case UnitType::DPPX: return "dppx"; break;
|
121
131
|
// for unknown units
|
122
132
|
default: return ""; break;
|
123
133
|
}
|
124
134
|
}
|
125
135
|
|
136
|
+
std::string unit_to_class(const std::string& s)
|
137
|
+
{
|
138
|
+
if (s == "px") return "LENGTH";
|
139
|
+
else if (s == "pt") return "LENGTH";
|
140
|
+
else if (s == "pc") return "LENGTH";
|
141
|
+
else if (s == "mm") return "LENGTH";
|
142
|
+
else if (s == "cm") return "LENGTH";
|
143
|
+
else if (s == "in") return "LENGTH";
|
144
|
+
// angle units
|
145
|
+
else if (s == "deg") return "ANGLE";
|
146
|
+
else if (s == "grad") return "ANGLE";
|
147
|
+
else if (s == "rad") return "ANGLE";
|
148
|
+
else if (s == "turn") return "ANGLE";
|
149
|
+
// time units
|
150
|
+
else if (s == "s") return "TIME";
|
151
|
+
else if (s == "ms") return "TIME";
|
152
|
+
// frequency units
|
153
|
+
else if (s == "Hz") return "FREQUENCY";
|
154
|
+
else if (s == "kHz") return "FREQUENCY";
|
155
|
+
// resolutions units
|
156
|
+
else if (s == "dpi") return "RESOLUTION";
|
157
|
+
else if (s == "dpcm") return "RESOLUTION";
|
158
|
+
else if (s == "dppx") return "RESOLUTION";
|
159
|
+
// for unknown units
|
160
|
+
return "CUSTOM:" + s;
|
161
|
+
}
|
162
|
+
|
126
163
|
// throws incompatibleUnits exceptions
|
127
164
|
double conversion_factor(const std::string& s1, const std::string& s2, bool strict)
|
128
165
|
{
|
129
166
|
// assert for same units
|
130
167
|
if (s1 == s2) return 1;
|
131
168
|
// get unit enum from string
|
132
|
-
|
133
|
-
|
169
|
+
UnitType u1 = string_to_unit(s1);
|
170
|
+
UnitType u2 = string_to_unit(s2);
|
134
171
|
// query unit group types
|
135
|
-
|
136
|
-
|
172
|
+
UnitClass t1 = get_unit_type(u1);
|
173
|
+
UnitClass t2 = get_unit_type(u2);
|
137
174
|
// get absolute offset
|
138
175
|
// used for array acces
|
139
176
|
size_t i1 = u1 - t1;
|
@@ -144,17 +181,17 @@ namespace Sass {
|
|
144
181
|
// only process known units
|
145
182
|
if (u1 != UNKNOWN && u2 != UNKNOWN) {
|
146
183
|
switch (t1) {
|
147
|
-
case
|
148
|
-
case
|
149
|
-
case
|
150
|
-
case
|
151
|
-
case
|
184
|
+
case UnitClass::LENGTH: return size_conversion_factors[i1][i2]; break;
|
185
|
+
case UnitClass::ANGLE: return angle_conversion_factors[i1][i2]; break;
|
186
|
+
case UnitClass::TIME: return time_conversion_factors[i1][i2]; break;
|
187
|
+
case UnitClass::FREQUENCY: return frequency_conversion_factors[i1][i2]; break;
|
188
|
+
case UnitClass::RESOLUTION: return resolution_conversion_factors[i1][i2]; break;
|
152
189
|
// ToDo: should we throw error here?
|
153
|
-
case
|
190
|
+
case UnitClass::INCOMMENSURABLE: return 0; break;
|
154
191
|
}
|
155
192
|
}
|
156
193
|
// fallback
|
157
|
-
return
|
194
|
+
return 0;
|
158
195
|
}
|
159
196
|
|
160
197
|
}
|
data/ext/libsass/src/units.hpp
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
|
8
8
|
namespace Sass {
|
9
9
|
|
10
|
-
const double PI = acos(-1);
|
10
|
+
const double PI = std::acos(-1);
|
11
11
|
|
12
|
-
enum
|
12
|
+
enum UnitClass {
|
13
13
|
LENGTH = 0x000,
|
14
14
|
ANGLE = 0x100,
|
15
15
|
TIME = 0x200,
|
@@ -18,10 +18,10 @@ namespace Sass {
|
|
18
18
|
INCOMMENSURABLE = 0x500
|
19
19
|
};
|
20
20
|
|
21
|
-
enum
|
21
|
+
enum UnitType {
|
22
22
|
|
23
23
|
// size units
|
24
|
-
IN =
|
24
|
+
IN = UnitClass::LENGTH,
|
25
25
|
CM,
|
26
26
|
PC,
|
27
27
|
MM,
|
@@ -58,9 +58,11 @@ namespace Sass {
|
|
58
58
|
extern const double frequency_conversion_factors[2][2];
|
59
59
|
extern const double resolution_conversion_factors[3][3];
|
60
60
|
|
61
|
-
enum
|
62
|
-
const char* unit_to_string(
|
63
|
-
enum
|
61
|
+
enum Sass::UnitType string_to_unit(const std::string&);
|
62
|
+
const char* unit_to_string(Sass::UnitType unit);
|
63
|
+
enum Sass::UnitClass get_unit_type(Sass::UnitType unit);
|
64
|
+
std::string get_unit_class(Sass::UnitType unit);
|
65
|
+
std::string unit_to_class(const std::string&);
|
64
66
|
// throws incompatibleUnits exceptions
|
65
67
|
double conversion_factor(const std::string&, const std::string&, bool = true);
|
66
68
|
|
@@ -68,7 +70,7 @@ namespace Sass {
|
|
68
70
|
{
|
69
71
|
public:
|
70
72
|
const char* msg;
|
71
|
-
incompatibleUnits(
|
73
|
+
incompatibleUnits(Sass::UnitType a, Sass::UnitType b)
|
72
74
|
: exception()
|
73
75
|
{
|
74
76
|
std::stringstream ss;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
#include "sass.hpp"
|
1
2
|
#include <string>
|
2
3
|
#include <vector>
|
3
4
|
#include <cstdlib>
|
@@ -68,6 +69,8 @@ namespace Sass {
|
|
68
69
|
}
|
69
70
|
}
|
70
71
|
|
72
|
+
#ifdef _WIN32
|
73
|
+
|
71
74
|
// utf16 functions
|
72
75
|
using std::wstring;
|
73
76
|
|
@@ -93,5 +96,7 @@ namespace Sass {
|
|
93
96
|
return utf16;
|
94
97
|
}
|
95
98
|
|
99
|
+
#endif
|
100
|
+
|
96
101
|
}
|
97
102
|
}
|
data/ext/libsass/src/util.cpp
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#include "sass.hpp"
|
1
2
|
#include "sass.h"
|
2
3
|
#include "ast.hpp"
|
3
4
|
#include "util.hpp"
|
@@ -16,21 +17,15 @@ namespace Sass {
|
|
16
17
|
exit(EXIT_FAILURE); \
|
17
18
|
} while (0)
|
18
19
|
|
19
|
-
double round(double val)
|
20
|
+
double round(double val, size_t precision)
|
20
21
|
{
|
22
|
+
// https://github.com/sass/sass/commit/4e3e1d5684cc29073a507578fc977434ff488c93
|
23
|
+
if (fmod(val, 1) - 0.5 > - std::pow(0.1, precision + 1)) return std::ceil(val);
|
24
|
+
else if (fmod(val, 1) - 0.5 > std::pow(0.1, precision)) return std::floor(val);
|
21
25
|
// work around some compiler issue
|
22
26
|
// cygwin has it not defined in std
|
23
27
|
using namespace std;
|
24
|
-
|
25
|
-
// This was later repatched in 3.4.20
|
26
|
-
// which is as yet unreleased.
|
27
|
-
// https://github.com/sass/sass/commit/4e3e1d5684cc29073a507578fc977434ff488c93
|
28
|
-
if (fmod(val, 1) - 0.5 > -0.00001) return std::ceil(val);
|
29
28
|
return ::round(val);
|
30
|
-
|
31
|
-
// Use this version once sass-spec is at 3.4.20
|
32
|
-
// if (fmod(val, 1) - 0.5 > -0.00001) return ::round(val);
|
33
|
-
// return value > 0 ? std::ceil(val) : std::floor(val);
|
34
29
|
}
|
35
30
|
|
36
31
|
/* Sadly, sass_strdup is not portable. */
|
@@ -104,94 +99,6 @@ namespace Sass {
|
|
104
99
|
return *array = arr;
|
105
100
|
}
|
106
101
|
|
107
|
-
std::string string_eval_escapes(const std::string& s)
|
108
|
-
{
|
109
|
-
|
110
|
-
std::string out("");
|
111
|
-
bool esc = false;
|
112
|
-
for (size_t i = 0, L = s.length(); i < L; ++i) {
|
113
|
-
if(s[i] == '\\' && esc == false) {
|
114
|
-
esc = true;
|
115
|
-
|
116
|
-
// escape length
|
117
|
-
size_t len = 1;
|
118
|
-
|
119
|
-
// parse as many sequence chars as possible
|
120
|
-
// ToDo: Check if ruby aborts after possible max
|
121
|
-
while (i + len < L && s[i + len] && isxdigit(s[i + len])) ++ len;
|
122
|
-
|
123
|
-
// hex string?
|
124
|
-
if (len > 1) {
|
125
|
-
|
126
|
-
// convert the extracted hex string to code point value
|
127
|
-
// ToDo: Maybe we could do this without creating a substring
|
128
|
-
uint32_t cp = strtol(s.substr (i + 1, len - 1).c_str(), NULL, 16);
|
129
|
-
|
130
|
-
if (cp == 0) cp = 0xFFFD;
|
131
|
-
|
132
|
-
// assert invalid code points
|
133
|
-
if (cp >= 1) {
|
134
|
-
|
135
|
-
// use a very simple approach to convert via utf8 lib
|
136
|
-
// maybe there is a more elegant way; maybe we shoud
|
137
|
-
// convert the whole output from string to a stream!?
|
138
|
-
// allocate memory for utf8 char and convert to utf8
|
139
|
-
unsigned char u[5] = {0,0,0,0,0}; utf8::append(cp, u);
|
140
|
-
for(size_t m = 0; u[m] && m < 5; m++) out.push_back(u[m]);
|
141
|
-
|
142
|
-
// skip some more chars?
|
143
|
-
i += len - 1; esc = false;
|
144
|
-
if (cp == 10) out += ' ';
|
145
|
-
|
146
|
-
}
|
147
|
-
|
148
|
-
}
|
149
|
-
|
150
|
-
}
|
151
|
-
else {
|
152
|
-
out += s[i];
|
153
|
-
esc = false;
|
154
|
-
}
|
155
|
-
}
|
156
|
-
return out;
|
157
|
-
|
158
|
-
}
|
159
|
-
|
160
|
-
// double escape every escape sequences
|
161
|
-
// escape unescaped quotes and backslashes
|
162
|
-
std::string string_escape(const std::string& str)
|
163
|
-
{
|
164
|
-
std::string out("");
|
165
|
-
for (auto i : str) {
|
166
|
-
// escape some characters
|
167
|
-
if (i == '"') out += '\\';
|
168
|
-
if (i == '\'') out += '\\';
|
169
|
-
if (i == '\\') out += '\\';
|
170
|
-
out += i;
|
171
|
-
}
|
172
|
-
return out;
|
173
|
-
}
|
174
|
-
|
175
|
-
// unescape every escape sequence
|
176
|
-
// only removes unescaped backslashes
|
177
|
-
std::string string_unescape(const std::string& str)
|
178
|
-
{
|
179
|
-
std::string out("");
|
180
|
-
bool esc = false;
|
181
|
-
for (auto i : str) {
|
182
|
-
if (esc || i != '\\') {
|
183
|
-
esc = false;
|
184
|
-
out += i;
|
185
|
-
} else {
|
186
|
-
esc = true;
|
187
|
-
}
|
188
|
-
}
|
189
|
-
// open escape sequence at end
|
190
|
-
// maybe it should thow an error
|
191
|
-
if (esc) { out += '\\'; }
|
192
|
-
return out;
|
193
|
-
}
|
194
|
-
|
195
102
|
// read css string (handle multiline DELIM)
|
196
103
|
std::string read_css_string(const std::string& str)
|
197
104
|
{
|
@@ -215,28 +122,6 @@ namespace Sass {
|
|
215
122
|
return out;
|
216
123
|
}
|
217
124
|
|
218
|
-
// evacuate unescaped quoted
|
219
|
-
// leave everything else untouched
|
220
|
-
std::string evacuate_quotes(const std::string& str)
|
221
|
-
{
|
222
|
-
std::string out("");
|
223
|
-
bool esc = false;
|
224
|
-
for (auto i : str) {
|
225
|
-
if (!esc) {
|
226
|
-
// ignore next character
|
227
|
-
if (i == '\\') esc = true;
|
228
|
-
// evacuate unescaped quotes
|
229
|
-
else if (i == '"') out += '\\';
|
230
|
-
else if (i == '\'') out += '\\';
|
231
|
-
}
|
232
|
-
// get escaped char now
|
233
|
-
else { esc = false; }
|
234
|
-
// remove nothing
|
235
|
-
out += i;
|
236
|
-
}
|
237
|
-
return out;
|
238
|
-
}
|
239
|
-
|
240
125
|
// double escape all escape sequences
|
241
126
|
// keep unescaped quotes and backslashes
|
242
127
|
std::string evacuate_escapes(const std::string& str)
|
@@ -321,38 +206,6 @@ namespace Sass {
|
|
321
206
|
else return text;
|
322
207
|
}
|
323
208
|
|
324
|
-
std::string normalize_wspace(const std::string& str)
|
325
|
-
{
|
326
|
-
bool ws = false;
|
327
|
-
bool esc = false;
|
328
|
-
std::string text = "";
|
329
|
-
for(const char& i : str) {
|
330
|
-
if (!esc && i == '\\') {
|
331
|
-
esc = true;
|
332
|
-
ws = false;
|
333
|
-
text += i;
|
334
|
-
} else if (esc) {
|
335
|
-
esc = false;
|
336
|
-
ws = false;
|
337
|
-
text += i;
|
338
|
-
} else if (
|
339
|
-
i == ' ' ||
|
340
|
-
i == '\r' ||
|
341
|
-
i == '\n' ||
|
342
|
-
i == ' '
|
343
|
-
) {
|
344
|
-
// only add one space
|
345
|
-
if (!ws) text += ' ';
|
346
|
-
ws = true;
|
347
|
-
} else {
|
348
|
-
ws = false;
|
349
|
-
text += i;
|
350
|
-
}
|
351
|
-
}
|
352
|
-
if (esc) text += '\\';
|
353
|
-
return text;
|
354
|
-
}
|
355
|
-
|
356
209
|
// find best quote_mark by detecting if the string contains any single
|
357
210
|
// or double quotes. When a single quote is found, we not we want a double
|
358
211
|
// quote as quote_mark. Otherwise we check if the string cotains any double
|
@@ -462,7 +315,7 @@ namespace Sass {
|
|
462
315
|
|
463
316
|
}
|
464
317
|
|
465
|
-
std::string quote(const std::string& s, char q
|
318
|
+
std::string quote(const std::string& s, char q)
|
466
319
|
{
|
467
320
|
|
468
321
|
// autodetect with fallback to given quote
|
@@ -488,13 +341,27 @@ namespace Sass {
|
|
488
341
|
|
489
342
|
int cp = utf8::next(it, end);
|
490
343
|
|
344
|
+
// in case of \r, check if the next in sequence
|
345
|
+
// is \n and then advance the iterator.
|
346
|
+
if (cp == '\r' && it < end && utf8::peek_next(it, end) == '\n') {
|
347
|
+
cp = utf8::next(it, end);
|
348
|
+
}
|
349
|
+
|
491
350
|
if (cp == '\n') {
|
492
351
|
quoted.push_back('\\');
|
493
352
|
quoted.push_back('a');
|
494
353
|
// we hope we can remove this flag once we figure out
|
495
354
|
// why ruby sass has these different output behaviors
|
496
|
-
|
355
|
+
// gsub(/\n(?![a-fA-F0-9\s])/, "\\a").gsub("\n", "\\a ")
|
356
|
+
using namespace Prelexer;
|
357
|
+
if (alternatives <
|
358
|
+
Prelexer::char_range<'a', 'f'>,
|
359
|
+
Prelexer::char_range<'A', 'F'>,
|
360
|
+
Prelexer::char_range<'0', '9'>,
|
361
|
+
space
|
362
|
+
>(it) != NULL) {
|
497
363
|
quoted.push_back(' ');
|
364
|
+
}
|
498
365
|
} else if (cp < 127) {
|
499
366
|
quoted.push_back((char) cp);
|
500
367
|
} else {
|
@@ -615,7 +482,7 @@ namespace Sass {
|
|
615
482
|
}
|
616
483
|
} else if (Comment* c = dynamic_cast<Comment*>(stm)) {
|
617
484
|
// keep for uncompressed
|
618
|
-
if (style !=
|
485
|
+
if (style != COMPRESSED) {
|
619
486
|
hasDeclarations = true;
|
620
487
|
}
|
621
488
|
// output style compressed
|
@@ -720,7 +587,7 @@ namespace Sass {
|
|
720
587
|
else if (typeid(*stm) == typeid(Comment)) {
|
721
588
|
Comment* c = (Comment*) stm;
|
722
589
|
// keep for uncompressed
|
723
|
-
if (style !=
|
590
|
+
if (style != COMPRESSED) {
|
724
591
|
return true;
|
725
592
|
}
|
726
593
|
// output style compressed
|