Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safely join paths in main.cpp. #1494

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,10 @@ int run_nmodl(int argc, const char* argv[]) {
/// create file path for nmodl file
auto filepath = [scratch_dir, modfile](const std::string& suffix) {
static int count = 0;
return fmt::format(
"{}/{}.{}.{}.mod", scratch_dir, modfile, std::to_string(count++), suffix);

auto filename = fmt::format("{}.{}.{}.mod", modfile, std::to_string(count++), suffix);

return (std::filesystem::path(scratch_dir) / filename).string();
};

/// driver object creates lexer and parser, just call parser method
Expand Down Expand Up @@ -406,12 +408,10 @@ int run_nmodl(int argc, const char* argv[]) {
ast_to_nmodl(*ast, filepath("ast"));

if (json_ast) {
std::string file{scratch_dir};
file += "/";
file += modfile;
file += ".ast.json";
logger->info("Writing AST into {}", file);
JSONVisitor(file).write(*ast);
std::filesystem::path file{scratch_dir};
file /= modfile + ".ast.json";
logger->info("Writing AST into {}", file.string());
JSONVisitor(file.string()).write(*ast);
}

if (verbatim_rename) {
Expand Down
Loading