Skip to content

Commit

Permalink
fix #6600
Browse files Browse the repository at this point in the history
ensure that semantics of last-indexof(t,"") = len(t)
  • Loading branch information
NikolajBjorner committed Feb 19, 2023
1 parent 0758c93 commit 755b517
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ast/rewriter/seq_axioms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,8 @@ namespace seq {
!contains(t, s) => i = -1
|t| = 0 => |s| = 0 or i = -1
|t| = 0 & |s| = 0 => i = 0
|t| != 0 & contains(t, s) => t = xsy & i = len(x)
|s| = 0 => i = len(t)
|s| = 0 or s = s_head*s_tail
|s| = 0 or !contains(s_tail*y, s)
Expand All @@ -540,7 +540,7 @@ namespace seq {

add_clause(cnt, i_eq_m1);
add_clause(~t_eq_empty, s_eq_empty, i_eq_m1);
add_clause(~t_eq_empty, ~s_eq_empty, i_eq_0);
add_clause(~s_eq_empty, mk_eq(i, mk_len(t)));
add_clause(t_eq_empty, ~cnt, mk_seq_eq(t, xsy));
add_clause(t_eq_empty, ~cnt, mk_eq(i, mk_len(x)));
add_clause(s_eq_empty, mk_eq(s, mk_concat(s_head, s_tail)));
Expand Down
3 changes: 1 addition & 2 deletions src/util/zstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ int zstring::indexofu(zstring const& other, unsigned offset) const {
}

int zstring::last_indexof(zstring const& other) const {
if (length() == 0 && other.length() == 0) return 0;
if (other.length() == 0) return -1;
if (other.length() == 0) return length();
if (other.length() > length()) return -1;
for (unsigned last = length() - other.length() + 1; last-- > 0; ) {
bool suffix = true;
Expand Down

0 comments on commit 755b517

Please sign in to comment.