@@ -135,14 +135,39 @@ namespace Sass {
135135 real_path = dir + _base_scss;
136136 // if the file isn't found with '_' + filename + ".scss" ...
137137 if (!(contents = read_file (real_path))) {
138- string base_scss (base + " .scss" );
139- // try filename + ".scss" as the last resort
140- real_path = dir + base_scss;
141- contents = read_file (real_path);
138+ string _base_sass (_base + " .sass" );
139+ real_path = dir + _base_sass;
140+ // if the file isn't found with '_' + filename + ".sass" ...
141+ if (!(contents = read_file (real_path))) {
142+ string base_scss (base + " .scss" );
143+ real_path = dir + base_scss;
144+ // if the file isn't found with filename + ".scss" ...
145+ if (!(contents = read_file (real_path))) {
146+ string base_sass (base + " .sass" );
147+ real_path = dir + base_sass;
148+ // if the file isn't found with filename + ".sass" ...
149+ if (!(contents = read_file (real_path))) {
150+ // default back to scss version
151+ real_path = dir + base_scss;
152+ }
153+ }
154+ }
142155 }
143156 }
144157 }
145- return contents;
158+ string extension;
159+ if (real_path.length () > 5 ) {
160+ extension = real_path.substr (real_path.length () - 5 , 5 );
161+ }
162+ for (int i=0 ; i<extension.size ();++i)
163+ extension[i] = tolower (extension[i]);
164+ if (extension == " .sass" && contents != 0 ) {
165+ char * converted = ocbnet::sass2scss (contents, SASS2SCSS_PRETTIFY_1);
166+ delete[] contents; // free the indented contents
167+ return converted; // should be freed by caller
168+ } else {
169+ return contents;
170+ }
146171 }
147172
148173 char * read_file (string path)
@@ -163,9 +188,11 @@ namespace Sass {
163188 contents[size] = ' \0 ' ;
164189 file.close ();
165190 }
166- if (extension == " .sass" ) {
191+ for (int i=0 ; i<extension.size ();++i)
192+ extension[i] = tolower (extension[i]);
193+ if (extension == " .sass" && contents != 0 ) {
167194 char * converted = ocbnet::sass2scss (contents, SASS2SCSS_PRETTIFY_1);
168- delete[] contents; // free the sass content
195+ delete[] contents; // free the indented contents
169196 return converted; // should be freed by caller
170197 } else {
171198 return contents;
0 commit comments