diff options
author | John Wiegley <johnw@newartisans.com> | 2003-09-30 07:17:02 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2003-09-30 07:17:02 +0000 |
commit | 85c92e10db043170adbe9a36152907dbb0ea8138 (patch) | |
tree | eafde5c72272c055378a43b843428fdca7643bda | |
parent | 5bd2401bc7cde0e01cd5b9d18cf077e255c4bd45 (diff) | |
download | fork-ledger-85c92e10db043170adbe9a36152907dbb0ea8138.tar.gz fork-ledger-85c92e10db043170adbe9a36152907dbb0ea8138.tar.bz2 fork-ledger-85c92e10db043170adbe9a36152907dbb0ea8138.zip |
*** empty log message ***
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | amount.cc | 11 | ||||
-rw-r--r-- | ledger.cc | 3 | ||||
-rw-r--r-- | parse.cc | 3 |
4 files changed, 24 insertions, 7 deletions
@@ -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 @@ -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'; @@ -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 @@ -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]; |