Improved handling in main when no parser name given
This commit is contained in:
parent
da4f74e2c3
commit
3a646f03e3
28
src/main.cpp
28
src/main.cpp
|
@ -32,11 +32,35 @@ int main(int argc, char** argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
const char PATHSEP = '\\';
|
||||
#else
|
||||
const char PATHSEP = '/';
|
||||
#endif
|
||||
|
||||
std::string parsername = options["parsername"];
|
||||
|
||||
/* Set name of parser, if unset */
|
||||
if (parsername.empty() && args[0].size() >= 4 && args[0].substr(args[0].size() - 4,4) == ".pds")
|
||||
parsername = args[0].substr(0, args[0].length() - 4);
|
||||
if (parsername.empty()) {
|
||||
|
||||
if (args[0].size() >= 4 && args[0].substr(args[0].size() - 4,4) == ".pds")
|
||||
parsername = args[0].substr(0, args[0].length() - 4);
|
||||
else
|
||||
parsername = args[0];
|
||||
|
||||
std::size_t pos;
|
||||
// '/' can be used on most platforms (even windows)
|
||||
pos = parsername.find_last_of('/');
|
||||
if (pos != parsername.npos) {
|
||||
parsername = parsername.substr(pos + 1);
|
||||
}
|
||||
|
||||
// strip platform specific as well
|
||||
pos = parsername.find_last_of(PATHSEP);
|
||||
if (pos != parsername.npos) {
|
||||
parsername = parsername.substr(pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
auto backendManager = std::make_unique<pds::BackendManager>(pds::BackendManager());
|
||||
/* Register languages */
|
||||
|
|
Loading…
Reference in New Issue