mirror of
https://github.com/Z3Prover/z3
synced 2025-04-13 20:38:43 +00:00
parent
78ebe0a94c
commit
57d430b3fd
|
@ -1125,7 +1125,7 @@ br_status seq_rewriter::mk_seq_index(expr* a, expr* b, expr* c, expr_ref& result
|
|||
bool isc2 = m_util.str.is_string(b, s2);
|
||||
|
||||
if (isc1 && isc2 && m_autil.is_numeral(c, r) && r.is_unsigned()) {
|
||||
int idx = s1.indexof(s2, r.get_unsigned());
|
||||
int idx = s1.indexofu(s2, r.get_unsigned());
|
||||
result = m_autil.mk_numeral(rational(idx), true);
|
||||
return BR_DONE;
|
||||
}
|
||||
|
|
|
@ -280,13 +280,13 @@ bool zstring::contains(zstring const& other) const {
|
|||
return cont;
|
||||
}
|
||||
|
||||
int zstring::indexof(zstring const& other, int offset) const {
|
||||
SASSERT(offset >= 0);
|
||||
if (static_cast<unsigned>(offset) <= length() && other.length() == 0) return offset;
|
||||
if (static_cast<unsigned>(offset) == length()) return -1;
|
||||
int zstring::indexofu(zstring const& other, unsigned offset) const {
|
||||
if (offset <= length() && other.length() == 0) return offset;
|
||||
if (offset == length()) return -1;
|
||||
if (offset < other.length() + offset) return -1;
|
||||
if (other.length() + offset > length()) return -1;
|
||||
unsigned last = length() - other.length();
|
||||
for (unsigned i = static_cast<unsigned>(offset); i <= last; ++i) {
|
||||
for (unsigned i = offset; i <= last; ++i) {
|
||||
bool prefix = true;
|
||||
for (unsigned j = 0; prefix && j < other.length(); ++j) {
|
||||
prefix = m_buffer[i + j] == other[j];
|
||||
|
@ -313,10 +313,10 @@ int zstring::last_indexof(zstring const& other) const {
|
|||
return -1;
|
||||
}
|
||||
|
||||
zstring zstring::extract(int offset, int len) const {
|
||||
zstring zstring::extract(unsigned offset, unsigned len) const {
|
||||
zstring result(m_encoding);
|
||||
SASSERT(0 <= offset && 0 <= len);
|
||||
int last = std::min(offset+len, static_cast<int>(length()));
|
||||
if (offset + len < offset) return result;
|
||||
int last = std::min(offset+len, length());
|
||||
for (int i = offset; i < last; ++i) {
|
||||
result.m_buffer.push_back(m_buffer[i]);
|
||||
}
|
||||
|
|
|
@ -119,9 +119,9 @@ public:
|
|||
bool suffixof(zstring const& other) const;
|
||||
bool prefixof(zstring const& other) const;
|
||||
bool contains(zstring const& other) const;
|
||||
int indexof(zstring const& other, int offset) const;
|
||||
int indexofu(zstring const& other, unsigned offset) const;
|
||||
int last_indexof(zstring const& other) const;
|
||||
zstring extract(int lo, int hi) const;
|
||||
zstring extract(unsigned lo, unsigned hi) const;
|
||||
zstring operator+(zstring const& other) const;
|
||||
bool operator==(const zstring& other) const;
|
||||
bool operator!=(const zstring& other) const;
|
||||
|
|
Loading…
Reference in a new issue