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.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/ext/libsass/.gitignore +10 -6
  4. data/ext/libsass/.travis.yml +4 -1
  5. data/ext/libsass/GNUmakefile.am +88 -0
  6. data/ext/libsass/Makefile +157 -76
  7. data/ext/libsass/Makefile.conf +47 -0
  8. data/ext/libsass/Readme.md +13 -14
  9. data/ext/libsass/appveyor.yml +25 -41
  10. data/ext/libsass/configure.ac +20 -7
  11. data/ext/libsass/contrib/plugin.cpp +1 -1
  12. data/ext/libsass/include/sass.h +15 -0
  13. data/ext/libsass/{sass.h → include/sass/base.h} +17 -9
  14. data/ext/libsass/{sass_context.h → include/sass/context.h} +3 -1
  15. data/ext/libsass/{sass_functions.h → include/sass/functions.h} +4 -4
  16. data/ext/libsass/{sass_interface.h → include/sass/interface.h} +5 -2
  17. data/ext/libsass/{sass_values.h → include/sass/values.h} +15 -1
  18. data/ext/libsass/{sass_version.h → include/sass/version.h} +0 -0
  19. data/ext/libsass/{sass_version.h.in → include/sass/version.h.in} +0 -0
  20. data/ext/libsass/{sass2scss.h → include/sass2scss.h} +6 -7
  21. data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +167 -0
  22. data/ext/libsass/script/ci-build-libsass +67 -23
  23. data/ext/libsass/src/GNUmakefile.am +54 -0
  24. data/ext/libsass/src/ast.cpp +2029 -0
  25. data/ext/libsass/{ast.hpp → src/ast.hpp} +832 -660
  26. data/ext/libsass/src/ast_def_macros.hpp +47 -0
  27. data/ext/libsass/src/ast_factory.hpp +93 -0
  28. data/ext/libsass/{ast_fwd_decl.hpp → src/ast_fwd_decl.hpp} +9 -4
  29. data/ext/libsass/{b64 → src/b64}/cencode.h +1 -1
  30. data/ext/libsass/{b64 → src/b64}/encode.h +0 -0
  31. data/ext/libsass/{backtrace.hpp → src/backtrace.hpp} +9 -10
  32. data/ext/libsass/{base64vlq.cpp → src/base64vlq.cpp} +2 -2
  33. data/ext/libsass/{base64vlq.hpp → src/base64vlq.hpp} +1 -2
  34. data/ext/libsass/{bind.cpp → src/bind.cpp} +96 -59
  35. data/ext/libsass/{bind.hpp → src/bind.hpp} +1 -1
  36. data/ext/libsass/src/c99func.c +54 -0
  37. data/ext/libsass/{cencode.c → src/cencode.c} +5 -5
  38. data/ext/libsass/src/color_maps.cpp +643 -0
  39. data/ext/libsass/src/color_maps.hpp +333 -0
  40. data/ext/libsass/{constants.cpp → src/constants.cpp} +10 -1
  41. data/ext/libsass/{constants.hpp → src/constants.hpp} +7 -0
  42. data/ext/libsass/{context.cpp → src/context.cpp} +152 -122
  43. data/ext/libsass/src/context.hpp +150 -0
  44. data/ext/libsass/{cssize.cpp → src/cssize.cpp} +123 -109
  45. data/ext/libsass/{cssize.hpp → src/cssize.hpp} +9 -13
  46. data/ext/libsass/{debug.hpp → src/debug.hpp} +9 -9
  47. data/ext/libsass/src/debugger.hpp +683 -0
  48. data/ext/libsass/{emitter.cpp → src/emitter.cpp} +13 -13
  49. data/ext/libsass/{emitter.hpp → src/emitter.hpp} +10 -11
  50. data/ext/libsass/src/environment.cpp +184 -0
  51. data/ext/libsass/src/environment.hpp +92 -0
  52. data/ext/libsass/src/error_handling.cpp +46 -0
  53. data/ext/libsass/src/error_handling.hpp +34 -0
  54. data/ext/libsass/src/eval.cpp +1462 -0
  55. data/ext/libsass/src/eval.hpp +107 -0
  56. data/ext/libsass/src/expand.cpp +653 -0
  57. data/ext/libsass/{expand.hpp → src/expand.hpp} +17 -16
  58. data/ext/libsass/{extend.cpp → src/extend.cpp} +198 -139
  59. data/ext/libsass/{extend.hpp → src/extend.hpp} +7 -8
  60. data/ext/libsass/{file.cpp → src/file.cpp} +103 -57
  61. data/ext/libsass/{file.hpp → src/file.hpp} +23 -14
  62. data/ext/libsass/{functions.cpp → src/functions.cpp} +642 -333
  63. data/ext/libsass/{functions.hpp → src/functions.hpp} +17 -4
  64. data/ext/libsass/{inspect.cpp → src/inspect.cpp} +147 -260
  65. data/ext/libsass/{inspect.hpp → src/inspect.hpp} +7 -7
  66. data/ext/libsass/{json.cpp → src/json.cpp} +33 -43
  67. data/ext/libsass/{json.hpp → src/json.hpp} +1 -1
  68. data/ext/libsass/{kwd_arg_macros.hpp → src/kwd_arg_macros.hpp} +0 -0
  69. data/ext/libsass/{lexer.cpp → src/lexer.cpp} +28 -0
  70. data/ext/libsass/{lexer.hpp → src/lexer.hpp} +25 -10
  71. data/ext/libsass/{listize.cpp → src/listize.cpp} +17 -13
  72. data/ext/libsass/{listize.hpp → src/listize.hpp} +0 -2
  73. data/ext/libsass/{mapping.hpp → src/mapping.hpp} +0 -0
  74. data/ext/libsass/src/memory_manager.cpp +76 -0
  75. data/ext/libsass/src/memory_manager.hpp +48 -0
  76. data/ext/libsass/{node.cpp → src/node.cpp} +89 -18
  77. data/ext/libsass/{node.hpp → src/node.hpp} +5 -6
  78. data/ext/libsass/{operation.hpp → src/operation.hpp} +18 -12
  79. data/ext/libsass/{output.cpp → src/output.cpp} +47 -55
  80. data/ext/libsass/{output.hpp → src/output.hpp} +5 -4
  81. data/ext/libsass/src/parser.cpp +2529 -0
  82. data/ext/libsass/{parser.hpp → src/parser.hpp} +84 -60
  83. data/ext/libsass/{paths.hpp → src/paths.hpp} +10 -13
  84. data/ext/libsass/{plugins.cpp → src/plugins.cpp} +14 -17
  85. data/ext/libsass/{plugins.hpp → src/plugins.hpp} +10 -11
  86. data/ext/libsass/{position.cpp → src/position.cpp} +5 -6
  87. data/ext/libsass/{position.hpp → src/position.hpp} +19 -22
  88. data/ext/libsass/{prelexer.cpp → src/prelexer.cpp} +401 -53
  89. data/ext/libsass/{prelexer.hpp → src/prelexer.hpp} +50 -10
  90. data/ext/libsass/{remove_placeholders.cpp → src/remove_placeholders.cpp} +12 -16
  91. data/ext/libsass/{remove_placeholders.hpp → src/remove_placeholders.hpp} +1 -7
  92. data/ext/libsass/{sass.cpp → src/sass.cpp} +3 -5
  93. data/ext/libsass/{sass2scss.cpp → src/sass2scss.cpp} +51 -46
  94. data/ext/libsass/{sass_context.cpp → src/sass_context.cpp} +114 -112
  95. data/ext/libsass/{sass_functions.cpp → src/sass_functions.cpp} +11 -18
  96. data/ext/libsass/{sass_interface.cpp → src/sass_interface.cpp} +44 -81
  97. data/ext/libsass/{sass_util.cpp → src/sass_util.cpp} +26 -8
  98. data/ext/libsass/{sass_util.hpp → src/sass_util.hpp} +14 -18
  99. data/ext/libsass/{sass_values.cpp → src/sass_values.cpp} +91 -20
  100. data/ext/libsass/{source_map.cpp → src/source_map.cpp} +13 -13
  101. data/ext/libsass/{source_map.hpp → src/source_map.hpp} +9 -9
  102. data/ext/libsass/{subset_map.hpp → src/subset_map.hpp} +29 -31
  103. data/ext/libsass/{support → src/support}/libsass.pc.in +0 -0
  104. data/ext/libsass/src/to_c.cpp +73 -0
  105. data/ext/libsass/src/to_c.hpp +41 -0
  106. data/ext/libsass/src/to_string.cpp +47 -0
  107. data/ext/libsass/{to_string.hpp → src/to_string.hpp} +9 -7
  108. data/ext/libsass/src/to_value.cpp +109 -0
  109. data/ext/libsass/src/to_value.hpp +50 -0
  110. data/ext/libsass/{units.cpp → src/units.cpp} +56 -51
  111. data/ext/libsass/{units.hpp → src/units.hpp} +8 -9
  112. data/ext/libsass/{utf8.h → src/utf8.h} +0 -0
  113. data/ext/libsass/{utf8 → src/utf8}/checked.h +0 -0
  114. data/ext/libsass/{utf8 → src/utf8}/core.h +12 -12
  115. data/ext/libsass/{utf8 → src/utf8}/unchecked.h +0 -0
  116. data/ext/libsass/{utf8_string.cpp → src/utf8_string.cpp} +0 -0
  117. data/ext/libsass/{utf8_string.hpp → src/utf8_string.hpp} +6 -6
  118. data/ext/libsass/{util.cpp → src/util.cpp} +144 -86
  119. data/ext/libsass/src/util.hpp +59 -0
  120. data/ext/libsass/src/values.cpp +137 -0
  121. data/ext/libsass/src/values.hpp +12 -0
  122. data/ext/libsass/test/test_node.cpp +33 -33
  123. data/ext/libsass/test/test_paths.cpp +5 -6
  124. data/ext/libsass/test/test_selector_difference.cpp +4 -5
  125. data/ext/libsass/test/test_specificity.cpp +4 -5
  126. data/ext/libsass/test/test_subset_map.cpp +91 -91
  127. data/ext/libsass/test/test_superselector.cpp +11 -11
  128. data/ext/libsass/test/test_unification.cpp +4 -4
  129. data/ext/libsass/win/libsass.targets +101 -0
  130. data/ext/libsass/win/libsass.vcxproj +45 -127
  131. data/ext/libsass/win/libsass.vcxproj.filters +303 -0
  132. data/lib/sassc/import_handler.rb +1 -1
  133. data/lib/sassc/native/native_functions_api.rb +3 -3
  134. data/lib/sassc/version.rb +1 -1
  135. data/test/custom_importer_test.rb +1 -4
  136. data/test/functions_test.rb +3 -2
  137. data/test/native_test.rb +4 -3
  138. metadata +117 -110
  139. data/ext/libsass/Makefile.am +0 -146
  140. data/ext/libsass/ast.cpp +0 -945
  141. data/ext/libsass/ast_def_macros.hpp +0 -21
  142. data/ext/libsass/ast_factory.hpp +0 -92
  143. data/ext/libsass/color_names.hpp +0 -327
  144. data/ext/libsass/context.hpp +0 -157
  145. data/ext/libsass/contextualize.cpp +0 -148
  146. data/ext/libsass/contextualize.hpp +0 -46
  147. data/ext/libsass/contextualize_eval.cpp +0 -93
  148. data/ext/libsass/contextualize_eval.hpp +0 -44
  149. data/ext/libsass/debugger.hpp +0 -558
  150. data/ext/libsass/environment.hpp +0 -163
  151. data/ext/libsass/error_handling.cpp +0 -35
  152. data/ext/libsass/error_handling.hpp +0 -32
  153. data/ext/libsass/eval.cpp +0 -1392
  154. data/ext/libsass/eval.hpp +0 -88
  155. data/ext/libsass/expand.cpp +0 -575
  156. data/ext/libsass/memory_manager.hpp +0 -57
  157. data/ext/libsass/parser.cpp +0 -2403
  158. data/ext/libsass/posix/getopt.c +0 -562
  159. data/ext/libsass/posix/getopt.h +0 -95
  160. data/ext/libsass/to_c.cpp +0 -61
  161. data/ext/libsass/to_c.hpp +0 -44
  162. data/ext/libsass/to_string.cpp +0 -34
  163. data/ext/libsass/util.hpp +0 -54
  164. data/ext/libsass/win/libsass.filters +0 -312
