From 695ae39b7e641f7f5f9132caa52c2bf64041b1ac Mon Sep 17 00:00:00 2001 From: xzyfer Date: Mon, 2 Jul 2018 21:10:56 +1000 Subject: [PATCH 1/4] Revert "Remove raw css imports" This reverts commit 27d502612c2ec5f68e0c5f5b9e7f851e3fa1acc9. --- src/file.cpp | 18 +++++++++++++++--- src/file.hpp | 5 +++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index ab20651943..61b8f2ddff 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -323,7 +323,7 @@ namespace Sass { // (2) underscore + given // (3) underscore + given + extension // (4) given + extension - std::vector resolve_includes(const std::string& root, const std::string& file, const std::vector& exts) + std::vector resolve_includes(const std::string& root, const std::string& file, const std::vector& exts, const std::vector& d_exts) { std::string filename = join_paths(root, file); // split the filename @@ -342,13 +342,25 @@ namespace Sass { for(auto ext : exts) { rel_path = join_paths(base, "_" + name + ext); abs_path = join_paths(root, rel_path); - if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path, ext == ".css" }); + if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path }); } // next test plain name with exts for(auto ext : exts) { rel_path = join_paths(base, name + ext); abs_path = join_paths(root, rel_path); - if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path, ext == ".css" }); + if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path }); + } + // next test d_exts plus underscore + for(auto ext : d_exts) { + rel_path = join_paths(base, "_" + name + ext); + abs_path = join_paths(root, rel_path); + if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path, true }); + } + // next test plain name with d_exts + for(auto ext : d_exts) { + rel_path = join_paths(base, name + ext); + abs_path = join_paths(root, rel_path); + if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path, true }); } // nothing found return includes; diff --git a/src/file.hpp b/src/file.hpp index a043bea7ac..718a529cd1 100644 --- a/src/file.hpp +++ b/src/file.hpp @@ -127,10 +127,11 @@ namespace Sass { namespace File { static std::vector defaultExtensions = { ".scss", ".sass" }; + static std::vector deprecatedExtensions = { ".css" }; std::vector resolve_includes(const std::string& root, const std::string& file, - const std::vector& exts = defaultExtensions); - + const std::vector& exts = defaultExtensions, + const std::vector& d_exts = deprecatedExtensions); } From 980e6317857bf22c30ae8dc8a013527768206d6d Mon Sep 17 00:00:00 2001 From: xzyfer Date: Mon, 2 Jul 2018 21:11:03 +1000 Subject: [PATCH 2/4] Revert "Add configuration for supporting additional extensions as .scss" This reverts commit 6fe62e90be534e6d5e324e525c5a3ed9971afb97. --- include/sass/context.h | 3 --- src/context.cpp | 42 ++---------------------------------------- src/context.hpp | 3 --- src/sass_context.cpp | 34 ++-------------------------------- src/sass_context.hpp | 5 +---- 5 files changed, 5 insertions(+), 82 deletions(-) diff --git a/include/sass/context.h b/include/sass/context.h index 29754b75ff..2f88d68880 100644 --- a/include/sass/context.h +++ b/include/sass/context.h @@ -149,9 +149,6 @@ ADDAPI size_t ADDCALL sass_compiler_get_callee_stack_size(struct Sass_Compiler* ADDAPI Sass_Callee_Entry ADDCALL sass_compiler_get_last_callee(struct Sass_Compiler* compiler); ADDAPI Sass_Callee_Entry ADDCALL sass_compiler_get_callee_entry(struct Sass_Compiler* compiler, size_t idx); -// Push function for import extenions -ADDAPI void ADDCALL sass_option_push_import_extension (struct Sass_Options* options, const char* ext); - // Push function for paths (no manipulation support for now) ADDAPI void ADDCALL sass_option_push_plugin_path (struct Sass_Options* options, const char* path); ADDAPI void ADDCALL sass_option_push_include_path (struct Sass_Options* options, const char* path); diff --git a/src/context.cpp b/src/context.cpp index b199412cd8..dd6d74bfde 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -96,8 +96,6 @@ namespace Sass { // include_paths.push_back(CWD); // collect more paths from different options - collect_extensions(c_options.extension); - collect_extensions(c_options.extensions); collect_include_paths(c_options.include_path); collect_include_paths(c_options.include_paths); collect_plugin_paths(c_options.plugin_path); @@ -168,37 +166,6 @@ namespace Sass { { } - void Context::collect_extensions(const char* exts_str) - { - if (exts_str) { - const char* beg = exts_str; - const char* end = Prelexer::find_first(beg); - - while (end) { - std::string ext(beg, end - beg); - if (!ext.empty()) { - extensions.push_back(ext); - } - beg = end + 1; - end = Prelexer::find_first(beg); - } - - std::string ext(beg); - if (!ext.empty()) { - extensions.push_back(ext); - } - } - } - - void Context::collect_extensions(string_list* paths_array) - { - while (paths_array) - { - collect_extensions(paths_array->string); - paths_array = paths_array->next; - } - } - void Context::collect_include_paths(const char* paths_str) { if (paths_str) { @@ -269,20 +236,15 @@ namespace Sass { // looks for alternatives and returns a list from one directory std::vector Context::find_includes(const Importer& import) { - // include configured extensions - std::vector exts(File::defaultExtensions); - if (extensions.size() > 0) { - exts.insert(exts.end(), extensions.begin(), extensions.end()); - } // make sure we resolve against an absolute path std::string base_path(rel2abs(import.base_path)); // first try to resolve the load path relative to the base path - std::vector vec(resolve_includes(base_path, import.imp_path, exts)); + std::vector vec(resolve_includes(base_path, import.imp_path)); // then search in every include path (but only if nothing found yet) for (size_t i = 0, S = include_paths.size(); vec.size() == 0 && i < S; ++i) { // call resolve_includes and individual base path and append all results - std::vector resolved(resolve_includes(include_paths[i], import.imp_path, exts)); + std::vector resolved(resolve_includes(include_paths[i], import.imp_path)); if (resolved.size()) vec.insert(vec.end(), resolved.begin(), resolved.end()); } // return vector diff --git a/src/context.hpp b/src/context.hpp index f14e69f6d0..d3caba13e9 100644 --- a/src/context.hpp +++ b/src/context.hpp @@ -67,7 +67,6 @@ namespace Sass { std::vector plugin_paths; // relative paths to load plugins std::vector include_paths; // lookup paths for includes - std::vector extensions; // lookup extensions for imports` @@ -110,8 +109,6 @@ namespace Sass { void collect_plugin_paths(string_list* paths_array); void collect_include_paths(const char* paths_str); void collect_include_paths(string_list* paths_array); - void collect_extensions(const char* extensions_str); - void collect_extensions(string_list* extensions_array); std::string format_embedded_source_map(); std::string format_source_mapping_url(const std::string& out_path); diff --git a/src/sass_context.cpp b/src/sass_context.cpp index 7a0a49ce13..afadc66e13 100644 --- a/src/sass_context.cpp +++ b/src/sass_context.cpp @@ -74,14 +74,14 @@ namespace Sass { // move line_beg pointer to line start while (line_beg && *line_beg && lines != 0) { if (*line_beg == '\n') --lines; - utf8::unchecked::next(line_beg); + utf8::unchecked::next(line_beg); } const char* line_end = line_beg; // move line_end before next newline character while (line_end && *line_end && *line_end != '\n') { if (*line_end == '\n') break; if (*line_end == '\r') break; - utf8::unchecked::next(line_end); + utf8::unchecked::next(line_end); } if (line_end && *line_end != 0) ++ line_end; size_t line_len = line_end - line_beg; @@ -524,7 +524,6 @@ extern "C" { options->c_headers = 0; options->plugin_paths = 0; options->include_paths = 0; - options->extensions = 0; } // helper function, not exported, only accessible locally @@ -559,18 +558,6 @@ extern "C" { cur = next; } } - // Deallocate extension - if (options->extensions) { - struct string_list* cur; - struct string_list* next; - cur = options->extensions; - while (cur) { - next = cur->next; - free(cur->string); - free(cur); - cur = next; - } - } // Free options strings free(options->input_path); free(options->output_path); @@ -590,7 +577,6 @@ extern "C" { options->c_headers = 0; options->plugin_paths = 0; options->include_paths = 0; - options->extensions = 0; } // helper function, not exported, only accessible locally @@ -727,22 +713,6 @@ extern "C" { IMPLEMENT_SASS_CONTEXT_TAKER(char*, source_map_string); IMPLEMENT_SASS_CONTEXT_TAKER(char**, included_files); - // Push function for import extenions - void ADDCALL sass_option_push_import_extension(struct Sass_Options* options, const char* ext) - { - struct string_list* extension = (struct string_list*) calloc(1, sizeof(struct string_list)); - if (extension == 0) return; - extension->string = ext ? sass_copy_c_string(ext) : 0; - struct string_list* last = options->extensions; - if (!options->extensions) { - options->extensions = extension; - } else { - while (last->next) - last = last->next; - last->next = extension; - } - } - // Push function for include paths (no manipulation support for now) void ADDCALL sass_option_push_include_path(struct Sass_Options* options, const char* path) { diff --git a/src/sass_context.hpp b/src/sass_context.hpp index 9d192a3017..8ae1fb12cd 100644 --- a/src/sass_context.hpp +++ b/src/sass_context.hpp @@ -40,12 +40,9 @@ struct Sass_Options : Sass_Output_Options { // Colon-separated list of paths // Semicolon-separated on Windows // Maybe use array interface instead? - char* extension; char* include_path; char* plugin_path; - // Extensions (linked string list) - struct string_list* extensions; // Include paths (linked string list) struct string_list* include_paths; // Plugin paths (linked string list) @@ -129,4 +126,4 @@ struct Sass_Compiler { Sass::Block_Obj root; }; -#endif +#endif \ No newline at end of file From ad533713ced0caa22e91f8be7e7220e5f3dd6487 Mon Sep 17 00:00:00 2001 From: xzyfer Date: Mon, 2 Jul 2018 21:11:13 +1000 Subject: [PATCH 3/4] Revert "Add a deprecation warning for @import's that resolved .css files" This reverts commit fd989f6fb783a0f0f0f5892b1f710fdedb94a579. --- src/context.cpp | 8 -------- src/file.cpp | 4 ++-- src/file.hpp | 7 +------ 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/context.cpp b/src/context.cpp index dd6d74bfde..dae2cbd75e 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -365,14 +365,6 @@ namespace Sass { // process the resolved entry else if (resolved.size() == 1) { bool use_cache = c_importers.size() == 0; - if (resolved[0].deprecated) { - // emit deprecation warning when import resolves to a .css file - deprecated( - "Including .css files with @import is non-standard behaviour which will be removed in future versions of LibSass.", - "Use a custom importer to maintain this behaviour. Check your implementations documentation on how to create a custom importer.", - true, pstate - ); - } // use cache for the resource loading if (use_cache && sheets.count(resolved[0].abs_path)) return resolved[0]; // try to read the content of the resolved file entry diff --git a/src/file.cpp b/src/file.cpp index 61b8f2ddff..46973057a3 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -354,13 +354,13 @@ namespace Sass { for(auto ext : d_exts) { rel_path = join_paths(base, "_" + name + ext); abs_path = join_paths(root, rel_path); - if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path, true }); + if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path }); } // next test plain name with d_exts for(auto ext : d_exts) { rel_path = join_paths(base, name + ext); abs_path = join_paths(root, rel_path); - if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path, true }); + if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path }); } // nothing found return includes; diff --git a/src/file.hpp b/src/file.hpp index 718a529cd1..759996fa85 100644 --- a/src/file.hpp +++ b/src/file.hpp @@ -89,14 +89,9 @@ namespace Sass { public: // resolved absolute path std::string abs_path; - // is a deprecated file type - bool deprecated; public: - Include(const Importer& imp, std::string abs_path, bool deprecated) - : Importer(imp), abs_path(abs_path), deprecated(deprecated) - { } Include(const Importer& imp, std::string abs_path) - : Importer(imp), abs_path(abs_path), deprecated(false) + : Importer(imp), abs_path(abs_path) { } }; From 463532a1eaa5631cc3c8c9db447af2cc7c8a9ce3 Mon Sep 17 00:00:00 2001 From: xzyfer Date: Mon, 2 Jul 2018 21:11:20 +1000 Subject: [PATCH 4/4] Revert "Separate out deprecated import file extensions" This reverts commit b9662fc5b16d8dc985d2077a471d0aa0ee8f8c7f. --- src/file.cpp | 14 +------------- src/file.hpp | 6 ++---- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index 46973057a3..32d4a7c639 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -323,7 +323,7 @@ namespace Sass { // (2) underscore + given // (3) underscore + given + extension // (4) given + extension - std::vector resolve_includes(const std::string& root, const std::string& file, const std::vector& exts, const std::vector& d_exts) + std::vector resolve_includes(const std::string& root, const std::string& file, const std::vector& exts) { std::string filename = join_paths(root, file); // split the filename @@ -350,18 +350,6 @@ namespace Sass { abs_path = join_paths(root, rel_path); if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path }); } - // next test d_exts plus underscore - for(auto ext : d_exts) { - rel_path = join_paths(base, "_" + name + ext); - abs_path = join_paths(root, rel_path); - if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path }); - } - // next test plain name with d_exts - for(auto ext : d_exts) { - rel_path = join_paths(base, name + ext); - abs_path = join_paths(root, rel_path); - if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path }); - } // nothing found return includes; } diff --git a/src/file.hpp b/src/file.hpp index 759996fa85..279b9e9f62 100644 --- a/src/file.hpp +++ b/src/file.hpp @@ -121,12 +121,10 @@ namespace Sass { namespace File { - static std::vector defaultExtensions = { ".scss", ".sass" }; - static std::vector deprecatedExtensions = { ".css" }; + static std::vector defaultExtensions = { ".scss", ".sass", ".css" }; std::vector resolve_includes(const std::string& root, const std::string& file, - const std::vector& exts = defaultExtensions, - const std::vector& d_exts = deprecatedExtensions); + const std::vector& exts = defaultExtensions); }