@@ -240,6 +240,8 @@ namespace Sass {
240
240
if (char * contents = read_file (resolved)) {
241
241
add_source (path, resolved, contents);
242
242
style_sheets[path] = 0 ;
243
+ size_t i = queue.size () - 1 ;
244
+ process_queue_entry (queue[i], i);
243
245
return path;
244
246
}
245
247
return std::string (" " );
@@ -268,6 +270,8 @@ namespace Sass {
268
270
if (char * contents = read_file (resolved[0 ].abs_path )) {
269
271
add_source (base_file, resolved[0 ].abs_path , contents);
270
272
style_sheets[base_file] = 0 ;
273
+ size_t i = queue.size () - 1 ;
274
+ process_queue_entry (queue[i], i);
271
275
return base_file;
272
276
}
273
277
}
@@ -300,28 +304,34 @@ namespace Sass {
300
304
return sass_strdup (output.c_str ());
301
305
}
302
306
307
+ void Context::process_queue_entry (Sass_Queued& entry, size_t i)
308
+ {
309
+ if (style_sheets[queue[i].load_path ]) return ;
310
+ Sass_Import_Entry import = sass_make_import (
311
+ queue[i].load_path .c_str (),
312
+ queue[i].abs_path .c_str (),
313
+ 0 , 0
314
+ );
315
+ import_stack.push_back (import );
316
+ // keep a copy of the path around (for parser states)
317
+ strings.push_back (sass_strdup (queue[i].abs_path .c_str ()));
318
+ ParserState pstate (strings.back (), queue[i].source , i);
319
+ Parser p (Parser::from_c_str (queue[i].source , *this , pstate));
320
+ Block* ast = p.parse ();
321
+ sass_delete_import (import_stack.back ());
322
+ import_stack.pop_back ();
323
+ // ToDo: we store by load_path, which can lead
324
+ // to duplicates if importer reports the same path
325
+ // Maybe we should add an error for duplicates!?
326
+ style_sheets[queue[i].load_path ] = ast;
327
+ }
328
+
303
329
Block* Context::parse_file ()
304
330
{
305
331
Block* root = 0 ;
306
332
for (size_t i = 0 ; i < queue.size (); ++i) {
307
- Sass_Import_Entry import = sass_make_import (
308
- queue[i].load_path .c_str (),
309
- queue[i].abs_path .c_str (),
310
- 0 , 0
311
- );
312
- import_stack.push_back (import );
313
- // keep a copy of the path around (for parser states)
314
- strings.push_back (sass_strdup (queue[i].abs_path .c_str ()));
315
- ParserState pstate (strings.back (), queue[i].source , i);
316
- Parser p (Parser::from_c_str (queue[i].source , *this , pstate));
317
- Block* ast = p.parse ();
318
- sass_delete_import (import_stack.back ());
319
- import_stack.pop_back ();
320
- if (i == 0 ) root = ast;
321
- // ToDo: we store by load_path, which can lead
322
- // to duplicates if importer reports the same path
323
- // Maybe we should add an error for duplicates!?
324
- style_sheets[queue[i].load_path ] = ast;
333
+ process_queue_entry (queue[i], i);
334
+ if (i == 0 ) root = style_sheets[queue[i].load_path ];
325
335
}
326
336
if (root == 0 ) return 0 ;
327
337
@@ -368,6 +378,8 @@ namespace Sass {
368
378
return parse_file ();
369
379
}
370
380
add_source (input_path, input_path, source_c_str);
381
+ size_t idx = queue.size () - 1 ;
382
+ process_queue_entry (queue[idx], idx);
371
383
return parse_file ();
372
384
}
373
385
0 commit comments