Changes for building with Visual Studio 2008
This commit is contained in:
parent
76b1ed6850
commit
968a6f3c0a
18 changed files with 42 additions and 28 deletions
|
|
@ -60,8 +60,8 @@
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
class commodity_t;
|
class commodity_t;
|
||||||
class annotation_t;
|
struct annotation_t;
|
||||||
class keep_details_t;
|
struct keep_details_t;
|
||||||
|
|
||||||
DECLARE_EXCEPTION(amount_error, std::runtime_error);
|
DECLARE_EXCEPTION(amount_error, std::runtime_error);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
class keep_details_t;
|
struct keep_details_t;
|
||||||
class commodity_pool_t;
|
class commodity_pool_t;
|
||||||
|
|
||||||
DECLARE_EXCEPTION(commodity_error, std::runtime_error);
|
DECLARE_EXCEPTION(commodity_error, std::runtime_error);
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ value_t expr_t::real_calc(scope_t& scope)
|
||||||
try {
|
try {
|
||||||
return ptr->calc(scope, &locus);
|
return ptr->calc(scope, &locus);
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
if (locus) {
|
if (locus) {
|
||||||
string current_context = error_context();
|
string current_context = error_context();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ pass_down_posts::pass_down_posts(post_handler_ptr handler,
|
||||||
try {
|
try {
|
||||||
item_handler<post_t>::operator()(*post);
|
item_handler<post_t>::operator()(*post);
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
add_error_context(item_context(*post, _("While handling posting")));
|
add_error_context(item_context(*post, _("While handling posting")));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +257,7 @@ void anonymize_posts::render_commodity(amount_t& amt)
|
||||||
void anonymize_posts::operator()(post_t& post)
|
void anonymize_posts::operator()(post_t& post)
|
||||||
{
|
{
|
||||||
SHA1 sha;
|
SHA1 sha;
|
||||||
uint_least32_t message_digest[5];
|
unsigned int message_digest[5];
|
||||||
bool copy_xact_details = false;
|
bool copy_xact_details = false;
|
||||||
|
|
||||||
if (last_xact != post.xact) {
|
if (last_xact != post.xact) {
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,9 @@ public:
|
||||||
report_t& _report,
|
report_t& _report,
|
||||||
expr_t _group_by_expr)
|
expr_t _group_by_expr)
|
||||||
: post_chain(_post_chain), report(_report),
|
: post_chain(_post_chain), report(_report),
|
||||||
group_by_expr(_group_by_expr),
|
group_by_expr(_group_by_expr) {
|
||||||
preflush_func(bind(&post_splitter::print_title, this, _1)) {
|
|
||||||
TRACE_CTOR(post_splitter, "scope_t&, post_handler_ptr, expr_t");
|
TRACE_CTOR(post_splitter, "scope_t&, post_handler_ptr, expr_t");
|
||||||
|
preflush_func = bind(&post_splitter::print_title, this, _1);
|
||||||
}
|
}
|
||||||
virtual ~post_splitter() {
|
virtual ~post_splitter() {
|
||||||
TRACE_DTOR(post_splitter);
|
TRACE_DTOR(post_splitter);
|
||||||
|
|
@ -350,8 +350,7 @@ class anonymize_posts : public item_handler<post_t>
|
||||||
public:
|
public:
|
||||||
anonymize_posts(post_handler_ptr handler)
|
anonymize_posts(post_handler_ptr handler)
|
||||||
: item_handler<post_t>(handler), next_comm_id(0), last_xact(NULL),
|
: item_handler<post_t>(handler), next_comm_id(0), last_xact(NULL),
|
||||||
rnd_gen(static_cast<unsigned int>(reinterpret_cast<uintmax_t>(this) +
|
rnd_gen(static_cast<unsigned int>(static_cast<uintmax_t>(std::time(0)))),
|
||||||
static_cast<uintmax_t>(std::time(0)))),
|
|
||||||
integer_range(1, 2000000000L),
|
integer_range(1, 2000000000L),
|
||||||
integer_gen(rnd_gen, integer_range) {
|
integer_gen(rnd_gen, integer_range) {
|
||||||
TRACE_CTOR(anonymize_posts, "post_handler_ptr");
|
TRACE_CTOR(anonymize_posts, "post_handler_ptr");
|
||||||
|
|
|
||||||
|
|
@ -367,13 +367,13 @@ post_t * generate_posts_iterator::operator()()
|
||||||
post = posts();
|
post = posts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception& err) {
|
catch (std::exception&) {
|
||||||
add_error_context(_("While parsing generated transaction (seed %1):")
|
add_error_context(_("While parsing generated transaction (seed %1):")
|
||||||
<< seed);
|
<< seed);
|
||||||
add_error_context(buf.str());
|
add_error_context(buf.str());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (int status) {
|
catch (int) {
|
||||||
add_error_context(_("While parsing generated transaction (seed %1):")
|
add_error_context(_("While parsing generated transaction (seed %1):")
|
||||||
<< seed);
|
<< seed);
|
||||||
add_error_context(buf.str());
|
add_error_context(buf.str());
|
||||||
|
|
|
||||||
|
|
@ -422,6 +422,7 @@ expr_t::func_t global_scope_t::look_for_command(scope_t& scope,
|
||||||
|
|
||||||
void global_scope_t::visit_man_page() const
|
void global_scope_t::visit_man_page() const
|
||||||
{
|
{
|
||||||
|
#ifndef WIN32
|
||||||
int pid = fork();
|
int pid = fork();
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
throw std::logic_error(_("Failed to fork child process"));
|
throw std::logic_error(_("Failed to fork child process"));
|
||||||
|
|
@ -436,6 +437,7 @@ void global_scope_t::visit_man_page() const
|
||||||
|
|
||||||
int status = -1;
|
int status = -1;
|
||||||
wait(&status);
|
wait(&status);
|
||||||
|
#endif
|
||||||
exit(0); // parent
|
exit(0); // parent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -471,7 +473,7 @@ void handle_debug_options(int argc, char * argv[])
|
||||||
// global in utils.h
|
// global in utils.h
|
||||||
_trace_level = boost::lexical_cast<uint8_t>(argv[i + 1]);
|
_trace_level = boost::lexical_cast<uint8_t>(argv[i + 1]);
|
||||||
}
|
}
|
||||||
catch (const boost::bad_lexical_cast& e) {
|
catch (const boost::bad_lexical_cast&) {
|
||||||
throw std::logic_error(_("Argument to --trace must be an integer"));
|
throw std::logic_error(_("Argument to --trace must be an integer"));
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,9 @@ int main(int argc, char * argv[], char * envp[])
|
||||||
filesystem::path::default_name_check(filesystem::portable_posix_name);
|
filesystem::path::default_name_check(filesystem::portable_posix_name);
|
||||||
|
|
||||||
std::signal(SIGINT, sigint_handler);
|
std::signal(SIGINT, sigint_handler);
|
||||||
|
#ifndef WIN32
|
||||||
std::signal(SIGPIPE, sigpipe_handler);
|
std::signal(SIGPIPE, sigpipe_handler);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_GETTEXT)
|
#if defined(HAVE_GETTEXT)
|
||||||
::textdomain("ledger");
|
::textdomain("ledger");
|
||||||
|
|
|
||||||
|
|
@ -406,7 +406,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
if (locus && ! *locus)
|
if (locus && ! *locus)
|
||||||
*locus = this;
|
*locus = this;
|
||||||
throw;
|
throw;
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ namespace {
|
||||||
|
|
||||||
opt(args);
|
opt(args);
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
if (name[0] == '-')
|
if (name[0] == '-')
|
||||||
add_error_context(_("While parsing option '%1'") << name);
|
add_error_context(_("While parsing option '%1'") << name);
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@ void process_environment(const char ** envp, const string& tag,
|
||||||
if (! value.empty())
|
if (! value.empty())
|
||||||
process_option(string("$") + buf, string(buf), scope, q + 1, value);
|
process_option(string("$") + buf, string(buf), scope, q + 1, value);
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
add_error_context(_("While parsing environment variable option '%1':")
|
add_error_context(_("While parsing environment variable option '%1':")
|
||||||
<< *p);
|
<< *p);
|
||||||
throw;
|
throw;
|
||||||
|
|
|
||||||
|
|
@ -484,7 +484,7 @@ expr_t::parser_t::parse(std::istream& in,
|
||||||
|
|
||||||
return top_node;
|
return top_node;
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
if (original_string) {
|
if (original_string) {
|
||||||
add_error_context(_("While parsing value expression:"));
|
add_error_context(_("While parsing value expression:"));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,9 @@ namespace ledger {
|
||||||
|
|
||||||
class query_t : public predicate_t
|
class query_t : public predicate_t
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
class parser_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class lexer_t
|
class lexer_t
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ commodity_quote_from_script(commodity_t& commodity,
|
||||||
DEBUG("commodity.download", "invoking command: " << getquote_cmd);
|
DEBUG("commodity.download", "invoking command: " << getquote_cmd);
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
#ifndef WIN32
|
||||||
if (FILE * fp = popen(getquote_cmd.c_str(), "r")) {
|
if (FILE * fp = popen(getquote_cmd.c_str(), "r")) {
|
||||||
if (std::feof(fp) || ! std::fgets(buf, 255, fp))
|
if (std::feof(fp) || ! std::fgets(buf, 255, fp))
|
||||||
success = false;
|
success = false;
|
||||||
|
|
@ -103,6 +104,7 @@ commodity_quote_from_script(commodity_t& commodity,
|
||||||
// Don't try to download this commodity again.
|
// Don't try to download this commodity again.
|
||||||
commodity.add_flags(COMMODITY_NOMARKET);
|
commodity.add_flags(COMMODITY_NOMARKET);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ namespace {
|
||||||
*/
|
*/
|
||||||
int do_fork(std::ostream ** os, const path& pager_path)
|
int do_fork(std::ostream ** os, const path& pager_path)
|
||||||
{
|
{
|
||||||
|
#ifndef WIN32
|
||||||
int pfd[2];
|
int pfd[2];
|
||||||
|
|
||||||
int status = pipe(pfd);
|
int status = pipe(pfd);
|
||||||
|
|
@ -104,6 +105,9 @@ namespace {
|
||||||
*os = new fdstream(pfd[1]);
|
*os = new fdstream(pfd[1]);
|
||||||
}
|
}
|
||||||
return pfd[1];
|
return pfd[1];
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,6 +124,7 @@ void output_stream_t::initialize(const optional<path>& output_file,
|
||||||
|
|
||||||
void output_stream_t::close()
|
void output_stream_t::close()
|
||||||
{
|
{
|
||||||
|
#ifndef WIN32
|
||||||
if (os != &std::cout) {
|
if (os != &std::cout) {
|
||||||
checked_delete(os);
|
checked_delete(os);
|
||||||
os = &std::cout;
|
os = &std::cout;
|
||||||
|
|
@ -134,6 +139,7 @@ void output_stream_t::close()
|
||||||
if (! WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
if (! WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||||
throw std::logic_error(_("Error in the pager"));
|
throw std::logic_error(_("Error in the pager"));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ledger
|
} // namespace ledger
|
||||||
|
|
|
||||||
|
|
@ -611,7 +611,7 @@ void instance_t::automated_xact_directive(char * line)
|
||||||
|
|
||||||
ae.release();
|
ae.release();
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
if (reveal_context) {
|
if (reveal_context) {
|
||||||
add_error_context(_("While parsing automated transaction:"));
|
add_error_context(_("While parsing automated transaction:"));
|
||||||
add_error_context(source_context(pathname, pos, curr_pos, "> "));
|
add_error_context(source_context(pathname, pos, curr_pos, "> "));
|
||||||
|
|
@ -657,7 +657,7 @@ void instance_t::period_xact_directive(char * line)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
if (reveal_context) {
|
if (reveal_context) {
|
||||||
add_error_context(_("While parsing periodic transaction:"));
|
add_error_context(_("While parsing periodic transaction:"));
|
||||||
add_error_context(source_context(pathname, pos, curr_pos, "> "));
|
add_error_context(source_context(pathname, pos, curr_pos, "> "));
|
||||||
|
|
@ -1359,7 +1359,7 @@ post_t * instance_t::parse_post(char * line,
|
||||||
return post.release();
|
return post.release();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
add_error_context(_("While parsing posting:"));
|
add_error_context(_("While parsing posting:"));
|
||||||
add_error_context(line_context(buf, beg, len));
|
add_error_context(line_context(buf, beg, len));
|
||||||
throw;
|
throw;
|
||||||
|
|
@ -1557,7 +1557,7 @@ xact_t * instance_t::parse_xact(char * line,
|
||||||
return xact.release();
|
return xact.release();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
if (reveal_context) {
|
if (reveal_context) {
|
||||||
add_error_context(_("While parsing transaction:"));
|
add_error_context(_("While parsing transaction:"));
|
||||||
add_error_context(source_context(xact->pos->pathname,
|
add_error_context(source_context(xact->pos->pathname,
|
||||||
|
|
|
||||||
|
|
@ -437,7 +437,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
|
||||||
length = static_cast<std::size_t>(in.tellg() - pos);
|
length = static_cast<std::size_t>(in.tellg() - pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
kind = ERROR;
|
kind = ERROR;
|
||||||
length = static_cast<std::size_t>(in.tellg() - pos);
|
length = static_cast<std::size_t>(in.tellg() - pos);
|
||||||
throw;
|
throw;
|
||||||
|
|
@ -449,7 +449,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
|
||||||
|
|
||||||
void expr_t::token_t::rewind(std::istream& in)
|
void expr_t::token_t::rewind(std::istream& in)
|
||||||
{
|
{
|
||||||
in.seekg(- length, std::ios::cur);
|
in.seekg(- int(length), std::ios::cur);
|
||||||
if (in.fail())
|
if (in.fail())
|
||||||
throw_(parse_error, _("Failed to rewind input stream"));
|
throw_(parse_error, _("Failed to rewind input stream"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -645,7 +645,7 @@ inline char peek_next_nonws(std::istream& in) {
|
||||||
*_p = '\0'; \
|
*_p = '\0'; \
|
||||||
}
|
}
|
||||||
|
|
||||||
inline string to_hex(uint_least32_t * message_digest, const int len = 1)
|
inline string to_hex(unsigned int * message_digest, const int len = 1)
|
||||||
{
|
{
|
||||||
std::ostringstream buf;
|
std::ostringstream buf;
|
||||||
|
|
||||||
|
|
@ -664,7 +664,7 @@ inline string sha1sum(const string& str)
|
||||||
SHA1 sha;
|
SHA1 sha;
|
||||||
sha.Reset();
|
sha.Reset();
|
||||||
sha << str.c_str();
|
sha << str.c_str();
|
||||||
uint_least32_t message_digest[5];
|
unsigned int message_digest[5];
|
||||||
sha.Result(message_digest);
|
sha.Result(message_digest);
|
||||||
return to_hex(message_digest, 5);
|
return to_hex(message_digest, 5);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -787,7 +787,7 @@ void auto_xact_t::extend_xact(xact_base_t& xact)
|
||||||
xact.verify();
|
xact.verify();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception&) {
|
||||||
add_error_context(item_context(*this, _("While applying automated transaction")));
|
add_error_context(item_context(*this, _("While applying automated transaction")));
|
||||||
add_error_context(item_context(xact, _("While extending transaction")));
|
add_error_context(item_context(xact, _("While extending transaction")));
|
||||||
throw;
|
throw;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue