}
return 0;
}
+ if(!i) {
+ as3_warning("Include directory stack is empty, while looking for file %s", filename);
+ }
while(i) {
char*p = concat_paths(i->path, filename);
fi = fopen(p, "rb");
char*enter_file(char*filename, void*state)
{
+ filename = strdup(filename);
+
if(include_stack_ptr >= MAX_INCLUDE_DEPTH) {
- syntaxerror("Includes nested too deeply");
+ as3_error("Includes nested too deeply");
exit(1);
}
char*fullfilename = find_file(filename);
if(!fullfilename) {
- syntaxerror("Couldn't find file %s", filename);
+ as3_error("Couldn't find file %s", filename);
include_dir_t*i = current_include_dirs;
while(i) {
fprintf(stderr, "include dir: %s\n", i->path);
include_stack[include_stack_ptr] = state;
line_stack[include_stack_ptr] = current_line;
column_stack[include_stack_ptr] = current_column;
- shortfilename_stack[include_stack_ptr] = current_filename_short = strdup(filename);
+ shortfilename_stack[include_stack_ptr] = current_filename_short;
filename_stack[include_stack_ptr] = current_filename;
includedir_stack[include_stack_ptr] = current_include_dirs;
add_include_dir(get_path(fullfilename));
current_line=1;
current_column=0;
- current_filename=fullfilename;
+ current_filename = fullfilename;
+ current_filename_short = filename;
return fullfilename;
}
void* leave_file()
{
dbg("leaving file %s", current_filename);
- if(--include_stack_ptr<0) {
+ if(--include_stack_ptr<=0) {
return 0;
} else {
- current_column = column_stack[include_stack_ptr];
- current_line = line_stack[include_stack_ptr];
free(current_filename);current_filename = filename_stack[include_stack_ptr];
free(current_filename_short);current_filename_short = shortfilename_stack[include_stack_ptr];
+ current_column = column_stack[include_stack_ptr];
+ current_line = line_stack[include_stack_ptr];
current_include_dirs = includedir_stack[include_stack_ptr];
return include_stack[include_stack_ptr];
}