Skip to content

Commit ef3c598

Browse files
Merge pull request diffblue#1775 from diffblue/refactor/set_classpath
Use string_split in set_classpath
2 parents 45dd840 + 80b972b commit ef3c598

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

src/util/config.cpp

+13-25
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Author: Daniel Kroening, [email protected]
1818
#include "std_expr.h"
1919
#include "cprover_prefix.h"
2020
#include "string2int.h"
21+
#include "string_utils.h"
2122

2223
configt config;
2324

@@ -1286,31 +1287,18 @@ irep_idt configt::this_architecture()
12861287

12871288
void configt::set_classpath(const std::string &cp)
12881289
{
1289-
std::string current;
1290-
for(std::size_t pos=0; pos<cp.size(); pos++)
1291-
{
1292-
// These are separated by colons on Unix, and semicolons on
1293-
// Windows.
1294-
#ifdef _WIN32
1295-
const char cp_separator=';';
1296-
#else
1297-
const char cp_separator=':';
1298-
#endif
1299-
1300-
if(cp[pos]==cp_separator)
1301-
{
1302-
if(!current.empty())
1303-
{
1304-
java.classpath.push_back(current);
1305-
current.clear();
1306-
}
1307-
}
1308-
else
1309-
current+=cp[pos];
1310-
}
1311-
1312-
if(!current.empty())
1313-
java.classpath.push_back(current);
1290+
// These are separated by colons on Unix, and semicolons on
1291+
// Windows.
1292+
#ifdef _WIN32
1293+
const char cp_separator = ';';
1294+
#else
1295+
const char cp_separator = ':';
1296+
#endif
1297+
1298+
std::vector<std::string> class_path;
1299+
split_string(cp, cp_separator, class_path);
1300+
java.classpath.insert(
1301+
java.classpath.end(), class_path.begin(), class_path.end());
13141302
}
13151303

13161304
irep_idt configt::this_operating_system()

0 commit comments

Comments
 (0)