Skip to content

Commit a5a21ea

Browse files
bjh7242zimmerle
authored andcommitted
added remove_comments_char to address issue #971
1 parent 8da4984 commit a5a21ea

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/actions/transformations/remove_comments_char.cc

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,28 @@ RemoveCommentsChar::RemoveCommentsChar(std::string action)
3737

3838
std::string RemoveCommentsChar::evaluate(std::string value,
3939
Transaction *transaction) {
40-
/**
41-
* @todo Implement the transformation RemoveCommentsChar
42-
*/
43-
if (transaction) {
44-
#ifndef NO_LOGS
45-
transaction->debug(4, "Transformation RemoveCommentsChar " \
46-
"is not implemented yet.");
47-
#endif
40+
int64_t i;
41+
42+
i = 0;
43+
while (i < value.size()) {
44+
if (value.at(i) == '/' && (i+1 < value.size()) && value.at(i+1) == '*') {
45+
value.erase(i, 2);
46+
} else if (value.at(i) == '*' && (i+1 < value.size()) && value.at(i+1) == '/') {
47+
value.erase(i, 2);
48+
} else if (value.at(i) == '<' && (i+1 < value.size()) && value.at(i+1) == '!' &&
49+
(i+2 < value.size()) && value.at(i+2) == '-' && (i+3 < value.size()) &&
50+
value.at(i+3) == '-') {
51+
value.erase(i, 4);
52+
} else if (value.at(i) == '-' && (i+1 < value.size()) && value.at(i+1) == '-' &&
53+
(i+2 < value.size()) && value.at(i+2) == '>') {
54+
value.erase(i, 3);
55+
} else if (value.at(i) == '-' && (i+1 < value.size()) && value.at(i+1) == '-') {
56+
value.erase(i, 2);
57+
} else if (value.at(i) == '#') {
58+
value.erase(i, 1);
59+
} else {
60+
i++;
61+
}
4862
}
4963
return value;
5064
}

0 commit comments

Comments
 (0)