mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Refactor search_for_file() util function.
It was getting too bloated and allocated memory in ways that were difficult to understand how to manage. Separated out primarily in to new find_file() and open_file()/open_package() functions. Also renamed other util functions for path-related things.
This commit is contained in:
parent
68227f112d
commit
90477df973
9 changed files with 331 additions and 304 deletions
10
src/Debug.cc
10
src/Debug.cc
|
@ -342,18 +342,16 @@ vector<ParseLocationRec> parse_location_string(const string& s)
|
|||
if ( ! sscanf(line_string.c_str(), "%d", &plr.line) )
|
||||
plr.type = plrUnknown;
|
||||
|
||||
FILE* throwaway = search_for_file(filename.c_str(), "bro",
|
||||
&full_filename, true, 0);
|
||||
if ( ! throwaway )
|
||||
string path(find_file(filename, bro_path(), "bro"));
|
||||
|
||||
if ( path.empty() )
|
||||
{
|
||||
debug_msg("No such policy file: %s.\n", filename.c_str());
|
||||
plr.type = plrUnknown;
|
||||
return result;
|
||||
}
|
||||
|
||||
fclose(throwaway);
|
||||
|
||||
loc_filename = full_filename;
|
||||
loc_filename = copy_string(path.c_str());
|
||||
plr.type = plrFileAndLine;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue