From 55bf0489d4935ef5c5e100cda53f6d44ca762cda Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 19 Aug 2018 22:19:56 -0700 Subject: [PATCH] Load a local rc file. --- src/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 9c3c0d8..6720d3a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "types.hpp" #include "ref.hpp" #include "functions.hpp" @@ -31,6 +33,15 @@ FUNCTION(request_precision) { return LIBAB_SUCCESS; } +void run_rc(abacus& ab) { + std::ifstream rcfile("./.abcsrc"); + std::ostringstream str; + if(rcfile.good()) { + str << rcfile.rdbuf(); + ab.run(str.str()); + } +} + int main() { abacus ab; rl_bind_key('\t', rl_insert); @@ -82,6 +93,7 @@ int main() { ab.add_operator_prefix("-", "negate"); ab.add_operator_postfix("!", "factorial"); + run_rc(ab); while(!close_requested) { char* data = readline(" > "); std::string buffer(data);