mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-23 09:05:32 +00:00
substr() -> compare()
This commit is contained in:
parent
71eff6f0de
commit
6d77236f38
31 changed files with 127 additions and 127 deletions
|
@ -200,7 +200,7 @@ void Pass::extra_args(std::vector<std::string> args, size_t argidx, RTLIL::Desig
|
|||
{
|
||||
std::string arg = args[argidx];
|
||||
|
||||
if (arg.substr(0, 1) == "-")
|
||||
if (arg.compare(0, 1, "-") == 0)
|
||||
cmd_error(args, argidx, "Unknown option or option in arguments.");
|
||||
|
||||
if (!select)
|
||||
|
@ -449,7 +449,7 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s
|
|||
{
|
||||
std::string arg = args[argidx];
|
||||
|
||||
if (arg.substr(0, 1) == "-")
|
||||
if (arg.compare(0, 1, "-") == 0)
|
||||
cmd_error(args, argidx, "Unknown option or option in arguments.");
|
||||
if (f != NULL)
|
||||
cmd_error(args, argidx, "Extra filename argument in direct file mode.");
|
||||
|
@ -457,7 +457,7 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s
|
|||
filename = arg;
|
||||
if (filename == "<<" && argidx+1 < args.size())
|
||||
filename += args[++argidx];
|
||||
if (filename.substr(0, 2) == "<<") {
|
||||
if (filename.compare(0, 2, "<<") == 0) {
|
||||
if (Frontend::current_script_file == NULL)
|
||||
log_error("Unexpected here document '%s' outside of script!\n", filename.c_str());
|
||||
if (filename.size() <= 2)
|
||||
|
@ -475,7 +475,7 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s
|
|||
break;
|
||||
}
|
||||
size_t indent = buffer.find_first_not_of(" \t\r\n");
|
||||
if (indent != std::string::npos && buffer.substr(indent, eot_marker.size()) == eot_marker)
|
||||
if (indent != std::string::npos && buffer.compare(indent, eot_marker.size(), eot_marker) == 0)
|
||||
break;
|
||||
last_here_document += buffer;
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s
|
|||
log_cmd_error("Can't open input file `%s' for reading: %s\n", filename.c_str(), strerror(errno));
|
||||
|
||||
for (size_t i = argidx+1; i < args.size(); i++)
|
||||
if (args[i].substr(0, 1) == "-")
|
||||
if (args[i].compare(0, 1, "-") == 0)
|
||||
cmd_error(args, i, "Found option, expected arguments.");
|
||||
|
||||
if (argidx+1 < args.size()) {
|
||||
|
@ -612,7 +612,7 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st
|
|||
{
|
||||
std::string arg = args[argidx];
|
||||
|
||||
if (arg.substr(0, 1) == "-" && arg != "-")
|
||||
if (arg.compare(0, 1, "-") == 0 && arg != "-")
|
||||
cmd_error(args, argidx, "Unknown option or option in arguments.");
|
||||
if (f != NULL)
|
||||
cmd_error(args, argidx, "Extra filename argument in direct file mode.");
|
||||
|
@ -625,7 +625,7 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st
|
|||
|
||||
filename = arg;
|
||||
rewrite_filename(filename);
|
||||
if (filename.size() > 3 && filename.substr(filename.size()-3) == ".gz") {
|
||||
if (filename.size() > 3 && filename.compare(filename.size()-3, std::string::npos, ".gz") == 0) {
|
||||
#ifdef YOSYS_ENABLE_ZLIB
|
||||
gzip_ostream *gf = new gzip_ostream;
|
||||
if (!gf->open(filename)) {
|
||||
|
|
|
@ -647,12 +647,12 @@ std::vector<std::string> glob_filename(const std::string &filename_pattern)
|
|||
|
||||
void rewrite_filename(std::string &filename)
|
||||
{
|
||||
if (filename.substr(0, 1) == "\"" && filename.substr(GetSize(filename)-1) == "\"")
|
||||
if (filename.compare(0, 1, "\"") == 0 && filename.compare(GetSize(filename)-1, std::string::npos, "\"") == 0)
|
||||
filename = filename.substr(1, GetSize(filename)-2);
|
||||
if (filename.substr(0, 2) == "+/")
|
||||
if (filename.compare(0, 2, "+/") == 0)
|
||||
filename = proc_share_dirname() + filename.substr(2);
|
||||
#ifndef _WIN32
|
||||
if (filename.substr(0, 2) == "~/")
|
||||
if (filename.compare(0, 2, "~/") == 0)
|
||||
filename = filename.replace(0, 1, getenv("HOME"));
|
||||
#endif
|
||||
}
|
||||
|
@ -895,25 +895,25 @@ void run_frontend(std::string filename, std::string command, std::string *backen
|
|||
|
||||
if (command == "auto") {
|
||||
std::string filename_trim = filename;
|
||||
if (filename_trim.size() > 3 && filename_trim.substr(filename_trim.size()-3) == ".gz")
|
||||
if (filename_trim.size() > 3 && filename_trim.compare(filename_trim.size()-3, std::string::npos, ".gz") == 0)
|
||||
filename_trim.erase(filename_trim.size()-3);
|
||||
if (filename_trim.size() > 2 && filename_trim.substr(filename_trim.size()-2) == ".v")
|
||||
if (filename_trim.size() > 2 && filename_trim.compare(filename_trim.size()-2, std::string::npos, ".v") == 0)
|
||||
command = "verilog";
|
||||
else if (filename_trim.size() > 2 && filename_trim.substr(filename_trim.size()-3) == ".sv")
|
||||
else if (filename_trim.size() > 2 && filename_trim.compare(filename_trim.size()-3, std::string::npos, ".sv") == 0)
|
||||
command = "verilog -sv";
|
||||
else if (filename_trim.size() > 3 && filename_trim.substr(filename_trim.size()-4) == ".vhd")
|
||||
else if (filename_trim.size() > 3 && filename_trim.compare(filename_trim.size()-4, std::string::npos, ".vhd") == 0)
|
||||
command = "vhdl";
|
||||
else if (filename_trim.size() > 4 && filename_trim.substr(filename_trim.size()-5) == ".blif")
|
||||
else if (filename_trim.size() > 4 && filename_trim.compare(filename_trim.size()-5, std::string::npos, ".blif") == 0)
|
||||
command = "blif";
|
||||
else if (filename_trim.size() > 5 && filename_trim.substr(filename_trim.size()-6) == ".eblif")
|
||||
else if (filename_trim.size() > 5 && filename_trim.compare(filename_trim.size()-6, std::string::npos, ".eblif") == 0)
|
||||
command = "blif";
|
||||
else if (filename_trim.size() > 4 && filename_trim.substr(filename_trim.size()-5) == ".json")
|
||||
else if (filename_trim.size() > 4 && filename_trim.compare(filename_trim.size()-5, std::string::npos, ".json") == 0)
|
||||
command = "json";
|
||||
else if (filename_trim.size() > 3 && filename_trim.substr(filename_trim.size()-3) == ".il")
|
||||
else if (filename_trim.size() > 3 && filename_trim.compare(filename_trim.size()-3, std::string::npos, ".il") == 0)
|
||||
command = "ilang";
|
||||
else if (filename_trim.size() > 3 && filename_trim.substr(filename_trim.size()-3) == ".ys")
|
||||
else if (filename_trim.size() > 3 && filename_trim.compare(filename_trim.size()-3, std::string::npos, ".ys") == 0)
|
||||
command = "script";
|
||||
else if (filename_trim.size() > 3 && filename_trim.substr(filename_trim.size()-4) == ".tcl")
|
||||
else if (filename_trim.size() > 3 && filename_trim.compare(filename_trim.size()-4, std::string::npos, ".tcl") == 0)
|
||||
command = "tcl";
|
||||
else if (filename == "-")
|
||||
command = "script";
|
||||
|
@ -1028,17 +1028,17 @@ void run_backend(std::string filename, std::string command, RTLIL::Design *desig
|
|||
design = yosys_design;
|
||||
|
||||
if (command == "auto") {
|
||||
if (filename.size() > 2 && filename.substr(filename.size()-2) == ".v")
|
||||
if (filename.size() > 2 && filename.compare(filename.size()-2, std::string::npos, ".v") == 0)
|
||||
command = "verilog";
|
||||
else if (filename.size() > 3 && filename.substr(filename.size()-3) == ".il")
|
||||
else if (filename.size() > 3 && filename.compare(filename.size()-3, std::string::npos, ".il") == 0)
|
||||
command = "ilang";
|
||||
else if (filename.size() > 4 && filename.substr(filename.size()-4) == ".aig")
|
||||
else if (filename.size() > 4 && filename.compare(filename.size()-4, std::string::npos, ".aig") == 0)
|
||||
command = "aiger";
|
||||
else if (filename.size() > 5 && filename.substr(filename.size()-5) == ".blif")
|
||||
else if (filename.size() > 5 && filename.compare(filename.size()-5, std::string::npos, ".blif") == 0)
|
||||
command = "blif";
|
||||
else if (filename.size() > 5 && filename.substr(filename.size()-5) == ".edif")
|
||||
else if (filename.size() > 5 && filename.compare(filename.size()-5, std::string::npos, ".edif") == 0)
|
||||
command = "edif";
|
||||
else if (filename.size() > 5 && filename.substr(filename.size()-5) == ".json")
|
||||
else if (filename.size() > 5 && filename.compare(filename.size()-5, std::string::npos, ".json") == 0)
|
||||
command = "json";
|
||||
else if (filename == "-")
|
||||
command = "ilang";
|
||||
|
@ -1072,7 +1072,7 @@ static char *readline_cmd_generator(const char *text, int state)
|
|||
}
|
||||
|
||||
for (; it != pass_register.end(); it++) {
|
||||
if (it->first.substr(0, len) == text)
|
||||
if (it->first.compare(0, len, text) == 0)
|
||||
return strdup((it++)->first.c_str());
|
||||
}
|
||||
return NULL;
|
||||
|
@ -1094,7 +1094,7 @@ static char *readline_obj_generator(const char *text, int state)
|
|||
if (design->selected_active_module.empty())
|
||||
{
|
||||
for (auto &it : design->modules_)
|
||||
if (RTLIL::unescape_id(it.first).substr(0, len) == text)
|
||||
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(RTLIL::id2cstr(it.first)));
|
||||
}
|
||||
else
|
||||
|
@ -1103,19 +1103,19 @@ static char *readline_obj_generator(const char *text, int state)
|
|||
RTLIL::Module *module = design->modules_.at(design->selected_active_module);
|
||||
|
||||
for (auto &it : module->wires_)
|
||||
if (RTLIL::unescape_id(it.first).substr(0, len) == text)
|
||||
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(RTLIL::id2cstr(it.first)));
|
||||
|
||||
for (auto &it : module->memories)
|
||||
if (RTLIL::unescape_id(it.first).substr(0, len) == text)
|
||||
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(RTLIL::id2cstr(it.first)));
|
||||
|
||||
for (auto &it : module->cells_)
|
||||
if (RTLIL::unescape_id(it.first).substr(0, len) == text)
|
||||
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(RTLIL::id2cstr(it.first)));
|
||||
|
||||
for (auto &it : module->processes)
|
||||
if (RTLIL::unescape_id(it.first).substr(0, len) == text)
|
||||
if (RTLIL::unescape_id(it.first).compare(0, len, text) == 0)
|
||||
obj_names.push_back(strdup(RTLIL::id2cstr(it.first)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue