Skip to content

Commit

Permalink
Fix #251
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Sep 2, 2019
1 parent 1dee616 commit d210a86
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
4 changes: 4 additions & 0 deletions c/draft-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@

## Bugfixes:

* https://github.com/johnkerl/miller/issues/250 fixes a bug using [**in-place mode**](https://johnkerl.org/miller/doc/reference.html#In-place_mode) in conjunction with verbs (such as [**rename**](http://johnkerl.org/miller/doc/reference-dsl.html#rename) or [**sort**](http://johnkerl.org/miller/doc/reference-dsl.html#sort)) which take field-name lists as arguments.

* https://github.com/johnkerl/miller/issues/253 fixes a bug in the [**label**](http://johnkerl.org/miller/doc/reference-verbs.html#label) when one or more names are common between old and new.

* https://github.com/johnkerl/miller/issues/251 fixes a corner-case bug when (a) input is CSV; (b) the last field ends with a comma and no newline; (c) input is from standard input and/or <tt>--no-mmap</tt> is supplied.
9 changes: 5 additions & 4 deletions c/input/lrec_reader_stdio_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,11 @@ static int lrec_reader_stdio_csv_get_fields(lrec_reader_stdio_csv_state_t* pstat
field_done = TRUE;
record_done = TRUE;
break;
case IFS_EOF_STRIDX:
fprintf(stderr, "%s: syntax error: record-ending field separator at line %lld.\n",
MLR_GLOBALS.bargv0, pstate->ilno);
exit(1);
case IFS_EOF_STRIDX: // end of record, last field is empty
rslls_append(pfields, sb_finish(psb), FREE_ENTRY_VALUE, 0);
rslls_append(pfields, "", NO_FREE, 0);
field_done = TRUE;
record_done = TRUE;
break;
case IFS_STRIDX: // end of field
rslls_append(pfields, sb_finish(psb), FREE_ENTRY_VALUE, 0);
Expand Down
18 changes: 18 additions & 0 deletions c/reg_test/expected/out
Original file line number Diff line number Diff line change
Expand Up @@ -47649,6 +47649,24 @@ c,b,a
6,"5",4
"9",8,"7"

mlr --mmap --icsv --oxtab cat ./reg_test/input/comma-at-eof.csv
a 1
b 2
c 3

a 4
b 5
c

mlr --no-mmap --icsv --oxtab cat ./reg_test/input/comma-at-eof.csv
a 1
b 2
c 3

a 4
b 5
c

mlr --csv --quote-all cat ./reg_test/input/rfc-csv/simple.csv-crlf
"a","b","c"
"1","x","3"
Expand Down
1 change: 1 addition & 0 deletions c/reg_test/input/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ EXTRA_DIST= \
capture-lengths.dkvp \
capture.dkvp \
clean-whitespace.csv \
comma-at-eof.csv \
comments \
d.csv \
d.pprint \
Expand Down
1 change: 1 addition & 0 deletions c/reg_test/input/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ EXTRA_DIST = \
capture-lengths.dkvp \
capture.dkvp \
clean-whitespace.csv \
comma-at-eof.csv \
comments \
d.csv \
d.pprint \
Expand Down
3 changes: 3 additions & 0 deletions c/reg_test/input/comma-at-eof.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a,b,c
1,2,3
4,5,
3 changes: 3 additions & 0 deletions c/reg_test/run
Original file line number Diff line number Diff line change
Expand Up @@ -5788,6 +5788,9 @@ run_mlr --mmap --csv cat $indir/rfc-csv/simple-truncated.csv $indir/rfc-csv/simp
run_mlr --mmap --csv --ifs semicolon --ofs pipe --irs lf --ors lflf cut -x -f b $indir/rfc-csv/modify-defaults.csv
run_mlr --mmap --csv --rs lf --quote-original cut -o -f c,b,a $indir/quote-original.csv

run_mlr --mmap --icsv --oxtab cat $indir/comma-at-eof.csv
run_mlr --no-mmap --icsv --oxtab cat $indir/comma-at-eof.csv

run_mlr --csv --quote-all cat $indir/rfc-csv/simple.csv-crlf
run_mlr --csv --quote-original cat $indir/rfc-csv/simple.csv-crlf

Expand Down

0 comments on commit d210a86

Please sign in to comment.