Skip to content

Commit 66c529c

Browse files
Tidied up java_class_loader_limitt
1 parent 5cbb758 commit 66c529c

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/java_bytecode/java_class_loader_limit.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ void java_class_loader_limitt::setup_class_load_limit(
2222
throw "class regexp cannot be empty, `get_language_options` not called?";
2323

2424
// '@' signals file reading with list of class files to load
25-
regex_match=java_cp_include_files[0]!='@';
26-
if(regex_match)
25+
use_regex_match = java_cp_include_files[0] != '@';
26+
if(use_regex_match)
2727
regex_matcher=std::regex(java_cp_include_files);
2828
else
2929
{
@@ -49,16 +49,14 @@ void java_class_loader_limitt::setup_class_load_limit(
4949

5050
/// \par parameters: class file name
5151
/// \return true if file should be loaded, else false
52-
bool java_class_loader_limitt::load_class_file(const irep_idt &file_name)
52+
bool java_class_loader_limitt::load_class_file(const std::string &file_name)
5353
{
54-
if(regex_match)
54+
if(use_regex_match)
5555
{
56-
return std::regex_match(
57-
id2string(file_name),
58-
string_matcher,
59-
regex_matcher);
56+
std::smatch string_matches;
57+
return std::regex_match(file_name, string_matches, regex_matcher);
6058
}
61-
// load .class file only if it is in the match set
6259
else
63-
return set_matcher.find(id2string(file_name))!=set_matcher.end();
60+
// load .class file only if it is in the match set
61+
return set_matcher.find(file_name) != set_matcher.end();
6462
}

src/java_bytecode/java_class_loader_limit.h

+6-7
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,23 @@ Author: Daniel Kroening, [email protected]
2020

2121
class java_class_loader_limitt:public messaget
2222
{
23+
/// Whether to use regex_matcher instead of set_matcher
24+
bool use_regex_match;
2325
std::regex regex_matcher;
2426
std::set<std::string> set_matcher;
25-
bool regex_match;
26-
std::smatch string_matcher;
2727

2828
void setup_class_load_limit(const std::string &);
2929

3030
public:
3131
explicit java_class_loader_limitt(
32-
message_handlert &_message_handler,
33-
const std::string &java_cp_include_files):
34-
messaget(_message_handler),
35-
regex_match(false)
32+
message_handlert &message_handler,
33+
const std::string &java_cp_include_files)
34+
: messaget(message_handler)
3635
{
3736
setup_class_load_limit(java_cp_include_files);
3837
}
3938

40-
bool load_class_file(const irep_idt &class_file_name);
39+
bool load_class_file(const std::string &class_file_name);
4140
};
4241

4342
#endif

0 commit comments

Comments
 (0)