Merge branch 'next'

This commit is contained in:
John Wiegley 2010-06-15 06:28:30 -04:00
commit be91f38ab4
33 changed files with 241 additions and 138 deletions

72
.gitignore vendored
View file

@ -1,58 +1,38 @@
.timestamp *.[oa]
*.backup *.backup
*.elc *.elc
*.l[oa]
*.pyc *.pyc
*~ *~
.timestamp
/*.tar.bz2
/*.tar.gz
/.deps/
/.libs/
/ABOUT-NLS /ABOUT-NLS
/BaselineTests
/Doxyfile.gen
/Makefile
/Makefile.am /Makefile.am
/Makefile.in /Makefile.in
/PyUnitTests
/RegressionTests
/TAGS /TAGS
/acconf.h.in /acconf.h.in
/aclocal.m4 /aclocal.m4
/autogen.sh /autogen.sh
/autom4te.cache/ /autom4te.cache/
/config.guess /config.guess
/config.h
/config.h.in /config.h.in
/config.log
/config.rpath /config.rpath
/config.status
/config.sub /config.sub
/configure /configure
/configure.ac /configure.ac
/depcomp
/elisp-comp
/install-sh
/intl/
/ledger
/ltmain.sh
/m4/
/make.sh
/missing
/po/
/py-compile
/src/system.hh.gch
/texinfo.tex
/version.m4
*.[oa]
*.l[oa]
/*.tar.bz2
/*.tar.gz
/.deps/
/.libs/
/BaselineTests
/Doxyfile.gen
/Makefile
/PyUnitTests
/RegressionTests
/config.h
/config.log
/config.status
/data_tests /data_tests
/doc/.dirstamp /depcomp
/doc/html/
/doc/latex/
/doc/ledger.info
/doc/refman.pdf
/doc/report/
/doc/*.aux /doc/*.aux
/doc/*.cp /doc/*.cp
/doc/*.fn /doc/*.fn
@ -63,15 +43,33 @@
/doc/*.toc /doc/*.toc
/doc/*.tp /doc/*.tp
/doc/*.vr /doc/*.vr
/doc/.dirstamp
/doc/html/
/doc/latex/
/doc/ledger.info
/doc/refman.pdf
/doc/report/
/elisp-comp
/expr_tests /expr_tests
/install-sh
/intl/
/ledger
/libtool /libtool
/ltmain.sh
/m4/
/make.sh
/math_tests /math_tests
/missing
/mkinstalldirs
/po/
/py-compile
/report_tests /report_tests
/shave /shave
/shave-libtool /shave-libtool
/src/system.hh.gch
/stamp-h1 /stamp-h1
/test/python/ /test/python/
/texinfo.tex
/tmpcvs*/ /tmpcvs*/
/tmpwrk*/ /tmpwrk*/
/util_tests /util_tests
/mkinstalldirs

27
acprep
View file

