If std::string.length() is zero, then back() method's behavior is
undefined.
Change-Id: I5ccededf83b76058e91ebefec6b11ad8ff8f1db6
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
tab_size--;
}
- back = line.back();
+ back = "__INVALID__";
+ if (line.length() > 0)
+ back = line.back();
+
if (back != ":" && line.length() > 0)
tab += Tab(tab_size);
if (back == "," || back == "\\")
continuous = true;
- if (line.empty() ||
- line.length() == 0 ||
- std::all_of(line.begin(), line.end(), isspace)) {
+ if (line.empty() || std::all_of(line.begin(), line.end(), isspace)) {
std::string n_line = Trim(next_line);
if (n_line.empty() ||
n_line.length() == 0 ||
if_statement = true;
}
- back = line.back();
found = line.find("while (");
if (found != std::string::npos && back != ";") {
tab_size++;
tab += Tab(2);
// Checks whether switch case is end or not.
- line_back = line.back();
+ line_back = "__INVALID__";
+ if (line.length() > 0)
+ line_back = line.back();
+
if (!prev_tab_size.empty() && prev_tab_size.top() == (tab_size - 1) &&
line_back == "}") {
prev_tab_size.pop();
tab_size--;
}
- back = line.back();
+ back = "__INVALID__";
+ if (line.length() > 0)
+ back = line.back();
+
if (back != ":" && line.length() > 0)
tab += Tab(tab_size);
if (back == "," || back == "\\")
continuous = true;
- if (line.empty() ||
- line.length() == 0 ||
- std::all_of(line.begin(), line.end(), isspace)) {
+ if (line.empty() || std::all_of(line.begin(), line.end(), isspace)) {
std::string n_line = Trim(next_line);
if (n_line.empty() ||
n_line.length() == 0 ||
if_statement = true;
}
- back = line.back();
found = line.find("while (");
if (found != std::string::npos && back != ";") {
tab_size++;