Skip to content

Commit 1033e85

Browse files
committed
Merge pull request #1974 from xoofx/fix_sass_option_push_include_path
Fix sass_option_push_include_path / sass_option_push_plugin_path
2 parents d53c063 + bf471e2 commit 1033e85

File tree

3 files changed

+14
-53
lines changed

3 files changed

+14
-53
lines changed

src/context.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ namespace Sass {
9292

9393
// collect more paths from different options
9494
collect_include_paths(c_options.include_path);
95-
// collect_include_paths(c_options.include_paths);
95+
collect_include_paths(c_options.include_paths);
9696
collect_plugin_paths(c_options.plugin_path);
97-
// collect_plugin_paths(c_options.plugin_paths);
97+
collect_plugin_paths(c_options.plugin_paths);
9898

9999
// load plugins and register custom behaviors
100100
for(auto plug : plugin_paths) plugins.load_plugins(plug);
@@ -162,7 +162,6 @@ namespace Sass {
162162

163163
void Context::collect_include_paths(const char* paths_str)
164164
{
165-
166165
if (paths_str) {
167166
const char* beg = paths_str;
168167
const char* end = Prelexer::find_first<PATH_SEP>(beg);
@@ -185,17 +184,17 @@ namespace Sass {
185184
}
186185
}
187186

188-
void Context::collect_include_paths(const char** paths_array)
187+
void Context::collect_include_paths(string_list* paths_array)
189188
{
190-
if (!paths_array) return;
191-
for (size_t i = 0; paths_array[i]; i++) {
192-
collect_include_paths(paths_array[i]);
189+
while (paths_array)
190+
{
191+
collect_include_paths(paths_array->string);
192+
paths_array = paths_array->next;
193193
}
194194
}
195195

196196
void Context::collect_plugin_paths(const char* paths_str)
197197
{
198-
199198
if (paths_str) {
200199
const char* beg = paths_str;
201200
const char* end = Prelexer::find_first<PATH_SEP>(beg);
@@ -218,15 +217,15 @@ namespace Sass {
218217
}
219218
}
220219

221-
void Context::collect_plugin_paths(const char** paths_array)
220+
void Context::collect_plugin_paths(string_list* paths_array)
222221
{
223-
if (!paths_array) return;
224-
for (size_t i = 0; paths_array[i]; i++) {
225-
collect_plugin_paths(paths_array[i]);
222+
while (paths_array)
223+
{
224+
collect_plugin_paths(paths_array->string);
225+
paths_array = paths_array->next;
226226
}
227227
}
228228

229-
230229
// resolve the imp_path in base_path or include_paths
231230
// looks for alternatives and returns a list from one directory
232231
std::vector<Include> Context::find_includes(const Importer& import)

src/context.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ namespace Sass {
101101

102102
private:
103103
void collect_plugin_paths(const char* paths_str);
104-
void collect_plugin_paths(const char** paths_array);
104+
void collect_plugin_paths(string_list* paths_array);
105105
void collect_include_paths(const char* paths_str);
106-
void collect_include_paths(const char** paths_array);
106+
void collect_include_paths(string_list* paths_array);
107107
std::string format_embedded_source_map();
108108
std::string format_source_mapping_url(const std::string& out_path);
109109

src/sass_context.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -198,44 +198,6 @@ extern "C" {
198198
static Sass_Compiler* sass_prepare_context (Sass_Context* c_ctx, Context* cpp_ctx) throw()
199199
{
200200
try {
201-
202-
// convert include path linked list to static array
203-
struct string_list* inc = c_ctx->include_paths;
204-
// very poor loop to get the length of the linked list
205-
size_t inc_size = 0; while (inc) { inc_size ++; inc = inc->next; }
206-
// create char* array to hold all paths plus null terminator
207-
const char** include_paths = (const char**) calloc(inc_size + 1, sizeof(char*));
208-
if (include_paths == 0) throw(std::bad_alloc());
209-
// reset iterator
210-
inc = c_ctx->include_paths;
211-
// copy over the paths
212-
for (size_t i = 0; inc; i++) {
213-
include_paths[i] = inc->string;
214-
inc = inc->next;
215-
}
216-
217-
// convert plugin path linked list to static array
218-
struct string_list* imp = c_ctx->plugin_paths;
219-
// very poor loop to get the length of the linked list
220-
size_t imp_size = 0; while (imp) { imp_size ++; imp = imp->next; }
221-
// create char* array to hold all paths plus null terminator
222-
const char** plugin_paths = (const char**) calloc(imp_size + 1, sizeof(char*));
223-
if (plugin_paths == 0) {
224-
free(include_paths); //free include_paths before throw
225-
throw(std::bad_alloc());
226-
}
227-
// reset iterator
228-
imp = c_ctx->plugin_paths;
229-
// copy over the paths
230-
for (size_t i = 0; imp; i++) {
231-
plugin_paths[i] = imp->string;
232-
imp = imp->next;
233-
}
234-
235-
// free intermediate data
236-
free(include_paths);
237-
free(plugin_paths);
238-
239201
// register our custom functions
240202
if (c_ctx->c_functions) {
241203
auto this_func_data = c_ctx->c_functions;

0 commit comments

Comments
 (0)