Skip to content

Commit

Permalink
removing unused function with insecure buffer operations eclipse-sumo#12
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Sep 28, 2022
1 parent 00db199 commit 93e63d0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 35 deletions.
20 changes: 0 additions & 20 deletions src/utils/common/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,26 +205,6 @@ StringUtils::substituteEnvironment(const std::string& str, const std::chrono::ti
}


std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}


bool
StringUtils::startsWith(const std::string& str, const std::string prefix) {
return str.compare(0, prefix.length(), prefix) == 0;
Expand Down
3 changes: 0 additions & 3 deletions src/utils/common/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ class StringUtils {
syntax for a variable is ${NAME} */
static std::string substituteEnvironment(const std::string& str, const std::chrono::time_point<std::chrono::system_clock>* const timeRef = nullptr);

/// Builds a time string (hh:mm:ss) from the given seconds
static std::string toTimeString(int time);

/// Checks whether a given string starts with the prefix
static bool startsWith(const std::string& str, const std::string prefix);

Expand Down
12 changes: 0 additions & 12 deletions unittest/src/utils/common/StringUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,6 @@ TEST(StringUtils, test_method_replace_empty_third_argument) {
EXPECT_EQ("test", StringUtils::replace("ltestl", "l", ""));
}


/* Tests the method toTimeString. */
TEST(StringUtils, test_method_toTimeString) {
EXPECT_EQ("-00:00:01", StringUtils::toTimeString(-1));
EXPECT_EQ("00:00:00", StringUtils::toTimeString(0));
EXPECT_EQ("00:00:00", StringUtils::toTimeString(-0));
EXPECT_EQ("01:00:00", StringUtils::toTimeString(3600));
EXPECT_EQ("00:00:01", StringUtils::toTimeString(1));
EXPECT_EQ("49:40:00", StringUtils::toTimeString(178800));
EXPECT_EQ("30883:00:01", StringUtils::toTimeString(111178801));
}

/* Tests the method escapeXML. */
TEST(StringUtils, test_method_escapeXML) {
std::string str;
Expand Down

0 comments on commit 93e63d0

Please sign in to comment.