@ -633,17 +633,13 @@ class PrepareBuild(CommandLineApp):
def current_version(self): def current_version(self):
if not self.current_ver: if not self.current_ver:
if self.git_working_tree(): version_m4 = open('version.m4', 'r')
#date = self.get_stdout('git', 'log', '--format=%ci', '-1', 'HEAD') for line in version_m4.readlines():
#date = re.sub(" [-+][0-9][0-9][0-9][0-9]$", "", date) match = re.match('m4_define\(\[VERSION_NUMBER\], \[([0-9.]+[-abgrc0-9]*)\]\)',
#when = datetime.datetime.strptime(date, "%Y-%m-%d %H:%M:%S") line)
#self.current_ver = when.strftime("%Y%m%d_%H%M%S") assert(match)
#commit = self.get_stdout('git', 'log', '--format=%h', 'HEAD^..HEAD') self.current_ver = match.group(1)
#self.current_ver += "_" + commit version_m4.close()
tag = self.get_stdout('git', 'describe', '--all', '--long')
self.current_ver = re.sub('heads/', '', tag)
else:
self.current_ver = "no-git"
return self.current_ver return self.current_ver
def need_to_prepare_autotools(self): def need_to_prepare_autotools(self):
@ -726,13 +722,6 @@ class PrepareBuild(CommandLineApp):
POTFILES_in.write('\n') POTFILES_in.write('\n')
POTFILES_in.close() POTFILES_in.close()
def phase_version(self, *args):
self.log.info('Executing phase: version')
version_m4 = open('version.m4', 'w')
version_m4.write("m4_define([VERSION_NUMBER], [%s])\n" %
self.current_version())
version_m4.close()
def copytimes(self, src, dest): def copytimes(self, src, dest):
os.utime(dest, (os.stat(src)[ST_ATIME], os.stat(src)[ST_MTIME])) os.utime(dest, (os.stat(src)[ST_ATIME], os.stat(src)[ST_MTIME]))
@ -766,7 +755,6 @@ class PrepareBuild(CommandLineApp):
reason = self.need_to_prepare_autotools() reason = self.need_to_prepare_autotools()
if reason: if reason:
self.log.info('autogen.sh must be run ' + reason) self.log.info('autogen.sh must be run ' + reason)
self.phase_version()
self.phase_autogen() self.phase_autogen()
self.phase_gettext() self.phase_gettext()
self.phase_aclocal() self.phase_aclocal()
@ -1419,6 +1407,7 @@ class PrepareBuild(CommandLineApp):
if self.options.jobs > 1: if self.options.jobs > 1:
make_args.append('-j%d' % self.options.jobs) make_args.append('-j%d' % self.options.jobs)
make_args.append('JOBS=%d' % self.options.jobs)
self.log.debug('Configure arguments => ' + str(config_args)) self.log.debug('Configure arguments => ' + str(config_args))
self.log.debug('Makefile arguments => ' + str(make_args)) self.log.debug('Makefile arguments => ' + str(make_args))

View file

@ -1,4 +1,4 @@
.Dd February 2, 2010 .Dd June 15, 2010
.Dt ledger 1 .Dt ledger 1
.Sh NAME .Sh NAME
.Nm ledger .Nm ledger
@ -53,7 +53,7 @@ Also show accounts whose total is zero.
Rather than display a hierarchical tree, flatten the report to show subtotals Rather than display a hierarchical tree, flatten the report to show subtotals
for only accounts matching for only accounts matching
.Ar report-query . .Ar report-query .
.It Fl \-no\-total .It Fl \-no-total
Suppress the summary total shown at the bottom of the report (when not zero). Suppress the summary total shown at the bottom of the report (when not zero).
.El .El
.Pp .Pp
@ -263,6 +263,7 @@ transactions they are contained in. See the manual for more information.
.It Fl \-account Ar STR .It Fl \-account Ar STR
.It Fl \-account-width Ar INT .It Fl \-account-width Ar INT
.It Fl \-actual Pq Fl L .It Fl \-actual Pq Fl L
.It Fl \-actual-dates
.It Fl \-add-budget .It Fl \-add-budget
.It Fl \-amount Ar EXPR Pq Fl t .It Fl \-amount Ar EXPR Pq Fl t
.It Fl \-amount-data Pq Fl j .It Fl \-amount-data Pq Fl j
@ -275,8 +276,11 @@ transactions they are contained in. See the manual for more information.
.It Fl \-basis Pq Fl B .It Fl \-basis Pq Fl B
.It Fl \-begin Ar DATE Pq Fl b .It Fl \-begin Ar DATE Pq Fl b
.It Fl \-budget .It Fl \-budget
.It Fl \-budget-format Ar FMT
.It Fl \-by-payee Pq Fl P .It Fl \-by-payee Pq Fl P
.It Fl \-cache Ar FILE
.It Fl \-cleared Pq Fl C .It Fl \-cleared Pq Fl C
.It Fl \-cleared-format Ar FMT
.It Fl \-collapse Pq Fl n .It Fl \-collapse Pq Fl n
.It Fl \-collapse-if-zero .It Fl \-collapse-if-zero
.It Fl \-color .It Fl \-color
@ -284,12 +288,16 @@ transactions they are contained in. See the manual for more information.
.It Fl \-cost .It Fl \-cost
See See
.Fl \-basis . .Fl \-basis .
.It Fl \-count
.It Fl \-csv-format Ar FMT .It Fl \-csv-format Ar FMT
.It Fl \-current Pq Fl c .It Fl \-current Pq Fl c
.It Fl \-daily .It Fl \-daily
.It Fl \-date Ar EXPR
.It Fl \-date-format Ar DATEFMT Pq Fl y .It Fl \-date-format Ar DATEFMT Pq Fl y
.It Fl \-datetime-format Ar FMT
.It Fl \-date-width Ar INT .It Fl \-date-width Ar INT
.It Fl \-debug Ar STR .It Fl \-debug Ar STR
.It Fl \-decimal-comma
.It Fl \-depth Ar INT .It Fl \-depth Ar INT
.It Fl \-deviation Pq Fl D .It Fl \-deviation Pq Fl D
.It Fl \-display Ar EXPR Pq Fl d .It Fl \-display Ar EXPR Pq Fl d
@ -308,13 +316,25 @@ See
See See
.Fl \-head . .Fl \-head .
.It Fl \-flat .It Fl \-flat
.It Fl \-force-color
.It Fl \-force-pager
.It Fl \-forecast-while Ar EXPR .It Fl \-forecast-while Ar EXPR
(Also (Also
.Fl \-forecast .Fl \-forecast
). ).
.It Fl \-forecast-years Ar INT
.It Fl \-format Ar FMT Pq Fl F .It Fl \-format Ar FMT Pq Fl F
.It Fl \-full-help
.It Fl \-gain Pq Fl G .It Fl \-gain Pq Fl G
.It Fl \-generated
.It Fl \-group-by Ar EXPR
.It Fl \-group-title-format Ar FMT
.It Fl \-head Ar INT .It Fl \-head Ar INT
.It Fl \-help
.It Fl \-help-calc
.It Fl \-help-comm
.It Fl \-help-disp
.It Fl \-import Ar STR
.It Fl \-init-file Ar FILE .It Fl \-init-file Ar FILE
.It Fl \-input-date-format Ar DATEFMT .It Fl \-input-date-format Ar DATEFMT
.It Fl \-invert .It Fl \-invert
@ -329,26 +349,37 @@ See
.It Fl \-lots .It Fl \-lots
.It Fl \-lots-actual .It Fl \-lots-actual
.It Fl \-market Pq Fl V .It Fl \-market Pq Fl V
.It Fl \-master-account Ar STR
.It Fl \-meta Ar EXPR
.It Fl \-meta-width Ar INT
.It Fl \-monthly Pq Fl M .It Fl \-monthly Pq Fl M
.It Fl \-no-color
.It Fl \-no-rounding
.It Fl \-no-titles
.It Fl \-no-total
.It Fl \-now Ar DATE
.It Fl \-only Ar EXPR .It Fl \-only Ar EXPR
.It Fl \-options
.It Fl \-output Ar FILE Pq Fl o .It Fl \-output Ar FILE Pq Fl o
.It Fl \-pager Ar STR .It Fl \-pager Ar STR
.It Fl \-payee
.It Fl \-payee-width Ar INT .It Fl \-payee-width Ar INT
.It Fl \-pending .It Fl \-pending
.It Fl \-percentage Pq Fl \% .It Fl \-percent Pq Fl \%
.It Fl \-period Ar PERIOD Pq Fl p .It Fl \-period Ar PERIOD Pq Fl p
.It Fl \-period-sort .It Fl \-period-sort
.It Fl \-pivot Ar STR .It Fl \-pivot Ar STR
.It Fl \-plot-amount-format Ar FMT .It Fl \-plot-amount-format Ar FMT
.It Fl \-plot-total-format Ar FMT .It Fl \-plot-total-format Ar FMT
.It Fl \-prepend-format Ar FMT
.It Fl \-prepend-width Ar INT
.It Fl \-price Pq Fl I .It Fl \-price Pq Fl I
.It Fl \-price-db Ar FILE .It Fl \-price-db Ar FILE
.It Fl \-price-exp Ar STR .It Fl \-price-exp Ar STR
See See
.Fl \-leeway . .Fl \-leeway .
.It Fl \-prices-format Ar FMT .It Fl \-prices-format Ar FMT
.It Fl \-pricesdb-format Ar FMT .It Fl \-pricedb-format Ar FMT
.It Fl \-print-format Ar FMT
.It Fl \-quantity Pq Fl O .It Fl \-quantity Pq Fl O
.It Fl \-quarterly .It Fl \-quarterly
.It Fl \-raw .It Fl \-raw
@ -365,9 +396,6 @@ appeared in the original journal file.
.It Fl \-revalued-total Ar EXPR .It Fl \-revalued-total Ar EXPR
.It Fl \-seed Ar INT .It Fl \-seed Ar INT
.It Fl \-script .It Fl \-script
.It Fl \-set-account Ar EXPR
.It Fl \-set-payee Ar EXPR
.It Fl \-set-price Ar EXPR
.It Fl \-sort Ar EXPR Pq Fl S .It Fl \-sort Ar EXPR Pq Fl S
.It Fl \-sort-all .It Fl \-sort-all
.It Fl \-sort-xacts .It Fl \-sort-xacts
@ -382,6 +410,9 @@ appeared in the original journal file.
.It Fl \-truncate .It Fl \-truncate
.It Fl \-unbudgeted .It Fl \-unbudgeted
.It Fl \-uncleared Pq Fl U .It Fl \-uncleared Pq Fl U
.It Fl \-unrealized
.It Fl \-unrealized-gains
.It Fl \-unrealized-losses
.It Fl \-unround .It Fl \-unround
.It Fl \-verbose .It Fl \-verbose
.It Fl \-verify .It Fl \-verify

