From cc927fc6bc0734c013a54ad8311ed12528b720c8 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 12 Sep 2011 11:09:57 -0600 Subject: [PATCH] Remove remaining non-boost_pp libraries as requirements. --- samples/example.cpp | 10 +++++----- src/main.cpp | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/samples/example.cpp b/samples/example.cpp index 5a706f0..cd3ad9b 100644 --- a/samples/example.cpp +++ b/samples/example.cpp @@ -8,17 +8,15 @@ #include #include -#include -#include void log(const std::string &msg) { - std::cout << "[" << boost::posix_time::microsec_clock::local_time() << "] " << msg << std::endl; + std::cout << "[" << time(nullptr) << "] " << msg << std::endl; } void log(const std::string &module, const std::string &msg) { - std::cout << "[" << boost::posix_time::microsec_clock::local_time() << "] <" << module << "> " << msg << std::endl; + std::cout << "[" << time(nullptr) << "] <" << module << "> " << msg << std::endl; } void bound_log(const std::string &msg) @@ -140,7 +138,9 @@ int main(int /*argc*/, char * /*argv*/[]) { //Creating a functor on the stack and using it immediatly int x = chai.eval >("fun (x, y) { return x + y; }")(5, 6); - log("Functor test output", boost::lexical_cast(x)); + std::stringstream ss; + ss << x; + log("Functor test output", ss.str()); chai.add(var(std::shared_ptr()), "nullvar"); chai("print(\"This should be true.\"); print(nullvar.is_var_null())"); diff --git a/src/main.cpp b/src/main.cpp index 9cec2db..50cb43a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #define _CRT_SECURE_NO_WARNINGS #include @@ -80,7 +80,21 @@ std::string get_next_command() { char *input_raw = readline("eval> "); if ( input_raw ) { add_history(input_raw); - retval = boost::trim_copy_if(std::string(input_raw),boost::algorithm::is_any_of(" \t")); + + std::string val(input_raw); + size_t pos = val.find_first_not_of("\t \n"); + if (pos != std::string::npos) + { + val.erase(0, pos); + } + pos = val.find_last_not_of("\t \n"); + if (pos != std::string::npos) + { + val.erase(pos+1, std::string::npos); + } + + retval = val; + ::free(input_raw); } }