mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-24 17:45:33 +00:00
reduce OS ifdefs, refactor getting dirs and filenames from paths to files
This commit is contained in:
parent
f20f913223
commit
1759609321
5 changed files with 24 additions and 26 deletions
|
@ -4440,12 +4440,7 @@ AstNode *AstNode::readmem(bool is_readmemh, std::string mem_filename, AstNode *m
|
|||
std::ifstream f;
|
||||
f.open(mem_filename.c_str());
|
||||
if (f.fail()) {
|
||||
#ifdef _WIN32
|
||||
char slash = '\\';
|
||||
#else
|
||||
char slash = '/';
|
||||
#endif
|
||||
std::string path = filename.substr(0, filename.find_last_of(slash)+1);
|
||||
std::string path = parent_from_file_path(filename);
|
||||
f.open(path + mem_filename.c_str());
|
||||
yosys_input_files.insert(path + mem_filename);
|
||||
} else {
|
||||
|
|
|
@ -892,11 +892,7 @@ frontend_verilog_preproc(std::istream &f,
|
|||
// if the include file was not found, it is not given with an absolute path, and the
|
||||
// currently read file is given with a path, then try again relative to its directory
|
||||
ff.clear();
|
||||
#ifdef _WIN32
|
||||
fixed_fn = filename.substr(0, filename.find_last_of("/\\")+1) + fn;
|
||||
#else
|
||||
fixed_fn = filename.substr(0, filename.rfind('/')+1) + fn;
|
||||
#endif
|
||||
fixed_fn = parent_from_file_path(filename) + fn;
|
||||
ff.open(fixed_fn);
|
||||
}
|
||||
if (ff.fail() && fn.size() > 0 && fn_relative) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue