sassc 1.7.1 → 1.8.0.pre1
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/.gitignore +10 -6
- data/ext/libsass/.travis.yml +4 -1
- data/ext/libsass/GNUmakefile.am +88 -0
- data/ext/libsass/Makefile +157 -76
- data/ext/libsass/Makefile.conf +47 -0
- data/ext/libsass/Readme.md +13 -14
- data/ext/libsass/appveyor.yml +25 -41
- data/ext/libsass/configure.ac +20 -7
- data/ext/libsass/contrib/plugin.cpp +1 -1
- data/ext/libsass/include/sass.h +15 -0
- data/ext/libsass/{sass.h → include/sass/base.h} +17 -9
- data/ext/libsass/{sass_context.h → include/sass/context.h} +3 -1
- data/ext/libsass/{sass_functions.h → include/sass/functions.h} +4 -4
- data/ext/libsass/{sass_interface.h → include/sass/interface.h} +5 -2
- data/ext/libsass/{sass_values.h → include/sass/values.h} +15 -1
- data/ext/libsass/{sass_version.h → include/sass/version.h} +0 -0
- data/ext/libsass/{sass_version.h.in → include/sass/version.h.in} +0 -0
- data/ext/libsass/{sass2scss.h → include/sass2scss.h} +6 -7
- data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +167 -0
- data/ext/libsass/script/ci-build-libsass +67 -23
- data/ext/libsass/src/GNUmakefile.am +54 -0
- data/ext/libsass/src/ast.cpp +2029 -0
- data/ext/libsass/{ast.hpp → src/ast.hpp} +832 -660
- data/ext/libsass/src/ast_def_macros.hpp +47 -0
- data/ext/libsass/src/ast_factory.hpp +93 -0
- data/ext/libsass/{ast_fwd_decl.hpp → src/ast_fwd_decl.hpp} +9 -4
- data/ext/libsass/{b64 → src/b64}/cencode.h +1 -1
- data/ext/libsass/{b64 → src/b64}/encode.h +0 -0
- data/ext/libsass/{backtrace.hpp → src/backtrace.hpp} +9 -10
- data/ext/libsass/{base64vlq.cpp → src/base64vlq.cpp} +2 -2
- data/ext/libsass/{base64vlq.hpp → src/base64vlq.hpp} +1 -2
- data/ext/libsass/{bind.cpp → src/bind.cpp} +96 -59
- data/ext/libsass/{bind.hpp → src/bind.hpp} +1 -1
- data/ext/libsass/src/c99func.c +54 -0
- data/ext/libsass/{cencode.c → src/cencode.c} +5 -5
- data/ext/libsass/src/color_maps.cpp +643 -0
- data/ext/libsass/src/color_maps.hpp +333 -0
- data/ext/libsass/{constants.cpp → src/constants.cpp} +10 -1
- data/ext/libsass/{constants.hpp → src/constants.hpp} +7 -0
- data/ext/libsass/{context.cpp → src/context.cpp} +152 -122
- data/ext/libsass/src/context.hpp +150 -0
- data/ext/libsass/{cssize.cpp → src/cssize.cpp} +123 -109
- data/ext/libsass/{cssize.hpp → src/cssize.hpp} +9 -13
- data/ext/libsass/{debug.hpp → src/debug.hpp} +9 -9
- data/ext/libsass/src/debugger.hpp +683 -0
- data/ext/libsass/{emitter.cpp → src/emitter.cpp} +13 -13
- data/ext/libsass/{emitter.hpp → src/emitter.hpp} +10 -11
- data/ext/libsass/src/environment.cpp +184 -0
- data/ext/libsass/src/environment.hpp +92 -0
- data/ext/libsass/src/error_handling.cpp +46 -0
- data/ext/libsass/src/error_handling.hpp +34 -0
- data/ext/libsass/src/eval.cpp +1462 -0
- data/ext/libsass/src/eval.hpp +107 -0
- data/ext/libsass/src/expand.cpp +653 -0
- data/ext/libsass/{expand.hpp → src/expand.hpp} +17 -16
- data/ext/libsass/{extend.cpp → src/extend.cpp} +198 -139
- data/ext/libsass/{extend.hpp → src/extend.hpp} +7 -8
- data/ext/libsass/{file.cpp → src/file.cpp} +103 -57
- data/ext/libsass/{file.hpp → src/file.hpp} +23 -14
- data/ext/libsass/{functions.cpp → src/functions.cpp} +642 -333
- data/ext/libsass/{functions.hpp → src/functions.hpp} +17 -4
- data/ext/libsass/{inspect.cpp → src/inspect.cpp} +147 -260
- data/ext/libsass/{inspect.hpp → src/inspect.hpp} +7 -7
- data/ext/libsass/{json.cpp → src/json.cpp} +33 -43
- data/ext/libsass/{json.hpp → src/json.hpp} +1 -1
- data/ext/libsass/{kwd_arg_macros.hpp → src/kwd_arg_macros.hpp} +0 -0
- data/ext/libsass/{lexer.cpp → src/lexer.cpp} +28 -0
- data/ext/libsass/{lexer.hpp → src/lexer.hpp} +25 -10
- data/ext/libsass/{listize.cpp → src/listize.cpp} +17 -13
- data/ext/libsass/{listize.hpp → src/listize.hpp} +0 -2
- data/ext/libsass/{mapping.hpp → src/mapping.hpp} +0 -0
- data/ext/libsass/src/memory_manager.cpp +76 -0
- data/ext/libsass/src/memory_manager.hpp +48 -0
- data/ext/libsass/{node.cpp → src/node.cpp} +89 -18
- data/ext/libsass/{node.hpp → src/node.hpp} +5 -6
- data/ext/libsass/{operation.hpp → src/operation.hpp} +18 -12
- data/ext/libsass/{output.cpp → src/output.cpp} +47 -55
- data/ext/libsass/{output.hpp → src/output.hpp} +5 -4
- data/ext/libsass/src/parser.cpp +2529 -0
- data/ext/libsass/{parser.hpp → src/parser.hpp} +84 -60
- data/ext/libsass/{paths.hpp → src/paths.hpp} +10 -13
- data/ext/libsass/{plugins.cpp → src/plugins.cpp} +14 -17
- data/ext/libsass/{plugins.hpp → src/plugins.hpp} +10 -11
- data/ext/libsass/{position.cpp → src/position.cpp} +5 -6
- data/ext/libsass/{position.hpp → src/position.hpp} +19 -22
- data/ext/libsass/{prelexer.cpp → src/prelexer.cpp} +401 -53
- data/ext/libsass/{prelexer.hpp → src/prelexer.hpp} +50 -10
- data/ext/libsass/{remove_placeholders.cpp → src/remove_placeholders.cpp} +12 -16
- data/ext/libsass/{remove_placeholders.hpp → src/remove_placeholders.hpp} +1 -7
- data/ext/libsass/{sass.cpp → src/sass.cpp} +3 -5
- data/ext/libsass/{sass2scss.cpp → src/sass2scss.cpp} +51 -46
- data/ext/libsass/{sass_context.cpp → src/sass_context.cpp} +114 -112
- data/ext/libsass/{sass_functions.cpp → src/sass_functions.cpp} +11 -18
- data/ext/libsass/{sass_interface.cpp → src/sass_interface.cpp} +44 -81
- data/ext/libsass/{sass_util.cpp → src/sass_util.cpp} +26 -8
- data/ext/libsass/{sass_util.hpp → src/sass_util.hpp} +14 -18
- data/ext/libsass/{sass_values.cpp → src/sass_values.cpp} +91 -20
- data/ext/libsass/{source_map.cpp → src/source_map.cpp} +13 -13
- data/ext/libsass/{source_map.hpp → src/source_map.hpp} +9 -9
- data/ext/libsass/{subset_map.hpp → src/subset_map.hpp} +29 -31
- data/ext/libsass/{support → src/support}/libsass.pc.in +0 -0
- data/ext/libsass/src/to_c.cpp +73 -0
- data/ext/libsass/src/to_c.hpp +41 -0
- data/ext/libsass/src/to_string.cpp +47 -0
- data/ext/libsass/{to_string.hpp → src/to_string.hpp} +9 -7
- data/ext/libsass/src/to_value.cpp +109 -0
- data/ext/libsass/src/to_value.hpp +50 -0
- data/ext/libsass/{units.cpp → src/units.cpp} +56 -51
- data/ext/libsass/{units.hpp → src/units.hpp} +8 -9
- data/ext/libsass/{utf8.h → src/utf8.h} +0 -0
- data/ext/libsass/{utf8 → src/utf8}/checked.h +0 -0
- data/ext/libsass/{utf8 → src/utf8}/core.h +12 -12
- data/ext/libsass/{utf8 → src/utf8}/unchecked.h +0 -0
- data/ext/libsass/{utf8_string.cpp → src/utf8_string.cpp} +0 -0
- data/ext/libsass/{utf8_string.hpp → src/utf8_string.hpp} +6 -6
- data/ext/libsass/{util.cpp → src/util.cpp} +144 -86
- data/ext/libsass/src/util.hpp +59 -0
- data/ext/libsass/src/values.cpp +137 -0
- data/ext/libsass/src/values.hpp +12 -0
- data/ext/libsass/test/test_node.cpp +33 -33
- data/ext/libsass/test/test_paths.cpp +5 -6
- data/ext/libsass/test/test_selector_difference.cpp +4 -5
- data/ext/libsass/test/test_specificity.cpp +4 -5
- data/ext/libsass/test/test_subset_map.cpp +91 -91
- data/ext/libsass/test/test_superselector.cpp +11 -11
- data/ext/libsass/test/test_unification.cpp +4 -4
- data/ext/libsass/win/libsass.targets +101 -0
- data/ext/libsass/win/libsass.vcxproj +45 -127
- data/ext/libsass/win/libsass.vcxproj.filters +303 -0
- data/lib/sassc/import_handler.rb +1 -1
- data/lib/sassc/native/native_functions_api.rb +3 -3
- data/lib/sassc/version.rb +1 -1
- data/test/custom_importer_test.rb +1 -4
- data/test/functions_test.rb +3 -2
- data/test/native_test.rb +4 -3
- metadata +117 -110
- data/ext/libsass/Makefile.am +0 -146
- data/ext/libsass/ast.cpp +0 -945
- data/ext/libsass/ast_def_macros.hpp +0 -21
- data/ext/libsass/ast_factory.hpp +0 -92
- data/ext/libsass/color_names.hpp +0 -327
- data/ext/libsass/context.hpp +0 -157
- data/ext/libsass/contextualize.cpp +0 -148
- data/ext/libsass/contextualize.hpp +0 -46
- data/ext/libsass/contextualize_eval.cpp +0 -93
- data/ext/libsass/contextualize_eval.hpp +0 -44
- data/ext/libsass/debugger.hpp +0 -558
- data/ext/libsass/environment.hpp +0 -163
- data/ext/libsass/error_handling.cpp +0 -35
- data/ext/libsass/error_handling.hpp +0 -32
- data/ext/libsass/eval.cpp +0 -1392
- data/ext/libsass/eval.hpp +0 -88
- data/ext/libsass/expand.cpp +0 -575
- data/ext/libsass/memory_manager.hpp +0 -57
- data/ext/libsass/parser.cpp +0 -2403
- data/ext/libsass/posix/getopt.c +0 -562
- data/ext/libsass/posix/getopt.h +0 -95
- data/ext/libsass/to_c.cpp +0 -61
- data/ext/libsass/to_c.hpp +0 -44
- data/ext/libsass/to_string.cpp +0 -34
- data/ext/libsass/util.hpp +0 -54
- data/ext/libsass/win/libsass.filters +0 -312
@@ -1,30 +1,29 @@
|
|
1
1
|
#ifndef SASS_EXTEND_H
|
2
2
|
#define SASS_EXTEND_H
|
3
3
|
|
4
|
-
#include <
|
5
|
-
#include <set>
|
6
|
-
#include <vector>
|
7
|
-
#include <iostream>
|
4
|
+
#include <string>
|
8
5
|
|
9
6
|
#include "ast.hpp"
|
10
7
|
#include "operation.hpp"
|
11
8
|
#include "subset_map.hpp"
|
12
9
|
|
13
10
|
namespace Sass {
|
14
|
-
using namespace std;
|
15
11
|
|
16
12
|
class Context;
|
13
|
+
class Node;
|
17
14
|
|
18
|
-
typedef Subset_Map<string, pair<Complex_Selector*, Compound_Selector*> > ExtensionSubsetMap;
|
15
|
+
typedef Subset_Map<std::string, std::pair<Complex_Selector*, Compound_Selector*> > ExtensionSubsetMap;
|
19
16
|
|
20
17
|
class Extend : public Operation_CRTP<void, Extend> {
|
21
18
|
|
22
19
|
Context& ctx;
|
23
20
|
ExtensionSubsetMap& subset_map;
|
24
21
|
|
25
|
-
void fallback_impl(AST_Node* n) { }
|
22
|
+
void fallback_impl(AST_Node* n) { }
|
26
23
|
|
27
24
|
public:
|
25
|
+
static Node subweave(Node& one, Node& two, Context& ctx);
|
26
|
+
static Selector_List* extendSelectorList(Selector_List* pSelectorList, Context& ctx, ExtensionSubsetMap& subset_map, bool isReplace, bool& extendedSomething);
|
28
27
|
Extend(Context&, ExtensionSubsetMap&);
|
29
28
|
virtual ~Extend() { }
|
30
29
|
|
@@ -32,7 +31,7 @@ namespace Sass {
|
|
32
31
|
|
33
32
|
void operator()(Block*);
|
34
33
|
void operator()(Ruleset*);
|
35
|
-
void operator()(
|
34
|
+
void operator()(Supports_Block*);
|
36
35
|
void operator()(Media_Block*);
|
37
36
|
void operator()(At_Rule*);
|
38
37
|
|
@@ -1,10 +1,18 @@
|
|
1
1
|
#ifdef _WIN32
|
2
|
+
#ifdef __MINGW32__
|
3
|
+
#ifndef off64_t
|
4
|
+
#define off64_t _off64_t /* Workaround for http://sourceforge.net/p/mingw/bugs/2024/ */
|
5
|
+
#endif
|
6
|
+
#endif
|
2
7
|
#include <direct.h>
|
3
8
|
#define getcwd _getcwd
|
4
9
|
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
5
10
|
#else
|
6
11
|
#include <unistd.h>
|
7
12
|
#endif
|
13
|
+
#ifdef _MSC_VER
|
14
|
+
#define NOMINMAX
|
15
|
+
#endif
|
8
16
|
|
9
17
|
#include <iostream>
|
10
18
|
#include <fstream>
|
@@ -14,6 +22,7 @@
|
|
14
22
|
#include <sys/stat.h>
|
15
23
|
#include "file.hpp"
|
16
24
|
#include "context.hpp"
|
25
|
+
#include "prelexer.hpp"
|
17
26
|
#include "utf8_string.hpp"
|
18
27
|
#include "sass2scss.h"
|
19
28
|
|
@@ -31,15 +40,14 @@
|
|
31
40
|
|
32
41
|
namespace Sass {
|
33
42
|
namespace File {
|
34
|
-
using namespace std;
|
35
43
|
|
36
44
|
// return the current directory
|
37
45
|
// always with forward slashes
|
38
|
-
string get_cwd()
|
46
|
+
std::string get_cwd()
|
39
47
|
{
|
40
48
|
const size_t wd_len = 1024;
|
41
49
|
char wd[wd_len];
|
42
|
-
string cwd = getcwd(wd, wd_len);
|
50
|
+
std::string cwd = getcwd(wd, wd_len);
|
43
51
|
#ifdef _WIN32
|
44
52
|
//convert backslashes to forward slashes
|
45
53
|
replace(cwd.begin(), cwd.end(), '\\', '/');
|
@@ -49,10 +57,10 @@ namespace Sass {
|
|
49
57
|
}
|
50
58
|
|
51
59
|
// test if path exists and is a file
|
52
|
-
bool file_exists(const string& path)
|
60
|
+
bool file_exists(const std::string& path)
|
53
61
|
{
|
54
62
|
#ifdef _WIN32
|
55
|
-
wstring wpath = UTF_8::convert_to_utf16(path);
|
63
|
+
std::wstring wpath = UTF_8::convert_to_utf16(path);
|
56
64
|
DWORD dwAttrib = GetFileAttributesW(wpath.c_str());
|
57
65
|
return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
|
58
66
|
(!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)));
|
@@ -65,28 +73,35 @@ namespace Sass {
|
|
65
73
|
|
66
74
|
// return if given path is absolute
|
67
75
|
// works with *nix and windows paths
|
68
|
-
bool is_absolute_path(const string& path)
|
76
|
+
bool is_absolute_path(const std::string& path)
|
69
77
|
{
|
70
78
|
#ifdef _WIN32
|
71
79
|
if (path.length() >= 2 && isalpha(path[0]) && path[1] == ':') return true;
|
72
80
|
#endif
|
73
|
-
|
81
|
+
size_t i = 0;
|
82
|
+
// check if we have a protocol
|
83
|
+
if (path[i] && Prelexer::is_alpha(path[i])) {
|
84
|
+
// skip over all alphanumeric characters
|
85
|
+
while (path[i] && Prelexer::is_alnum(path[i])) ++i;
|
86
|
+
i = i && path[i] == ':' ? i + 1 : 0;
|
87
|
+
}
|
88
|
+
return path[i] == '/';
|
74
89
|
}
|
75
90
|
|
76
91
|
// helper function to find the last directory seperator
|
77
|
-
inline size_t find_last_folder_separator(const string& path, size_t limit = string::npos)
|
92
|
+
inline size_t find_last_folder_separator(const std::string& path, size_t limit = std::string::npos)
|
78
93
|
{
|
79
|
-
size_t pos = string::npos;
|
94
|
+
size_t pos = std::string::npos;
|
80
95
|
size_t pos_p = path.find_last_of('/', limit);
|
81
96
|
#ifdef _WIN32
|
82
97
|
size_t pos_w = path.find_last_of('\\', limit);
|
83
98
|
#else
|
84
|
-
size_t pos_w = string::npos;
|
99
|
+
size_t pos_w = std::string::npos;
|
85
100
|
#endif
|
86
|
-
if (pos_p != string::npos && pos_w != string::npos) {
|
87
|
-
pos = max(pos_p, pos_w);
|
101
|
+
if (pos_p != std::string::npos && pos_w != std::string::npos) {
|
102
|
+
pos = std::max(pos_p, pos_w);
|
88
103
|
}
|
89
|
-
else if (pos_p != string::npos) {
|
104
|
+
else if (pos_p != std::string::npos) {
|
90
105
|
pos = pos_p;
|
91
106
|
}
|
92
107
|
else {
|
@@ -96,24 +111,24 @@ namespace Sass {
|
|
96
111
|
}
|
97
112
|
|
98
113
|
// return only the directory part of path
|
99
|
-
string dir_name(const string& path)
|
114
|
+
std::string dir_name(const std::string& path)
|
100
115
|
{
|
101
116
|
size_t pos = find_last_folder_separator(path);
|
102
|
-
if (pos == string::npos) return "";
|
117
|
+
if (pos == std::string::npos) return "";
|
103
118
|
else return path.substr(0, pos+1);
|
104
119
|
}
|
105
120
|
|
106
121
|
// return only the filename part of path
|
107
|
-
string base_name(const string& path)
|
122
|
+
std::string base_name(const std::string& path)
|
108
123
|
{
|
109
124
|
size_t pos = find_last_folder_separator(path);
|
110
|
-
if (pos == string::npos) return path;
|
125
|
+
if (pos == std::string::npos) return path;
|
111
126
|
else return path.substr(pos+1);
|
112
127
|
}
|
113
128
|
|
114
129
|
// do a locigal clean up of the path
|
115
130
|
// no physical check on the filesystem
|
116
|
-
string make_canonical_path (string path)
|
131
|
+
std::string make_canonical_path (std::string path)
|
117
132
|
{
|
118
133
|
|
119
134
|
// declarations
|
@@ -125,14 +140,27 @@ namespace Sass {
|
|
125
140
|
#endif
|
126
141
|
|
127
142
|
pos = 0; // remove all self references inside the path string
|
128
|
-
while((pos = path.find("/./", pos)) != string::npos) path.erase(pos, 2);
|
143
|
+
while((pos = path.find("/./", pos)) != std::string::npos) path.erase(pos, 2);
|
129
144
|
|
130
145
|
pos = 0; // remove all leading and trailing self references
|
131
146
|
while(path.length() > 1 && path.substr(0, 2) == "./") path.erase(0, 2);
|
132
147
|
while((pos = path.length()) > 1 && path.substr(pos - 2) == "/.") path.erase(pos - 2);
|
133
148
|
|
134
|
-
|
135
|
-
|
149
|
+
|
150
|
+
size_t proto = 0;
|
151
|
+
// check if we have a protocol
|
152
|
+
if (path[proto] && Prelexer::is_alpha(path[proto])) {
|
153
|
+
// skip over all alphanumeric characters
|
154
|
+
while (path[proto] && Prelexer::is_alnum(path[proto++])) {}
|
155
|
+
// then skip over the mandatory colon
|
156
|
+
if (proto && path[proto] == ':') ++ proto;
|
157
|
+
}
|
158
|
+
|
159
|
+
// then skip over start slashes
|
160
|
+
while (path[proto++] == '/') {}
|
161
|
+
|
162
|
+
pos = proto; // collapse multiple delimiters into a single one
|
163
|
+
while((pos = path.find("//", pos)) != std::string::npos) path.erase(pos, 1);
|
136
164
|
|
137
165
|
return path;
|
138
166
|
|
@@ -140,7 +168,7 @@ namespace Sass {
|
|
140
168
|
|
141
169
|
// join two path segments cleanly together
|
142
170
|
// but only if right side is not absolute yet
|
143
|
-
string join_paths(string l, string r)
|
171
|
+
std::string join_paths(std::string l, std::string r)
|
144
172
|
{
|
145
173
|
|
146
174
|
#ifdef _WIN32
|
@@ -158,25 +186,38 @@ namespace Sass {
|
|
158
186
|
while ((r.length() > 3) && ((r.substr(0, 3) == "../") || (r.substr(0, 3)) == "..\\")) {
|
159
187
|
r = r.substr(3);
|
160
188
|
size_t pos = find_last_folder_separator(l, l.length() - 2);
|
161
|
-
l = l.substr(0, pos == string::npos ? pos : pos + 1);
|
189
|
+
l = l.substr(0, pos == std::string::npos ? pos : pos + 1);
|
162
190
|
}
|
163
191
|
|
164
192
|
return l + r;
|
165
193
|
}
|
166
194
|
|
167
195
|
// create an absolute path by resolving relative paths with cwd
|
168
|
-
string make_absolute_path(const string& path, const string& cwd)
|
196
|
+
std::string make_absolute_path(const std::string& path, const std::string& cwd)
|
169
197
|
{
|
170
198
|
return make_canonical_path((is_absolute_path(path) ? path : join_paths(cwd, path)));
|
171
199
|
}
|
172
200
|
|
173
201
|
// create a path that is relative to the given base directory
|
174
202
|
// path and base will first be resolved against cwd to make them absolute
|
175
|
-
string resolve_relative_path(const string& uri, const string& base, const string& cwd)
|
203
|
+
std::string resolve_relative_path(const std::string& uri, const std::string& base, const std::string& cwd)
|
176
204
|
{
|
177
205
|
|
178
|
-
string absolute_uri = make_absolute_path(uri, cwd);
|
179
|
-
string absolute_base = make_absolute_path(base, cwd);
|
206
|
+
std::string absolute_uri = make_absolute_path(uri, cwd);
|
207
|
+
std::string absolute_base = make_absolute_path(base, cwd);
|
208
|
+
|
209
|
+
size_t proto = 0;
|
210
|
+
// check if we have a protocol
|
211
|
+
if (uri[proto] && Prelexer::is_alpha(uri[proto])) {
|
212
|
+
// skip over all alphanumeric characters
|
213
|
+
while (uri[proto] && Prelexer::is_alnum(uri[proto++])) {}
|
214
|
+
// then skip over the mandatory colon
|
215
|
+
if (proto && uri[proto] == ':') ++ proto;
|
216
|
+
}
|
217
|
+
|
218
|
+
// distinguish between windows absolute paths and valid protocols
|
219
|
+
// we assume that protocols must at least have two chars to be valid
|
220
|
+
if (proto && uri[proto++] == '/' && proto > 3) return uri;
|
180
221
|
|
181
222
|
#ifdef _WIN32
|
182
223
|
// absolute link must have a drive letter, and we know that we
|
@@ -184,11 +225,11 @@ namespace Sass {
|
|
184
225
|
if (absolute_base[0] != absolute_uri[0]) return absolute_uri;
|
185
226
|
#endif
|
186
227
|
|
187
|
-
string stripped_uri = "";
|
188
|
-
string stripped_base = "";
|
228
|
+
std::string stripped_uri = "";
|
229
|
+
std::string stripped_base = "";
|
189
230
|
|
190
231
|
size_t index = 0;
|
191
|
-
size_t minSize = min(absolute_uri.size(), absolute_base.size());
|
232
|
+
size_t minSize = std::min(absolute_uri.size(), absolute_base.size());
|
192
233
|
for (size_t i = 0; i < minSize; ++i) {
|
193
234
|
#ifdef FS_CASE_SENSITIVE
|
194
235
|
if (absolute_uri[i] != absolute_base[i]) break;
|
@@ -223,7 +264,7 @@ namespace Sass {
|
|
223
264
|
}
|
224
265
|
}
|
225
266
|
|
226
|
-
string result = "";
|
267
|
+
std::string result = "";
|
227
268
|
for (size_t i = 0; i < directories; ++i) {
|
228
269
|
result += "../";
|
229
270
|
}
|
@@ -237,54 +278,59 @@ namespace Sass {
|
|
237
278
|
// (2) underscore + given
|
238
279
|
// (3) underscore + given + extension
|
239
280
|
// (4) given + extension
|
240
|
-
|
281
|
+
std::vector<Sass_Queued> resolve_file(const std::string& root, const std::string& file)
|
241
282
|
{
|
283
|
+
std::string filename = join_paths(root, file);
|
242
284
|
// supported extensions
|
243
|
-
const vector<string> exts = {
|
285
|
+
const std::vector<std::string> exts = {
|
244
286
|
".scss", ".sass", ".css"
|
245
287
|
};
|
246
288
|
// split the filename
|
247
|
-
string base(dir_name(
|
248
|
-
string name(base_name(
|
289
|
+
std::string base(dir_name(file));
|
290
|
+
std::string name(base_name(file));
|
291
|
+
std::vector<Sass_Queued> resolved;
|
249
292
|
// create full path (maybe relative)
|
250
|
-
string
|
251
|
-
|
293
|
+
std::string rel_path(join_paths(base, name));
|
294
|
+
std::string abs_path(join_paths(root, rel_path));
|
295
|
+
if (file_exists(abs_path)) resolved.push_back(Sass_Queued(rel_path, abs_path, 0));
|
252
296
|
// next test variation with underscore
|
253
|
-
|
254
|
-
|
297
|
+
rel_path = join_paths(base, "_" + name);
|
298
|
+
abs_path = join_paths(root, rel_path);
|
299
|
+
if (file_exists(abs_path)) resolved.push_back(Sass_Queued(rel_path, abs_path, 0));
|
255
300
|
// next test exts plus underscore
|
256
301
|
for(auto ext : exts) {
|
257
|
-
|
258
|
-
|
302
|
+
rel_path = join_paths(base, "_" + name + ext);
|
303
|
+
abs_path = join_paths(root, rel_path);
|
304
|
+
if (file_exists(abs_path)) resolved.push_back(Sass_Queued(rel_path, abs_path, 0));
|
259
305
|
}
|
260
306
|
// next test plain name with exts
|
261
307
|
for(auto ext : exts) {
|
262
|
-
|
263
|
-
|
308
|
+
rel_path = join_paths(base, name + ext);
|
309
|
+
abs_path = join_paths(root, rel_path);
|
310
|
+
if (file_exists(abs_path)) resolved.push_back(Sass_Queued(rel_path, abs_path, 0));
|
264
311
|
}
|
265
312
|
// nothing found
|
266
|
-
return
|
313
|
+
return resolved;
|
267
314
|
}
|
268
315
|
|
269
316
|
// helper function to resolve a filename
|
270
|
-
string find_file(const string& file, const vector<string> paths)
|
317
|
+
std::string find_file(const std::string& file, const std::vector<std::string> paths)
|
271
318
|
{
|
272
319
|
// search in every include path for a match
|
273
320
|
for (size_t i = 0, S = paths.size(); i < S; ++i)
|
274
321
|
{
|
275
|
-
|
276
|
-
|
277
|
-
if (resolved != "") return resolved;
|
322
|
+
std::vector<Sass_Queued> resolved(resolve_file(paths[i], file));
|
323
|
+
if (resolved.size()) return resolved[0].abs_path;
|
278
324
|
}
|
279
325
|
// nothing found
|
280
|
-
return string("");
|
326
|
+
return std::string("");
|
281
327
|
}
|
282
328
|
|
283
329
|
// inc paths can be directly passed from C code
|
284
|
-
string find_file(const string& file, const char* paths[])
|
330
|
+
std::string find_file(const std::string& file, const char* paths[])
|
285
331
|
{
|
286
|
-
if (paths == 0) return string("");
|
287
|
-
vector<string> includes(0);
|
332
|
+
if (paths == 0) return std::string("");
|
333
|
+
std::vector<std::string> includes(0);
|
288
334
|
// includes.push_back(".");
|
289
335
|
const char** it = paths;
|
290
336
|
while (it && *it) {
|
@@ -297,13 +343,13 @@ namespace Sass {
|
|
297
343
|
// try to load the given filename
|
298
344
|
// returned memory must be freed
|
299
345
|
// will auto convert .sass files
|
300
|
-
char* read_file(const string& path)
|
346
|
+
char* read_file(const std::string& path)
|
301
347
|
{
|
302
348
|
#ifdef _WIN32
|
303
349
|
BYTE* pBuffer;
|
304
350
|
DWORD dwBytes;
|
305
351
|
// windows unicode filepaths are encoded in utf16
|
306
|
-
wstring wpath = UTF_8::convert_to_utf16(path);
|
352
|
+
std::wstring wpath = UTF_8::convert_to_utf16(path);
|
307
353
|
HANDLE hFile = CreateFileW(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
308
354
|
if (hFile == INVALID_HANDLE_VALUE) return 0;
|
309
355
|
DWORD dwFileLength = GetFileSize(hFile, NULL);
|
@@ -318,19 +364,19 @@ namespace Sass {
|
|
318
364
|
#else
|
319
365
|
struct stat st;
|
320
366
|
if (stat(path.c_str(), &st) == -1 || S_ISDIR(st.st_mode)) return 0;
|
321
|
-
ifstream file(path.c_str(), ios::in | ios::binary | ios::ate);
|
367
|
+
std::ifstream file(path.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
322
368
|
char* contents = 0;
|
323
369
|
if (file.is_open()) {
|
324
370
|
size_t size = file.tellg();
|
325
371
|
// allocate an extra byte for the null char
|
326
372
|
contents = (char*) malloc((size+1)*sizeof(char));
|
327
|
-
file.seekg(0, ios::beg);
|
373
|
+
file.seekg(0, std::ios::beg);
|
328
374
|
file.read(contents, size);
|
329
375
|
contents[size] = '\0';
|
330
376
|
file.close();
|
331
377
|
}
|
332
378
|
#endif
|
333
|
-
string extension;
|
379
|
+
std::string extension;
|
334
380
|
if (path.length() > 5) {
|
335
381
|
extension = path.substr(path.length() - 5, 5);
|
336
382
|
}
|
@@ -5,54 +5,63 @@
|
|
5
5
|
#include <vector>
|
6
6
|
|
7
7
|
namespace Sass {
|
8
|
-
|
8
|
+
|
9
9
|
class Context;
|
10
|
+
|
11
|
+
struct Sass_Queued {
|
12
|
+
std::string abs_path;
|
13
|
+
std::string load_path;
|
14
|
+
const char* source;
|
15
|
+
public:
|
16
|
+
Sass_Queued(const std::string& load_path, const std::string& abs_path, const char* source);
|
17
|
+
};
|
18
|
+
|
10
19
|
namespace File {
|
11
20
|
|
12
21
|
// return the current directory
|
13
22
|
// always with forward slashes
|
14
|
-
string get_cwd();
|
23
|
+
std::string get_cwd();
|
15
24
|
|
16
25
|
// test if path exists and is a file
|
17
|
-
bool file_exists(const string& file);
|
26
|
+
bool file_exists(const std::string& file);
|
18
27
|
|
19
28
|
// return if given path is absolute
|
20
29
|
// works with *nix and windows paths
|
21
|
-
bool is_absolute_path(const string& path);
|
30
|
+
bool is_absolute_path(const std::string& path);
|
22
31
|
|
23
32
|
// return only the directory part of path
|
24
|
-
string dir_name(const string& path);
|
33
|
+
std::string dir_name(const std::string& path);
|
25
34
|
|
26
35
|
// return only the filename part of path
|
27
|
-
string base_name(const string&);
|
36
|
+
std::string base_name(const std::string&);
|
28
37
|
|
29
38
|
// do a locigal clean up of the path
|
30
39
|
// no physical check on the filesystem
|
31
|
-
string make_canonical_path (string path);
|
40
|
+
std::string make_canonical_path (std::string path);
|
32
41
|
|
33
42
|
// join two path segments cleanly together
|
34
43
|
// but only if right side is not absolute yet
|
35
|
-
string join_paths(string root, string name);
|
44
|
+
std::string join_paths(std::string root, std::string name);
|
36
45
|
|
37
46
|
// create an absolute path by resolving relative paths with cwd
|
38
|
-
string make_absolute_path(const string& path, const string& cwd = ".");
|
47
|
+
std::string make_absolute_path(const std::string& path, const std::string& cwd = ".");
|
39
48
|
|
40
49
|
// create a path that is relative to the given base directory
|
41
50
|
// path and base will first be resolved against cwd to make them absolute
|
42
|
-
string resolve_relative_path(const string& path, const string& base, const string& cwd = ".");
|
51
|
+
std::string resolve_relative_path(const std::string& path, const std::string& base, const std::string& cwd = ".");
|
43
52
|
|
44
53
|
// try to find/resolve the filename
|
45
|
-
|
54
|
+
std::vector<Sass_Queued> resolve_file(const std::string& root, const std::string& file);
|
46
55
|
|
47
56
|
// helper function to resolve a filename
|
48
|
-
string find_file(const string& file, const vector<string> paths);
|
57
|
+
std::string find_file(const std::string& file, const std::vector<std::string> paths);
|
49
58
|
// inc paths can be directly passed from C code
|
50
|
-
string find_file(const string& file, const char** paths);
|
59
|
+
std::string find_file(const std::string& file, const char** paths);
|
51
60
|
|
52
61
|
// try to load the given filename
|
53
62
|
// returned memory must be freed
|
54
63
|
// will auto convert .sass files
|
55
|
-
char* read_file(const string& file);
|
64
|
+
char* read_file(const std::string& file);
|
56
65
|
|
57
66
|
}
|
58
67
|
}
|