From 75e5eacebaf8b9ad3a18b6f1a91a8cb227fa5c9c Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 30 Nov 2023 12:38:44 -0800 Subject: Add support for --hashes=sha512_256 as another algorithm --- src/textual.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/textual.cc') 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 #if HAVE_BOOST_PYTHON #include "pyinterp.h" @@ -79,7 +80,7 @@ namespace { instance_t * parent; std::list 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(); -- cgit v1.2.3