Skip to content

Commit e8c2360

Browse files
fix #7461
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
1 parent 8f5658b commit e8c2360

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

src/ast/sls/sls_seq_plugin.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -697,18 +697,18 @@ namespace sls {
697697
u[i][j] = d[i - 1][j - 1];
698698
}
699699
if (d[i - 1][j] == u[i][j] && !a_is_value[i - 1]) {
700-
add_string_update(side::left, op::del, i - 1, 0);
701-
add_string_update(side::left, op::add, j - 1, i - 1);
700+
add_string_update(side_t::left, op_t::del, i - 1, 0);
701+
add_string_update(side_t::left, op_t::add, j - 1, i - 1);
702702
}
703703
if (d[i][j - 1] == u[i][j] && !b_is_value[j - 1]) {
704-
add_string_update(side::right, op::del, j - 1, 0);
705-
add_string_update(side::right, op::add, i - 1, j - 1);
704+
add_string_update(side_t::right, op_t::del, j - 1, 0);
705+
add_string_update(side_t::right, op_t::add, i - 1, j - 1);
706706
}
707707
if (d[i - 1][j - 1] == u[i][j] && !a_is_value[i - 1])
708-
add_string_update(side::left, op::copy, j - 1, i - 1);
708+
add_string_update(side_t::left, op_t::copy, j - 1, i - 1);
709709

710710
if (d[i - 1][j - 1] == u[i][j] && !b_is_value[j - 1])
711-
add_string_update(side::right, op::copy, i - 1, j - 1);
711+
add_string_update(side_t::right, op_t::copy, i - 1, j - 1);
712712

713713
}
714714
}
@@ -833,20 +833,20 @@ namespace sls {
833833
#if 1
834834
for (auto const& [side, op, i, j] : m_string_updates) {
835835
switch (op) {
836-
case op::del:
837-
if (side == side::left)
836+
case op_t::del:
837+
if (side == side_t::left)
838838
verbose_stream() << "del " << a[i] << " @ " << i << " left\n";
839839
else
840840
verbose_stream() << "del " << b[i] << " @ " << i << " right\n";
841841
break;
842-
case op::add:
843-
if (side == side::left)
842+
case op_t::add:
843+
if (side == side_t::left)
844844
verbose_stream() << "add " << b[i] << " @ " << j << " left\n";
845845
else
846846
verbose_stream() << "add " << a[i] << " @ " << j << " right\n";
847847
break;
848-
case op::copy:
849-
if (side == side::left)
848+
case op_t::copy:
849+
if (side == side_t::left)
850850
verbose_stream() << "copy " << b[i] << " @ " << j << " left\n";
851851
else
852852
verbose_stream() << "copy " << a[i] << " @ " << j << " right\n";
@@ -855,7 +855,7 @@ namespace sls {
855855
}
856856
#endif
857857
for (auto& [side, op, i, j] : m_string_updates) {
858-
if (op == op::del && side == side::left) {
858+
if (op == op_t::del && side == side_t::left) {
859859
for (auto x : L) {
860860

861861
auto const& value = strval0(x);
@@ -868,7 +868,7 @@ namespace sls {
868868
}
869869
}
870870
}
871-
else if (op == op::del && side == side::right) {
871+
else if (op == op_t::del && side == side_t::right) {
872872
for (auto x : R) {
873873
auto const& value = strval0(x);
874874
if (i >= value.length())
@@ -880,7 +880,7 @@ namespace sls {
880880
}
881881
}
882882
}
883-
else if (op == op::add && side == side::left) {
883+
else if (op == op_t::add && side == side_t::left) {
884884
for (auto x : L) {
885885
auto const& value = strval0(x);
886886
//verbose_stream() << "add " << j << " " << value << " " << value.length() << " " << is_value(x) << "\n";
@@ -894,7 +894,7 @@ namespace sls {
894894
break;
895895
}
896896
}
897-
else if (op == op::add && side == side::right) {
897+
else if (op == op_t::add && side == side_t::right) {
898898
for (auto x : R) {
899899
auto const& value = strval0(x);
900900
//verbose_stream() << "add " << j << " " << value << " " << value.length() << " " << is_value(x) << "\n";
@@ -908,7 +908,7 @@ namespace sls {
908908
break;
909909
}
910910
}
911-
else if (op == op::copy && side == side::left) {
911+
else if (op == op_t::copy && side == side_t::left) {
912912
for (auto x : L) {
913913
auto const& value = strval0(x);
914914
if (j >= value.length())
@@ -920,7 +920,7 @@ namespace sls {
920920
}
921921
}
922922
}
923-
else if (op == op::copy && side == side::right) {
923+
else if (op == op_t::copy && side == side_t::right) {
924924
for (auto x : R) {
925925
auto const& value = strval0(x);
926926
if (j >= value.length())

src/ast/sls/sls_seq_plugin.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,19 @@ namespace sls {
9292
void repair_up_str_itos(app* e);
9393
void repair_up_str_stoi(app* e);
9494

95-
enum op {
95+
enum op_t {
9696
add, del, copy
9797
};
98-
enum side {
98+
enum side_t {
9999
left, right
100100
};
101101
struct string_update {
102-
side side;
103-
op op;
102+
side_t side;
103+
op_t op;
104104
unsigned i, j;
105105
};
106106
svector<string_update> m_string_updates;
107-
void add_string_update(side side, op op, unsigned i, unsigned j) { m_string_updates.push_back({ side, op, i, j }); }
107+
void add_string_update(side_t side, op_t op, unsigned i, unsigned j) { m_string_updates.push_back({ side, op, i, j }); }
108108
unsigned edit_distance_with_updates(zstring const& a, bool_vector const& a_is_value, zstring const& b, bool_vector const& b_is_value);
109109
unsigned edit_distance(zstring const& a, zstring const& b);
110110
void add_edit_updates(ptr_vector<expr> const& w, zstring const& val, zstring const& val_other, uint_set const& chars);

src/shell/main.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ void display_usage() {
123123
std::cout << " module_name.param_name=value for setting module parameters.\n";
124124
std::cout << "Use 'z3 -p' for the complete list of global and module parameters.\n";
125125
}
126+
127+
static bool validate_is_ulong(char const* s) {
128+
for (; *s; ++s)
129+
if (*s < '0' || *s > '9')
130+
return false;
131+
return true;
132+
}
126133

127134
static void parse_cmd_line_args(std::string& input_file, int argc, char ** argv) {
128135
long timeout = 0;
@@ -220,6 +227,8 @@ static void parse_cmd_line_args(std::string& input_file, int argc, char ** argv)
220227
else if (strcmp(opt_name, "v") == 0) {
221228
if (!opt_arg)
222229
error("option argument (-v:level) is missing.");
230+
if (!validate_is_ulong(opt_arg))
231+
error("invalid argument for -v option, it must be a non-negative integer.");
223232
long lvl = strtol(opt_arg, nullptr, 10);
224233
set_verbosity_level(lvl);
225234
}
@@ -229,6 +238,8 @@ static void parse_cmd_line_args(std::string& input_file, int argc, char ** argv)
229238
else if (strcmp(opt_name, "T") == 0) {
230239
if (!opt_arg)
231240
error("option argument (-T:timeout) is missing.");
241+
if (!validate_is_ulong(opt_arg))
242+
error("invalid argument for -T option, it must be a non-negative integer.");
232243
timeout = strtol(opt_arg, nullptr, 10);
233244
}
234245
else if (strcmp(opt_name, "t") == 0) {

0 commit comments

Comments
 (0)