@@ -13,22 +13,22 @@ namespace Sass {
13
13
  // index: code point offset (1 based or negative)
14
14
 
15
15
  // function that will count the number of code points (utf-8 characters) from the beginning to the given end
16
- size_t code_point_count(const string& str, size_t start, size_t end);
17
- size_t code_point_count(const string& str);
16
+ size_t code_point_count(const std::string& str, size_t start, size_t end);
17
+ size_t code_point_count(const std::string& str);
18
18
 
19
19
  // function that will return the byte offset of a code point in a
20
- size_t offset_at_position(const string& str, size_t position);
20
+ size_t offset_at_position(const std::string& str, size_t position);
21
21
 
22
22
  // function that returns number of bytes in a character in a string
23
- size_t code_point_size_at_offset(const string& str, size_t offset);
23
+ size_t code_point_size_at_offset(const std::string& str, size_t offset);
24
24
 
25
25
  // function that will return a normalized index, given a crazy one
26
26
  size_t normalize_index(int index, size_t len);
27
27
 
28
28
  #ifdef _WIN32
29
29
  // functions to handle unicode paths on windows
30
- string convert_from_utf16(const wstring& wstr);
31
- wstring convert_to_utf16(const string& str);
30
+ std::string convert_from_utf16(const std::wstring& wstr);
31
+ std::wstring convert_to_utf16(const std::string& str);
32
32
  #endif
33
33
 
34
34
  }
