forked from Lainports/freebsd-ports
finance/ledger: fix build with boost-1.86
Sponsored by: Future Crew, LLC
This commit is contained in:
parent
6e5235dcf1
commit
e287976630
4 changed files with 106 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
|||
PORTNAME= ledger
|
||||
DISTVERSIONPREFIX= v
|
||||
DISTVERSION= 3.3.2
|
||||
PORTREVISION= 1
|
||||
PORTREVISION= 2
|
||||
CATEGORIES= finance
|
||||
|
||||
MAINTAINER= woodycarey@hotmail.com
|
||||
|
|
|
|||
48
finance/ledger/files/patch-src_filters.cc
Normal file
48
finance/ledger/files/patch-src_filters.cc
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
--- src/filters.cc.orig 2023-03-30 07:40:48 UTC
|
||||
+++ src/filters.cc
|
||||
@@ -237,8 +237,6 @@ void anonymize_posts::operator()(post_t& post)
|
||||
|
||||
void anonymize_posts::operator()(post_t& post)
|
||||
{
|
||||
- boost::uuids::detail::sha1 sha;
|
||||
- unsigned int message_digest[5];
|
||||
bool copy_xact_details = false;
|
||||
|
||||
if (last_xact != post.xact) {
|
||||
@@ -255,12 +253,7 @@ void anonymize_posts::operator()(post_t& post)
|
||||
std::ostringstream buf;
|
||||
buf << reinterpret_cast<boost::uintmax_t>(post.xact->payee.c_str())
|
||||
<< integer_gen() << post.xact->payee.c_str();
|
||||
-
|
||||
- sha.reset();
|
||||
- sha.process_bytes(buf.str().c_str(), buf.str().length());
|
||||
- sha.get_digest(message_digest);
|
||||
-
|
||||
- xact.payee = to_hex(message_digest);
|
||||
+ xact.payee = sha1sum(buf.str(), 8);
|
||||
xact.note = none;
|
||||
} else {
|
||||
xact.journal = post.xact->journal;
|
||||
@@ -273,12 +266,7 @@ void anonymize_posts::operator()(post_t& post)
|
||||
acct = acct->parent) {
|
||||
std::ostringstream buf;
|
||||
buf << integer_gen() << acct << acct->fullname();
|
||||
-
|
||||
- sha.reset();
|
||||
- sha.process_bytes(buf.str().c_str(), buf.str().length());
|
||||
- sha.get_digest(message_digest);
|
||||
-
|
||||
- account_names.push_front(to_hex(message_digest));
|
||||
+ account_names.push_front(sha1sum(buf.str(), 8));
|
||||
}
|
||||
|
||||
account_t * new_account =
|
||||
@@ -1268,7 +1256,7 @@ void budget_posts::report_budget_items(const date_t& d
|
||||
foreach (pending_posts_list::iterator& i, posts_to_erase)
|
||||
pending_posts.erase(i);
|
||||
}
|
||||
-
|
||||
+
|
||||
if (pending_posts.size() == 0)
|
||||
return;
|
||||
|
||||
57
finance/ledger/files/patch-src_utils.h
Normal file
57
finance/ledger/files/patch-src_utils.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
--- src/utils.h.orig 2023-03-30 07:40:48 UTC
|
||||
+++ src/utils.h
|
||||
@@ -607,29 +607,39 @@ inline int peek_next_nonws(std::istream& in) {
|
||||
*_p = '\0'; \
|
||||
}
|
||||
|
||||
-inline string to_hex(unsigned int * message_digest, const int len = 1)
|
||||
-{
|
||||
+inline string digest_to_hex(
|
||||
+ const boost::uuids::detail::sha1::digest_type& message_digest,
|
||||
+ size_t len = sizeof(boost::uuids::detail::sha1::digest_type) * 2
|
||||
+) {
|
||||
std::ostringstream buf;
|
||||
+ buf.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||
+ buf.fill('0');
|
||||
|
||||
- for(int i = 0; i < 5 ; i++) {
|
||||
- buf.width(8);
|
||||
- buf.fill('0');
|
||||
- buf << std::hex << message_digest[i];
|
||||
- if (i + 1 >= len)
|
||||
- break; // only output the first LEN dwords
|
||||
+ // sha1::digest_type is an array type and may change between Boost versions
|
||||
+ const size_t count = std::min(
|
||||
+ sizeof(message_digest) / sizeof(message_digest[0]),
|
||||
+ (len - 1) / (sizeof(message_digest[0]) * 2) + 1
|
||||
+ );
|
||||
+ for(size_t i = 0; i < count; i++) {
|
||||
+ buf.width(sizeof(message_digest[i]) * 2);
|
||||
+ buf << (unsigned int)message_digest[i];
|
||||
}
|
||||
- return buf.str();
|
||||
+ string hex = buf.str();
|
||||
+ hex.resize(len, '0'); // in case a partial element is requested
|
||||
+ return hex;
|
||||
}
|
||||
|
||||
-inline string sha1sum(const string& str)
|
||||
-{
|
||||
- boost::uuids::detail::sha1 sha;
|
||||
+inline string sha1sum(
|
||||
+ const string& str,
|
||||
+ size_t len = sizeof(boost::uuids::detail::sha1::digest_type) * 2
|
||||
+) {
|
||||
+ static boost::uuids::detail::sha1 sha;
|
||||
+ boost::uuids::detail::sha1::digest_type message_digest;
|
||||
|
||||
+ sha.reset();
|
||||
sha.process_bytes(str.c_str(), str.length());
|
||||
-
|
||||
- unsigned int message_digest[5];
|
||||
sha.get_digest(message_digest);
|
||||
- return to_hex(message_digest, 5);
|
||||
+ return digest_to_hex(message_digest, len);
|
||||
}
|
||||
|
||||
extern const string version;
|
||||
Loading…
Add table
Reference in a new issue