[Nix-dev] [PATCH] Fix ledger to compile with recent gcc.

David Brown nix at davidb.org
Tue May 18 21:48:30 CEST 2010


Also makes ledger overridable.
---
 pkgs/applications/office/ledger/const.patch |   41 +++++++++++++++++++++++++++
 pkgs/applications/office/ledger/default.nix |    2 +
 pkgs/top-level/all-packages.nix             |    2 +-
 3 files changed, 44 insertions(+), 1 deletions(-)
 create mode 100644 pkgs/applications/office/ledger/const.patch

diff --git a/pkgs/applications/office/ledger/const.patch b/pkgs/applications/office/ledger/const.patch
new file mode 100644
index 0000000..9a51fc0
--- /dev/null
+++ b/pkgs/applications/office/ledger/const.patch
@@ -0,0 +1,41 @@
+diff --git a/gnucash.cc b/gnucash.cc
+index 7d31526..c4edd77 100644
+--- a/gnucash.cc
++++ b/gnucash.cc
+@@ -201,7 +201,7 @@ static amount_t convert_number(const std::string& number,
+ {
+   const char * num = number.c_str();
+ 
+-  if (char * p = std::strchr(num, '/')) {
++  if (const char * p = std::strchr(num, '/')) {
+     std::string numer_str(num, p - num);
+     std::string denom_str(p + 1);
+ 
+diff --git a/option.cc b/option.cc
+index 10c23a7..8f2fead 100644
+--- a/option.cc
++++ b/option.cc
+@@ -892,7 +892,7 @@ OPT_BEGIN(market, "V") {
+ namespace {
+   void parse_price_setting(const char * optarg)
+   {
+-    char * equals = std::strchr(optarg, '=');
++    const char * equals = std::strchr(optarg, '=');
+     if (! equals)
+       return;
+ 
+diff --git a/textual.cc b/textual.cc
+index 2033106..d897368 100644
+--- a/textual.cc
++++ b/textual.cc
+@@ -298,8 +298,8 @@ transaction_t * parse_transaction(char * line, account_t * account,
+       DEBUG_PRINT("ledger.textual.parse", "line " << linenum << ": " <<
+ 		  "Parsed a note '" << xact->note << "'");
+ 
+-      if (char * b = std::strchr(xact->note.c_str(), '['))
+-	if (char * e = std::strchr(xact->note.c_str(), ']')) {
++      if (const char * b = std::strchr(xact->note.c_str(), '['))
++	if (const char * e = std::strchr(xact->note.c_str(), ']')) {
+ 	  char buf[256];
+ 	  std::strncpy(buf, b + 1, e - b - 1);
+ 	  buf[e - b - 1] = '\0';
diff --git a/pkgs/applications/office/ledger/default.nix b/pkgs/applications/office/ledger/default.nix
index c6c2fd4..14121e6 100644
--- a/pkgs/applications/office/ledger/default.nix
+++ b/pkgs/applications/office/ledger/default.nix
@@ -20,6 +20,8 @@ stdenv.mkDerivation {
 
   buildInputs = [ emacs gmp pcre ];
 
+  patches = [ ./const.patch ];
+
   # Something goes wrong with pathelf...
   # this is a small workaround: adds a small shell script for
   # setting LD_LIBRARY_PATH
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 848d712..91f7d3c 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -8037,7 +8037,7 @@ let
     inherit fetchurl stdenv;
   };
 
-  ledger = import ../applications/office/ledger {
+  ledger = makeOverridable (import ../applications/office/ledger) {
     inherit stdenv fetchurl emacs gmp pcre;
   };
 
-- 
1.7.1




More information about the nix-dev mailing list