aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/bookmaker/bookmaker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bookmaker/bookmaker.cpp')
-rw-r--r--tools/bookmaker/bookmaker.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/bookmaker/bookmaker.cpp b/tools/bookmaker/bookmaker.cpp
index ca60084100..b0b052355b 100644
--- a/tools/bookmaker/bookmaker.cpp
+++ b/tools/bookmaker/bookmaker.cpp
@@ -308,9 +308,12 @@ bool Definition::exampleToScript(string* result, ExampleOptions exampleOptions)
code += "}";
}
string example = "\"" + normalizedName + "\": {\n";
- size_t nameStart = fFileName.find("\\", 0);
- SkASSERT(string::npos != nameStart);
- string baseFile = fFileName.substr(nameStart + 1, fFileName.length() - nameStart - 5);
+
+ string baseFile = [this]() {
+ string baseNameExt = fFileName.substr(fFileName.find_last_of("/\\") + 1);
+ size_t p = baseNameExt.find_last_of('.');
+ return (p > 0 && p != string::npos) ? baseNameExt.substr(0, p) : baseNameExt;
+ }();
if (ExampleOptions::kText == exampleOptions) {
example += " \"code\": \"" + code + "\",\n";
example += " \"hash\": \"" + fHash + "\",\n";