Skip to content

Commit 6607bd9

Browse files
author
riastradh
committed
finance/ledger32: Fix build with boost>=1.86, and fix ctype abuse.
1. Boost patch backported from upstream master, since there's been no upstream release since the breakage. 2. Ctype abuse adapted afresh -- not sure how I missed this last time around! Almsot all the tests pass now, and the same handful of test that fail fail in finance/ledger too (RegressTest_553, RegressTest_BF3C1F82-2, RegressTest_BF3C1F82). No revbump because this has been broken since the revbump last month for boost 1.86.
1 parent 13c1791 commit 6607bd9

5 files changed

Lines changed: 136 additions & 6 deletions

File tree

finance/ledger32/distinfo

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
$NetBSD: distinfo,v 1.3 2024/05/02 12:22:13 riastradh Exp $
1+
$NetBSD: distinfo,v 1.4 2024/11/26 23:07:02 riastradh Exp $
22

33
BLAKE2s (ledger-3.2.1.tar.gz) = c07ef3f13ef6fa24c3a0d4e1ef91e02c39673f143aa910810d64f00751ab76ff
44
SHA512 (ledger-3.2.1.tar.gz) = 526c60cee354c9d2ead38cef3b89b349467e41fa3ec0927b51e7246a3352f19f0f81574211f20ba9bac5915590b870b9f9478a103ab661d3d9a10f41c52f4512
55
Size (ledger-3.2.1.tar.gz) = 790959 bytes
66
SHA1 (patch-src_CMakeLists.txt) = 8d6a16523554c98c8559702db681af6fb4f413aa
7-
SHA1 (patch-src_amount.cc) = ddabd294a25d05b7caf85e701817f5a78d28e04a
7+
SHA1 (patch-src_amount.cc) = 63baa56b38c5f773e66d4e9cde1fe99b3686339f
88
SHA1 (patch-src_expr.cc) = e707cbcba58a31534072ed490c9ba95f8dc4005d
9+
SHA1 (patch-src_filters.cc) = be5a1f382006ae014cea0c028d774f68d4e58ca8
910
SHA1 (patch-src_format.cc) = c7fe4821bc86a9126978235fa44859f84ea92989
1011
SHA1 (patch-src_item.cc) = 5e97a09824a04092161d8a0ca956a43ef084a03d
1112
SHA1 (patch-src_lookup.cc) = 0140f88386a6a9bbfa82e48fca4f3555f40a03aa
@@ -17,5 +18,7 @@ SHA1 (patch-src_strptime.cc) = 9e5f77e6300b3c88aa47540f03675a5001eac5bc
1718
SHA1 (patch-src_system.hh.in) = d96c4bf691868e790110c73473e4a9f81e48d617
1819
SHA1 (patch-src_textual.cc) = 3b52947bbdf41bbf4181e5c5519df2b105da60ad
1920
SHA1 (patch-src_times.cc) = 544235432f6811f1a5c73ee72b3011709b606f17
21+
SHA1 (patch-src_token.cc) = b158a92eed40b632cbcc376936757d5ed82691e5
2022
SHA1 (patch-src_utils.cc) = 764badb5363a6ab6a98672ff5fde897a477d2fbd
23+
SHA1 (patch-src_utils.h) = 3bc839a71cb21b1001bdde8c9b5311bfd65abd1c
2124
SHA1 (patch-src_xact.cc) = 89befd42102146e7a46f92ce458a7f1bc321ce55

finance/ledger32/patches/patch-src_amount.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
$NetBSD: patch-src_amount.cc,v 1.1 2024/05/02 12:22:13 riastradh Exp $
1+
$NetBSD: patch-src_amount.cc,v 1.2 2024/11/26 23:07:02 riastradh Exp $
22

33
Fix ctype abuse.
44
https://github.com/ledger/ledger/pull/2341
55

66
--- src/amount.cc.orig 2020-05-18 05:30:10.000000000 +0000
77
+++ src/amount.cc
8-
@@ -979,7 +979,8 @@ namespace {
9-
std::isdigit(c) || c == '-' || c == '.' || c == ',');
8+
@@ -976,10 +976,11 @@ namespace {
9+
char buf[256];
10+
char c = peek_next_nonws(in);
11+
READ_INTO(in, buf, 255, c,
12+
- std::isdigit(c) || c == '-' || c == '.' || c == ',');
13+
+ std::isdigit(static_cast<unsigned char>(c)) || c == '-' || c == '.' || c == ',');
1014