@@ -1,9 +1,13 @@
1
- #include<stdint.h>
1
+ #include "sass.h"
2
2
  #include "ast.hpp"
3
3
  #include "util.hpp"
4
+ #include "lexer.hpp"
4
5
  #include "prelexer.hpp"
6
+ #include "constants.hpp"
5
7
  #include "utf8/checked.h"
6
8
 
9
+ #include <stdint.h>
10
+
7
11
  namespace Sass {
8
12
 
9
13
  #define out_of_memory() do { \
@@ -44,10 +48,48 @@ namespace Sass {
44
48
  return atof(str);
45
49
  }
46
50
 
47
- string string_eval_escapes(const string& s)
51
+ // helper for safe access to c_ctx
52
+ const char* safe_str (const char* str) {
53
+ return str == NULL ? "" : str;
54
+ }
55
+
56
+ void free_string_array(char ** arr) {
57
+ if(!arr)
58
+ return;
59
+
60
+ char **it = arr;
61
+ while (it && (*it)) {
62
+ free(*it);
63
+ ++it;
64
+ }
65
+
66
+ free(arr);
67
+ }
68
+
69
+ char **copy_strings(const std::vector<std::string>& strings, char*** array, int skip) {
70
+ int num = static_cast<int>(strings.size()) - skip;
71
+ char** arr = (char**) calloc(num + 1, sizeof(char*));
72
+ if (arr == 0)
73
+ return *array = (char **)NULL;
74
+
75
+ for(int i = 0; i < num; i++) {
76
+ arr[i] = (char*) malloc(sizeof(char) * (strings[i + skip].size() + 1));
77
+ if (arr[i] == 0) {
78
+ free_string_array(arr);
79
+ return *array = (char **)NULL;
80
+ }
81
+ std::copy(strings[i + skip].begin(), strings[i + skip].end(), arr[i]);
82
+ arr[i][strings[i + skip].size()] = '\0';
83
+ }
84
+
85
+ arr[num] = 0;
86
+ return *array = arr;
87
+ }
88
+
89
+ std::string string_eval_escapes(const std::string& s)
48
90
  {
49
91
 
50
- string out("");
92
+ std::string out("");
51
93
  bool esc = false;
52
94
  for (size_t i = 0, L = s.length(); i < L; ++i) {
53
95
  if(s[i] == '\\' && esc == false) {
@@ -99,9 +141,9 @@ namespace Sass {
99
141
 
100
142
  // double escape every escape sequences
101
143
  // escape unescaped quotes and backslashes
102
- string string_escape(const string& str)
144
+ std::string string_escape(const std::string& str)
103
145
  {
104
- string out("");
146
+ std::string out("");
105
147
  for (auto i : str) {
106
148
  // escape some characters
107
149
  if (i == '"') out += '\\';
@@ -114,9 +156,9 @@ namespace Sass {
114
156
 
115
157
  // unescape every escape sequence
116
158
  // only removes unescaped backslashes
117
- string string_unescape(const string& str)
159
+ std::string string_unescape(const std::string& str)
118
160
  {
119
- string out("");
161
+ std::string out("");
120
162
  bool esc = false;
121
163
  for (auto i : str) {
122
164
  if (esc || i != '\\') {
@@ -133,9 +175,9 @@ namespace Sass {
133
175
  }
134
176
 
135
177
  // read css string (handle multiline DELIM)
136
- string read_css_string(const string& str)
178
+ std::string read_css_string(const std::string& str)
137
179
  {
138
- string out("");
180
+ std::string out("");
139
181
  bool esc = false;
140
182
  for (auto i : str) {
141
183
  if (i == '\\') {
@@ -157,9 +199,9 @@ namespace Sass {
157
199
 
158
200
  // evacuate unescaped quoted
159
201
  // leave everything else untouched
160
- string evacuate_quotes(const string& str)
202
+ std::string evacuate_quotes(const std::string& str)
161
203
  {
162
- string out("");
204
+ std::string out("");
163
205
  bool esc = false;
164
206
  for (auto i : str) {
165
207
  if (!esc) {
@@ -179,9 +221,9 @@ namespace Sass {
179
221
 
180
222
  // double escape all escape sequences
181
223
  // keep unescaped quotes and backslashes
182
- string evacuate_escapes(const string& str)
224
+ std::string evacuate_escapes(const std::string& str)
183
225
  {
184
- string out("");
226
+ std::string out("");
185
227
  bool esc = false;
186
228
  for (auto i : str) {
187
229
  if (i == '\\' && !esc) {
@@ -213,22 +255,25 @@ namespace Sass {
213
255
  }
214
256
 
215
257
  // bell character is replaces with space
216
- string string_to_output(const string& str)
258
+ std::string string_to_output(const std::string& str)
217
259
  {
218
- string out("");
260
+ std::string out("");
261
+ bool lf = false;
219
262
  for (auto i : str) {
220
263
  if (i == 10) {
221
264
  out += ' ';
222
- } else {
265
+ lf = true;
266
+ } else if (!(lf && isspace(i))) {
223
267
  out += i;
268
+ lf = false;
224
269
  }
225
270
  }
226
271
  return out;
227
272
  }
228
273
 
229
- string comment_to_string(const string& text)
274
+ std::string comment_to_string(const std::string& text)
230
275
  {
231
- string str = "";
276
+ std::string str = "";
232
277
  size_t has = 0;
233
278
  char prev = 0;
234
279
  bool clean = false;
@@ -258,11 +303,11 @@ namespace Sass {
258
303
  else return text;
259
304
  }
260
305
 
261
- string normalize_wspace(const string& str)
306
+ std::string normalize_wspace(const std::string& str)
262
307
  {
263
308
  bool ws = false;
264
309
  bool esc = false;
265
- string text = "";
310
+ std::string text = "";
266
311
  for(const char& i : str) {
267
312
  if (!esc && i == '\\') {
268
313
  esc = true;
@@ -310,7 +355,7 @@ namespace Sass {
310
355
  return quote_mark;
311
356
  }
312
357
 
313
- string unquote(const string& s, char* qd)
358
+ std::string unquote(const std::string& s, char* qd, bool keep_utf8_sequences)
314
359
  {
315
360
 
316
361
  // not enough room for quotes
@@ -326,7 +371,7 @@ namespace Sass {
326
371
  else if (*s.begin() == '\'' && *s.rbegin() == '\'') q = '\'';
327
372
  else return s;
328
373
 
329
- string unq;
374
+ std::string unq;
330
375
  unq.reserve(s.length()-2);
331
376
 
332
377
  for (size_t i = 1, L = s.length() - 1; i < L; ++i) {
@@ -350,12 +395,16 @@ namespace Sass {
350
395
  while (i + len < L && s[i + len] && isxdigit(s[i + len])) ++ len;
351
396
 
352
397
  // hex string?
353
- if (len > 1) {
398
+ if (keep_utf8_sequences) {
399
+ unq.push_back(s[i]);
400
+ } else if (len > 1) {
354
401
 
355
402
  // convert the extracted hex string to code point value
356
403
  // ToDo: Maybe we could do this without creating a substring
357
404
  uint32_t cp = strtol(s.substr (i + 1, len - 1).c_str(), nullptr, 16);
358
405
 
406
+ if (s[i + len] == ' ') ++ len;
407
+
359
408
  // assert invalid code points
360
409
  if (cp == 0) cp = 0xFFFD;
361
410
  // replace bell character
@@ -395,16 +444,16 @@ namespace Sass {
395
444
 
396
445
  }
397
446
 
398
- string quote(const string& s, char q, bool keep_linefeed_whitespace)
447
+ std::string quote(const std::string& s, char q, bool keep_linefeed_whitespace)
399
448
  {
400
449
 
401
450
  // autodetect with fallback to given quote
402
451
  q = detect_best_quotemark(s.c_str(), q);
403
452
 
404
453
  // return an empty quoted string
405
- if (s.empty()) return string(2, q ? q : '"');
454
+ if (s.empty()) return std::string(2, q ? q : '"');
406
455
 
407
- string quoted;
456
+ std::string quoted;
408
457
  quoted.reserve(s.length()+2);
409
458
  quoted.push_back(q);
410
459
 
@@ -421,7 +470,7 @@ namespace Sass {
421
470
 
422
471
  int cp = utf8::next(it, end);
423
472
 
424
- if (cp == 10) {
473
+ if (cp == '\n') {
425
474
  quoted.push_back('\\');
426
475
  quoted.push_back('a');
427
476
  // we hope we can remove this flag once we figure out
@@ -457,19 +506,40 @@ namespace Sass {
457
506
 
458
507
  bool peek_linefeed(const char* start)
459
508
  {
460
- while (*start) {
461
- if (*start == '\n' || *start == '\r') return true;
462
- if (*start != ' ' && *start != '\t') return false;
463
- ++ start;
464
- }
465
- return false;
509
+ using namespace Prelexer;
510
+ using namespace Constants;
511
+ return sequence <
512
+ zero_plus <
513
+ alternatives <
514
+ exactly <' '>,
515
+ exactly <'\t'>,
516
+ line_comment,
517
+ block_comment,
518
+ delimited_by <
519
+ slash_star,
520
+ star_slash,
521
+ false
522
+ >
523
+ >
524
+ >,
525
+ re_linebreak
526
+ >(start) != 0;
466
527
  }
467
528
 
468
529
  namespace Util {
469
530
  using std::string;
470
531
 
471
- string normalize_underscores(const string& str) {
472
- string normalized = str;
532
+ std::string rtrim(const std::string &str) {
533
+ std::string trimmed = str;
534
+ size_t pos_ws = trimmed.find_last_not_of(" \t\n\v\f\r");
535
+ if (pos_ws != std::string::npos)
536
+ { trimmed.erase(pos_ws + 1); }
537
+ else { trimmed.clear(); }
538
+ return trimmed;
539
+ }
540
+
541
+ std::string normalize_underscores(const std::string& str) {
542
+ std::string normalized = str;
473
543
  for(size_t i = 0, L = normalized.length(); i < L; ++i) {
474
544
  if(normalized[i] == '_') {
475
545
  normalized[i] = '-';
@@ -478,26 +548,26 @@ namespace Sass {
478
548
  return normalized;
479
549
  }
480
550
 
481
- string normalize_decimals(const string& str) {
482
- string prefix = "0";
483
- string normalized = str;
551
+ std::string normalize_decimals(const std::string& str) {
552
+ std::string prefix = "0";
553
+ std::string normalized = str;
484
554
 
485
555
  return normalized[0] == '.' ? normalized.insert(0, prefix) : normalized;
486
556
  }
487
557
 
488
558
  // compress a color sixtuplet if possible
489
559
  // input: "#CC9900" -> output: "#C90"
490
- string normalize_sixtuplet(const string& col) {
560
+ std::string normalize_sixtuplet(const std::string& col) {
491
561
  if(
492
562
  col.substr(1, 1) == col.substr(2, 1) &&
493
563
  col.substr(3, 1) == col.substr(4, 1) &&
494
564
  col.substr(5, 1) == col.substr(6, 1)
495
565
  ) {
496
- return string("#" + col.substr(1, 1)
566
+ return std::string("#" + col.substr(1, 1)
497
567
  + col.substr(3, 1)
498
568
  + col.substr(5, 1));
499
569
  } else {
500
- return string(col);
570
+ return std::string(col);
501
571
  }
502
572
  }
503
573
 
@@ -518,17 +588,22 @@ namespace Sass {
518
588
  bool hasPrintableChildBlocks = false;
519
589
  for (size_t i = 0, L = b->length(); i < L; ++i) {
520
590
  Statement* stm = (*b)[i];
521
- if (dynamic_cast<Has_Block*>(stm)) {
591
+ if (dynamic_cast<At_Rule*>(stm)) {
592
+ return true;
593
+ } else if (dynamic_cast<Has_Block*>(stm)) {
522
594
  Block* pChildBlock = ((Has_Block*)stm)->block();
523
595
  if (isPrintable(pChildBlock, style)) {
524
596
  hasPrintableChildBlocks = true;
525
597
  }
526
598
  } else if (Comment* c = dynamic_cast<Comment*>(stm)) {
527
- if (style == COMPRESSED) {
528
- hasDeclarations = c->is_important();
529
- } else {
599
+ // keep for uncompressed
600
+ if (style != COMPRESSED) {
530
601
  hasDeclarations = true;
531
602
  }
603
+ // output style compressed
604
+ if (c->is_important()) {
605
+ hasDeclarations = c->is_important();
606
+ }
532
607
  } else if (Declaration* d = dynamic_cast<Declaration*>(stm)) {
533
608
  return isPrintable(d, style);
534
609
  } else {
@@ -561,24 +636,20 @@ namespace Sass {
561
636
  return true;
562
637
  }
563
638
 
564
- bool isPrintable(Expression* e, Output_Style style) {
565
- return isPrintable(e, style);
566
- }
567
-
568
- bool isPrintable(Feature_Block* f, Output_Style style) {
639
+ bool isPrintable(Supports_Block* f, Output_Style style) {
569
640
  if (f == NULL) {
570
641
  return false;
571
642
  }
572
643
 
573
644
  Block* b = f->block();
574
645
 
575
- bool hasSelectors = f->selector() && static_cast<Selector_List*>(f->selector())->length() > 0;
646
+ // bool hasSelectors = f->selector() && static_cast<Selector_List*>(f->selector())->length() > 0;
576
647
 
577
648
  bool hasDeclarations = false;
578
649
  bool hasPrintableChildBlocks = false;
579
650
  for (size_t i = 0, L = b->length(); i < L; ++i) {
580
651
  Statement* stm = (*b)[i];
581
- if (!stm->is_hoistable() && f->selector() != NULL && !hasSelectors) {
652
+ if (!stm->is_hoistable()) {
582
653
  // If a statement isn't hoistable, the selectors apply to it. If there are no selectors (a selector list of length 0),
583
654
  // then those statements aren't considered printable. That means there was a placeholder that was removed. If the selector
584
655
  // is NULL, then that means there was never a wrapping selector and it is printable (think of a top level media block with
@@ -602,40 +673,19 @@ namespace Sass {
602
673
  return false;
603
674
  }
604
675
 
605
- bool isPrintable(Media_Block* m, Output_Style style) {
606
- if (m == NULL) {
607
- return false;
608
- }
609
-
676
+ bool isPrintable(Media_Block* m, Output_Style style)
677
+ {
678
+ if (m == 0) return false;
610
679
  Block* b = m->block();
611
-
612
- bool hasSelectors = m->selector() && static_cast<Selector_List*>(m->selector())->length() > 0;
613
-
614
- bool hasDeclarations = false;
615
- bool hasPrintableChildBlocks = false;
680
+ if (b == 0) return false;
616
681
  for (size_t i = 0, L = b->length(); i < L; ++i) {
617
682
  Statement* stm = (*b)[i];
618
- if (!stm->is_hoistable() && m->selector() != NULL && !hasSelectors) {
619
- // If a statement isn't hoistable, the selectors apply to it. If there are no selectors (a selector list of length 0),
620
- // then those statements aren't considered printable. That means there was a placeholder that was removed. If the selector
621
- // is NULL, then that means there was never a wrapping selector and it is printable (think of a top level media block with
622
- // a declaration in it).
623
- }
624
- else if (typeid(*stm) == typeid(Declaration) || typeid(*stm) == typeid(At_Rule)) {
625
- hasDeclarations = true;
626
- }
627
- else if (dynamic_cast<Has_Block*>(stm)) {
628
- Block* pChildBlock = ((Has_Block*)stm)->block();
629
- if (isPrintable(pChildBlock, style)) {
630
- hasPrintableChildBlocks = true;
631
- }
632
- }
633
-
634
- if (hasDeclarations || hasPrintableChildBlocks) {
635
- return true;
683
+ if (typeid(*stm) == typeid(At_Rule)) return true;
684
+ if (typeid(*stm) == typeid(Declaration)) return true;
685
+ if (Has_Block* child = dynamic_cast<Has_Block*>(stm)) {
686
+ if (isPrintable(child->block(), style)) return true;
636
687
  }
637
688
  }
638
-
639
689
  return false;
640
690
  }
641
691
 
@@ -650,7 +700,15 @@ namespace Sass {
650
700
  return true;
651
701
  }
652
702
  else if (typeid(*stm) == typeid(Comment)) {
653
-
703
+ Comment* c = (Comment*) stm;
704
+ // keep for uncompressed
705
+ if (style != COMPRESSED) {
706
+ return true;
707
+ }
708
+ // output style compressed
709
+ if (c->is_important()) {
710
+ return true;
711
+ }
654
712
  }
655
713
  else if (typeid(*stm) == typeid(Ruleset)) {
656
714
  Ruleset* r = (Ruleset*) stm;
@@ -658,8 +716,8 @@ namespace Sass {
658
716
  return true;
659
717
  }
660
718
  }
661
- else if (typeid(*stm) == typeid(Feature_Block)) {
662
- Feature_Block* f = (Feature_Block*) stm;
719
+ else if (typeid(*stm) == typeid(Supports_Block)) {
720
+ Supports_Block* f = (Supports_Block*) stm;
663
721
  if (isPrintable(f, style)) {
664
722
  return true;
665
723
  }
@@ -678,12 +736,12 @@ namespace Sass {
678
736
  return false;
679
737
  }
680
738
 
681
- string vecJoin(const vector<string>& vec, const string& sep)
739
+ std::string vecJoin(const std::vector<std::string>& vec, const std::string& sep)
682
740
  {
683
741
  switch (vec.size())
684
742
  {
685
743
  case 0:
686
- return string("");
744
+ return std::string("");
687
745
  case 1:
688
746
  return vec[0];
689
747
  default: