summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-07-18 04:24:49 -0400
committerjohnw <johnw@newartisans.com>2004-07-18 04:24:49 -0400
commitfde56d0f1214b8fb9de5ba4d42d683ed494c45b0 (patch)
tree7e49f494b2a9b2b57e3fab62ef12004a7d279c04
parenta8c4ecbc8ecd887d54a4aa5483580f2031dda205 (diff)
downloadfork-ledger-fde56d0f1214b8fb9de5ba4d42d683ed494c45b0.tar.gz
fork-ledger-fde56d0f1214b8fb9de5ba4d42d683ed494c45b0.tar.bz2
fork-ledger-fde56d0f1214b8fb9de5ba4d42d683ed494c45b0.zip
fix to european number handling
-rw-r--r--Makefile10
-rw-r--r--amount.cc16
2 files changed, 13 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index cae7c23e..6ff88b8b 100644
--- a/Makefile
+++ b/Makefile
@@ -2,11 +2,11 @@ CODE = amount.cc ledger.cc parse.cc reports.cc
OBJS = $(patsubst %.cc,%.o,$(CODE))
#CXX = cc
CXX = g++
-CFLAGS = -Wall -ansi -pedantic
-#DFLAGS = -O3 -fomit-frame-pointer
-DFLAGS = -g -DDEBUG=1
-INCS = -I/sw/include -I/usr/include/gcc/darwin/3.3/c++ -I/usr/include/gcc/darwin/3.3/c++/ppc-darwin
-LIBS = -L/sw/lib -lgmpxx -lgmp -lpcre
+CFLAGS = #-Wall -ansi -pedantic
+DFLAGS = -O3 -fomit-frame-pointer
+#DFLAGS = -g -DDEBUG=1
+INCS = -I/usr/local/include
+LIBS = -L/usr/local/lib -lgmpxx -lgmp -lpcre
ifdef GNUCASH
CODE := $(CODE) gnucash.cc
diff --git a/amount.cc b/amount.cc
index 3217c698..3b6a8866 100644
--- a/amount.cc
+++ b/amount.cc
@@ -532,14 +532,6 @@ static commodity * parse_amount(mpz_t out, const char * num,
result = pcre_copy_substring(num, ovector, matched, base + 3, buf, 255);
assert(result >= 0);
- // Determine the precision used
- if (char * p = std::strchr(buf, '.'))
- precision = std::strlen(++p);
- else if (char * p = std::strchr(buf, '/'))
- precision = std::strlen(++p) - 1;
- else
- precision = 0;
-
// Where "thousands" markers used? Is it a european number?
if (char * p = std::strrchr(buf, ',')) {
if (std::strchr(p, '.'))
@@ -548,6 +540,14 @@ static commodity * parse_amount(mpz_t out, const char * num,
european = true;
}
+ // Determine the precision used
+ if (char * p = std::strchr(buf, european ? ',' : '.'))
+ precision = std::strlen(++p);
+ else if (char * p = std::strchr(buf, '/'))
+ precision = std::strlen(++p) - 1;
+ else
+ precision = 0;
+
// Parse the actual quantity
std::string value_str = buf;