View file

@ -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);

View file

@ -188,12 +188,6 @@ post_handler_ptr chain_post_handlers(post_handler_ptr base_handler,
else else
handler.reset(new sort_posts(handler, report.HANDLER(sort_).str())); handler.reset(new sort_posts(handler, report.HANDLER(sort_).str()));
} }
#if 0
else if (! report.HANDLED(period_) &&
! report.HANDLED(unsorted)) {
handler.reset(new sort_posts(handler, "date"));
}
#endif
// collapse_posts causes xacts with multiple posts to appear as xacts // collapse_posts causes xacts with multiple posts to appear as xacts
// with a subtotaled post for each commodity used. // with a subtotaled post for each commodity used.

View file

@ -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);

View file

@ -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();

View file

@ -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;
} }
@ -256,9 +256,9 @@ 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) {
temps.copy_xact(*post.xact); temps.copy_xact(*post.xact);

View file

@ -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");

View file

@ -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());

View file

@ -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++;

View file

@ -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");

View file

@ -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;

View file

@ -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;

View file

@ -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:"));

View file

@ -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
{ {

View file

@ -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;
} }

View file

@ -1040,7 +1040,6 @@ option_t<report_t> * report_t::lookup_option(const char * p)
else OPT(unrealized_gains_); else OPT(unrealized_gains_);
else OPT(unrealized_losses_); else OPT(unrealized_losses_);
else OPT(unround); else OPT(unround);
else OPT(unsorted);
break; break;
case 'w': case 'w':
OPT(weekly); OPT(weekly);

View file

@ -315,7 +315,6 @@ public:
HANDLER(unrealized_gains_).report(out); HANDLER(unrealized_gains_).report(out);
HANDLER(unrealized_losses_).report(out); HANDLER(unrealized_losses_).report(out);
HANDLER(unround).report(out); HANDLER(unround).report(out);
HANDLER(unsorted).report(out);
HANDLER(weekly).report(out); HANDLER(weekly).report(out);
HANDLER(wide).report(out); HANDLER(wide).report(out);
HANDLER(yearly).report(out); HANDLER(yearly).report(out);
@ -914,8 +913,6 @@ public:
.set_expr(string("--unround"), "unrounded(total_expr)"); .set_expr(string("--unround"), "unrounded(total_expr)");
}); });
OPTION(report_t, unsorted);
OPTION_(report_t, weekly, DO() { // -W OPTION_(report_t, weekly, DO() { // -W
parent->HANDLER(period_).on(string("--weekly"), "weekly"); parent->HANDLER(period_).on(string("--weekly"), "weekly");
}); });

View file

@ -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

View file

@ -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,

View file

@ -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"));
} }

View file

@ -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);
} }

View file

@ -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;

View file

