Load a local rc file.

This commit is contained in:
Danila Fedorin 2018-08-19 22:19:56 -07:00
parent c5a968ad24
commit 55bf0489d4

View File

@ -3,6 +3,8 @@
#include <mpfr.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <fstream>
#include <sstream>
#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);