From: Eddie Hung Date: Tue, 26 Feb 2019 20:04:16 +0000 (-0800) Subject: Add IdString::ends_with() X-Git-Tag: working-ls180~1237^2~254 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3ea0161ae7f6111cb435c839eff694476a6527ab;p=yosys.git Add IdString::ends_with() --- diff --git a/kernel/rtlil.h b/kernel/rtlil.h index f877622aa..eb71fec7b 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -222,6 +222,12 @@ namespace RTLIL return std::string(c_str() + pos, len); } + bool ends_with(const char* suffix) const { + size_t len = strlen(suffix); + if (size() < len) return false; + return substr(size()-len) == suffix; + } + size_t size() const { return str().size(); }