This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RFC - Gold Patch] Implement INCLUDE directive
Sterling Augustine <saugustine@google.com> writes:
> 011-11-16 Sterling Augustine <saugustine@google.com>
>
> * script.cc (script_include_directive): Implement.
> (read_script_file): New local variables name and search_path. Update
> comment. Call IS_ABSOLUTE_PATH and Dirsearch::find_file_in_dir_list.
> * dirsearch.h (Dirsearch::find_file_in_dir_list): Declare new method.
> * dirsearch.cc (Dirsearch::find_file_in_dir_list): Implement it.
> +std::string
> +Dirsearch::find_file_in_dir_list(const std::string& name,
> + const General_options::Dir_list& directories,
> + const char* extra_search_dir)
> +{
> + struct stat buf;
> + std::string extra_name = std::string(extra_search_dir) + "/" + name;
s|"/"|'/'|
> + for (unsigned int i = 0; i < directories.size(); ++i)
> + {
> + const Search_directory* p = &directories.at(i);
> + std::string full_name = p->name() + "/" + name;
s|"/"|'/'|
> + if (stat(full_name.c_str(), &buf) == 0)
> + return full_name;
> + }
Write the loop using an iterator, as in Dirsearch::initialize.
> static bool
> read_script_file(const char* filename, Command_line* cmdline,
> Script_options* script_options,
> int first_token, Lex::Mode lex_mode)
> {
> - // TODO: if filename is a relative filename, search for it manually
> - // using "." + cmdline->options()->search_path() -- not dirsearch.
> Dirsearch dirsearch;
> + std::string name = std::string(filename);
Just write
std::string name = filename;
> +
> + // If filename is a relative filename, search for it manually using "." +
> + // cmdline->options()->library_path() -- not dirsearch.
> + if (!IS_ABSOLUTE_PATH(filename))
> + {
> + const General_options::Dir_list& search_path
> + = cmdline->options().library_path();
Put the '=' at the end of the preceding line.
This is OK with those changes.
Thanks.
Ian