Skip to content

Commit 5e7178c

Browse files
committed
add some standard conformance improvements
1 parent 5af1376 commit 5e7178c

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

code/bbcode/ListBBCode.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ bool ListBBCode::actualApply(std::string& text, const std::string::size_type off
4141
if (end_pos==std::string::npos) return false;
4242
std::string::size_type item_pos = find_ci(text, item_code, pos+1);
4343
//no [*] within opening and closing tag means error
44-
if ((item_pos==std::string::npos) or (item_pos>end_pos)) return false;
44+
if ((item_pos == std::string::npos) || (item_pos > end_pos))
45+
{
46+
return false;
47+
}
4548
std::string::size_type inner_pos = find_ci(text, code, pos+1);
46-
while ((inner_pos!=std::string::npos) and (inner_pos<end_pos))
49+
while ((inner_pos != std::string::npos) && (inner_pos < end_pos))
4750
{
4851
//malformed code, if next list starts before first list item
4952
if (inner_pos<item_pos) return false;
@@ -54,7 +57,7 @@ bool ListBBCode::actualApply(std::string& text, const std::string::size_type off
5457
inner_pos = find_ci(text, code, pos+1);
5558
end_pos = find_ci(text, end_code, pos+1);
5659
//If there are no more end tags or item "tags" left, the code is invalid.
57-
if ((item_pos==std::string::npos) or (end_pos==std::string::npos))
60+
if ((item_pos == std::string::npos) || (end_pos == std::string::npos))
5861
return false;
5962
}//inner while
6063

@@ -64,7 +67,7 @@ bool ListBBCode::actualApply(std::string& text, const std::string::size_type off
6467
++end_pos;
6568
item_pos = find_ci(text, item_code, item_pos+3);
6669
//replace all remaining "[*]" of that list
67-
while ((item_pos!=std::string::npos) and (item_pos<end_pos))
70+
while ((item_pos != std::string::npos) && (item_pos < end_pos))
6871
{
6972
text.replace(item_pos, 3, "</li><li>");
7073
end_pos += 6;

code/bbcode/TableBBCode.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ std::string TableBBCode::attributesToString(const TableElementType eleType,
230230
std::string result;
231231
std::map<std::string, std::string>::const_iterator iter = attrs.begin();
232232
bool got_grid = false;
233-
while (iter!=attrs.end())
233+
while (iter != attrs.end())
234234
{
235-
if ((iter->first=="class") and (iter->second=="grid"))
235+
if ((iter->first == "class") && (iter->second == "grid"))
236236
{
237237
appendGridAttributes(result, eleType);
238238
got_grid = true;
@@ -257,7 +257,7 @@ std::string TableBBCode::attributesToString(const TableElementType eleType,
257257
else if (iter->first=="align")
258258
{
259259
//align
260-
if ((iter->second=="left") or (iter->second=="right") or (iter->second=="center"))
260+
if ((iter->second == "left") || (iter->second == "right") || (iter->second == "center"))
261261
{
262262
result += " align=\""+iter->second+"\"";
263263
}
@@ -271,13 +271,13 @@ std::string TableBBCode::attributesToString(const TableElementType eleType,
271271
if (!got_grid)
272272
{
273273
iter = parent_attrs.find("class");
274-
if ((iter!=parent_attrs.end()) and (iter->second == "grid"))
274+
if ((iter != parent_attrs.end()) && (iter->second == "grid"))
275275
{
276276
appendGridAttributes(result, eleType);
277277
got_grid = true;
278278
}
279279
iter = grandparent_attrs.find("class");
280-
if (!got_grid and (iter!=grandparent_attrs.end()) and (iter->second == "grid"))
280+
if (!got_grid && (iter != grandparent_attrs.end()) && (iter->second == "grid"))
281281
{
282282
appendGridAttributes(result, eleType);
283283
}

0 commit comments

Comments
 (0)