X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Ffiles.c;h=8b951d9149a9a31362be65c82262f66e1eaf5952;hb=6029bb1f7ed190e21886a5b7ab9cc51c8be04f0f;hp=10e5de6e04a75ff96f797a1c02758b58943e341b;hpb=be3759d7bc8e2d537974363a32389f9e47d8c867;p=swftools.git diff --git a/lib/as3/files.c b/lib/as3/files.c index 10e5de6..8b951d9 100644 --- a/lib/as3/files.c +++ b/lib/as3/files.c @@ -131,6 +131,9 @@ char*find_file(char*filename) } 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"); @@ -145,13 +148,15 @@ char*find_file(char*filename) 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); @@ -162,7 +167,7 @@ char*enter_file(char*filename, void*state) 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)); @@ -172,20 +177,21 @@ char*enter_file(char*filename, void*state) 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]; }