@@ -101,15 +101,9 @@ extern "C" {
101
101
int sass_compile_file (sass_file_context* c_ctx)
102
102
{
103
103
using namespace Sass ;
104
+ Context cpp_ctx (c_ctx->options .include_paths , c_ctx->options .image_path , c_ctx->options .source_comments );
104
105
try {
105
- Context cpp_ctx (c_ctx->options .include_paths , c_ctx->options .image_path , c_ctx->options .source_comments );
106
- // Document doc(c_ctx->input_path, 0, cpp_ctx);
107
- // string path_string(c_ctx->options.image_path);
108
- // path_string = "'" + path_string + "/";
109
- // cpp_ctx.image_path = c_ctx->options.image_path;
110
106
Document doc (Document::make_from_file (cpp_ctx, string (c_ctx->input_path )));
111
- // cerr << "MADE A DOC AND CONTEXT OBJ" << endl;
112
- // cerr << "REGISTRY: " << doc.context.registry.size() << endl;
113
107
c_ctx->output_string = process_document (doc, c_ctx->options .output_style );
114
108
c_ctx->error_message = 0 ;
115
109
c_ctx->error_status = 0 ;
@@ -134,6 +128,29 @@ extern "C" {
134
128
c_ctx->output_string = 0 ;
135
129
c_ctx->error_message = msg_str;
136
130
}
131
+ catch (string& bad_path) {
132
+ for (vector<string>::iterator path = cpp_ctx.include_paths .begin (); path < cpp_ctx.include_paths .end (); ++path) {
133
+ try {
134
+ Document doc (Document::make_from_file (cpp_ctx, *path + string (c_ctx->input_path )));
135
+ c_ctx->output_string = process_document (doc, c_ctx->options .output_style );
136
+ c_ctx->error_message = 0 ;
137
+ c_ctx->error_status = 0 ;
138
+ return 0 ;
139
+ }
140
+ catch (string& bad_path) {
141
+ // continue looping
142
+ }
143
+ }
144
+ // couldn't find the specified file in the include paths; report an error
145
+ stringstream msg_stream;
146
+ msg_stream << " error reading file \" " << bad_path << " \" " << endl;
147
+ string msg (msg_stream.str ());
148
+ char * msg_str = (char *) malloc (msg.size () + 1 );
149
+ strcpy (msg_str, msg.c_str ());
150
+ c_ctx->error_status = 1 ;
151
+ c_ctx->output_string = 0 ;
152
+ c_ctx->error_message = msg_str;
153
+ }
137
154
// TO DO: CATCH EVERYTHING ELSE
138
155
return 0 ;
139
156
}
0 commit comments