3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-05 23:05:46 +00:00

return non-escaped string value for Python #3080

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-02-26 09:16:23 -08:00
parent dddd740846
commit f0689546f3
5 changed files with 16 additions and 8 deletions

View file

@ -150,7 +150,7 @@ extern "C" {
Z3_CATCH_RETURN("");
}
Z3_string Z3_API Z3_get_lstring(Z3_context c, Z3_ast s, unsigned* length) {
Z3_char_ptr Z3_API Z3_get_lstring(Z3_context c, Z3_ast s, unsigned* length) {
Z3_TRY;
LOG_Z3_get_lstring(c, s, length);
RESET_ERROR_CODE();
@ -163,9 +163,12 @@ extern "C" {
SET_ERROR_CODE(Z3_INVALID_ARG, "expression is not a string literal");
return "";
}
std::string s = str.as_string();
*length = (unsigned)(s.size());
return mk_c(c)->mk_external_string(s.c_str(), *length);
mk_c(c)->m_char_buffer.reset();
for (unsigned i = 0; i < str.length(); ++i) {
mk_c(c)->m_char_buffer.push_back((char)str[i]);
}
*length = str.length();
return mk_c(c)->m_char_buffer.c_ptr();
Z3_CATCH_RETURN("");
}