mirror of
https://github.com/Z3Prover/z3
synced 2025-06-20 21:03:39 +00:00
fix for #975, add mask to ensure character encoding is unique within range of bits used for encoding
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
7bb5e72e07
commit
48638c6f1e
2 changed files with 6 additions and 2 deletions
|
@ -1435,6 +1435,7 @@ bool seq_rewriter::reduce_eq(expr_ref_vector& ls, expr_ref_vector& rs, expr_ref_
|
||||||
zstring s;
|
zstring s;
|
||||||
bool lchange = false;
|
bool lchange = false;
|
||||||
SASSERT(lhs.empty());
|
SASSERT(lhs.empty());
|
||||||
|
TRACE("seq", tout << ls << "\n"; tout << rs << "\n";);
|
||||||
// solve from back
|
// solve from back
|
||||||
while (true) {
|
while (true) {
|
||||||
while (!rs.empty() && m_util.str.is_empty(rs.back())) {
|
while (!rs.empty() && m_util.str.is_empty(rs.back())) {
|
||||||
|
@ -1552,9 +1553,11 @@ bool seq_rewriter::reduce_eq(expr_ref_vector& ls, expr_ref_vector& rs, expr_ref_
|
||||||
head2 < rs.size() &&
|
head2 < rs.size() &&
|
||||||
m_util.str.is_string(ls[head1].get(), s1) &&
|
m_util.str.is_string(ls[head1].get(), s1) &&
|
||||||
m_util.str.is_string(rs[head2].get(), s2)) {
|
m_util.str.is_string(rs[head2].get(), s2)) {
|
||||||
|
TRACE("seq", tout << s1 << " - " << s2 << " " << s1.length() << " " << s2.length() << "\n";);
|
||||||
unsigned l = std::min(s1.length(), s2.length());
|
unsigned l = std::min(s1.length(), s2.length());
|
||||||
for (unsigned i = 0; i < l; ++i) {
|
for (unsigned i = 0; i < l; ++i) {
|
||||||
if (s1[i] != s2[i]) {
|
if (s1[i] != s2[i]) {
|
||||||
|
TRACE("seq", tout << "different at position " << i << " " << s1[i] << " " << s2[i] << "\n";);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,13 +126,14 @@ static bool is_escape_char(char const *& s, unsigned& result) {
|
||||||
zstring::zstring(encoding enc): m_encoding(enc) {}
|
zstring::zstring(encoding enc): m_encoding(enc) {}
|
||||||
|
|
||||||
zstring::zstring(char const* s, encoding enc): m_encoding(enc) {
|
zstring::zstring(char const* s, encoding enc): m_encoding(enc) {
|
||||||
|
unsigned mask = 0xFF; // TBD for UTF
|
||||||
while (*s) {
|
while (*s) {
|
||||||
unsigned ch;
|
unsigned ch;
|
||||||
if (is_escape_char(s, ch)) {
|
if (is_escape_char(s, ch)) {
|
||||||
m_buffer.push_back(ch);
|
m_buffer.push_back(ch & mask);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_buffer.push_back(*s);
|
m_buffer.push_back(*s & mask);
|
||||||
++s;
|
++s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue