pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Add Ledger from main at 3.3.2nb9



Module Name:	pkgsrc-wip
Committed By:	atomicules <base%atomicules.co.uk@localhost>
Pushed By:	atomicules
Date:		Sun Dec 7 21:09:40 2025 +0000
Changeset:	906849eb24c486a127976b8c598a4f1cf54e16cf

Added Files:
	ledger/DESCR
	ledger/Makefile
	ledger/PLIST
	ledger/distinfo
	ledger/options.mk
	ledger/patches/patch-CMakeLists.txt
	ledger/patches/patch-src_CMakeLists.txt
	ledger/patches/patch-src_amount.cc
	ledger/patches/patch-src_expr.cc
	ledger/patches/patch-src_filters.cc
	ledger/patches/patch-src_format.cc
	ledger/patches/patch-src_item.cc
	ledger/patches/patch-src_lookup.cc
	ledger/patches/patch-src_main.cc
	ledger/patches/patch-src_option.cc
	ledger/patches/patch-src_pool.cc
	ledger/patches/patch-src_report.cc
	ledger/patches/patch-src_strptime.cc
	ledger/patches/patch-src_system.hh.in
	ledger/patches/patch-src_textual.cc
	ledger/patches/patch-src_times.cc
	ledger/patches/patch-src_utils.cc
	ledger/patches/patch-src_utils.h
	ledger/patches/patch-src_xact.cc

Log Message:
Add Ledger from main at 3.3.2nb9

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=906849eb24c486a127976b8c598a4f1cf54e16cf

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 ledger/DESCR                            |  12 ++++
 ledger/Makefile                         |  49 ++++++++++++++
 ledger/PLIST                            |  64 +++++++++++++++++++
 ledger/distinfo                         |  24 +++++++
 ledger/options.mk                       |  23 +++++++
 ledger/patches/patch-CMakeLists.txt     |  15 +++++
 ledger/patches/patch-src_CMakeLists.txt |  16 +++++
 ledger/patches/patch-src_amount.cc      |  35 ++++++++++
 ledger/patches/patch-src_expr.cc        |  16 +++++
 ledger/patches/patch-src_filters.cc     |  25 ++++++++
 ledger/patches/patch-src_format.cc      |  78 ++++++++++++++++++++++
 ledger/patches/patch-src_item.cc        |  17 +++++
 ledger/patches/patch-src_lookup.cc      |  22 +++++++
 ledger/patches/patch-src_main.cc        |  18 ++++++
 ledger/patches/patch-src_option.cc      |  17 +++++
 ledger/patches/patch-src_pool.cc        |  25 ++++++++
 ledger/patches/patch-src_report.cc      |  20 ++++++
 ledger/patches/patch-src_strptime.cc    |  27 ++++++++
 ledger/patches/patch-src_system.hh.in   |  14 ++++
 ledger/patches/patch-src_textual.cc     | 110 ++++++++++++++++++++++++++++++++
 ledger/patches/patch-src_times.cc       |  57 +++++++++++++++++
 ledger/patches/patch-src_utils.cc       |  16 +++++
 ledger/patches/patch-src_utils.h        |  38 +++++++++++
 ledger/patches/patch-src_xact.cc        |  20 ++++++
 24 files changed, 758 insertions(+)

