Skip to content

Commit 43e9849

Browse files
fixup! Add builtin class for string_to_upper_case
1 parent b4d4198 commit 43e9849

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/solvers/refinement/string_builtin_function.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ exprt string_set_char_builtin_functiont::length_constraint() const
187187
equal_exprt(return_code, return_value));
188188
}
189189

190+
static bool eval_is_upper_case(const mp_integer &c)
191+
{
192+
return ('A' <= c && c <= 'Z') || (0xc0 <= c && c <= 0xd6) ||
193+
(0xd8 <= c && c <= 0xde);
194+
}
195+
190196
optionalt<exprt> string_to_lower_case_builtin_functiont::eval(
191197
const std::function<exprt(const exprt &)> &get_value) const
192198
{
@@ -195,9 +201,7 @@ optionalt<exprt> string_to_lower_case_builtin_functiont::eval(
195201
return {};
196202
for(mp_integer &c : input_opt.value())
197203
{
198-
if(
199-
('A' <= c && c <= 'Z') || (0xc0 <= c && c <= 0xd6) ||
200-
(0xd8 <= c && c <= 0xde))
204+
if(eval_is_upper_case(c))
201205
c += 0x20;
202206
}
203207
const auto length =
@@ -214,7 +218,7 @@ optionalt<exprt> string_to_upper_case_builtin_functiont::eval(
214218
return {};
215219
for(mp_integer &c : input_opt.value())
216220
{
217-
if('a' <= c && c <= 'z')
221+
if(eval_is_upper_case(c - 0x20))
218222
c -= 0x20;
219223
}
220224
const auto length =

0 commit comments

Comments
 (0)