@@ -91,9 +91,9 @@ namespace Sass {
9191
9292 include_paths.push_back (cwd);
9393 collect_include_paths (initializers.include_paths_c_str ());
94- collect_include_paths (initializers.include_paths_array ());
94+ // collect_include_paths(initializers.include_paths_array());
9595 collect_plugin_paths (initializers.plugin_paths_c_str ());
96- collect_plugin_paths (initializers.plugin_paths_array ());
96+ // collect_plugin_paths(initializers.plugin_paths_array());
9797
9898 setup_color_map ();
9999
@@ -225,50 +225,37 @@ namespace Sass {
225225 include_links.push_back (resolve_relative_path (abs_path, source_map_file, cwd));
226226 }
227227
228- string Context::add_file (string path)
228+ // Add a new import file to the context
229+ string Context::add_file (const string& file)
229230 {
230231 using namespace File ;
231- char * contents = 0 ;
232- string real_path;
233- path = make_canonical_path (path);
234- for (size_t i = 0 , S = include_paths.size (); i < S; ++i) {
235- string full_path (join_paths (include_paths[i], path));
236- if (style_sheets.count (full_path)) return full_path;
237- contents = resolve_and_load (full_path, real_path);
238- if (contents) {
239- add_source (full_path, real_path, contents);
240- style_sheets[full_path] = 0 ;
241- return full_path;
242- }
232+ string path (make_canonical_path (file));
233+ string resolved (find_file (path, include_paths));
234+ if (resolved == " " ) return resolved;
235+ if (char * contents = read_file (resolved)) {
236+ add_source (path, resolved, contents);
237+ style_sheets[path] = 0 ;
238+ return path;
243239 }
244- return string ();
240+ return string (" " );
245241 }
246242
247- string Context::add_file (string dir, string rel_filepath)
243+ // Add a new import file to the context
244+ // This has some previous directory context
245+ string Context::add_file (const string& base, const string& file)
248246 {
249247 using namespace File ;
250- char * contents = 0 ;
251- string real_path;
252- rel_filepath = make_canonical_path (rel_filepath);
253- string full_path (join_paths (dir, rel_filepath));
254- if (style_sheets.count (full_path)) return full_path;
255- contents = resolve_and_load (full_path, real_path);
256- if (contents) {
257- add_source (full_path, real_path, contents);
258- style_sheets[full_path] = 0 ;
259- return full_path;
260- }
261- for (size_t i = 0 , S = include_paths.size (); i < S; ++i) {
262- string full_path (join_paths (include_paths[i], rel_filepath));
263- if (style_sheets.count (full_path)) return full_path;
264- contents = resolve_and_load (full_path, real_path);
265- if (contents) {
266- add_source (full_path, real_path, contents);
267- style_sheets[full_path] = 0 ;
268- return full_path;
269- }
248+ string path (make_canonical_path (file));
249+ string base_file (join_paths (base, path));
250+ string resolved (resolve_file (base_file));
251+ if (style_sheets.count (base_file)) return base_file;
252+ if (char * contents = read_file (resolved)) {
253+ add_source (base_file, resolved, contents);
254+ style_sheets[base_file] = 0 ;
255+ return base_file;
270256 }
271- return string ();
257+ // now go the regular code path
258+ return add_file (path);
272259 }
273260
274261 void register_function (Context&, Signature sig, Native_Function f, Env* env);
0 commit comments