diffs:
diff --git a/ledger/DESCR b/ledger/DESCR
new file mode 100644
index 0000000000..f6277096ea
--- /dev/null
+++ b/ledger/DESCR
@@ -0,0 +1,12 @@
+Ledger is a powerful, double-entry accounting system that is accessed
+from the UNIX command-line. This may put off some users, since there is
+no flashy UI, but for those who want unparalleled reporting access to
+their data there are few alternatives.
+
+Ledger uses text files for input. It reads the files and generates
+reports; there is no other database or stored state. To use Ledger, you
+create a file of your account names and transactions, run from the
+command line with some options to specify input and requested reports,
+and get output. The output is generally plain text, though you could
+generate a graph or html instead. Ledger is simple in concept,
+surprisingly rich in ability, and easy to use.
diff --git a/ledger/Makefile b/ledger/Makefile
new file mode 100644
index 0000000000..f84ff4d02a
--- /dev/null
+++ b/ledger/Makefile
@@ -0,0 +1,49 @@
+# $NetBSD: Makefile,v 1.42 2025/09/27 09:57:16 wiz Exp $
+
+DISTNAME=	ledger-3.3.2
+PKGREVISION=	9
+CATEGORIES=	finance
+MASTER_SITES=	${MASTER_SITE_GITHUB:=ledger/}
+GITHUB_TAG=	v${PKGVERSION_NOREV}
+
+MAINTAINER=	base%atomicules.co.uk@localhost
+HOMEPAGE=	https://ledger-cli.org/
+COMMENT=	Double-entry accounting system for command-line
+LICENSE=	modified-bsd
+
+CONFLICTS+=	ledger32>=0
+
+USE_CXX_FEATURES+=	c++11
+
+USE_LANGUAGES=	c c++
+TEST_TARGET=	check
+TEST_ENV+=	LD_LIBRARY_PATH=${WRKSRC:Q}/${CMAKE_BUILD_DIR:Q}
+TEST_ENV+=	DYLD_LIBRARY_PATH=${WRKSRC:Q}/${CMAKE_BUILD_DIR:Q}
+
+# https://github.com/ledger/ledger/issues/2332
+PYTHON_VERSIONS_ACCEPTED=	311 310	# PyUnicode_GET_SIZE
+
+CMAKE_CONFIGURE_ARGS+=	-DPython_EXECUTABLE:STRING=${TOOL_PYTHONBIN:Q}
+CMAKE_CONFIGURE_ARGS+=	-DCMAKE_POLICY_VERSION_MINIMUM=3.5
+
+.include "options.mk"
+
+REPLACE_PYTHON+=	contrib/getquote-uk.py
+REPLACE_PYTHON+=	acprep
+REPLACE_PYTHON+=	python/demo.py
+REPLACE_PYTHON+=	test/DocTests.py
+REPLACE_PYTHON+=	test/LedgerHarness.py
+REPLACE_PYTHON+=	test/RegressTests.py
+REPLACE_PYTHON+=	test/convert.py
+REPLACE_PYTHON+=	tools/genuuid
+
+.include "../../devel/boost-headers/buildlink3.mk"
+.include "../../devel/boost-libs/buildlink3.mk"
+.include "../../devel/cmake/build.mk"
+.include "../../devel/editline/buildlink3.mk"
+.include "../../devel/gmp/buildlink3.mk"
+.include "../../lang/python/application.mk"
+.include "../../lang/python/tool.mk"
+.include "../../math/mpfr/buildlink3.mk"
+.include "../../textproc/utf8-cpp/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/ledger/PLIST b/ledger/PLIST
new file mode 100644
index 0000000000..b370b2cee5
--- /dev/null
+++ b/ledger/PLIST
@@ -0,0 +1,64 @@
+@comment $NetBSD: PLIST,v 1.4 2023/04/27 13:16:35 yhardy Exp $
+bin/ledger
+include/ledger/account.h
+include/ledger/amount.h
+include/ledger/annotate.h
+include/ledger/balance.h
+include/ledger/chain.h
+include/ledger/commodity.h
+include/ledger/compare.h
+include/ledger/context.h
+include/ledger/convert.h
+include/ledger/csv.h
+include/ledger/draft.h
+include/ledger/emacs.h
+include/ledger/error.h
+include/ledger/expr.h
+include/ledger/exprbase.h
+include/ledger/filters.h
+include/ledger/flags.h
+include/ledger/format.h
+include/ledger/generate.h
+include/ledger/global.h
+include/ledger/gpgme.h
+include/ledger/history.h
+include/ledger/item.h
+include/ledger/iterators.h
+include/ledger/journal.h
+include/ledger/lookup.h
+include/ledger/mask.h
+include/ledger/op.h
+include/ledger/option.h
+include/ledger/output.h
+include/ledger/parser.h
+include/ledger/pool.h
+include/ledger/post.h
+include/ledger/precmd.h
+include/ledger/predicate.h
+include/ledger/print.h
+include/ledger/pstream.h
+include/ledger/ptree.h
+include/ledger/pyinterp.h
+include/ledger/pyutils.h
+include/ledger/query.h
+include/ledger/quotes.h
+include/ledger/report.h
+include/ledger/scope.h
+include/ledger/select.h
+include/ledger/session.h
+include/ledger/stats.h
+include/ledger/stream.h
+include/ledger/system.hh
+include/ledger/temps.h
+include/ledger/timelog.h
+include/ledger/times.h
+include/ledger/token.h
+include/ledger/unistring.h
+include/ledger/utils.h
+include/ledger/value.h
+include/ledger/views.h
+include/ledger/xact.h
+lib/libledger.so
+lib/libledger.so.3
+${PLIST.python}${PYSITELIB}/ledger.so
+man/man1/ledger.1
diff --git a/ledger/distinfo b/ledger/distinfo
new file mode 100644
index 0000000000..e7dab8338e
--- /dev/null
+++ b/ledger/distinfo
@@ -0,0 +1,24 @@
+$NetBSD: distinfo,v 1.15 2025/10/17 08:50:14 wiz Exp $
+
+BLAKE2s (ledger-3.3.2.tar.gz) = 9204b163d03fe6d2d286614a47d65317d33c8d1bca885d7f3c9447f334b57d7c
+SHA512 (ledger-3.3.2.tar.gz) = d5d7058f0e9a02ad1d46e6780675d446070824b321f0f4c1ea6ac0c3dd4f11f259113bc36cbc796e4bb6d0a7898d6a68a25cce639e27a2b2434eec11a612ecb0
+Size (ledger-3.3.2.tar.gz) = 825274 bytes
+SHA1 (patch-CMakeLists.txt) = 9fea4c8b09c9b5325bc6d5a8134a9a4fb19055f1
+SHA1 (patch-src_CMakeLists.txt) = 8d6a16523554c98c8559702db681af6fb4f413aa
+SHA1 (patch-src_amount.cc) = 245d2dfe0182ca431188c324531ac1204be902be
+SHA1 (patch-src_expr.cc) = e707cbcba58a31534072ed490c9ba95f8dc4005d
+SHA1 (patch-src_filters.cc) = be5a1f382006ae014cea0c028d774f68d4e58ca8
+SHA1 (patch-src_format.cc) = c7fe4821bc86a9126978235fa44859f84ea92989
+SHA1 (patch-src_item.cc) = 5e97a09824a04092161d8a0ca956a43ef084a03d
+SHA1 (patch-src_lookup.cc) = 0140f88386a6a9bbfa82e48fca4f3555f40a03aa
+SHA1 (patch-src_main.cc) = 7e21f5d903e3148c184f7473d003eb2dc27581c5
+SHA1 (patch-src_option.cc) = e2fced2a03927b91afbc3b3e390b5e1d9ea09a6e
+SHA1 (patch-src_pool.cc) = 69198d4961646171b85b73fbfa6920cfe4a5ac5c
+SHA1 (patch-src_report.cc) = b17a06c54dd7c3b20e8219add23cf2b26095f6d7
+SHA1 (patch-src_strptime.cc) = 730ba4f65e10721ecf4a9135f3fe65d669f6cf47
+SHA1 (patch-src_system.hh.in) = 2993ef00740cbaa0ba60792e421a33642b8bba6e
+SHA1 (patch-src_textual.cc) = 698581b6193b39449f84ff27bc695a9b14c877c9
+SHA1 (patch-src_times.cc) = 544235432f6811f1a5c73ee72b3011709b606f17
+SHA1 (patch-src_utils.cc) = 06d8c17822a945a9d08c1122fb05f0568fdcf493
+SHA1 (patch-src_utils.h) = b050118f37e8fe2c030fdd1dd8affcbdc08626c5
+SHA1 (patch-src_xact.cc) = 89befd42102146e7a46f92ce458a7f1bc321ce55
diff --git a/ledger/options.mk b/ledger/options.mk
new file mode 100644
index 0000000000..6830156ac0
--- /dev/null
+++ b/ledger/options.mk
@@ -0,0 +1,23 @@
+# $NetBSD: options.mk,v 1.6 2025/05/06 12:07:31 wiz Exp $
+
+PKG_OPTIONS_VAR=	PKG_OPTIONS.ledger
+PKG_SUPPORTED_OPTIONS+=	python
+PKG_SUGGESTED_OPTIONS+=	python
+
+PLIST_VARS+=		python
+
+.include "../../mk/bsd.options.mk"
+
+.if !empty(PKG_OPTIONS:Mpython)
+CMAKE_CONFIGURE_ARGS+=		-DUSE_PYTHON:BOOL=TRUE
+PLIST.python=		yes
+PLIST_SUBST+=		PYSITELIB=${PYSITELIB:Q}
+.include "../../devel/py-boost/buildlink3.mk"
+
+# Remove when src/CMakeLists.txt (see FIXME there) stops copying
+# uninstalled library as Python module. Make symlink here to
+# avoid problem with install_name on Darwin and save disk-space.
+post-install:
+	cd ${DESTDIR}${PREFIX}/${PYSITELIB} && \
+	${LN} -s -f ${DESTDIR}${PREFIX}/lib/libledger.${SHLIB_EXT} ledger.so
+.endif
diff --git a/ledger/patches/patch-CMakeLists.txt b/ledger/patches/patch-CMakeLists.txt
new file mode 100644
index 0000000000..ae7a6cbf3f
--- /dev/null
+++ b/ledger/patches/patch-CMakeLists.txt
@@ -0,0 +1,15 @@
+$NetBSD: patch-CMakeLists.txt,v 1.3 2025/10/17 08:50:14 wiz Exp $
+
+boost 1.89 made system header-only.
+
+--- CMakeLists.txt.orig	2025-10-17 08:46:39.605560063 +0000
++++ CMakeLists.txt
+@@ -90,7 +90,7 @@ endif()
+ 
+ # Set BOOST_ROOT to help CMake to find the right Boost version
+ find_package(Boost 1.49.0
+-  REQUIRED date_time filesystem system iostreams regex unit_test_framework
++  REQUIRED date_time filesystem iostreams regex unit_test_framework
+   ${BOOST_PYTHON} OPTIONAL_COMPONENTS nowide)
+ 
+ # enable Boost::nowide library (for UTF8 command line args on Windows)
diff --git a/ledger/patches/patch-src_CMakeLists.txt b/ledger/patches/patch-src_CMakeLists.txt
new file mode 100644
index 0000000000..b4bf915e9d
--- /dev/null
+++ b/ledger/patches/patch-src_CMakeLists.txt
@@ -0,0 +1,16 @@
+$NetBSD: patch-src_CMakeLists.txt,v 1.1 2020/06/15 16:54:38 adam Exp $
+
+Fix problem with install_name.
+
+--- src/CMakeLists.txt.orig	2020-05-18 05:30:10.000000000 +0000
++++ src/CMakeLists.txt
+@@ -277,8 +277,7 @@ if (BUILD_LIBRARY)
+   add_library(libledger SHARED ${LEDGER_SOURCES})
+   add_ledger_library_dependencies(libledger)
+   set_target_properties(libledger PROPERTIES
+-    PREFIX ""
+-    INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
++    OUTPUT_NAME "ledger"
+     VERSION ${Ledger_VERSION_MAJOR}
+     SOVERSION ${Ledger_VERSION_MAJOR})
+ 
diff --git a/ledger/patches/patch-src_amount.cc b/ledger/patches/patch-src_amount.cc
new file mode 100644
index 0000000000..553860607e
--- /dev/null
+++ b/ledger/patches/patch-src_amount.cc
@@ -0,0 +1,35 @@
+$NetBSD: patch-src_amount.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/amount.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/amount.cc
+@@ -983,7 +983,8 @@ namespace {
+               std::isdigit(c) || c == '.' || c == ',');
+ 
+     string::size_type len = std::strlen(buf);
+-    while (len > 0 && ! std::isdigit(buf[len - 1])) {
++    while (len > 0 &&
++           ! std::isdigit(static_cast<unsigned char>(buf[len - 1]))) {
+       buf[--len] = '\0';
+       in.unget();
+     }
+@@ -1018,7 +1019,7 @@ bool amount_t::parse(std::istream& in, c
+     parse_quantity(in, quant);
+ 
+     if (! in.eof() && ((n = static_cast<char>(in.peek())) != '\n')) {
+-      if (std::isspace(n))
++      if (std::isspace(static_cast<unsigned char>(n)))
+         comm_flags |= COMMODITY_STYLE_SEPARATED;
+ 
+       commodity_t::parse_symbol(in, symbol);
+@@ -1034,7 +1035,7 @@ bool amount_t::parse(std::istream& in, c
+     commodity_t::parse_symbol(in, symbol);
+ 
+     if (! in.eof() && ((n = static_cast<char>(in.peek())) != '\n')) {
+-      if (std::isspace(static_cast<char>(in.peek())))
++      if (std::isspace(in.peek()))
+         comm_flags |= COMMODITY_STYLE_SEPARATED;
+ 
+       parse_quantity(in, quant);
diff --git a/ledger/patches/patch-src_expr.cc b/ledger/patches/patch-src_expr.cc
new file mode 100644
index 0000000000..222be8a8d4
--- /dev/null
+++ b/ledger/patches/patch-src_expr.cc
@@ -0,0 +1,16 @@
+$NetBSD: patch-src_expr.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/expr.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/expr.cc
+@@ -222,7 +222,7 @@ bool merged_expr_t::check_for_single_ide
+ {
+   bool single_identifier = true;
+   for (const char * p = expr.c_str(); *p; ++p)
+-    if (! std::isalnum(*p) || *p == '_') {
++    if (! std::isalnum(static_cast<unsigned char>(*p)) || *p == '_') {
+       single_identifier = false;
+       break;
+     }
diff --git a/ledger/patches/patch-src_filters.cc b/ledger/patches/patch-src_filters.cc
new file mode 100644
index 0000000000..e0fbbc57b2
--- /dev/null
+++ b/ledger/patches/patch-src_filters.cc
@@ -0,0 +1,25 @@
+$NetBSD: patch-src_filters.cc,v 1.1 2024/11/26 22:59:34 riastradh Exp $
+
+Fix build with boost>=1.86, which broke API compatibility.
+https://github.com/ledger/ledger/issues/2378
+
+--- src/filters.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/filters.cc
+@@ -238,7 +238,7 @@ void anonymize_posts::render_commodity(a
+ void anonymize_posts::operator()(post_t& post)
+ {
+ 	boost::uuids::detail::sha1  sha;
+-  unsigned int message_digest[5];
++  unsigned char message_digest[20];
+   bool         copy_xact_details = false;
+ 
+   if (last_xact != post.xact) {
+@@ -1268,7 +1268,7 @@ void budget_posts::report_budget_items(c
+     foreach (pending_posts_list::iterator& i, posts_to_erase)
+       pending_posts.erase(i);
+   }
+-  
++
+   if (pending_posts.size() == 0)
+     return;
+ 
diff --git a/ledger/patches/patch-src_format.cc b/ledger/patches/patch-src_format.cc
new file mode 100644
index 0000000000..0ec5d8fa0c
--- /dev/null
+++ b/ledger/patches/patch-src_format.cc
@@ -0,0 +1,78 @@
+$NetBSD: patch-src_format.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/format.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/format.cc
+@@ -109,7 +109,7 @@ namespace {
+ 
+       // Don't gobble up any whitespace
+       const char * base = p;
+-      while (p >= base && std::isspace(*p))
++      while (p >= base && std::isspace(static_cast<unsigned char>(*p)))
+         p--;
+     }
+     return expr;
+@@ -183,7 +183,7 @@ format_t::element_t * format_t::parse_el
+     }
+ 
+     std::size_t num = 0;
+-    while (*p && std::isdigit(*p)) {
++    while (*p && std::isdigit(static_cast<unsigned char>(*p))) {
+       num *= 10;
+       num += static_cast<std::size_t>(*p++ - '0');
+     }
+@@ -192,7 +192,7 @@ format_t::element_t * format_t::parse_el
+     if (*p == '.') {
+       ++p;
+       num = 0;
+-      while (*p && std::isdigit(*p)) {
++      while (*p && std::isdigit(static_cast<unsigned char>(*p))) {
+         num *= 10;
+         num += static_cast<std::size_t>(*p++ - '0');
+       }
+@@ -201,7 +201,7 @@ format_t::element_t * format_t::parse_el
+         current->min_width = current->max_width;
+     }
+ 
+-    if (std::isalpha(*p)) {
++    if (std::isalpha(static_cast<unsigned char>(*p))) {
+       bool found = false;
+       for (std::size_t i = 0; i < (sizeof(single_letter_mappings) /
+                                    sizeof(format_mapping_t)); i++) {
+@@ -210,7 +210,7 @@ format_t::element_t * format_t::parse_el
+           for (const char * ptr = single_letter_mappings[i].expr; *ptr;) {
+             if (*ptr == '$') {
+               const char * beg = ++ptr;
+-              while (*ptr && std::isalpha(*ptr))
++              while (*ptr && std::isalpha(static_cast<unsigned char>(*ptr)))
+                 ++ptr;
+               string::size_type klen = static_cast<string::size_type>(ptr - beg);
+               string keyword(beg, 0, klen);
+@@ -250,12 +250,13 @@ format_t::element_t * format_t::parse_el
+           throw_(format_error, _("Prior field reference, but no template"));
+ 
+         p++;
+-        if (*p == '0' || (! std::isdigit(*p) &&
++        if (*p == '0' || (! std::isdigit(static_cast<unsigned char>(*p)) &&
+                           *p != 'A' && *p != 'B' && *p != 'C' &&
+                           *p != 'D' && *p != 'E' && *p != 'F'))
+           throw_(format_error, _("%$ field reference must be a digit from 1-9"));
+ 
+-        int         index     = std::isdigit(*p) ? *p - '0' : (*p - 'A' + 10);
++        int         index     = std::isdigit(static_cast<unsigned char>(*p))
++          ? *p - '0' : (*p - 'A' + 10);
+         element_t * tmpl_elem = tmpl->elements.get();
+ 
+         for (int i = 1; i < index && tmpl_elem; i++) {
+@@ -630,7 +631,8 @@ string format_t::truncate(const unistrin
+           if (adjust > 0) {
+             DEBUG("format.abbrev",
+                   "Reducing segment " << ++index << " by " << adjust << " chars");
+-            while (std::isspace((*x)[*i - adjust - 1]) && adjust < *i) {
++            while (std::isspace(static_cast<unsigned char>(
++                (*x)[*i - adjust - 1])) && adjust < *i) {
+               DEBUG("format.abbrev",
+                     "Segment ends in whitespace, adjusting down");
+               ++adjust;
diff --git a/ledger/patches/patch-src_item.cc b/ledger/patches/patch-src_item.cc
new file mode 100644
index 0000000000..060ffe07b1
--- /dev/null
+++ b/ledger/patches/patch-src_item.cc
@@ -0,0 +1,17 @@
+$NetBSD: patch-src_item.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/item.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/item.cc
+@@ -151,7 +151,8 @@ void item_t::parse_tags(const char * p,
+   if (! std::strchr(p, ':')) {
+     if (const char * b = std::strchr(p, '[')) {
+       if (*(b + 1) != '\0' &&
+-          (std::isdigit(*(b + 1)) || *(b + 1) == '=')) {
++          (std::isdigit(static_cast<unsigned char>(*(b + 1))) ||
++           *(b + 1) == '=')) {
+         if (const char * e = std::strchr(b, ']')) {
+           char buf[256];
+           std::strncpy(buf, b + 1, static_cast<std::size_t>(e - b - 1));
diff --git a/ledger/patches/patch-src_lookup.cc b/ledger/patches/patch-src_lookup.cc
new file mode 100644
index 0000000000..4f506abdcd
--- /dev/null
+++ b/ledger/patches/patch-src_lookup.cc
@@ -0,0 +1,22 @@
+$NetBSD: patch-src_lookup.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/lookup.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/lookup.cc
+@@ -188,7 +188,13 @@ lookup_probable_account(const string& id
+ 
+ #if 0
+ #if !HAVE_BOOST_REGEX_UNICODE
+-          if (pos == 0 || (pos > 0 && !std::isalnum(value_key[pos - 1])))
++          // Probably doesn't make sense with value_key as unistring,
++          // but this code is under #if 0 anyway, so if anyone is
++          // tempted to use this by changing value_key to string, let's
++          // avoid leaving a rake to step on.
++          if (pos == 0 ||
++              (pos > 0 &&
++               !std::isalnum(static_cast<unsigned char>(value_key[pos - 1]))))
+             addend++;
+ #else
+           // jww (2010-03-07): Not yet implemented
diff --git a/ledger/patches/patch-src_main.cc b/ledger/patches/patch-src_main.cc
new file mode 100644
index 0000000000..722780c0c2
--- /dev/null
+++ b/ledger/patches/patch-src_main.cc
@@ -0,0 +1,18 @@
+$NetBSD: patch-src_main.cc,v 1.2 2023/04/27 13:16:35 yhardy Exp $
+
+Canonicalize pkgsrc readline.h filename.  This is seen both by
+consumers of devel/readline and by consumers of devel/editline, via
+buildlink3 magic.  The only reason editline/readline.h may exist is to
+allow both devel/readline and devel/editline to coexist.
+
+--- src/main.cc.orig	2023-03-03 10:49:39.000000000 +0000
++++ src/main.cc
+@@ -40,7 +40,7 @@
+ #endif
+ 
+ #ifdef HAVE_EDIT
+-#include <editline/readline.h>
++#include <readline/readline.h>
+ #endif
+ 
+ using namespace ledger;
diff --git a/ledger/patches/patch-src_option.cc b/ledger/patches/patch-src_option.cc
new file mode 100644
index 0000000000..38f9a6d79b
--- /dev/null
+++ b/ledger/patches/patch-src_option.cc
@@ -0,0 +1,17 @@
+$NetBSD: patch-src_option.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/option.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/option.cc
+@@ -132,7 +132,8 @@ void process_environment(const char ** e
+         if (*q == '_')
+           *r++ = '-';
+         else
+-          *r++ = static_cast<char>(std::tolower(*q));
++          *r++ = static_cast<char>(std::tolower(
++            static_cast<unsigned char>(*q)));
+       *r = '\0';
+ 
+       if (*q == '=') {
diff --git a/ledger/patches/patch-src_pool.cc b/ledger/patches/patch-src_pool.cc
new file mode 100644
index 0000000000..6dbe32db7a
--- /dev/null
+++ b/ledger/patches/patch-src_pool.cc
@@ -0,0 +1,25 @@
+$NetBSD: patch-src_pool.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/pool.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/pool.cc
+@@ -327,13 +327,15 @@ commodity_pool_t::parse_price_directive
+   datetime_t datetime;
+   string     symbol;
+ 
+-  if (! no_date && std::isdigit(time_field_ptr[0])) {
++  if (! no_date &&
++      std::isdigit(static_cast<unsigned char>(time_field_ptr[0]))) {
+     symbol_and_price = next_element(time_field_ptr);
+     if (! symbol_and_price) return none;
+ 
+     datetime = parse_datetime(date_field + " " + time_field_ptr);
+   }
+-  else if (! no_date && std::isdigit(date_field_ptr[0])) {
++  else if (! no_date &&
++           std::isdigit(static_cast<unsigned char>(date_field_ptr[0]))) {
+     symbol_and_price = time_field_ptr;
+     datetime = datetime_t(parse_date(date_field));
+   }
diff --git a/ledger/patches/patch-src_report.cc b/ledger/patches/patch-src_report.cc
new file mode 100644
index 0000000000..1755317040
--- /dev/null
+++ b/ledger/patches/patch-src_report.cc
@@ -0,0 +1,20 @@
+$NetBSD: patch-src_report.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/report.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/report.cc
+@@ -642,10 +642,10 @@ value_t report_t::fn_trim(call_scope_t& 
+   const char * p = buf.get();
+   const char * e = buf.get() + temp.length() - 1;
+ 
+-  while (p <= e && std::isspace(*p))
++  while (p <= e && std::isspace(static_cast<unsigned char>(*p)))
+     p++;
+ 
+-  while (e > p && std::isspace(*e))
++  while (e > p && std::isspace(static_cast<unsigned char>(*e)))
+     e--;
+ 
+   if (p > e) {
diff --git a/ledger/patches/patch-src_strptime.cc b/ledger/patches/patch-src_strptime.cc
new file mode 100644
index 0000000000..60c931f1ba
--- /dev/null
+++ b/ledger/patches/patch-src_strptime.cc
@@ -0,0 +1,27 @@
+$NetBSD: patch-src_strptime.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/strptime.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/strptime.cc
+@@ -62,7 +62,9 @@ static const char* kMonthAbbr[] = {
+ 
+ static const char* _parse_num(const char* s, int low, int high, int* value) {
+   const char* p = s;
+-  for (*value = 0; *p != NULL && isdigit(*p); ++p) {
++  for (*value = 0;
++       *p != NULL && isdigit(static_cast<unsigned char>(*p));
++       ++p) {
+     *value = (*value) * 10 + static_cast<int>(*p) - static_cast<int>('0');
+   }
+ 
+@@ -177,7 +179,7 @@ static char* _strptime(const char *s, co
+       // arbitrary whitespace.
+       case 't':
+       case 'n':
+-        while (isspace(*s)) ++s;
++        while (isspace(static_cast<unsigned char>(*s))) ++s;
+         break;
+ 
+       // '%'.
diff --git a/ledger/patches/patch-src_system.hh.in b/ledger/patches/patch-src_system.hh.in
new file mode 100644
index 0000000000..bbceedc722
--- /dev/null
+++ b/ledger/patches/patch-src_system.hh.in
@@ -0,0 +1,14 @@
+$NetBSD: patch-src_system.hh.in,v 1.3 2024/04/18 17:42:17 adam Exp $
+
+Fix build with newer boost.
+
+--- src/system.hh.in.orig	2024-04-18 17:33:59.959388333 +0000
++++ src/system.hh.in
+@@ -144,7 +144,6 @@
+ #include <boost/date_time/posix_time/posix_time_io.hpp>
+ #include <boost/date_time/gregorian/gregorian_io.hpp>
+ 
+-#include <boost/filesystem/convenience.hpp>
+ #include <boost/filesystem/exception.hpp>
+ #include <boost/filesystem/fstream.hpp>
+ #include <boost/filesystem/operations.hpp>
diff --git a/ledger/patches/patch-src_textual.cc b/ledger/patches/patch-src_textual.cc
new file mode 100644
index 0000000000..588270c523
--- /dev/null
+++ b/ledger/patches/patch-src_textual.cc
@@ -0,0 +1,110 @@
+$NetBSD: patch-src_textual.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/textual.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/textual.cc
+@@ -340,7 +340,8 @@ std::streamsize instance_t::read_line(ch
+         --len;
+     }
+ 
+-    while (len > 0 && std::isspace(line[len - 1])) // strip trailing whitespace
++    // strip trailing whitespace
++    while (len > 0 && std::isspace(static_cast<unsigned char>(line[len - 1])))
+       line[--len] = '\0';
+ 
+     return len;
+@@ -355,7 +356,7 @@ void instance_t::read_next_directive(boo
+   if (len == 0 || line == NULL)
+     return;
+ 
+-  if (! std::isspace(line[0]))
++  if (! std::isspace(static_cast<unsigned char>(line[0])))
+     error_flag = false;
+ 
+   switch (line[0]) {
+@@ -615,12 +616,16 @@ void instance_t::automated_xact_directiv
+         item->pos->end_line++;
+       }
+       else if ((remlen > 7 && *p == 'a' &&
+-                std::strncmp(p, "assert", 6) == 0 && std::isspace(p[6])) ||
++                std::strncmp(p, "assert", 6) == 0 &&
++                std::isspace(static_cast<unsigned char>(p[6]))) ||
+                (remlen > 6 && *p == 'c' &&
+-                std::strncmp(p, "check", 5) == 0 && std::isspace(p[5])) ||
++                std::strncmp(p, "check", 5) == 0 &&
++                std::isspace(static_cast<unsigned char>(p[5]))) ||
+                (remlen > 5 && *p == 'e' &&
+-                ((std::strncmp(p, "expr", 4) == 0 && std::isspace(p[4])) ||
+-                 (std::strncmp(p, "eval", 4) == 0 && std::isspace(p[4]))))) {
++                ((std::strncmp(p, "expr", 4) == 0 &&
++                  std::isspace(static_cast<unsigned char>(p[4]))) ||
++                 (std::strncmp(p, "eval", 4) == 0 &&
++                  std::isspace(static_cast<unsigned char>(p[4])))))) {
+         const char c = *p;
+         p = skip_ws(&p[*p == 'a' ? 6 : (*p == 'c' ? 5 : 4)]);
+         if (! ae->check_exprs)
+@@ -1015,7 +1020,7 @@ void instance_t::alias_directive(char * 
+ {
+   if (char * e = std::strchr(line, '=')) {
+     char * z = e - 1;
+-    while (std::isspace(*z))
++    while (std::isspace(static_cast<unsigned char>(*z)))
+       *z-- = '\0';
+     *e++ = '\0';
+     e = skip_ws(e);
+@@ -1234,7 +1239,7 @@ void instance_t::python_directive(char *
+     if (read_line(line) > 0) {
+       if (! indent) {
+         const char * p = line;
+-        while (*p && std::isspace(*p)) {
++        while (*p && std::isspace(static_cast<unsigned char>(*p))) {
+           ++indent;
+           ++p;
+         }
+@@ -1242,7 +1247,7 @@ void instance_t::python_directive(char *
+ 
+       const char * p = line;
+       for (std::size_t i = 0; i < indent; i++) {
+-        if (std::isspace(*p))
++        if (std::isspace(static_cast<unsigned char>(*p)))
+           ++p;
+         else
+           break;
+@@ -1473,7 +1478,7 @@ post_t * instance_t::parse_post(char *  
+   char * next = next_element(p, true);
+   char * e = p + std::strlen(p);
+ 
+-  while (e > p && std::isspace(*(e - 1)))
++  while (e > p && std::isspace(static_cast<unsigned char>(*(e - 1))))
+     e--;
+ 
+   if ((*p == '[' && *(e - 1) == ']') || (*p == '(' && *(e - 1) == ')')) {
+@@ -1884,7 +1889,7 @@ xact_t * instance_t::parse_xact(char *  
+       }
+       else if (*p == ';' && (tabs > 0 || spaces > 1)) {
+         char *q = p - 1;
+-        while (q > next && std::isspace(*q))
++        while (q > next && std::isspace(static_cast<unsigned char>(*q)))
+           --q;
+         if (q >= next)
+           *(q + 1) = '\0';
+@@ -1937,11 +1942,14 @@ xact_t * instance_t::parse_xact(char *  
+       item->pos->end_line++;
+     }
+     else if ((remlen > 7 && *p == 'a' &&
+-              std::strncmp(p, "assert", 6) == 0 && std::isspace(p[6])) ||
++              std::strncmp(p, "assert", 6) == 0 &&
++              std::isspace(static_cast<unsigned char>(p[6]))) ||
+              (remlen > 6 && *p == 'c' &&
+-              std::strncmp(p, "check", 5) == 0 && std::isspace(p[5])) ||
++              std::strncmp(p, "check", 5) == 0 &&
++              std::isspace(static_cast<unsigned char>(p[5]))) ||
+              (remlen > 5 && *p == 'e' &&
+-              std::strncmp(p, "expr", 4) == 0 && std::isspace(p[4]))) {
++              std::strncmp(p, "expr", 4) == 0 &&
++              std::isspace(static_cast<unsigned char>(p[4])))) {
+       const char c = *p;
+       p = skip_ws(&p[*p == 'a' ? 6 : (*p == 'c' ? 5 : 4)]);
+       expr_t expr(p);
diff --git a/ledger/patches/patch-src_times.cc b/ledger/patches/patch-src_times.cc
new file mode 100644
index 0000000000..3231133a64
--- /dev/null
+++ b/ledger/patches/patch-src_times.cc
@@ -0,0 +1,57 @@
+$NetBSD: patch-src_times.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/times.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/times.cc
+@@ -1467,7 +1467,7 @@ date_parser_t::lexer_t::token_t date_par
+     return tok;
+   }
+ 
+-  while (begin != end && std::isspace(*begin))
++  while (begin != end && std::isspace(static_cast<unsigned char>(*begin)))
+     begin++;
+ 
+   if (begin == end)
+@@ -1486,9 +1486,11 @@ date_parser_t::lexer_t::token_t date_par
+   // date using the typical date formats.  This allows not only dates like
+   // "2009/08/01", but also dates that fit the user's --input-date-format,
+   // assuming their format fits in one argument and begins with a digit.
+-  if (std::isdigit(*begin)) {
++  if (std::isdigit(static_cast<unsigned char>(*begin))) {
+     string::const_iterator i = begin;
+-    for (i = begin; i != end && ! std::isspace(*i); i++) {}
++    for (i = begin;
++         i != end && ! std::isspace(static_cast<unsigned char>(*i));
++         i++) {}
+     assert(i != begin);
+ 
+     string possible_date(start, i);
+@@ -1513,18 +1515,20 @@ date_parser_t::lexer_t::token_t date_par
+   start = begin;
+ 
+   string term;
+-  bool alnum = std::isalnum(*begin);
+-  for (; (begin != end && ! std::isspace(*begin) &&
+-          ((alnum && static_cast<bool>(std::isalnum(*begin))) ||
+-           (! alnum && ! static_cast<bool>(std::isalnum(*begin))))); begin++)
++  bool alnum = std::isalnum(static_cast<unsigned char>(*begin));
++  for (; (begin != end && ! std::isspace(static_cast<unsigned char>(*begin)) &&
++          ((alnum && static_cast<bool>(std::isalnum(
++             static_cast<unsigned char>(*begin)))) ||
++           (! alnum && ! static_cast<bool>(std::isalnum(
++             static_cast<unsigned char>(*begin)))))); begin++)
+     term.push_back(*begin);
+ 
+   if (! term.empty()) {
+-    if (std::isdigit(term[0])) {
++    if (std::isdigit(static_cast<unsigned char>(term[0]))) {
+       return token_t(token_t::TOK_INT,
+                      token_t::content_t(lexical_cast<unsigned short>(term)));
+     }
+-    else if (std::isalpha(term[0])) {
++    else if (std::isalpha(static_cast<unsigned char>(term[0]))) {
+       to_lower(term);
+ 
+       if (optional<date_time::months_of_year> month =
diff --git a/ledger/patches/patch-src_utils.cc b/ledger/patches/patch-src_utils.cc
new file mode 100644
index 0000000000..72311d70f6
--- /dev/null
+++ b/ledger/patches/patch-src_utils.cc
@@ -0,0 +1,16 @@
+$NetBSD: patch-src_utils.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/utils.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/utils.cc
+@@ -516,7 +516,7 @@ strings_list split_arguments(const char 
+   char in_quoted_string = '\0';
+ 
+   for (const char * p = line; *p; p++) {
+-    if (! in_quoted_string && std::isspace(*p)) {
++    if (! in_quoted_string && std::isspace(static_cast<unsigned char>(*p))) {
+       if (q != buf) {
+         *q = '\0';
+         args.push_back(buf);
diff --git a/ledger/patches/patch-src_utils.h b/ledger/patches/patch-src_utils.h
new file mode 100644
index 0000000000..fef0a285a0
--- /dev/null
+++ b/ledger/patches/patch-src_utils.h
@@ -0,0 +1,38 @@
+$NetBSD: patch-src_utils.h,v 1.3 2024/11/26 22:59:34 riastradh Exp $
+
+Fix build with boost>=1.86, which broke API compatibility.
+https://github.com/ledger/ledger/issues/2378
+
+--- src/utils.h.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/utils.h
+@@ -607,14 +607,14 @@ inline int peek_next_nonws(std::istream&
+     *_p = '\0';                                         \
+   }
+ 
+-inline string to_hex(unsigned int * message_digest, const int len = 1)
++inline string to_hex(unsigned char * message_digest, const int len = 4)
+ {
+   std::ostringstream buf;
+ 
+-  for(int i = 0; i < 5 ; i++) {
+-    buf.width(8);
++  for(int i = 0; i < 20 ; i++) {
++    buf.width(2);
+     buf.fill('0');
+-    buf << std::hex << message_digest[i];
++    buf << std::hex << (int)message_digest[i];
+     if (i + 1 >= len)
+       break;                    // only output the first LEN dwords
+   }
+@@ -627,9 +627,9 @@ inline string sha1sum(const string& str)
+ 
+   sha.process_bytes(str.c_str(), str.length());
+ 
+-  unsigned int message_digest[5];
++  unsigned char message_digest[20];
+   sha.get_digest(message_digest);
+-  return to_hex(message_digest, 5);
++  return to_hex(message_digest, 20);
+ }
+ 
+ extern const string version;
diff --git a/ledger/patches/patch-src_xact.cc b/ledger/patches/patch-src_xact.cc
new file mode 100644
index 0000000000..1cecdf3bcb
--- /dev/null
+++ b/ledger/patches/patch-src_xact.cc
@@ -0,0 +1,20 @@
+$NetBSD: patch-src_xact.cc,v 1.1 2024/05/02 13:27:04 riastradh Exp $
+
+Fix ctype abuse.
+https://github.com/ledger/ledger/pull/2341
+
+--- src/xact.cc.orig	2023-03-30 07:40:48.000000000 +0000
++++ src/xact.cc
+@@ -116,8 +116,10 @@ value_t xact_base_t::magnitude() const
+ namespace {
+   inline bool account_ends_with_special_char(const string& name) {
+     string::size_type len(name.length());
+-    return (std::isdigit(name[len - 1]) || name[len - 1] == ')' ||
+-            name[len - 1] == '}' || name[len - 1] == ']');
++    return (std::isdigit(static_cast<unsigned char>(name[len - 1])) ||
++            name[len - 1] == ')' ||
++            name[len - 1] == '}' ||
++            name[len - 1] == ']');
+   }
+ 
+   struct add_balancing_post


Home | Main Index | Thread Index | Old Index