summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann Klähn <kljohann@gmail.com>2012-10-13 20:03:44 +0200
committerJohann Klähn <kljohann@gmail.com>2012-10-13 20:04:10 +0200
commit937c9c7bd1a96ca24ecae71695f12bd25641c14c (patch)
tree3ffa12d9ae72f422281dcab6f9b26f60c80747ea
parent27d9d770d3f6d40af4934da1dcf0306daf7678dd (diff)
downloadfork-ledger-937c9c7bd1a96ca24ecae71695f12bd25641c14c.tar.gz
fork-ledger-937c9c7bd1a96ca24ecae71695f12bd25641c14c.tar.bz2
fork-ledger-937c9c7bd1a96ca24ecae71695f12bd25641c14c.zip
ignore extra fields when converting csv files
This fixes bug #736.
-rw-r--r--src/csv.cc2
-rw-r--r--test/regress/68917252.dat2
-rw-r--r--test/regress/68917252.test5
3 files changed, 8 insertions, 1 deletions
diff --git a/src/csv.cc b/src/csv.cc
index aca69307..4992372a 100644
--- a/src/csv.cc
+++ b/src/csv.cc
@@ -166,7 +166,7 @@ xact_t * csv_reader::read_xact(bool rich_data)
string total;
string field;
- while (instr.good() && ! instr.eof()) {
+ while (instr.good() && ! instr.eof() && n < index.size()) {
field = read_field(instr);
switch (index[n]) {
diff --git a/test/regress/68917252.dat b/test/regress/68917252.dat
new file mode 100644
index 00000000..8857f741
--- /dev/null
+++ b/test/regress/68917252.dat
@@ -0,0 +1,2 @@
+date,amount,
+12/12/2011,10,test,extra,fields
diff --git a/test/regress/68917252.test b/test/regress/68917252.test
new file mode 100644
index 00000000..52fde1d9
--- /dev/null
+++ b/test/regress/68917252.test
@@ -0,0 +1,5 @@
+test -f /dev/null --input-date-format "%m/%d/%Y" convert test/regress/68917252.dat
+2011/12/12 *
+ Expenses:Unknown 10
+ Equity:Unknown
+end test