@@ -38,23 +38,39 @@ namespace Sass {
3838 const char * path_str = path.c_str ();
3939 struct stat st;
4040 string tmp;
41+
42+ // Resolution order for ambiguous imports:
43+ // (1) filename as given
44+ // (2) underscore + given
45+ // (3) underscore + given + extension
46+ // (4) given + extension
47+
48+ // if the file as given isn't found ...
4149 if (stat (path_str, &st) == -1 || S_ISDIR (st.st_mode )) {
42- tmp = path + " .scss" ;
50+ // then try "_" + given
51+ const char *full_path_str = path.c_str ();
52+ const char *file_name_str = Prelexer::folders (full_path_str);
53+ string folder (Token::make (full_path_str, file_name_str).to_string ());
54+ string partial_filename (" _" + string (file_name_str));
55+ tmp = folder + partial_filename;
56+ path_str = tmp.c_str ();
57+ // if "_" + given isn't found ...
58+ if (stat (path_str, &st) == -1 || S_ISDIR (st.st_mode )) {
59+ // then try "_" + given + ".scss"
60+ tmp += " .scss" ;
4361 path_str = tmp.c_str ();
62+ // if "_" + given + ".scss" isn't found ...
4463 if (stat (path_str, &st) == -1 || S_ISDIR (st.st_mode )) {
45- const char *full_path_str = path.c_str ();
46- const char *file_name_str = Prelexer::folders (full_path_str);
47- tmp = Token::make (full_path_str, file_name_str).to_string () +
48- " _" +
49- string (file_name_str);
50- path_str = tmp.c_str ();
51- if (stat (path_str, &st) == -1 || S_ISDIR (st.st_mode )) {
52- tmp = tmp + " .scss" ;
53- path_str = tmp.c_str ();
54- if (stat (path_str, &st) == -1 || S_ISDIR (st.st_mode ))
55- throw path;
56- }
64+ // then try given + ".scss"
65+ string non_partial_filename (string (file_name_str) + " .scss" );
66+ tmp = folder + non_partial_filename;
67+ path_str = tmp.c_str ();
68+ // if we still can't find the file, then throw an error
69+ if (stat (path_str, &st) == -1 || S_ISDIR (st.st_mode )) {
70+ throw path;
71+ }
5772 }
73+ }
5874 }
5975 f = std::fopen (path_str, " rb" );
6076 size_t len = st.st_size ;
@@ -71,7 +87,7 @@ namespace Sass {
7187 string include_path (path_str, file_name_str - path_str);
7288
7389 Document doc (ctx);
74- doc.path = path ;
90+ doc.path = path_str ;
7591 doc.line = 1 ;
7692 doc.root = ctx.new_Node (Node::root, path, 1 , 0 );
7793 doc.lexed = Token::make ();
@@ -80,9 +96,6 @@ namespace Sass {
8096 doc.end = end;
8197 doc.position = source;
8298 doc.context .source_refs .push_back (source);
83- if (!include_path.empty ()) {
84- doc.context .include_paths .push_back (include_path);
85- }
8699
87100 return doc;
88101 }
@@ -135,11 +148,14 @@ namespace Sass {
135148 root.echo (output);
136149 break ;
137150 case nested:
138- root.emit_nested_css (output, 0 , true );
151+ root.emit_nested_css (output, 0 , true , false , context. source_comments );
139152 break ;
140153 case expanded:
141154 root.emit_expanded_css (output, " " );
142155 break ;
156+ case compressed:
157+ root.emit_compressed_css (output);
158+ break ;
143159 default :
144160 break ;
145161 }
0 commit comments