@ -4,13 +4,30 @@
# final balance is the same as what the balance report shows. # final balance is the same as what the balance report shows.
import sys import sys
#import re import re
from difflib import ndiff from difflib import ndiff
multiproc = False
try:
from multiprocessing import Pool
multiproc = True
except:
pass
args = sys.argv
jobs = 1
match = re.match('-j([0-9]+)?', args[1])
if match:
args = [args[0]] + args[2:]
if match.group(1):
jobs = int(match.group(1))
if jobs == 1:
multiproc = False
from LedgerHarness import LedgerHarness from LedgerHarness import LedgerHarness
harness = LedgerHarness(sys.argv) harness = LedgerHarness(args)
#def normalize(line): #def normalize(line):
# match = re.match("((\s*)([A-Za-z]+)?(\s*)([-0-9.]+)(\s*)([A-Za-z]+)?)( (.+))?$", line) # match = re.match("((\s*)([A-Za-z]+)?(\s*)([-0-9.]+)(\s*)([A-Za-z]+)?)( (.+))?$", line)
@ -104,14 +121,28 @@ def generation_test(seed):
beg_range = 1 beg_range = 1
end_range = 20 end_range = 20
if len(sys.argv) > 4: if len(args) > 4:
beg_range = int(sys.argv[3]) beg_range = int(args[3])
end_range = int(sys.argv[4]) end_range = int(args[4])
for i in range(beg_range, end_range): def run_gen_test(i):
if generation_test(i): if generation_test(i):
harness.success() harness.success()
else: else:
harness.failure() harness.failure()
if multiproc:
pool = Pool(jobs*2)
else:
pool = None
if pool:
pool.map(run_gen_test, range(beg_range, end_range))
else:
for i in range(beg_range, end_range):
run_gen_test(i)
if pool:
pool.close()
pool.join()
harness.exit() harness.exit()

View file

@ -6,6 +6,27 @@ import re
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import copy_reg
import types
def _pickle_method(method):
func_name = method.im_func.__name__
obj = method.im_self
cls = method.im_class
return _unpickle_method, (func_name, obj, cls)
def _unpickle_method(func_name, obj, cls):
for cls in cls.mro():
try:
func = cls.__dict__[func_name]
except KeyError:
pass
else:
break
return func.__get__(obj, cls)
copy_reg.pickle(types.MethodType, _pickle_method, _unpickle_method)
class LedgerHarness: class LedgerHarness:
ledger = None ledger = None
sourcepath = None sourcepath = None

View file

@ -5,18 +5,35 @@ import os
import re import re
import tempfile import tempfile
multiproc = False
try:
from multiprocessing import Pool
multiproc = True
except:
pass
from string import join from string import join
from difflib import unified_diff from difflib import unified_diff
from LedgerHarness import LedgerHarness from LedgerHarness import LedgerHarness
harness = LedgerHarness(sys.argv) args = sys.argv
tests = sys.argv[3] jobs = 1
match = re.match('-j([0-9]+)?', args[1])
if match:
args = [args[0]] + args[2:]
if match.group(1):
jobs = int(match.group(1))
if jobs == 1:
multiproc = False
harness = LedgerHarness(args)
tests = args[3]
if not os.path.isdir(tests) and not os.path.isfile(tests): if not os.path.isdir(tests) and not os.path.isfile(tests):
sys.exit(1) sys.exit(1)
class RegressFile: class RegressFile(object):
def __init__(self, filename): def __init__(self, filename):
self.filename = filename self.filename = filename
self.fd = open(self.filename) self.fd = open(self.filename)
@ -137,24 +154,36 @@ class RegressFile:
if not use_stdin: if not use_stdin:
os.remove(tempdata[1]) os.remove(tempdata[1])
def run_tests(self): def run_tests(self, pool):
test = self.read_test() test = self.read_test()
while test: while test:
self.run_test(test) if pool:
pool.apply_async(RegressFile.run_test, (self, test,))
else:
self.run_test(test)
test = self.read_test(test) test = self.read_test(test)
def close(self): def close(self):
self.fd.close() self.fd.close()
if os.path.isdir(tests): if __name__ == '__main__':
for test_file in os.listdir(tests): if multiproc:
if re.search('\.test$', test_file): pool = Pool(jobs*2)
entry = RegressFile(os.path.join(tests, test_file)) else:
entry.run_tests() pool = None
entry.close()
else:
entry = RegressFile(tests)
entry.run_tests()
entry.close()
harness.exit() if os.path.isdir(tests):
for test_file in os.listdir(tests):
if re.search('\.test$', test_file):
entry = RegressFile(os.path.join(tests, test_file))
entry.run_tests(pool)
entry.close()
else:
entry = RegressFile(tests)
entry.run_tests(pool)
entry.close()
if pool:
pool.close()
pool.join()
harness.exit()

