Commit 9dae3eac authored by Bastien Brunnenstein's avatar Bastien Brunnenstein Committed by Wouter van Oortmerssen

Fix error in ConCatPathFileName (#4575)

parent 99a8a68a
...@@ -38,6 +38,10 @@ namespace flatbuffers { ...@@ -38,6 +38,10 @@ namespace flatbuffers {
// Retrieve ::back() from a string in a way that is compatible with pre C++11 // Retrieve ::back() from a string in a way that is compatible with pre C++11
// STLs (e.g stlport). // STLs (e.g stlport).
inline char& string_back(std::string &value) {
return value[value.length() - 1];
}
inline char string_back(const std::string &value) { inline char string_back(const std::string &value) {
return value[value.length() - 1]; return value[value.length() - 1];
} }
......
...@@ -216,7 +216,7 @@ inline std::string ConCatPathFileName(const std::string &path, ...@@ -216,7 +216,7 @@ inline std::string ConCatPathFileName(const std::string &path,
const std::string &filename) { const std::string &filename) {
std::string filepath = path; std::string filepath = path;
if (filepath.length()) { if (filepath.length()) {
char filepath_last_character = string_back(filepath); char &filepath_last_character = string_back(filepath);
if (filepath_last_character == kPathSeparatorWindows) { if (filepath_last_character == kPathSeparatorWindows) {
filepath_last_character = kPathSeparator; filepath_last_character = kPathSeparator;
} else if (filepath_last_character != kPathSeparator) { } else if (filepath_last_character != kPathSeparator) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment