diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-05-29 20:14:42 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-05-29 20:14:42 +1000 |
| commit | 7de3ea786ff87daa9d554c7390dc066516758ab7 (patch) | |
| tree | 75aae2b7048ffacf28a27304a738045743c84cb6 /src | |
| parent | 8ae490752f93d98e769dc98cab901b162ee90091 (diff) | |
Fix trailing slash removal code with root directory
Diffstat (limited to 'src')
| -rw-r--r-- | src/file.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/file.cc b/src/file.cc index 9c5f23ab..36d354e6 100644 --- a/src/file.cc +++ b/src/file.cc @@ -86,7 +86,7 @@ String real_path(StringView filename) return res; StringView dir = res; - while (dir.substr(dir.length()-1_byte, 1_byte) == "/") + while (not dir.empty() and dir.back() == '/') dir = dir.substr(0_byte, dir.length()-1_byte); return format("{}/{}", dir, non_existing); } @@ -116,7 +116,7 @@ String compact_path(StringView filename) return real_filename.substr(real_cwd.length()).str(); StringView home = homedir(); - while (home.substr(home.length()-1_byte, 1_byte) == "/") + while (not home.empty() and home.back() == '/') home = home.substr(0_byte, home.length()-1_byte); if (not home.empty()) |
