summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2003-09-30 07:17:02 +0000
committerJohn Wiegley <johnw@newartisans.com>2003-09-30 07:17:02 +0000
commit85c92e10db043170adbe9a36152907dbb0ea8138 (patch)
treeeafde5c72272c055378a43b843428fdca7643bda
parent5bd2401bc7cde0e01cd5b9d18cf077e255c4bd45 (diff)
downloadfork-ledger-85c92e10db043170adbe9a36152907dbb0ea8138.tar.gz
fork-ledger-85c92e10db043170adbe9a36152907dbb0ea8138.tar.bz2
fork-ledger-85c92e10db043170adbe9a36152907dbb0ea8138.zip
*** empty log message ***
-rw-r--r--Makefile14
-rw-r--r--amount.cc11
-rw-r--r--ledger.cc3
-rw-r--r--parse.cc3
4 files changed, 24 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index acabc563..96db5db4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,21 @@
-CODE = amount.cc ledger.cc parse.cc gnucash.cc balance.cc main.cc
+define GNUCASH
+true
+endef
+
+CODE = amount.cc ledger.cc parse.cc balance.cc main.cc
+ifdef GNUCASH
+CODE := $(CODE) gnucash.cc
+endif
OBJS = $(patsubst %.cc,%.o,$(CODE))
CFLAGS = -Wall -ansi -pedantic
DFLAGS = -g
INCS = -I/usr/include/xmltok
-LIBS = -lgmpxx -lgmp -lpcre -lxmlparse
+LIBS = -lgmpxx -lgmp -lpcre
+ifdef GNUCASH
+LIBS := $(LIBS) -lxmlparse
+endif
all: make.deps ledger
diff --git a/amount.cc b/amount.cc
index 8a880e5b..69b3a6bd 100644
--- a/amount.cc
+++ b/amount.cc
@@ -268,7 +268,11 @@ static std::string amount_to_str(const commodity * comm, const mpz_t val,
if (negative)
s << "-";
- if (comm->thousands) {
+ if (mpz_sgn(quotient) == 0)
+ s << '0';
+ else if (! comm->thousands)
+ s << quotient;
+ else {
// jww (2003-09-29): use a smarter starting value
bool printed = false;
@@ -298,8 +302,6 @@ static std::string amount_to_str(const commodity * comm, const mpz_t val,
printed = true;
}
}
- } else {
- s << quotient;
}
if (comm->european)
@@ -320,7 +322,8 @@ static std::string amount_to_str(const commodity * comm, const mpz_t val,
width = MAX_PRECISION - width;
- while (p >= buf && *p == '0')
+ while (p >= buf && *p == '0' &&
+ (p - buf) >= (comm->precision - width))
p--;
*(p + 1) = '\0';
diff --git a/ledger.cc b/ledger.cc
index 301e109b..7829173b 100644
--- a/ledger.cc
+++ b/ledger.cc
@@ -45,10 +45,11 @@ void entry::print(std::ostream& out) const
out << std::right << (*i)->cost->as_str(true);
if (! (*i)->note.empty())
- out << " ; " << (*i)->note;
+ out << " ; " << (*i)->note;
out << std::endl;
}
+ out << std::endl;
}
bool entry::validate() const
diff --git a/parse.cc b/parse.cc
index 579bc432..90369a1e 100644
--- a/parse.cc
+++ b/parse.cc
@@ -78,6 +78,9 @@ bool parse_ledger(std::istream& in)
if (in.eof()) {
break;
}
+ else if (line[0] == '\n') {
+ continue;
+ }
else if (std::isdigit(line[0])) {
static char buf[256];
int ovector[60];