Skip to content

Commit

Permalink
use scm_c_primitive_load instead of ifstream->string->eval-string
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Oct 7, 2023
1 parent 2cb92e2 commit c2fee6d
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions gnucash/gnucash-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,25 +162,15 @@ scm_run_cli (void *data, [[maybe_unused]] int argc, [[maybe_unused]] char **argv
scm_c_eval_string ("(activate-readline)");
if (args->filename_str)
{
std::cout << "Loading script from " << *args->filename_str << "...";
std::ifstream fs (*args->filename_str, std::ifstream::in);
if (!fs.is_open())
{
std::cout << "failed!" << std::endl;
return;
}
std::cout << "success!" << std::endl;
std::string str;
std::ostringstream ss;
ss << fs.rdbuf();
fs.close();
str = ss.str();
std::cout << "Running script... " << std::endl;
scm_c_eval_string (ss.str().c_str());
std::cout << "Running script from " << *args->filename_str << "...";
scm_c_primitive_load (args->filename_str->c_str());
std::cout << "success!" << std::endl;
}
std::cout << "Starting CLI... " << std::endl;
scm_c_eval_string ("(start-repl)");
else
{
std::cout << "Starting CLI... " << std::endl;
scm_c_eval_string ("(start-repl)");
}
}

static void load_file (std::string m_file_to_load,
Expand Down

0 comments on commit c2fee6d

Please sign in to comment.