View file

@ -1,4 +1,4 @@
reg -F '%(justify(scrub(total_expr), 80, 80, true))\n' --lot-dates --unsorted reg -F '%(justify(scrub(total_expr), 80, 80, true))\n' --lot-dates
<<< <<<
C 1.00s = 100c C 1.00s = 100c
C 1.00G = 100s C 1.00G = 100s

View file

@ -1,4 +1,4 @@
reg -F '%(justify(scrub(total_expr), 80, 80, true))\n' --lot-prices --unsorted reg -F '%(justify(scrub(total_expr), 80, 80, true))\n' --lot-prices
<<< <<<
C 1.00s = 100c C 1.00s = 100c
C 1.00G = 100s C 1.00G = 100s

View file

@ -1,4 +1,4 @@
reg -F '%(justify(scrub(total_expr), 80, 80, true))\n' --lots --unsorted reg -F '%(justify(scrub(total_expr), 80, 80, true))\n' --lots
<<< <<<
C 1.00s = 100c C 1.00s = 100c
C 1.00G = 100s C 1.00G = 100s

View file

@ -1,4 +1,4 @@
VERSION = 3.0.0 LIBVERSION = $(shell echo $(PACKAGE_VERSION) | sed 's/[-abgrc].*//')
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
dist_man_MANS = doc/ledger.1 dist_man_MANS = doc/ledger.1
SUBDIRS = po intl SUBDIRS = po intl
@ -25,7 +25,7 @@ libledger_util_la_SOURCES = \
lib/sha1.cpp lib/sha1.cpp
libledger_util_la_CPPFLAGS = $(lib_cppflags) libledger_util_la_CPPFLAGS = $(lib_cppflags)
libledger_util_la_LDFLAGS = -release $(VERSION) libledger_util_la_LDFLAGS = -release $(LIBVERSION)
libledger_math_la_SOURCES = \ libledger_math_la_SOURCES = \
src/balance.cc \ src/balance.cc \
@ -36,7 +36,7 @@ libledger_math_la_SOURCES = \
src/amount.cc src/amount.cc
libledger_math_la_CPPFLAGS = $(lib_cppflags) libledger_math_la_CPPFLAGS = $(lib_cppflags)
libledger_math_la_LDFLAGS = -release $(VERSION) libledger_math_la_LDFLAGS = -release $(LIBVERSION)
libledger_expr_la_SOURCES = \ libledger_expr_la_SOURCES = \
src/option.cc \ src/option.cc \
@ -51,7 +51,7 @@ libledger_expr_la_SOURCES = \
src/value.cc src/value.cc
libledger_expr_la_CPPFLAGS = $(lib_cppflags) libledger_expr_la_CPPFLAGS = $(lib_cppflags)
libledger_expr_la_LDFLAGS = -release $(VERSION) libledger_expr_la_LDFLAGS = -release $(LIBVERSION)
libledger_data_la_SOURCES = \ libledger_data_la_SOURCES = \
src/lookup.cc \ src/lookup.cc \
@ -68,7 +68,7 @@ libledger_data_la_SOURCES = \
src/item.cc src/item.cc
libledger_data_la_CPPFLAGS = $(lib_cppflags) libledger_data_la_CPPFLAGS = $(lib_cppflags)
libledger_data_la_LDFLAGS = -release $(VERSION) libledger_data_la_LDFLAGS = -release $(LIBVERSION)
libledger_report_la_SOURCES = \ libledger_report_la_SOURCES = \
src/stats.cc \ src/stats.cc \
@ -87,7 +87,7 @@ libledger_report_la_SOURCES = \
src/session.cc src/session.cc
libledger_report_la_CPPFLAGS = $(lib_cppflags) libledger_report_la_CPPFLAGS = $(lib_cppflags)
libledger_report_la_LDFLAGS = -release $(VERSION) libledger_report_la_LDFLAGS = -release $(LIBVERSION)
pkginclude_HEADERS = \ pkginclude_HEADERS = \
src/utils.h \ src/utils.h \
@ -369,7 +369,7 @@ RegressTests_SOURCES = test/RegressTests.py
EXTRA_DIST += test/regress test/convert.py test/LedgerHarness.py EXTRA_DIST += test/regress test/convert.py test/LedgerHarness.py
RegressTests: $(srcdir)/test/RegressTests.py RegressTests: $(srcdir)/test/RegressTests.py
echo "$(PYTHON) $(srcdir)/test/RegressTests.py $(top_builddir)/ledger$(EXEEXT) $(srcdir) $(srcdir)/test/regress \"\$$@\"" > $@ echo "$(PYTHON) $(srcdir)/test/RegressTests.py -j$(JOBS) $(top_builddir)/ledger$(EXEEXT) $(srcdir) $(srcdir)/test/regress \"\$$@\"" > $@
chmod 755 $@ chmod 755 $@
BaselineTests_SOURCES = test/RegressTests.py BaselineTests_SOURCES = test/RegressTests.py
@ -377,7 +377,7 @@ BaselineTests_SOURCES = test/RegressTests.py
EXTRA_DIST += test/baseline EXTRA_DIST += test/baseline
BaselineTests: $(srcdir)/test/RegressTests.py BaselineTests: $(srcdir)/test/RegressTests.py
echo "$(PYTHON) $(srcdir)/test/RegressTests.py $(top_builddir)/ledger$(EXEEXT) $(srcdir) $(srcdir)/test/baseline \"\$$@\"" > $@ echo "$(PYTHON) $(srcdir)/test/RegressTests.py -j$(JOBS) $(top_builddir)/ledger$(EXEEXT) $(srcdir) $(srcdir)/test/baseline \"\$$@\"" > $@
chmod 755 $@ chmod 755 $@
ManualTests_SOURCES = test/RegressTests.py ManualTests_SOURCES = test/RegressTests.py
@ -385,7 +385,7 @@ ManualTests_SOURCES = test/RegressTests.py
EXTRA_DIST += test/manual EXTRA_DIST += test/manual
ManualTests: $(srcdir)/test/RegressTests.py ManualTests: $(srcdir)/test/RegressTests.py
echo "$(PYTHON) $(srcdir)/test/RegressTests.py $(top_builddir)/ledger$(EXEEXT) $(srcdir) $(srcdir)/test/manual \"\$$@\"" > $@ echo "$(PYTHON) $(srcdir)/test/RegressTests.py -j$(JOBS) $(top_builddir)/ledger$(EXEEXT) $(srcdir) $(srcdir)/test/manual \"\$$@\"" > $@
chmod 755 $@ chmod 755 $@
ConfirmTests_SOURCES = test/ConfirmTests.py ConfirmTests_SOURCES = test/ConfirmTests.py
@ -406,7 +406,7 @@ ConfirmTests: $(srcdir)/test/ConfirmTests.py
GenerateTests_SOURCES = test/GenerateTests.py GenerateTests_SOURCES = test/GenerateTests.py
GenerateTests: $(srcdir)/test/GenerateTests.py GenerateTests: $(srcdir)/test/GenerateTests.py
echo "$(PYTHON) $(srcdir)/test/GenerateTests.py $(top_builddir)/ledger$(EXEEXT) $(srcdir) 1 ${1:-20} \"\$$@\"" > $@ echo "$(PYTHON) $(srcdir)/test/GenerateTests.py -j$(JOBS) $(top_builddir)/ledger$(EXEEXT) $(srcdir) 1 ${1:-20} \"\$$@\"" > $@
chmod 755 $@ chmod 755 $@
FULLCHECK=$(srcdir)/test/fullcheck.sh FULLCHECK=$(srcdir)/test/fullcheck.sh

View file

@ -44,4 +44,3 @@ src/system.hh.gch
stamp-h1 stamp-h1
texinfo.tex texinfo.tex
util_tests util_tests
version.m4

1
version.m4 Normal file
View file

@ -0,0 +1 @@
m4_define([VERSION_NUMBER], [3.0.0])