1115
string::size_type len = std::strlen(buf);
1216
- while (len > 0 && ! std::isdigit(buf[len - 1])) {
@@ -15,7 +19,12 @@ Fix ctype abuse.
1519
buf[--len] = '\0';
1620
in.unget();
1721
}
18-
@@ -1014,7 +1015,7 @@ bool amount_t::parse(std::istream& in, c
22+
@@ -1010,11 +1011,11 @@ bool amount_t::parse(std::istream& in, c
23+
}
24+
25+
char n;
26+
- if (std::isdigit(c)) {
27+
+ if (std::isdigit(static_cast<unsigned char>(c))) {
1928
parse_quantity(in, quant);
2029

2130
if (! in.eof() && ((n = static_cast<char>(in.peek())) != '\n')) {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
$NetBSD: patch-src_filters.cc,v 1.1 2024/11/26 23:07:02 riastradh Exp $
2+
3+
Fix build with boost>=1.86, which broke API compatibility.
4+
https://github.com/ledger/ledger/issues/2378
5+
6+
--- src/filters.cc.orig 2023-03-30 07:40:48.000000000 +0000
7+
+++ src/filters.cc
8+
@@ -238,7 +238,7 @@ void anonymize_posts::render_commodity(a
9+
void anonymize_posts::operator()(post_t& post)
10+
{
11+
boost::uuids::detail::sha1 sha;
12+
- unsigned int message_digest[5];
13+
+ unsigned char message_digest[20];
14+
bool copy_xact_details = false;
15+
16+
if (last_xact != post.xact) {
17+
@@ -1268,7 +1268,7 @@ void budget_posts::report_budget_items(c
18+
foreach (pending_posts_list::iterator& i, posts_to_erase)
19+
pending_posts.erase(i);
20+
}
21+
-
22+
+
23+
if (pending_posts.size() == 0)
24+
return;
25+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
$NetBSD: patch-src_token.cc,v 1.1 2024/11/26 23:07:02 riastradh Exp $
2+
3+
Fix ctype abuse.
4+
https://github.com/ledger/ledger/pull/2341
5+
6+
--- src/token.cc.orig 2020-05-18 05:30:10.000000000 +0000
7+
+++ src/token.cc
8+
@@ -45,7 +45,7 @@ int expr_t::token_t::parse_reserved_word
9+
length = 0;
10+
11+
char buf[6];
12+
- READ_INTO_(in, buf, 5, c, length, std::isalpha(c));
13+
+ READ_INTO_(in, buf, 5, c, length, std::isalpha(static_cast<unsigned char>(c)));
14+
15+
switch (buf[0]) {
16+
case 'a':
17+
@@ -132,7 +132,7 @@ void expr_t::token_t::parse_ident(std::i
18+
length = 0;
19+
20+
char c, buf[256];
21+
- READ_INTO_(in, buf, 255, c, length, std::isalnum(c) || c == '_');
22+
+ READ_INTO_(in, buf, 255, c, length, std::isalnum(static_cast<unsigned char>(c)) || c == '_');
23+
24+
value.set_string(buf);
25+
}
26+
@@ -384,7 +384,7 @@ void expr_t::token_t::next(std::istream&
27+
28+
// First, check to see if it's a reserved word, such as: and or not
29+
int result = parse_reserved_word(in);
30+
- if (std::isalpha(c) && result == 1)
31+
+ if (std::isalpha(static_cast<unsigned char>(c)) && result == 1)
32+
break;
33+
34+
// If not, rewind back to the beginning of the word to scan it
35+
@@ -422,7 +422,7 @@ void expr_t::token_t::next(std::istream&
36+
37+
c = static_cast<char>(in.peek());
38+
if (c != -1) {
39+
- if (! std::isalpha(c) && c != '_')
40+
+ if (! std::isalpha(static_cast<unsigned char>(c)) && c != '_')
41+
expected('\0', c);
42+
43+
parse_ident(in);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
$NetBSD: patch-src_utils.h,v 1.1 2024/11/26 23:07:02 riastradh Exp $
2+
3+
Fix ctype abuse.
4+
https://github.com/ledger/ledger/pull/2341
5+
6+
Fix build with boost>=1.86, which broke API compatibility.
7+
https://github.com/ledger/ledger/issues/2378
8+
9+
--- src/utils.h.orig 2020-05-18 05:30:10.000000000 +0000
10+
+++ src/utils.h
11+
@@ -542,7 +542,7 @@ inline char * next_element(char * buf, b
12+
13+
inline char peek_next_nonws(std::istream& in) {
14+
char c = static_cast<char>(in.peek());
15+
- while (in.good() && ! in.eof() && std::isspace(c)) {
16+
+ while (in.good() && ! in.eof() && std::isspace(static_cast<unsigned char>(c))) {
17+
in.get(c);
18+
c = static_cast<char>(in.peek());
19+
}
20+
@@ -607,14 +607,14 @@ inline char peek_next_nonws(std::istream
21+
*_p = '\0'; \
22+
}
23+
24+
-inline string to_hex(unsigned int * message_digest, const int len = 1)
25+
+inline string to_hex(unsigned char * message_digest, const int len = 4)
26+
{
27+
std::ostringstream buf;
28+
29+
- for(int i = 0; i < 5 ; i++) {
30+
- buf.width(8);
31+
+ for(int i = 0; i < 20 ; i++) {
32+
+ buf.width(2);
33+
buf.fill('0');
34+
- buf << std::hex << message_digest[i];
35+
+ buf << std::hex << (int)message_digest[i];
36+
if (i + 1 >= len)
37+
break; // only output the first LEN dwords
38+
}
39+
@@ -627,9 +627,9 @@ inline string sha1sum(const string& str)
40+
41+
sha.process_bytes(str.c_str(), str.length());
42+
43+
- unsigned int message_digest[5];
44+
+ unsigned char message_digest[20];
45+
sha.get_digest(message_digest);
46+
- return to_hex(message_digest, 5);
47+
+ return to_hex(message_digest, 20);
48+
}
49+
50+
extern const string version;

0 commit comments

Comments
 (0)