fix to european number handling
This commit is contained in:
parent
a8c4ecbc8e
commit
fde56d0f12
2 changed files with 13 additions and 13 deletions
10
Makefile
10
Makefile
|
|
@ -2,11 +2,11 @@ CODE = amount.cc ledger.cc parse.cc reports.cc
|
||||||
OBJS = $(patsubst %.cc,%.o,$(CODE))
|
OBJS = $(patsubst %.cc,%.o,$(CODE))
|
||||||
#CXX = cc
|
#CXX = cc
|
||||||
CXX = g++
|
CXX = g++
|
||||||
CFLAGS = -Wall -ansi -pedantic
|
CFLAGS = #-Wall -ansi -pedantic
|
||||||
#DFLAGS = -O3 -fomit-frame-pointer
|
DFLAGS = -O3 -fomit-frame-pointer
|
||||||
DFLAGS = -g -DDEBUG=1
|
#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
|
INCS = -I/usr/local/include
|
||||||
LIBS = -L/sw/lib -lgmpxx -lgmp -lpcre
|
LIBS = -L/usr/local/lib -lgmpxx -lgmp -lpcre
|
||||||
|
|
||||||
ifdef GNUCASH
|
ifdef GNUCASH
|
||||||
CODE := $(CODE) gnucash.cc
|
CODE := $(CODE) gnucash.cc
|
||||||
|
|
|
||||||
16
amount.cc
16
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);
|
result = pcre_copy_substring(num, ovector, matched, base + 3, buf, 255);
|
||||||
assert(result >= 0);
|
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?
|
// Where "thousands" markers used? Is it a european number?
|
||||||
if (char * p = std::strrchr(buf, ',')) {
|
if (char * p = std::strrchr(buf, ',')) {
|
||||||
if (std::strchr(p, '.'))
|
if (std::strchr(p, '.'))
|
||||||
|
|
@ -548,6 +540,14 @@ static commodity * parse_amount(mpz_t out, const char * num,
|
||||||
european = true;
|
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
|
// Parse the actual quantity
|
||||||
std::string value_str = buf;
|
std::string value_str = buf;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue