sassc 2.2.1 → 2.4.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.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGELOG.md +18 -0
  4. data/Rakefile +1 -3
  5. data/ext/extconf.rb +13 -5
  6. data/ext/libsass/VERSION +1 -1
  7. data/ext/libsass/include/sass/base.h +2 -1
  8. data/ext/libsass/include/sass/context.h +4 -0
  9. data/ext/libsass/src/MurmurHash2.hpp +91 -0
  10. data/ext/libsass/src/ast.cpp +158 -168
  11. data/ext/libsass/src/ast.hpp +389 -230
  12. data/ext/libsass/src/ast_def_macros.hpp +18 -10
  13. data/ext/libsass/src/ast_fwd_decl.cpp +4 -3
  14. data/ext/libsass/src/ast_fwd_decl.hpp +98 -165
  15. data/ext/libsass/src/ast_helpers.hpp +292 -0
  16. data/ext/libsass/src/ast_sel_cmp.cpp +219 -732
  17. data/ext/libsass/src/ast_sel_super.cpp +539 -0
  18. data/ext/libsass/src/ast_sel_unify.cpp +207 -212
  19. data/ext/libsass/src/ast_sel_weave.cpp +616 -0
  20. data/ext/libsass/src/ast_selectors.cpp +594 -1026
  21. data/ext/libsass/src/ast_selectors.hpp +339 -385
  22. data/ext/libsass/src/ast_supports.cpp +36 -52
  23. data/ext/libsass/src/ast_supports.hpp +29 -29
  24. data/ext/libsass/src/ast_values.cpp +271 -84
  25. data/ext/libsass/src/ast_values.hpp +116 -107
  26. data/ext/libsass/src/backtrace.cpp +9 -9
  27. data/ext/libsass/src/backtrace.hpp +5 -5
  28. data/ext/libsass/src/base64vlq.cpp +2 -2
  29. data/ext/libsass/src/base64vlq.hpp +1 -1
  30. data/ext/libsass/src/bind.cpp +18 -18
  31. data/ext/libsass/src/bind.hpp +1 -1
  32. data/ext/libsass/src/c2ast.cpp +3 -3
  33. data/ext/libsass/src/c2ast.hpp +1 -1
  34. data/ext/libsass/src/cencode.c +4 -6
  35. data/ext/libsass/src/check_nesting.cpp +40 -41
  36. data/ext/libsass/src/check_nesting.hpp +6 -2
  37. data/ext/libsass/src/color_maps.cpp +14 -13
  38. data/ext/libsass/src/color_maps.hpp +1 -9
  39. data/ext/libsass/src/constants.cpp +5 -0
  40. data/ext/libsass/src/constants.hpp +6 -0
  41. data/ext/libsass/src/context.cpp +92 -119
  42. data/ext/libsass/src/context.hpp +41 -53
  43. data/ext/libsass/src/cssize.cpp +66 -149
  44. data/ext/libsass/src/cssize.hpp +17 -23
  45. data/ext/libsass/src/dart_helpers.hpp +199 -0
  46. data/ext/libsass/src/debugger.hpp +451 -295
  47. data/ext/libsass/src/emitter.cpp +15 -16
  48. data/ext/libsass/src/emitter.hpp +10 -12
  49. data/ext/libsass/src/environment.cpp +27 -27
  50. data/ext/libsass/src/environment.hpp +29 -24
  51. data/ext/libsass/src/error_handling.cpp +62 -41
  52. data/ext/libsass/src/error_handling.hpp +61 -51
  53. data/ext/libsass/src/eval.cpp +167 -281
  54. data/ext/libsass/src/eval.hpp +27 -29
  55. data/ext/libsass/src/eval_selectors.cpp +75 -0
  56. data/ext/libsass/src/expand.cpp +275 -222
  57. data/ext/libsass/src/expand.hpp +36 -16
  58. data/ext/libsass/src/extender.cpp +1188 -0
  59. data/ext/libsass/src/extender.hpp +399 -0
  60. data/ext/libsass/src/extension.cpp +43 -0
  61. data/ext/libsass/src/extension.hpp +89 -0
  62. data/ext/libsass/src/file.cpp +81 -72
  63. data/ext/libsass/src/file.hpp +28 -37
  64. data/ext/libsass/src/fn_colors.cpp +20 -18
  65. data/ext/libsass/src/fn_lists.cpp +30 -29
  66. data/ext/libsass/src/fn_maps.cpp +3 -3
  67. data/ext/libsass/src/fn_miscs.cpp +34 -46
  68. data/ext/libsass/src/fn_numbers.cpp +20 -13
  69. data/ext/libsass/src/fn_selectors.cpp +98 -128
  70. data/ext/libsass/src/fn_strings.cpp +47 -33
  71. data/ext/libsass/src/fn_utils.cpp +31 -29
  72. data/ext/libsass/src/fn_utils.hpp +17 -11
  73. data/ext/libsass/src/inspect.cpp +186 -148
  74. data/ext/libsass/src/inspect.hpp +31 -29
  75. data/ext/libsass/src/lexer.cpp +20 -82
  76. data/ext/libsass/src/lexer.hpp +5 -16
  77. data/ext/libsass/src/listize.cpp +23 -37
  78. data/ext/libsass/src/listize.hpp +8 -9
  79. data/ext/libsass/src/mapping.hpp +1 -0
  80. data/ext/libsass/src/memory/allocator.cpp +48 -0
  81. data/ext/libsass/src/memory/allocator.hpp +138 -0
  82. data/ext/libsass/src/memory/config.hpp +20 -0
  83. data/ext/libsass/src/memory/memory_pool.hpp +186 -0
  84. data/ext/libsass/src/memory/{SharedPtr.cpp → shared_ptr.cpp} +2 -2
  85. data/ext/libsass/src/memory/{SharedPtr.hpp → shared_ptr.hpp} +55 -9
  86. data/ext/libsass/src/memory.hpp +12 -0
  87. data/ext/libsass/src/operation.hpp +71 -61
  88. data/ext/libsass/src/operators.cpp +19 -18
  89. data/ext/libsass/src/operators.hpp +11 -11
  90. data/ext/libsass/src/ordered_map.hpp +112 -0
  91. data/ext/libsass/src/output.cpp +45 -64
  92. data/ext/libsass/src/output.hpp +6 -6
  93. data/ext/libsass/src/parser.cpp +512 -700
  94. data/ext/libsass/src/parser.hpp +89 -97
  95. data/ext/libsass/src/parser_selectors.cpp +189 -0
  96. data/ext/libsass/src/permutate.hpp +164 -0
  97. data/ext/libsass/src/plugins.cpp +7 -7
  98. data/ext/libsass/src/plugins.hpp +8 -8
  99. data/ext/libsass/src/position.cpp +7 -26
  100. data/ext/libsass/src/position.hpp +44 -21
  101. data/ext/libsass/src/prelexer.cpp +6 -6
  102. data/ext/libsass/src/remove_placeholders.cpp +55 -56
  103. data/ext/libsass/src/remove_placeholders.hpp +21 -18
  104. data/ext/libsass/src/sass.cpp +16 -15
  105. data/ext/libsass/src/sass.hpp +10 -5
  106. data/ext/libsass/src/sass2scss.cpp +4 -4
  107. data/ext/libsass/src/sass_context.cpp +91 -122
  108. data/ext/libsass/src/sass_context.hpp +2 -2
  109. data/ext/libsass/src/sass_functions.cpp +1 -1
  110. data/ext/libsass/src/sass_values.cpp +8 -11
  111. data/ext/libsass/src/settings.hpp +19 -0
  112. data/ext/libsass/src/source.cpp +69 -0
  113. data/ext/libsass/src/source.hpp +95 -0
  114. data/ext/libsass/src/source_data.hpp +32 -0
  115. data/ext/libsass/src/source_map.cpp +22 -18
  116. data/ext/libsass/src/source_map.hpp +12 -9
  117. data/ext/libsass/src/stylesheet.cpp +22 -0
  118. data/ext/libsass/src/stylesheet.hpp +57 -0
  119. data/ext/libsass/src/to_value.cpp +2 -2
  120. data/ext/libsass/src/to_value.hpp +1 -1
  121. data/ext/libsass/src/units.cpp +24 -22
  122. data/ext/libsass/src/units.hpp +8 -8
  123. data/ext/libsass/src/utf8_string.cpp +9 -10
  124. data/ext/libsass/src/utf8_string.hpp +7 -6
  125. data/ext/libsass/src/util.cpp +48 -50
  126. data/ext/libsass/src/util.hpp +20 -21
  127. data/ext/libsass/src/util_string.cpp +111 -61
  128. data/ext/libsass/src/util_string.hpp +62 -8
  129. data/ext/libsass/src/values.cpp +12 -12
  130. data/lib/sassc/engine.rb +5 -3
  131. data/lib/sassc/functions_handler.rb +8 -8
  132. data/lib/sassc/native.rb +4 -6
  133. data/lib/sassc/script.rb +4 -4
  134. data/lib/sassc/version.rb +1 -1
  135. data/test/functions_test.rb +18 -1
  136. data/test/native_test.rb +4 -4
  137. metadata +29 -15
  138. data/ext/libsass/src/extend.cpp +0 -2132
  139. data/ext/libsass/src/extend.hpp +0 -86
  140. data/ext/libsass/src/node.cpp +0 -322
  141. data/ext/libsass/src/node.hpp +0 -118
  142. data/ext/libsass/src/paths.hpp +0 -71
  143. data/ext/libsass/src/sass_util.cpp +0 -152
  144. data/ext/libsass/src/sass_util.hpp +0 -256
  145. data/ext/libsass/src/subset_map.cpp +0 -58
  146. data/ext/libsass/src/subset_map.hpp +0 -76
  147. data/lib/sassc/native/lib_c.rb +0 -21
@@ -13,7 +13,6 @@
13
13
  #else
14
14
  # include <unistd.h>
15
15
  #endif
16
- #include <cctype>
17
16
  #include <cstdio>
18
17
  #include <vector>
19
18
  #include <algorithm>
@@ -25,6 +24,7 @@
25
24
  #include "sass_functions.hpp"
26
25
  #include "error_handling.hpp"
27
26
  #include "util.hpp"
27
+ #include "util_string.hpp"
28
28
  #include "sass2scss.h"
29
29
 
30
30
  #ifdef _WIN32
@@ -32,16 +32,16 @@
32
32
 
33
33
  # ifdef _MSC_VER
34
34
  # include <codecvt>
35
- inline static std::string wstring_to_string(const std::wstring& wstr)
35
+ inline static Sass::sass::string wstring_to_string(const std::wstring& wstr)
36
36
  {
37
37
  std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> wchar_converter;
38
38
  return wchar_converter.to_bytes(wstr);
39
39
  }
40
40
  # else // mingw(/gcc) does not support C++11's codecvt yet.
41
- inline static std::string wstring_to_string(const std::wstring &wstr)
41
+ inline static Sass::sass::string wstring_to_string(const std::wstring &wstr)
42
42
  {
43
43
  int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
44
- std::string strTo(size_needed, 0);
44
+ Sass::sass::string strTo(size_needed, 0);
45
45
  WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
46
46
  return strTo;
47
47
  }
@@ -54,7 +54,7 @@ namespace Sass {
54
54
  // return the current directory
55
55
  // always with forward slashes
56
56
  // always with trailing slash
57
- std::string get_cwd()
57
+ sass::string get_cwd()
58
58
  {
59
59
  const size_t wd_len = 4096;
60
60
  #ifndef _WIN32
@@ -63,12 +63,12 @@ namespace Sass {
63
63
  // we should check error for more detailed info (e.g. ENOENT)
64
64
  // http://man7.org/linux/man-pages/man2/getcwd.2.html#ERRORS
65
65
  if (pwd == NULL) throw Exception::OperationError("cwd gone missing");
66
- std::string cwd = pwd;
66
+ sass::string cwd = pwd;
67
67
  #else
68
68
  wchar_t wd[wd_len];
69
69
  wchar_t* pwd = _wgetcwd(wd, wd_len);
70
70
  if (pwd == NULL) throw Exception::OperationError("cwd gone missing");
71
- std::string cwd = wstring_to_string(pwd);
71
+ sass::string cwd = wstring_to_string(pwd);
72
72
  //convert backslashes to forward slashes
73
73
  replace(cwd.begin(), cwd.end(), '\\', '/');
74
74
  #endif
@@ -77,12 +77,12 @@ namespace Sass {
77
77
  }
78
78
 
79
79
  // test if path exists and is a file
80
- bool file_exists(const std::string& path)
80
+ bool file_exists(const sass::string& path)
81
81
  {
82
82
  #ifdef _WIN32
83
83
  wchar_t resolved[32768];
84
84
  // windows unicode filepaths are encoded in utf16
85
- std::string abspath(join_paths(get_cwd(), path));
85
+ sass::string abspath(join_paths(get_cwd(), path));
86
86
  if (!(abspath[0] == '/' && abspath[1] == '/')) {
87
87
  abspath = "//?/" + abspath;
88
88
  }
@@ -103,35 +103,35 @@ namespace Sass {
103
103
 
104
104
  // return if given path is absolute
105
105
  // works with *nix and windows paths
106
- bool is_absolute_path(const std::string& path)
106
+ bool is_absolute_path(const sass::string& path)
107
107
  {
108
108
  #ifdef _WIN32
109
- if (path.length() >= 2 && isalpha(path[0]) && path[1] == ':') return true;
109
+ if (path.length() >= 2 && Util::ascii_isalpha(path[0]) && path[1] == ':') return true;
110
110
  #endif
111
111
  size_t i = 0;
112
112
  // check if we have a protocol
113
- if (path[i] && Prelexer::is_alpha(path[i])) {
113
+ if (path[i] && Util::ascii_isalpha(static_cast<unsigned char>(path[i]))) {
114
114
  // skip over all alphanumeric characters
115
- while (path[i] && Prelexer::is_alnum(path[i])) ++i;
115
+ while (path[i] && Util::ascii_isalnum(static_cast<unsigned char>(path[i]))) ++i;
116
116
  i = i && path[i] == ':' ? i + 1 : 0;
117
117
  }
118
118
  return path[i] == '/';
119
119
  }
120
120
 
121
- // helper function to find the last directory seperator
122
- inline size_t find_last_folder_separator(const std::string& path, size_t limit = std::string::npos)
121
+ // helper function to find the last directory separator
122
+ inline size_t find_last_folder_separator(const sass::string& path, size_t limit = sass::string::npos)
123
123
  {
124
124
  size_t pos;
125
125
  size_t pos_p = path.find_last_of('/', limit);
126
126
  #ifdef _WIN32
127
127
  size_t pos_w = path.find_last_of('\\', limit);
128
128
  #else
129
- size_t pos_w = std::string::npos;
129
+ size_t pos_w = sass::string::npos;
130
130
  #endif
131
- if (pos_p != std::string::npos && pos_w != std::string::npos) {
131
+ if (pos_p != sass::string::npos && pos_w != sass::string::npos) {
132
132
  pos = std::max(pos_p, pos_w);
133
133
  }
134
- else if (pos_p != std::string::npos) {
134
+ else if (pos_p != sass::string::npos) {
135
135
  pos = pos_p;
136
136
  }
137
137
  else {
@@ -141,24 +141,24 @@ namespace Sass {
141
141
  }
142
142
 
143
143
  // return only the directory part of path
144
- std::string dir_name(const std::string& path)
144
+ sass::string dir_name(const sass::string& path)
145
145
  {
146
146
  size_t pos = find_last_folder_separator(path);
147
- if (pos == std::string::npos) return "";
147
+ if (pos == sass::string::npos) return "";
148
148
  else return path.substr(0, pos+1);
149
149
  }
150
150
 
151
151
  // return only the filename part of path
152
- std::string base_name(const std::string& path)
152
+ sass::string base_name(const sass::string& path)
153
153
  {
154
154
  size_t pos = find_last_folder_separator(path);
155
- if (pos == std::string::npos) return path;
155
+ if (pos == sass::string::npos) return path;
156
156
  else return path.substr(pos+1);
157
157
  }
158
158
 
159
159
  // do a logical clean up of the path
160
160
  // no physical check on the filesystem
161
- std::string make_canonical_path (std::string path)
161
+ sass::string make_canonical_path (sass::string path)
162
162
  {
163
163
 
164
164
  // declarations
@@ -170,18 +170,18 @@ namespace Sass {
170
170
  #endif
171
171
 
172
172
  pos = 0; // remove all self references inside the path string
173
- while((pos = path.find("/./", pos)) != std::string::npos) path.erase(pos, 2);
173
+ while((pos = path.find("/./", pos)) != sass::string::npos) path.erase(pos, 2);
174
174
 
175
175
  // remove all leading and trailing self references
176
- while(path.length() > 1 && path.substr(0, 2) == "./") path.erase(0, 2);
177
- while((pos = path.length()) > 1 && path.substr(pos - 2) == "/.") path.erase(pos - 2);
176
+ while(path.size() >= 2 && path[0] == '.' && path[1] == '/') path.erase(0, 2);
177
+ while((pos = path.length()) > 1 && path[pos - 2] == '/' && path[pos - 1] == '.') path.erase(pos - 2);
178
178
 
179
179
 
180
180
  size_t proto = 0;
181
181
  // check if we have a protocol
182
- if (path[proto] && Prelexer::is_alpha(path[proto])) {
182
+ if (path[proto] && Util::ascii_isalpha(static_cast<unsigned char>(path[proto]))) {
183
183
  // skip over all alphanumeric characters
184
- while (path[proto] && Prelexer::is_alnum(path[proto++])) {}
184
+ while (path[proto] && Util::ascii_isalnum(static_cast<unsigned char>(path[proto++]))) {}
185
185
  // then skip over the mandatory colon
186
186
  if (proto && path[proto] == ':') ++ proto;
187
187
  }
@@ -190,7 +190,7 @@ namespace Sass {
190
190
  while (path[proto++] == '/') {}
191
191
 
192
192
  pos = proto; // collapse multiple delimiters into a single one
193
- while((pos = path.find("//", pos)) != std::string::npos) path.erase(pos, 1);
193
+ while((pos = path.find("//", pos)) != sass::string::npos) path.erase(pos, 1);
194
194
 
195
195
  return path;
196
196
 
@@ -198,7 +198,7 @@ namespace Sass {
198
198
 
199
199
  // join two path segments cleanly together
200
200
  // but only if right side is not absolute yet
201
- std::string join_paths(std::string l, std::string r)
201
+ sass::string join_paths(sass::string l, sass::string r)
202
202
  {
203
203
 
204
204
  #ifdef _WIN32
@@ -225,16 +225,16 @@ namespace Sass {
225
225
  bool is_slash = pos + 2 == L && (l[pos+1] == '/' || l[pos+1] == '\\');
226
226
  bool is_self = pos + 3 == L && (l[pos+1] == '.');
227
227
  if (!is_self && !is_slash) r = r.substr(3);
228
- else if (pos == std::string::npos) break;
229
- l = l.substr(0, pos == std::string::npos ? pos : pos + 1);
228
+ else if (pos == sass::string::npos) break;
229
+ l = l.substr(0, pos == sass::string::npos ? pos : pos + 1);
230
230
  }
231
231
 
232
232
  return l + r;
233
233
  }
234
234
 
235
- std::string path_for_console(const std::string& rel_path, const std::string& abs_path, const std::string& orig_path)
235
+ sass::string path_for_console(const sass::string& rel_path, const sass::string& abs_path, const sass::string& orig_path)
236
236
  {
237
- // magic algorith goes here!!
237
+ // magic algorithm goes here!!
238
238
 
239
239
  // if the file is outside this directory show the absolute path
240
240
  if (rel_path.substr(0, 3) == "../") {
@@ -245,24 +245,32 @@ namespace Sass {
245
245
  }
246
246
 
247
247
  // create an absolute path by resolving relative paths with cwd
248
- std::string rel2abs(const std::string& path, const std::string& base, const std::string& cwd)
248
+ sass::string rel2abs(const sass::string& path, const sass::string& base, const sass::string& cwd)
249
249
  {
250
- return make_canonical_path(join_paths(join_paths(cwd + "/", base + "/"), path));
250
+ sass::string rv = make_canonical_path(join_paths(join_paths(cwd + "/", base + "/"), path));
251
+ #ifdef _WIN32
252
+ // On windows we may get an absolute path without directory
253
+ // In that case we should prepend the directory from the root
254
+ if (rv[0] == '/' && rv[1] != '/') {
255
+ rv.insert(0, cwd, 0, 2);
256
+ }
257
+ #endif
258
+ return rv;
251
259
  }
252
260
 
253
261
  // create a path that is relative to the given base directory
254
262
  // path and base will first be resolved against cwd to make them absolute
255
- std::string abs2rel(const std::string& path, const std::string& base, const std::string& cwd)
263
+ sass::string abs2rel(const sass::string& path, const sass::string& base, const sass::string& cwd)
256
264
  {
257
265
 
258
- std::string abs_path = rel2abs(path, cwd);
259
- std::string abs_base = rel2abs(base, cwd);
266
+ sass::string abs_path = rel2abs(path, cwd);
267
+ sass::string abs_base = rel2abs(base, cwd);
260
268
 
261
269
  size_t proto = 0;
262
270
  // check if we have a protocol
263
- if (path[proto] && Prelexer::is_alpha(path[proto])) {
271
+ if (path[proto] && Util::ascii_isalpha(static_cast<unsigned char>(path[proto]))) {
264
272
  // skip over all alphanumeric characters
265
- while (path[proto] && Prelexer::is_alnum(path[proto++])) {}
273
+ while (path[proto] && Util::ascii_isalnum(static_cast<unsigned char>(path[proto++]))) {}
266
274
  // then skip over the mandatory colon
267
275
  if (proto && path[proto] == ':') ++ proto;
268
276
  }
@@ -277,8 +285,8 @@ namespace Sass {
277
285
  if (abs_base[0] != abs_path[0]) return abs_path;
278
286
  #endif
279
287
 
280
- std::string stripped_uri = "";
281
- std::string stripped_base = "";
288
+ sass::string stripped_uri = "";
289
+ sass::string stripped_base = "";
282
290
 
283
291
  size_t index = 0;
284
292
  size_t minSize = std::min(abs_path.size(), abs_base.size());
@@ -288,7 +296,8 @@ namespace Sass {
288
296
  #else
289
297
  // compare the charactes in a case insensitive manner
290
298
  // windows fs is only case insensitive in ascii ranges
291
- if (tolower(abs_path[i]) != tolower(abs_base[i])) break;
299
+ if (Util::ascii_tolower(static_cast<unsigned char>(abs_path[i])) !=
300
+ Util::ascii_tolower(static_cast<unsigned char>(abs_base[i]))) break;
292
301
  #endif
293
302
  if (abs_path[i] == '/') index = i + 1;
294
303
  }
@@ -316,7 +325,7 @@ namespace Sass {
316
325
  }
317
326
  }
318
327
 
319
- std::string result = "";
328
+ sass::string result = "";
320
329
  for (size_t i = 0; i < directories; ++i) {
321
330
  result += "../";
322
331
  }
@@ -332,16 +341,16 @@ namespace Sass {
332
341
  // (4) given + extension
333
342
  // (5) given + _index.scss
334
343
  // (6) given + _index.sass
335
- std::vector<Include> resolve_includes(const std::string& root, const std::string& file, const std::vector<std::string>& exts)
344
+ sass::vector<Include> resolve_includes(const sass::string& root, const sass::string& file, const sass::vector<sass::string>& exts)
336
345
  {
337
- std::string filename = join_paths(root, file);
346
+ sass::string filename = join_paths(root, file);
338
347
  // split the filename
339
- std::string base(dir_name(file));
340
- std::string name(base_name(file));
341
- std::vector<Include> includes;
348
+ sass::string base(dir_name(file));
349
+ sass::string name(base_name(file));
350
+ sass::vector<Include> includes;
342
351
  // create full path (maybe relative)
343
- std::string rel_path(join_paths(base, name));
344
- std::string abs_path(join_paths(root, rel_path));
352
+ sass::string rel_path(join_paths(base, name));
353
+ sass::string abs_path(join_paths(root, rel_path));
345
354
  if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
346
355
  // next test variation with underscore
347
356
  rel_path = join_paths(base, "_" + name);
@@ -382,24 +391,24 @@ namespace Sass {
382
391
  return includes;
383
392
  }
384
393
 
385
- std::vector<std::string> find_files(const std::string& file, const std::vector<std::string> paths)
394
+ sass::vector<sass::string> find_files(const sass::string& file, const sass::vector<sass::string> paths)
386
395
  {
387
- std::vector<std::string> includes;
388
- for (std::string path : paths) {
389
- std::string abs_path(join_paths(path, file));
396
+ sass::vector<sass::string> includes;
397
+ for (sass::string path : paths) {
398
+ sass::string abs_path(join_paths(path, file));
390
399
  if (file_exists(abs_path)) includes.push_back(abs_path);
391
400
  }
392
401
  return includes;
393
402
  }
394
403
 
395
- std::vector<std::string> find_files(const std::string& file, struct Sass_Compiler* compiler)
404
+ sass::vector<sass::string> find_files(const sass::string& file, struct Sass_Compiler* compiler)
396
405
  {
397
406
  // get the last import entry to get current base directory
398
407
  // struct Sass_Options* options = sass_compiler_get_options(compiler);
399
408
  Sass_Import_Entry import = sass_compiler_get_last_import(compiler);
400
- const std::vector<std::string>& incs = compiler->cpp_ctx->include_paths;
409
+ const sass::vector<sass::string>& incs = compiler->cpp_ctx->include_paths;
401
410
  // create the vector with paths to lookup
402
- std::vector<std::string> paths(1 + incs.size());
411
+ sass::vector<sass::string> paths(1 + incs.size());
403
412
  paths.push_back(dir_name(import->abs_path));
404
413
  paths.insert(paths.end(), incs.begin(), incs.end());
405
414
  // dispatch to find files in paths
@@ -408,7 +417,7 @@ namespace Sass {
408
417
 
409
418
  // helper function to search one file in all include paths
410
419
  // this is normally not used internally by libsass (C-API sugar)
411
- std::string find_file(const std::string& file, const std::vector<std::string> paths)
420
+ sass::string find_file(const sass::string& file, const sass::vector<sass::string> paths)
412
421
  {
413
422
  if (file.empty()) return file;
414
423
  auto res = find_files(file, paths);
@@ -416,29 +425,29 @@ namespace Sass {
416
425
  }
417
426
 
418
427
  // helper function to resolve a filename
419
- std::string find_include(const std::string& file, const std::vector<std::string> paths)
428
+ sass::string find_include(const sass::string& file, const sass::vector<sass::string> paths)
420
429
  {
421
430
  // search in every include path for a match
422
431
  for (size_t i = 0, S = paths.size(); i < S; ++i)
423
432
  {
424
- std::vector<Include> resolved(resolve_includes(paths[i], file));
433
+ sass::vector<Include> resolved(resolve_includes(paths[i], file));
425
434
  if (resolved.size()) return resolved[0].abs_path;
426
435
  }
427
436
  // nothing found
428
- return std::string("");
437
+ return sass::string("");
429
438
  }
430
439
 
431
440
  // try to load the given filename
432
441
  // returned memory must be freed
433
442
  // will auto convert .sass files
434
- char* read_file(const std::string& path)
443
+ char* read_file(const sass::string& path)
435
444
  {
436
445
  #ifdef _WIN32
437
446
  BYTE* pBuffer;
438
447
  DWORD dwBytes;
439
448
  wchar_t resolved[32768];
440
449
  // windows unicode filepaths are encoded in utf16
441
- std::string abspath(join_paths(get_cwd(), path));
450
+ sass::string abspath(join_paths(get_cwd(), path));
442
451
  if (!(abspath[0] == '/' && abspath[1] == '/')) {
443
452
  abspath = "//?/" + abspath;
444
453
  }
@@ -474,6 +483,7 @@ namespace Sass {
474
483
  char* contents = static_cast<char*>(malloc(st.st_size + 2 * sizeof(char)));
475
484
  if (std::fread(static_cast<void*>(contents), 1, size, fd) != size) {
476
485
  free(contents);
486
+ std::fclose(fd);
477
487
  return nullptr;
478
488
  }
479
489
  if (std::fclose(fd) != 0) {
@@ -483,12 +493,11 @@ namespace Sass {
483
493
  contents[size] = '\0';
484
494
  contents[size + 1] = '\0';
485
495
  #endif
486
- std::string extension;
496
+ sass::string extension;
487
497
  if (path.length() > 5) {
488
498
  extension = path.substr(path.length() - 5, 5);
489
499
  }
490
- for(size_t i=0; i<extension.size();++i)
491
- extension[i] = tolower(extension[i]);
500
+ Util::ascii_str_tolower(&extension);
492
501
  if (extension == ".sass" && contents != 0) {
493
502
  char * converted = sass2scss(contents, SASS2SCSS_PRETTIFY_1 | SASS2SCSS_KEEP_COMMENT);
494
503
  free(contents); // free the indented contents
@@ -499,21 +508,21 @@ namespace Sass {
499
508
  }
500
509
 
501
510
  // split a path string delimited by semicolons or colons (OS dependent)
502
- std::vector<std::string> split_path_list(const char* str)
511
+ sass::vector<sass::string> split_path_list(const char* str)
503
512
  {
504
- std::vector<std::string> paths;
513
+ sass::vector<sass::string> paths;
505
514
  if (str == NULL) return paths;
506
515
  // find delimiter via prelexer (return zero at end)
507
516
  const char* end = Prelexer::find_first<PATH_SEP>(str);
508
517
  // search until null delimiter
509
518
  while (end) {
510
519
  // add path from current position to delimiter
511
- paths.push_back(std::string(str, end - str));
520
+ paths.push_back(sass::string(str, end - str));
512
521
  str = end + 1; // skip delimiter
513
522
  end = Prelexer::find_first<PATH_SEP>(str);
514
523
  }
515
524
  // add path from current position to end
516
- paths.push_back(std::string(str));
525
+ paths.push_back(sass::string(str));
517
526
  // return back
518
527
  return paths;
519
528
  }
@@ -1,6 +1,10 @@
1
1
  #ifndef SASS_FILE_H
2
2
  #define SASS_FILE_H
3
3
 
4
+ // sass.hpp must go before all system headers to get the
5
+ // __EXTENSIONS__ fix on Solaris.
6
+ #include "sass.hpp"
7
+
4
8
  #include <string>
5
9
  #include <vector>
6
10
 
@@ -13,56 +17,56 @@ namespace Sass {
13
17
 
14
18
  // return the current directory
15
19
  // always with forward slashes
16
- std::string get_cwd();
20
+ sass::string get_cwd();
17
21
 
18
22
  // test if path exists and is a file
19
- bool file_exists(const std::string& file);
23
+ bool file_exists(const sass::string& file);
20
24
 
21
25
  // return if given path is absolute
22
26
  // works with *nix and windows paths
23
- bool is_absolute_path(const std::string& path);
27
+ bool is_absolute_path(const sass::string& path);
24
28
 
25
29
  // return only the directory part of path
26
- std::string dir_name(const std::string& path);
30
+ sass::string dir_name(const sass::string& path);
27
31
 
28
32
  // return only the filename part of path
29
- std::string base_name(const std::string&);
33
+ sass::string base_name(const sass::string&);
30
34
 
31
35
  // do a locigal clean up of the path
32
36
  // no physical check on the filesystem
33
- std::string make_canonical_path (std::string path);
37
+ sass::string make_canonical_path (sass::string path);
34
38
 
35
39
  // join two path segments cleanly together
36
40
  // but only if right side is not absolute yet
37
- std::string join_paths(std::string root, std::string name);
41
+ sass::string join_paths(sass::string root, sass::string name);
38
42
 
39
43
  // if the relative path is outside of the cwd we want want to
40
44
  // show the absolute path in console messages
41
- std::string path_for_console(const std::string& rel_path, const std::string& abs_path, const std::string& orig_path);
45
+ sass::string path_for_console(const sass::string& rel_path, const sass::string& abs_path, const sass::string& orig_path);
42
46
 
43
47
  // create an absolute path by resolving relative paths with cwd
44
- std::string rel2abs(const std::string& path, const std::string& base = ".", const std::string& cwd = get_cwd());
48
+ sass::string rel2abs(const sass::string& path, const sass::string& base = ".", const sass::string& cwd = get_cwd());
45
49
 
46
50
  // create a path that is relative to the given base directory
47
51
  // path and base will first be resolved against cwd to make them absolute
48
- std::string abs2rel(const std::string& path, const std::string& base = ".", const std::string& cwd = get_cwd());
52
+ sass::string abs2rel(const sass::string& path, const sass::string& base = ".", const sass::string& cwd = get_cwd());
49
53
 
50
54
  // helper function to resolve a filename
51
55
  // searching without variations in all paths
52
- std::string find_file(const std::string& file, struct Sass_Compiler* options);
53
- std::string find_file(const std::string& file, const std::vector<std::string> paths);
56
+ sass::string find_file(const sass::string& file, struct Sass_Compiler* options);
57
+ sass::string find_file(const sass::string& file, const sass::vector<sass::string> paths);
54
58
 
55
59
  // helper function to resolve a include filename
56
60
  // this has the original resolve logic for sass include
57
- std::string find_include(const std::string& file, const std::vector<std::string> paths);
61
+ sass::string find_include(const sass::string& file, const sass::vector<sass::string> paths);
58
62
 
59
63
  // split a path string delimited by semicolons or colons (OS dependent)
60
- std::vector<std::string> split_path_list(const char* paths);
64
+ sass::vector<sass::string> split_path_list(const char* paths);
61
65
 
62
66
  // try to load the given filename
63
67
  // returned memory must be freed
64
68
  // will auto convert .sass files
65
- char* read_file(const std::string& file);
69
+ char* read_file(const sass::string& file);
66
70
 
67
71
  }
68
72
 
@@ -70,14 +74,14 @@ namespace Sass {
70
74
  class Importer {
71
75
  public:
72
76
  // requested import path
73
- std::string imp_path;
77
+ sass::string imp_path;
74
78
  // parent context path
75
- std::string ctx_path;
79
+ sass::string ctx_path;
76
80
  // base derived from context path
77
81
  // this really just acts as a cache
78
- std::string base_path;
82
+ sass::string base_path;
79
83
  public:
80
- Importer(std::string imp_path, std::string ctx_path)
84
+ Importer(sass::string imp_path, sass::string ctx_path)
81
85
  : imp_path(File::make_canonical_path(imp_path)),
82
86
  ctx_path(File::make_canonical_path(ctx_path)),
83
87
  base_path(File::dir_name(ctx_path))
@@ -88,9 +92,9 @@ namespace Sass {
88
92
  class Include : public Importer {
89
93
  public:
90
94
  // resolved absolute path
91
- std::string abs_path;
95
+ sass::string abs_path;
92
96
  public:
93
- Include(const Importer& imp, std::string abs_path)
97
+ Include(const Importer& imp, sass::string abs_path)
94
98
  : Importer(imp), abs_path(abs_path)
95
99
  { }
96
100
  };
@@ -100,7 +104,7 @@ namespace Sass {
100
104
  public:
101
105
  // the file contents
102
106
  char* contents;
103
- // conected sourcemap
107
+ // connected sourcemap
104
108
  char* srcmap;
105
109
  public:
106
110
  Resource(char* contents, char* srcmap)
@@ -108,23 +112,10 @@ namespace Sass {
108
112
  { }
109
113
  };
110
114
 
111
- // parsed stylesheet from loaded resource
112
- class StyleSheet : public Resource {
113
- public:
114
- // parsed root block
115
- Block_Obj root;
116
- public:
117
- StyleSheet(const Resource& res, Block_Obj root)
118
- : Resource(res), root(root)
119
- { }
120
- };
121
-
122
115
  namespace File {
123
116
 
124
- static std::vector<std::string> defaultExtensions = { ".scss", ".sass", ".css" };
125
-
126
- std::vector<Include> resolve_includes(const std::string& root, const std::string& file,
127
- const std::vector<std::string>& exts = defaultExtensions);
117
+ sass::vector<Include> resolve_includes(const sass::string& root, const sass::string& file,
118
+ const sass::vector<sass::string>& exts = { ".scss", ".sass", ".css" });
128
119
 
129
120
  }
130
121