summaryrefslogtreecommitdiff
path: root/src/textual.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2023-11-30 12:38:44 -0800
committerJohn Wiegley <johnw@newartisans.com>2024-08-05 08:35:56 -0700
commit75e5eacebaf8b9ad3a18b6f1a91a8cb227fa5c9c (patch)
tree896d7f2d1496bd19b2c5ba7a8b97285908bfde0c /src/textual.cc
parentf230125ecc0761e6bd082ac0d916db4f17f0278d (diff)
downloadfork-ledger-75e5eacebaf8b9ad3a18b6f1a91a8cb227fa5c9c.tar.gz
fork-ledger-75e5eacebaf8b9ad3a18b6f1a91a8cb227fa5c9c.tar.bz2
fork-ledger-75e5eacebaf8b9ad3a18b6f1a91a8cb227fa5c9c.zip
Add support for --hashes=sha512_256 as another algorithm
Diffstat (limited to 'src/textual.cc')
-rw-r--r--src/textual.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/textual.cc b/src/textual.cc
index af208232..5488c6a3 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -40,6 +40,7 @@
#include "query.h"
#include "pstream.h"
#include "pool.h"
+#include "session.h"
#include <algorithm>
#if HAVE_BOOST_PYTHON
#include "pyinterp.h"
@@ -79,7 +80,7 @@ namespace {
instance_t * parent;
std::list<application_t> apply_stack;
bool no_assertions;
- bool store_hashes;
+ hash_type_t hash_type;
#if TIMELOG_SUPPORT
time_log_t timelog;
#endif
@@ -88,10 +89,10 @@ namespace {
parse_context_t& _context,
instance_t * _parent = NULL,
const bool _no_assertions = false,
- const bool _store_hashes = false)
+ const hash_type_t _hash_type = NO_HASHES)
: context_stack(_context_stack), context(_context),
in(*context.stream.get()), parent(_parent),
- no_assertions(_no_assertions), store_hashes(_store_hashes),
+ no_assertions(_no_assertions), hash_type(_hash_type),
timelog(context) {}
virtual string description() {
@@ -805,7 +806,7 @@ void instance_t::include_directive(char * line)
context_stack.get_current().scope = scope;
try {
instance_t instance(context_stack, context_stack.get_current(),
- this, no_assertions, store_hashes);
+ this, no_assertions, hash_type);
instance.apply_stack.push_front(application_t("account", master));
instance.parse();
}
@@ -2020,11 +2021,12 @@ xact_t * instance_t::parse_xact(char * line,
TRACE_STOP(xact_details, 1);
- if (store_hashes) {
+ if (hash_type != NO_HASHES) {
string expected_hash =
xact->hash(previous_xact &&
previous_xact->has_tag("Hash") ?
- previous_xact->get_tag("Hash")->to_string() : "");
+ previous_xact->get_tag("Hash")->to_string() : "",
+ hash_type);
if (xact->has_tag("Hash")) {
string current_hash = xact->get_tag("Hash")->to_string();
if (! std::equal(expected_hash.begin(),
@@ -2059,13 +2061,13 @@ expr_t::ptr_op_t instance_t::lookup(const symbol_t::kind_t kind,
}
std::size_t journal_t::read_textual(parse_context_stack_t& context_stack,
- bool store_hashes)
+ hash_type_t hash_type)
{
TRACE_START(parsing_total, 1, "Total time spent parsing text:");
{
instance_t instance(context_stack, context_stack.get_current(), NULL,
checking_style == journal_t::CHECK_PERMISSIVE,
- store_hashes);
+ hash_type);
instance.apply_stack.push_front
(application_t("account", context_stack.get_current().master));
instance.parse();