@@ -91,9 +91,9 @@ namespace Sass {
91
91
92
92
include_paths.push_back (cwd);
93
93
collect_include_paths (initializers.include_paths_c_str ());
94
- collect_include_paths (initializers.include_paths_array ());
94
+ // collect_include_paths(initializers.include_paths_array());
95
95
collect_plugin_paths (initializers.plugin_paths_c_str ());
96
- collect_plugin_paths (initializers.plugin_paths_array ());
96
+ // collect_plugin_paths(initializers.plugin_paths_array());
97
97
98
98
setup_color_map ();
99
99
@@ -225,50 +225,37 @@ namespace Sass {
225
225
include_links.push_back (resolve_relative_path (abs_path, source_map_file, cwd));
226
226
}
227
227
228
- string Context::add_file (string path)
228
+ // Add a new import file to the context
229
+ string Context::add_file (const string& file)
229
230
{
230
231
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;
243
239
}
244
- return string ();
240
+ return string (" " );
245
241
}
246
242
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)
248
246
{
249
247
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;
270
256
}
271
- return string ();
257
+ // now go the regular code path
258
+ return add_file (path);
272
259
}
273
260
274
261
void register_function (Context&, Signature sig, Native_Function f, Env* env);
0 commit comments