fastcsv 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4bd98782c7284ce6b9041b789f9048aa7d9772b
4
- data.tar.gz: b970c8d7cd54e52aaa56ab5b88f61b575a7dd811
3
+ metadata.gz: 580efd5d55a6c7af840eb1b8a2d4a4b004744791
4
+ data.tar.gz: 4b35d9194465cda927956f1dcc4d19c8857c1ebf
5
5
  SHA512:
6
- metadata.gz: 407c12a75c2e24a14f0f65d144e9b525c79ae8c531b8dcaa67f12520083a6474a6af9ceebcf2eecaed86516730a6346a9c3323d7f0b2c2c63e9c50a197f18f5b
7
- data.tar.gz: 8b8880a373dc298da5e40c7b038ac04b9156c004222ba8ba7f315354b008805388da72b9e954d450bda6ccddec85559aaedc2e076354646c5b62b17bdc8eee94
6
+ metadata.gz: 70393b8705405bb70d2571aa63b7ac3925f2e194bfde800075a4ff370416c4d2835de0f6f4800925a9927cbed40d4a6f5773f099561242d5584e3e5341daef71
7
+ data.tar.gz: 8c3897c6523b5c602ea141e67eabff1336d1cf759ce15ae4fe0093e7a0aa72ffdc5a905179b13e04161730983e68a8c3061bc01ba6d1c1b6f31f2981e82977b3
data/README.md CHANGED
@@ -40,9 +40,9 @@ end
40
40
 
41
41
  FastCSV can be used as a drop-in replacement for [CSV](http://ruby-doc.org/stdlib-2.1.1/libdoc/csv/rdoc/CSV.html) (replace `CSV` with `FastCSV`) except:
42
42
 
43
- * The `:row_sep` option is ignored. The default `:auto` is implemented. [#9](https://github.com/jpmckinney/fastcsv/issues/9)
44
- * The `:col_sep` option must be a single-byte string, like the default `,`. [#8](https://github.com/jpmckinney/fastcsv/issues/8)
45
- * If FastCSV raises an error, you can't continue reading. [#3](https://github.com/jpmckinney/fastcsv/issues/3) Its error messages don't perfectly match those of CSV.
43
+ * The `:row_sep` option is ignored. The default `:auto` is implemented [#9](https://github.com/jpmckinney/fastcsv/issues/9).
44
+ * The `:col_sep` option must be a single-byte string, like the default `,` [#8](https://github.com/jpmckinney/fastcsv/issues/8). [Python](https://docs.python.org/3/library/csv.html#dialects-and-formatting-parameters) and [PHP](http://php.net/fgetcsv) support single-byte delimiters only, as do the major libraries in [JavaScript](http://papaparse.com/docs), [Java](http://commons.apache.org/proper/commons-csv/apidocs/index.html), [C](https://github.com/robertpostill/libcsv/blob/master/FAQ), [Objective-C](https://github.com/davedelong/CHCSVParser#parsing) and [Perl](http://search.cpan.org/~makamaka/Text-CSV-1.32/lib/Text/CSV.pm). A major [Node](https://github.com/wdavidw/node-csv-parse/issues/26) library supports multi-byte delimiters.
45
+ * If FastCSV raises an error, you can't continue reading [#3](https://github.com/jpmckinney/fastcsv/issues/3). Its error messages don't perfectly match those of CSV.
46
46
 
47
47
  A few minor caveats:
48
48
 
@@ -38,7 +38,7 @@ typedef struct {
38
38
  } Data;
39
39
 
40
40
 
41
- #line 169 "ext/fastcsv/fastcsv.rl"
41
+ #line 172 "ext/fastcsv/fastcsv.rl"
42
42
 
43
43
 
44
44
 
@@ -50,7 +50,7 @@ static const int raw_parse_error = 0;
50
50
  static const int raw_parse_en_main = 5;
51
51
 
52
52
 
53
- #line 172 "ext/fastcsv/fastcsv.rl"
53
+ #line 175 "ext/fastcsv/fastcsv.rl"
54
54
 
55
55
  // 16 kB
56
56
  #define BUFSIZE 16384
@@ -270,7 +270,7 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
270
270
  act = 0;
271
271
  }
272
272
 
273
- #line 383 "ext/fastcsv/fastcsv.rl"
273
+ #line 386 "ext/fastcsv/fastcsv.rl"
274
274
 
275
275
  while (!done) {
276
276
  VALUE str;
@@ -363,7 +363,7 @@ tr5:
363
363
  ENCODE;
364
364
  }
365
365
  }
366
- #line 137 "ext/fastcsv/fastcsv.rl"
366
+ #line 138 "ext/fastcsv/fastcsv.rl"
367
367
  {
368
368
  if (d->start == 0 || p == d->start) { // same as new_row
369
369
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -380,7 +380,7 @@ tr5:
380
380
  rb_yield(row);
381
381
  }
382
382
  }
383
- #line 167 "ext/fastcsv/fastcsv.rl"
383
+ #line 170 "ext/fastcsv/fastcsv.rl"
384
384
  {te = p+1;}
385
385
  goto st5;
386
386
  tr6:
@@ -400,7 +400,7 @@ tr6:
400
400
  rb_ary_push(row, field);
401
401
  field = Qnil;
402
402
  }
403
- #line 165 "ext/fastcsv/fastcsv.rl"
403
+ #line 168 "ext/fastcsv/fastcsv.rl"
404
404
  {te = p+1;}
405
405
  goto st5;
406
406
  tr7:
@@ -420,9 +420,9 @@ tr7:
420
420
  rb_ary_push(row, field);
421
421
  field = Qnil;
422
422
  }
423
- #line 165 "ext/fastcsv/fastcsv.rl"
423
+ #line 168 "ext/fastcsv/fastcsv.rl"
424
424
  {te = p+1;}
425
- #line 137 "ext/fastcsv/fastcsv.rl"
425
+ #line 138 "ext/fastcsv/fastcsv.rl"
426
426
  {
427
427
  if (d->start == 0 || p == d->start) { // same as new_row
428
428
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -441,7 +441,7 @@ tr7:
441
441
  }
442
442
  goto st5;
443
443
  tr13:
444
- #line 137 "ext/fastcsv/fastcsv.rl"
444
+ #line 138 "ext/fastcsv/fastcsv.rl"
445
445
  {
446
446
  if (d->start == 0 || p == d->start) { // same as new_row
447
447
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -458,7 +458,7 @@ tr13:
458
458
  rb_yield(row);
459
459
  }
460
460
  }
461
- #line 167 "ext/fastcsv/fastcsv.rl"
461
+ #line 170 "ext/fastcsv/fastcsv.rl"
462
462
  {te = p+1;}
463
463
  goto st5;
464
464
  tr19:
@@ -467,7 +467,7 @@ tr19:
467
467
  rb_ary_push(row, field);
468
468
  field = Qnil;
469
469
  }
470
- #line 165 "ext/fastcsv/fastcsv.rl"
470
+ #line 168 "ext/fastcsv/fastcsv.rl"
471
471
  {te = p+1;}
472
472
  goto st5;
473
473
  tr20:
@@ -476,9 +476,9 @@ tr20:
476
476
  rb_ary_push(row, field);
477
477
  field = Qnil;
478
478
  }
479
- #line 165 "ext/fastcsv/fastcsv.rl"
479
+ #line 168 "ext/fastcsv/fastcsv.rl"
480
480
  {te = p+1;}
481
- #line 137 "ext/fastcsv/fastcsv.rl"
481
+ #line 138 "ext/fastcsv/fastcsv.rl"
482
482
  {
483
483
  if (d->start == 0 || p == d->start) { // same as new_row
484
484
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -497,7 +497,7 @@ tr20:
497
497
  }
498
498
  goto st5;
499
499
  tr42:
500
- #line 167 "ext/fastcsv/fastcsv.rl"
500
+ #line 170 "ext/fastcsv/fastcsv.rl"
501
501
  {te = p;p--;}
502
502
  goto st5;
503
503
  tr43:
@@ -509,7 +509,7 @@ tr43:
509
509
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
510
510
  FREE;
511
511
 
512
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
512
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
513
513
  }
514
514
  }
515
515
  else {
@@ -517,6 +517,8 @@ tr43:
517
517
  row_sep = ALLOC_N(char, len_row_sep);
518
518
  memcpy(row_sep, mark_row_sep, len_row_sep);
519
519
  }
520
+
521
+ curline++;
520
522
  }
521
523
  #line 1 "NONE"
522
524
  { switch( act ) {
@@ -538,7 +540,7 @@ tr50:
538
540
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
539
541
  FREE;
540
542
 
541
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
543
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
542
544
  }
543
545
  }
544
546
  else {
@@ -546,8 +548,10 @@ tr50:
546
548
  row_sep = ALLOC_N(char, len_row_sep);
547
549
  memcpy(row_sep, mark_row_sep, len_row_sep);
548
550
  }
551
+
552
+ curline++;
549
553
  }
550
- #line 137 "ext/fastcsv/fastcsv.rl"
554
+ #line 138 "ext/fastcsv/fastcsv.rl"
551
555
  {
552
556
  if (d->start == 0 || p == d->start) { // same as new_row
553
557
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -564,7 +568,7 @@ tr50:
564
568
  rb_yield(row);
565
569
  }
566
570
  }
567
- #line 167 "ext/fastcsv/fastcsv.rl"
571
+ #line 170 "ext/fastcsv/fastcsv.rl"
568
572
  {te = p+1;}
569
573
  goto st5;
570
574
  tr56:
@@ -573,7 +577,7 @@ tr56:
573
577
  rb_ary_push(row, field);
574
578
  field = Qnil;
575
579
  }
576
- #line 165 "ext/fastcsv/fastcsv.rl"
580
+ #line 168 "ext/fastcsv/fastcsv.rl"
577
581
  {te = p+1;}
578
582
  #line 100 "ext/fastcsv/fastcsv.rl"
579
583
  {
@@ -583,7 +587,7 @@ tr56:
583
587
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
584
588
  FREE;
585
589
 
586
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
590
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
587
591
  }
588
592
  }
589
593
  else {
@@ -591,8 +595,10 @@ tr56:
591
595
  row_sep = ALLOC_N(char, len_row_sep);
592
596
  memcpy(row_sep, mark_row_sep, len_row_sep);
593
597
  }
598
+
599
+ curline++;
594
600
  }
595
- #line 137 "ext/fastcsv/fastcsv.rl"
601
+ #line 138 "ext/fastcsv/fastcsv.rl"
596
602
  {
597
603
  if (d->start == 0 || p == d->start) { // same as new_row
598
604
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -620,14 +626,14 @@ st5:
620
626
  case 5:
621
627
  #line 1 "NONE"
622
628
  {ts = p;}
623
- #line 624 "ext/fastcsv/fastcsv.c"
629
+ #line 630 "ext/fastcsv/fastcsv.c"
624
630
  _widec = (*p);
625
631
  _widec = (short)(1152 + ((*p) - -128));
626
632
  if (
627
- #line 155 "ext/fastcsv/fastcsv.rl"
633
+ #line 156 "ext/fastcsv/fastcsv.rl"
628
634
  (*p) == quote_char ) _widec += 256;
629
635
  if (
630
- #line 156 "ext/fastcsv/fastcsv.rl"
636
+ #line 157 "ext/fastcsv/fastcsv.rl"
631
637
  (*p) == col_sep ) _widec += 512;
632
638
  switch( _widec ) {
633
639
  case 1280: goto tr33;
@@ -665,10 +671,10 @@ case 1:
665
671
  _widec = (*p);
666
672
  _widec = (short)(1152 + ((*p) - -128));
667
673
  if (
668
- #line 155 "ext/fastcsv/fastcsv.rl"
674
+ #line 156 "ext/fastcsv/fastcsv.rl"
669
675
  (*p) == quote_char ) _widec += 256;
670
676
  if (
671
- #line 156 "ext/fastcsv/fastcsv.rl"
677
+ #line 157 "ext/fastcsv/fastcsv.rl"
672
678
  (*p) == col_sep ) _widec += 512;
673
679
  switch( _widec ) {
674
680
  case 1280: goto tr2;
@@ -704,7 +710,7 @@ tr2:
704
710
  ENCODE;
705
711
  }
706
712
  }
707
- #line 137 "ext/fastcsv/fastcsv.rl"
713
+ #line 138 "ext/fastcsv/fastcsv.rl"
708
714
  {
709
715
  if (d->start == 0 || p == d->start) { // same as new_row
710
716
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -721,21 +727,21 @@ tr2:
721
727
  rb_yield(row);
722
728
  }
723
729
  }
724
- #line 167 "ext/fastcsv/fastcsv.rl"
730
+ #line 170 "ext/fastcsv/fastcsv.rl"
725
731
  {act = 3;}
726
732
  goto st6;
727
733
  st6:
728
734
  if ( ++p == pe )
729
735
  goto _test_eof6;
730
736
  case 6:
731
- #line 732 "ext/fastcsv/fastcsv.c"
737
+ #line 738 "ext/fastcsv/fastcsv.c"
732
738
  _widec = (*p);
733
739
  _widec = (short)(1152 + ((*p) - -128));
734
740
  if (
735
- #line 155 "ext/fastcsv/fastcsv.rl"
741
+ #line 156 "ext/fastcsv/fastcsv.rl"
736
742
  (*p) == quote_char ) _widec += 256;
737
743
  if (
738
- #line 156 "ext/fastcsv/fastcsv.rl"
744
+ #line 157 "ext/fastcsv/fastcsv.rl"
739
745
  (*p) == col_sep ) _widec += 512;
740
746
  switch( _widec ) {
741
747
  case 1280: goto tr2;
@@ -771,10 +777,9 @@ tr3:
771
777
  ENCODE;
772
778
  }
773
779
  }
774
- #line 117 "ext/fastcsv/fastcsv.rl"
780
+ #line 119 "ext/fastcsv/fastcsv.rl"
775
781
  {
776
782
  mark_row_sep = p;
777
- curline++;
778
783
 
779
784
  if (d->start == 0 || p == d->start) {
780
785
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -791,7 +796,7 @@ tr3:
791
796
  rb_yield(row);
792
797
  row = rb_ary_new();
793
798
  }
794
- #line 166 "ext/fastcsv/fastcsv.rl"
799
+ #line 169 "ext/fastcsv/fastcsv.rl"
795
800
  {act = 2;}
796
801
  goto st7;
797
802
  tr8:
@@ -813,12 +818,11 @@ tr8:
813
818
  rb_ary_push(row, field);
814
819
  field = Qnil;
815
820
  }
816
- #line 165 "ext/fastcsv/fastcsv.rl"
821
+ #line 168 "ext/fastcsv/fastcsv.rl"
817
822
  {act = 1;}
818
- #line 117 "ext/fastcsv/fastcsv.rl"
823
+ #line 119 "ext/fastcsv/fastcsv.rl"
819
824
  {
820
825
  mark_row_sep = p;
821
- curline++;
822
826
 
823
827
  if (d->start == 0 || p == d->start) {
824
828
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -839,10 +843,9 @@ tr8:
839
843
  tr14:
840
844
  #line 1 "NONE"
841
845
  {te = p+1;}
842
- #line 117 "ext/fastcsv/fastcsv.rl"
846
+ #line 119 "ext/fastcsv/fastcsv.rl"
843
847
  {
844
848
  mark_row_sep = p;
845
- curline++;
846
849
 
847
850
  if (d->start == 0 || p == d->start) {
848
851
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -859,7 +862,7 @@ tr14:
859
862
  rb_yield(row);
860
863
  row = rb_ary_new();
861
864
  }
862
- #line 166 "ext/fastcsv/fastcsv.rl"
865
+ #line 169 "ext/fastcsv/fastcsv.rl"
863
866
  {act = 2;}
864
867
  goto st7;
865
868
  tr21:
@@ -870,12 +873,11 @@ tr21:
870
873
  rb_ary_push(row, field);
871
874
  field = Qnil;
872
875
  }
873
- #line 165 "ext/fastcsv/fastcsv.rl"
876
+ #line 168 "ext/fastcsv/fastcsv.rl"
874
877
  {act = 1;}
875
- #line 117 "ext/fastcsv/fastcsv.rl"
878
+ #line 119 "ext/fastcsv/fastcsv.rl"
876
879
  {
877
880
  mark_row_sep = p;
878
- curline++;
879
881
 
880
882
  if (d->start == 0 || p == d->start) {
881
883
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -896,14 +898,14 @@ tr21:
896
898
  tr44:
897
899
  #line 1 "NONE"
898
900
  {te = p+1;}
899
- #line 166 "ext/fastcsv/fastcsv.rl"
901
+ #line 169 "ext/fastcsv/fastcsv.rl"
900
902
  {act = 2;}
901
903
  goto st7;
902
904
  st7:
903
905
  if ( ++p == pe )
904
906
  goto _test_eof7;
905
907
  case 7:
906
- #line 907 "ext/fastcsv/fastcsv.c"
908
+ #line 909 "ext/fastcsv/fastcsv.c"
907
909
  goto tr43;
908
910
  tr4:
909
911
  #line 1 "NONE"
@@ -919,10 +921,9 @@ tr4:
919
921
  ENCODE;
920
922
  }
921
923
  }
922
- #line 117 "ext/fastcsv/fastcsv.rl"
924
+ #line 119 "ext/fastcsv/fastcsv.rl"
923
925
  {
924
926
  mark_row_sep = p;
925
- curline++;
926
927
 
927
928
  if (d->start == 0 || p == d->start) {
928
929
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -939,7 +940,7 @@ tr4:
939
940
  rb_yield(row);
940
941
  row = rb_ary_new();
941
942
  }
942
- #line 166 "ext/fastcsv/fastcsv.rl"
943
+ #line 169 "ext/fastcsv/fastcsv.rl"
943
944
  {act = 2;}
944
945
  goto st8;
945
946
  tr9:
@@ -961,12 +962,11 @@ tr9:
961
962
  rb_ary_push(row, field);
962
963
  field = Qnil;
963
964
  }
964
- #line 165 "ext/fastcsv/fastcsv.rl"
965
+ #line 168 "ext/fastcsv/fastcsv.rl"
965
966
  {act = 1;}
966
- #line 117 "ext/fastcsv/fastcsv.rl"
967
+ #line 119 "ext/fastcsv/fastcsv.rl"
967
968
  {
968
969
  mark_row_sep = p;
969
- curline++;
970
970
 
971
971
  if (d->start == 0 || p == d->start) {
972
972
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -987,10 +987,9 @@ tr9:
987
987
  tr15:
988
988
  #line 1 "NONE"
989
989
  {te = p+1;}
990
- #line 117 "ext/fastcsv/fastcsv.rl"
990
+ #line 119 "ext/fastcsv/fastcsv.rl"
991
991
  {
992
992
  mark_row_sep = p;
993
- curline++;
994
993
 
995
994
  if (d->start == 0 || p == d->start) {
996
995
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1007,7 +1006,7 @@ tr15:
1007
1006
  rb_yield(row);
1008
1007
  row = rb_ary_new();
1009
1008
  }
1010
- #line 166 "ext/fastcsv/fastcsv.rl"
1009
+ #line 169 "ext/fastcsv/fastcsv.rl"
1011
1010
  {act = 2;}
1012
1011
  goto st8;
1013
1012
  tr22:
@@ -1018,12 +1017,11 @@ tr22:
1018
1017
  rb_ary_push(row, field);
1019
1018
  field = Qnil;
1020
1019
  }
1021
- #line 165 "ext/fastcsv/fastcsv.rl"
1020
+ #line 168 "ext/fastcsv/fastcsv.rl"
1022
1021
  {act = 1;}
1023
- #line 117 "ext/fastcsv/fastcsv.rl"
1022
+ #line 119 "ext/fastcsv/fastcsv.rl"
1024
1023
  {
1025
1024
  mark_row_sep = p;
1026
- curline++;
1027
1025
 
1028
1026
  if (d->start == 0 || p == d->start) {
1029
1027
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1045,7 +1043,7 @@ st8:
1045
1043
  if ( ++p == pe )
1046
1044
  goto _test_eof8;
1047
1045
  case 8:
1048
- #line 1049 "ext/fastcsv/fastcsv.c"
1046
+ #line 1047 "ext/fastcsv/fastcsv.c"
1049
1047
  if ( (*p) == 10 )
1050
1048
  goto tr44;
1051
1049
  goto tr43;
@@ -1063,7 +1061,7 @@ tr33:
1063
1061
  ENCODE;
1064
1062
  }
1065
1063
  }
1066
- #line 137 "ext/fastcsv/fastcsv.rl"
1064
+ #line 138 "ext/fastcsv/fastcsv.rl"
1067
1065
  {
1068
1066
  if (d->start == 0 || p == d->start) { // same as new_row
1069
1067
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1080,21 +1078,21 @@ tr33:
1080
1078
  rb_yield(row);
1081
1079
  }
1082
1080
  }
1083
- #line 167 "ext/fastcsv/fastcsv.rl"
1081
+ #line 170 "ext/fastcsv/fastcsv.rl"
1084
1082
  {act = 3;}
1085
1083
  goto st9;
1086
1084
  st9:
1087
1085
  if ( ++p == pe )
1088
1086
  goto _test_eof9;
1089
1087
  case 9:
1090
- #line 1091 "ext/fastcsv/fastcsv.c"
1088
+ #line 1089 "ext/fastcsv/fastcsv.c"
1091
1089
  _widec = (*p);
1092
1090
  _widec = (short)(1152 + ((*p) - -128));
1093
1091
  if (
1094
- #line 155 "ext/fastcsv/fastcsv.rl"
1092
+ #line 156 "ext/fastcsv/fastcsv.rl"
1095
1093
  (*p) == quote_char ) _widec += 256;
1096
1094
  if (
1097
- #line 156 "ext/fastcsv/fastcsv.rl"
1095
+ #line 157 "ext/fastcsv/fastcsv.rl"
1098
1096
  (*p) == col_sep ) _widec += 512;
1099
1097
  if ( _widec < 1291 ) {
1100
1098
  if ( 1152 <= _widec && _widec <= 1289 )
@@ -1120,7 +1118,7 @@ tr45:
1120
1118
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
1121
1119
  FREE;
1122
1120
 
1123
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
1121
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
1124
1122
  }
1125
1123
  }
1126
1124
  else {
@@ -1128,6 +1126,8 @@ tr45:
1128
1126
  row_sep = ALLOC_N(char, len_row_sep);
1129
1127
  memcpy(row_sep, mark_row_sep, len_row_sep);
1130
1128
  }
1129
+
1130
+ curline++;
1131
1131
  }
1132
1132
  goto st2;
1133
1133
  st2:
@@ -1138,7 +1138,7 @@ case 2:
1138
1138
  _widec = (*p);
1139
1139
  _widec = (short)(128 + ((*p) - -128));
1140
1140
  if (
1141
- #line 155 "ext/fastcsv/fastcsv.rl"
1141
+ #line 156 "ext/fastcsv/fastcsv.rl"
1142
1142
  (*p) == quote_char ) _widec += 256;
1143
1143
  switch( _widec ) {
1144
1144
  case 522: goto tr12;
@@ -1242,7 +1242,7 @@ tr46:
1242
1242
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
1243
1243
  FREE;
1244
1244
 
1245
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
1245
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
1246
1246
  }
1247
1247
  }
1248
1248
  else {
@@ -1250,20 +1250,22 @@ tr46:
1250
1250
  row_sep = ALLOC_N(char, len_row_sep);
1251
1251
  memcpy(row_sep, mark_row_sep, len_row_sep);
1252
1252
  }
1253
+
1254
+ curline++;
1253
1255
  }
1254
1256
  goto st3;
1255
1257
  st3:
1256
1258
  if ( ++p == pe )
1257
1259
  goto _test_eof3;
1258
1260
  case 3:
1259
- #line 1260 "ext/fastcsv/fastcsv.c"
1261
+ #line 1262 "ext/fastcsv/fastcsv.c"
1260
1262
  _widec = (*p);
1261
1263
  _widec = (short)(1152 + ((*p) - -128));
1262
1264
  if (
1263
- #line 155 "ext/fastcsv/fastcsv.rl"
1265
+ #line 156 "ext/fastcsv/fastcsv.rl"
1264
1266
  (*p) == quote_char ) _widec += 256;
1265
1267
  if (
1266
- #line 156 "ext/fastcsv/fastcsv.rl"
1268
+ #line 157 "ext/fastcsv/fastcsv.rl"
1267
1269
  (*p) == col_sep ) _widec += 512;
1268
1270
  switch( _widec ) {
1269
1271
  case 1280: goto tr13;
@@ -1291,7 +1293,7 @@ case 3:
1291
1293
  tr16:
1292
1294
  #line 1 "NONE"
1293
1295
  {te = p+1;}
1294
- #line 137 "ext/fastcsv/fastcsv.rl"
1296
+ #line 138 "ext/fastcsv/fastcsv.rl"
1295
1297
  {
1296
1298
  if (d->start == 0 || p == d->start) { // same as new_row
1297
1299
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1308,7 +1310,7 @@ tr16:
1308
1310
  rb_yield(row);
1309
1311
  }
1310
1312
  }
1311
- #line 167 "ext/fastcsv/fastcsv.rl"
1313
+ #line 170 "ext/fastcsv/fastcsv.rl"
1312
1314
  {act = 3;}
1313
1315
  goto st10;
1314
1316
  tr23:
@@ -1319,7 +1321,7 @@ tr23:
1319
1321
  rb_ary_push(row, field);
1320
1322
  field = Qnil;
1321
1323
  }
1322
- #line 165 "ext/fastcsv/fastcsv.rl"
1324
+ #line 168 "ext/fastcsv/fastcsv.rl"
1323
1325
  {act = 1;}
1324
1326
  goto st10;
1325
1327
  tr24:
@@ -1330,9 +1332,9 @@ tr24:
1330
1332
  rb_ary_push(row, field);
1331
1333
  field = Qnil;
1332
1334
  }
1333
- #line 165 "ext/fastcsv/fastcsv.rl"
1335
+ #line 168 "ext/fastcsv/fastcsv.rl"
1334
1336
  {act = 1;}
1335
- #line 137 "ext/fastcsv/fastcsv.rl"
1337
+ #line 138 "ext/fastcsv/fastcsv.rl"
1336
1338
  {
1337
1339
  if (d->start == 0 || p == d->start) { // same as new_row
1338
1340
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1368,7 +1370,7 @@ tr35:
1368
1370
  ENCODE;
1369
1371
  }
1370
1372
  }
1371
- #line 137 "ext/fastcsv/fastcsv.rl"
1373
+ #line 138 "ext/fastcsv/fastcsv.rl"
1372
1374
  {
1373
1375
  if (d->start == 0 || p == d->start) { // same as new_row
1374
1376
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1385,7 +1387,7 @@ tr35:
1385
1387
  rb_yield(row);
1386
1388
  }
1387
1389
  }
1388
- #line 167 "ext/fastcsv/fastcsv.rl"
1390
+ #line 170 "ext/fastcsv/fastcsv.rl"
1389
1391
  {act = 3;}
1390
1392
  goto st10;
1391
1393
  tr38:
@@ -1411,7 +1413,7 @@ tr38:
1411
1413
  rb_ary_push(row, field);
1412
1414
  field = Qnil;
1413
1415
  }
1414
- #line 165 "ext/fastcsv/fastcsv.rl"
1416
+ #line 168 "ext/fastcsv/fastcsv.rl"
1415
1417
  {act = 1;}
1416
1418
  goto st10;
1417
1419
  tr39:
@@ -1437,9 +1439,9 @@ tr39:
1437
1439
  rb_ary_push(row, field);
1438
1440
  field = Qnil;
1439
1441
  }
1440
- #line 165 "ext/fastcsv/fastcsv.rl"
1442
+ #line 168 "ext/fastcsv/fastcsv.rl"
1441
1443
  {act = 1;}
1442
- #line 137 "ext/fastcsv/fastcsv.rl"
1444
+ #line 138 "ext/fastcsv/fastcsv.rl"
1443
1445
  {
1444
1446
  if (d->start == 0 || p == d->start) { // same as new_row
1445
1447
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1465,7 +1467,7 @@ tr55:
1465
1467
  rb_ary_push(row, field);
1466
1468
  field = Qnil;
1467
1469
  }
1468
- #line 165 "ext/fastcsv/fastcsv.rl"
1470
+ #line 168 "ext/fastcsv/fastcsv.rl"
1469
1471
  {act = 1;}
1470
1472
  #line 100 "ext/fastcsv/fastcsv.rl"
1471
1473
  {
@@ -1475,7 +1477,7 @@ tr55:
1475
1477
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
1476
1478
  FREE;
1477
1479
 
1478
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
1480
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
1479
1481
  }
1480
1482
  }
1481
1483
  else {
@@ -1483,17 +1485,19 @@ tr55:
1483
1485
  row_sep = ALLOC_N(char, len_row_sep);
1484
1486
  memcpy(row_sep, mark_row_sep, len_row_sep);
1485
1487
  }
1488
+
1489
+ curline++;
1486
1490
  }
1487
1491
  goto st10;
1488
1492
  st10:
1489
1493
  if ( ++p == pe )
1490
1494
  goto _test_eof10;
1491
1495
  case 10:
1492
- #line 1493 "ext/fastcsv/fastcsv.c"
1496
+ #line 1497 "ext/fastcsv/fastcsv.c"
1493
1497
  _widec = (*p);
1494
1498
  _widec = (short)(128 + ((*p) - -128));
1495
1499
  if (
1496
- #line 155 "ext/fastcsv/fastcsv.rl"
1500
+ #line 156 "ext/fastcsv/fastcsv.rl"
1497
1501
  (*p) == quote_char ) _widec += 256;
1498
1502
  switch( _widec ) {
1499
1503
  case 522: goto tr12;
@@ -1597,7 +1601,7 @@ tr47:
1597
1601
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
1598
1602
  FREE;
1599
1603
 
1600
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
1604
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
1601
1605
  }
1602
1606
  }
1603
1607
  else {
@@ -1605,20 +1609,22 @@ tr47:
1605
1609
  row_sep = ALLOC_N(char, len_row_sep);
1606
1610
  memcpy(row_sep, mark_row_sep, len_row_sep);
1607
1611
  }
1612
+
1613
+ curline++;
1608
1614
  }
1609
1615
  goto st4;
1610
1616
  st4:
1611
1617
  if ( ++p == pe )
1612
1618
  goto _test_eof4;
1613
1619
  case 4:
1614
- #line 1615 "ext/fastcsv/fastcsv.c"
1620
+ #line 1621 "ext/fastcsv/fastcsv.c"
1615
1621
  _widec = (*p);
1616
1622
  _widec = (short)(1152 + ((*p) - -128));
1617
1623
  if (
1618
- #line 155 "ext/fastcsv/fastcsv.rl"
1624
+ #line 156 "ext/fastcsv/fastcsv.rl"
1619
1625
  (*p) == quote_char ) _widec += 256;
1620
1626
  if (
1621
- #line 156 "ext/fastcsv/fastcsv.rl"
1627
+ #line 157 "ext/fastcsv/fastcsv.rl"
1622
1628
  (*p) == col_sep ) _widec += 512;
1623
1629
  switch( _widec ) {
1624
1630
  case 1280: goto tr13;
@@ -1649,10 +1655,9 @@ case 4:
1649
1655
  tr17:
1650
1656
  #line 1 "NONE"
1651
1657
  {te = p+1;}
1652
- #line 117 "ext/fastcsv/fastcsv.rl"
1658
+ #line 119 "ext/fastcsv/fastcsv.rl"
1653
1659
  {
1654
1660
  mark_row_sep = p;
1655
- curline++;
1656
1661
 
1657
1662
  if (d->start == 0 || p == d->start) {
1658
1663
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1669,7 +1674,7 @@ tr17:
1669
1674
  rb_yield(row);
1670
1675
  row = rb_ary_new();
1671
1676
  }
1672
- #line 166 "ext/fastcsv/fastcsv.rl"
1677
+ #line 169 "ext/fastcsv/fastcsv.rl"
1673
1678
  {act = 2;}
1674
1679
  goto st11;
1675
1680
  tr25:
@@ -1680,12 +1685,11 @@ tr25:
1680
1685
  rb_ary_push(row, field);
1681
1686
  field = Qnil;
1682
1687
  }
1683
- #line 165 "ext/fastcsv/fastcsv.rl"
1688
+ #line 168 "ext/fastcsv/fastcsv.rl"
1684
1689
  {act = 1;}
1685
- #line 117 "ext/fastcsv/fastcsv.rl"
1690
+ #line 119 "ext/fastcsv/fastcsv.rl"
1686
1691
  {
1687
1692
  mark_row_sep = p;
1688
- curline++;
1689
1693
 
1690
1694
  if (d->start == 0 || p == d->start) {
1691
1695
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1721,10 +1725,9 @@ tr36:
1721
1725
  ENCODE;
1722
1726
  }
1723
1727
  }
1724
- #line 117 "ext/fastcsv/fastcsv.rl"
1728
+ #line 119 "ext/fastcsv/fastcsv.rl"
1725
1729
  {
1726
1730
  mark_row_sep = p;
1727
- curline++;
1728
1731
 
1729
1732
  if (d->start == 0 || p == d->start) {
1730
1733
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1741,7 +1744,7 @@ tr36:
1741
1744
  rb_yield(row);
1742
1745
  row = rb_ary_new();
1743
1746
  }
1744
- #line 166 "ext/fastcsv/fastcsv.rl"
1747
+ #line 169 "ext/fastcsv/fastcsv.rl"
1745
1748
  {act = 2;}
1746
1749
  goto st11;
1747
1750
  tr40:
@@ -1767,12 +1770,11 @@ tr40:
1767
1770
  rb_ary_push(row, field);
1768
1771
  field = Qnil;
1769
1772
  }
1770
- #line 165 "ext/fastcsv/fastcsv.rl"
1773
+ #line 168 "ext/fastcsv/fastcsv.rl"
1771
1774
  {act = 1;}
1772
- #line 117 "ext/fastcsv/fastcsv.rl"
1775
+ #line 119 "ext/fastcsv/fastcsv.rl"
1773
1776
  {
1774
1777
  mark_row_sep = p;
1775
- curline++;
1776
1778
 
1777
1779
  if (d->start == 0 || p == d->start) {
1778
1780
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1801,7 +1803,7 @@ tr48:
1801
1803
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
1802
1804
  FREE;
1803
1805
 
1804
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
1806
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
1805
1807
  }
1806
1808
  }
1807
1809
  else {
@@ -1809,17 +1811,18 @@ tr48:
1809
1811
  row_sep = ALLOC_N(char, len_row_sep);
1810
1812
  memcpy(row_sep, mark_row_sep, len_row_sep);
1811
1813
  }
1814
+
1815
+ curline++;
1812
1816
  }
1813
- #line 166 "ext/fastcsv/fastcsv.rl"
1817
+ #line 169 "ext/fastcsv/fastcsv.rl"
1814
1818
  {act = 2;}
1815
1819
  goto st11;
1816
1820
  tr51:
1817
1821
  #line 1 "NONE"
1818
1822
  {te = p+1;}
1819
- #line 117 "ext/fastcsv/fastcsv.rl"
1823
+ #line 119 "ext/fastcsv/fastcsv.rl"
1820
1824
  {
1821
1825
  mark_row_sep = p;
1822
- curline++;
1823
1826
 
1824
1827
  if (d->start == 0 || p == d->start) {
1825
1828
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1844,7 +1847,7 @@ tr51:
1844
1847
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
1845
1848
  FREE;
1846
1849
 
1847
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
1850
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
1848
1851
  }
1849
1852
  }
1850
1853
  else {
@@ -1852,8 +1855,10 @@ tr51:
1852
1855
  row_sep = ALLOC_N(char, len_row_sep);
1853
1856
  memcpy(row_sep, mark_row_sep, len_row_sep);
1854
1857
  }
1858
+
1859
+ curline++;
1855
1860
  }
1856
- #line 166 "ext/fastcsv/fastcsv.rl"
1861
+ #line 169 "ext/fastcsv/fastcsv.rl"
1857
1862
  {act = 2;}
1858
1863
  goto st11;
1859
1864
  tr57:
@@ -1864,12 +1869,11 @@ tr57:
1864
1869
  rb_ary_push(row, field);
1865
1870
  field = Qnil;
1866
1871
  }
1867
- #line 165 "ext/fastcsv/fastcsv.rl"
1872
+ #line 168 "ext/fastcsv/fastcsv.rl"
1868
1873
  {act = 1;}
1869
- #line 117 "ext/fastcsv/fastcsv.rl"
1874
+ #line 119 "ext/fastcsv/fastcsv.rl"
1870
1875
  {
1871
1876
  mark_row_sep = p;
1872
- curline++;
1873
1877
 
1874
1878
  if (d->start == 0 || p == d->start) {
1875
1879
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1894,7 +1898,7 @@ tr57:
1894
1898
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
1895
1899
  FREE;
1896
1900
 
1897
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
1901
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
1898
1902
  }
1899
1903
  }
1900
1904
  else {
@@ -1902,17 +1906,19 @@ tr57:
1902
1906
  row_sep = ALLOC_N(char, len_row_sep);
1903
1907
  memcpy(row_sep, mark_row_sep, len_row_sep);
1904
1908
  }
1909
+
1910
+ curline++;
1905
1911
  }
1906
1912
  goto st11;
1907
1913
  st11:
1908
1914
  if ( ++p == pe )
1909
1915
  goto _test_eof11;
1910
1916
  case 11:
1911
- #line 1912 "ext/fastcsv/fastcsv.c"
1917
+ #line 1918 "ext/fastcsv/fastcsv.c"
1912
1918
  _widec = (*p);
1913
1919
  _widec = (short)(128 + ((*p) - -128));
1914
1920
  if (
1915
- #line 155 "ext/fastcsv/fastcsv.rl"
1921
+ #line 156 "ext/fastcsv/fastcsv.rl"
1916
1922
  (*p) == quote_char ) _widec += 256;
1917
1923
  switch( _widec ) {
1918
1924
  case 256: goto tr43;
@@ -1928,10 +1934,9 @@ case 11:
1928
1934
  tr18:
1929
1935
  #line 1 "NONE"
1930
1936
  {te = p+1;}
1931
- #line 117 "ext/fastcsv/fastcsv.rl"
1937
+ #line 119 "ext/fastcsv/fastcsv.rl"
1932
1938
  {
1933
1939
  mark_row_sep = p;
1934
- curline++;
1935
1940
 
1936
1941
  if (d->start == 0 || p == d->start) {
1937
1942
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -1948,7 +1953,7 @@ tr18:
1948
1953
  rb_yield(row);
1949
1954
  row = rb_ary_new();
1950
1955
  }
1951
- #line 166 "ext/fastcsv/fastcsv.rl"
1956
+ #line 169 "ext/fastcsv/fastcsv.rl"
1952
1957
  {act = 2;}
1953
1958
  goto st12;
1954
1959
  tr26:
@@ -1959,12 +1964,11 @@ tr26:
1959
1964
  rb_ary_push(row, field);
1960
1965
  field = Qnil;
1961
1966
  }
1962
- #line 165 "ext/fastcsv/fastcsv.rl"
1967
+ #line 168 "ext/fastcsv/fastcsv.rl"
1963
1968
  {act = 1;}
1964
- #line 117 "ext/fastcsv/fastcsv.rl"
1969
+ #line 119 "ext/fastcsv/fastcsv.rl"
1965
1970
  {
1966
1971
  mark_row_sep = p;
1967
- curline++;
1968
1972
 
1969
1973
  if (d->start == 0 || p == d->start) {
1970
1974
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2000,10 +2004,9 @@ tr37:
2000
2004
  ENCODE;
2001
2005
  }
2002
2006
  }
2003
- #line 117 "ext/fastcsv/fastcsv.rl"
2007
+ #line 119 "ext/fastcsv/fastcsv.rl"
2004
2008
  {
2005
2009
  mark_row_sep = p;
2006
- curline++;
2007
2010
 
2008
2011
  if (d->start == 0 || p == d->start) {
2009
2012
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2020,7 +2023,7 @@ tr37:
2020
2023
  rb_yield(row);
2021
2024
  row = rb_ary_new();
2022
2025
  }
2023
- #line 166 "ext/fastcsv/fastcsv.rl"
2026
+ #line 169 "ext/fastcsv/fastcsv.rl"
2024
2027
  {act = 2;}
2025
2028
  goto st12;
2026
2029
  tr41:
@@ -2046,12 +2049,11 @@ tr41:
2046
2049
  rb_ary_push(row, field);
2047
2050
  field = Qnil;
2048
2051
  }
2049
- #line 165 "ext/fastcsv/fastcsv.rl"
2052
+ #line 168 "ext/fastcsv/fastcsv.rl"
2050
2053
  {act = 1;}
2051
- #line 117 "ext/fastcsv/fastcsv.rl"
2054
+ #line 119 "ext/fastcsv/fastcsv.rl"
2052
2055
  {
2053
2056
  mark_row_sep = p;
2054
- curline++;
2055
2057
 
2056
2058
  if (d->start == 0 || p == d->start) {
2057
2059
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2072,10 +2074,9 @@ tr41:
2072
2074
  tr52:
2073
2075
  #line 1 "NONE"
2074
2076
  {te = p+1;}
2075
- #line 117 "ext/fastcsv/fastcsv.rl"
2077
+ #line 119 "ext/fastcsv/fastcsv.rl"
2076
2078
  {
2077
2079
  mark_row_sep = p;
2078
- curline++;
2079
2080
 
2080
2081
  if (d->start == 0 || p == d->start) {
2081
2082
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2100,7 +2101,7 @@ tr52:
2100
2101
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
2101
2102
  FREE;
2102
2103
 
2103
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
2104
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
2104
2105
  }
2105
2106
  }
2106
2107
  else {
@@ -2108,8 +2109,10 @@ tr52:
2108
2109
  row_sep = ALLOC_N(char, len_row_sep);
2109
2110
  memcpy(row_sep, mark_row_sep, len_row_sep);
2110
2111
  }
2112
+
2113
+ curline++;
2111
2114
  }
2112
- #line 166 "ext/fastcsv/fastcsv.rl"
2115
+ #line 169 "ext/fastcsv/fastcsv.rl"
2113
2116
  {act = 2;}
2114
2117
  goto st12;
2115
2118
  tr58:
@@ -2120,12 +2123,11 @@ tr58:
2120
2123
  rb_ary_push(row, field);
2121
2124
  field = Qnil;
2122
2125
  }
2123
- #line 165 "ext/fastcsv/fastcsv.rl"
2126
+ #line 168 "ext/fastcsv/fastcsv.rl"
2124
2127
  {act = 1;}
2125
- #line 117 "ext/fastcsv/fastcsv.rl"
2128
+ #line 119 "ext/fastcsv/fastcsv.rl"
2126
2129
  {
2127
2130
  mark_row_sep = p;
2128
- curline++;
2129
2131
 
2130
2132
  if (d->start == 0 || p == d->start) {
2131
2133
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2150,7 +2152,7 @@ tr58:
2150
2152
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
2151
2153
  FREE;
2152
2154
 
2153
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
2155
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
2154
2156
  }
2155
2157
  }
2156
2158
  else {
@@ -2158,17 +2160,19 @@ tr58:
2158
2160
  row_sep = ALLOC_N(char, len_row_sep);
2159
2161
  memcpy(row_sep, mark_row_sep, len_row_sep);
2160
2162
  }
2163
+
2164
+ curline++;
2161
2165
  }
2162
2166
  goto st12;
2163
2167
  st12:
2164
2168
  if ( ++p == pe )
2165
2169
  goto _test_eof12;
2166
2170
  case 12:
2167
- #line 2168 "ext/fastcsv/fastcsv.c"
2171
+ #line 2172 "ext/fastcsv/fastcsv.c"
2168
2172
  _widec = (*p);
2169
2173
  _widec = (short)(128 + ((*p) - -128));
2170
2174
  if (
2171
- #line 155 "ext/fastcsv/fastcsv.rl"
2175
+ #line 156 "ext/fastcsv/fastcsv.rl"
2172
2176
  (*p) == quote_char ) _widec += 256;
2173
2177
  switch( _widec ) {
2174
2178
  case 256: goto tr43;
@@ -2224,10 +2228,9 @@ tr28:
2224
2228
  {
2225
2229
  unclosed_line = 0;
2226
2230
  }
2227
- #line 117 "ext/fastcsv/fastcsv.rl"
2231
+ #line 119 "ext/fastcsv/fastcsv.rl"
2228
2232
  {
2229
2233
  mark_row_sep = p;
2230
- curline++;
2231
2234
 
2232
2235
  if (d->start == 0 || p == d->start) {
2233
2236
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2244,7 +2247,7 @@ tr28:
2244
2247
  rb_yield(row);
2245
2248
  row = rb_ary_new();
2246
2249
  }
2247
- #line 166 "ext/fastcsv/fastcsv.rl"
2250
+ #line 169 "ext/fastcsv/fastcsv.rl"
2248
2251
  {act = 2;}
2249
2252
  goto st13;
2250
2253
  tr31:
@@ -2294,12 +2297,11 @@ tr31:
2294
2297
  rb_ary_push(row, field);
2295
2298
  field = Qnil;
2296
2299
  }
2297
- #line 165 "ext/fastcsv/fastcsv.rl"
2300
+ #line 168 "ext/fastcsv/fastcsv.rl"
2298
2301
  {act = 1;}
2299
- #line 117 "ext/fastcsv/fastcsv.rl"
2302
+ #line 119 "ext/fastcsv/fastcsv.rl"
2300
2303
  {
2301
2304
  mark_row_sep = p;
2302
- curline++;
2303
2305
 
2304
2306
  if (d->start == 0 || p == d->start) {
2305
2307
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2367,7 +2369,7 @@ tr49:
2367
2369
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
2368
2370
  FREE;
2369
2371
 
2370
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
2372
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
2371
2373
  }
2372
2374
  }
2373
2375
  else {
@@ -2375,8 +2377,10 @@ tr49:
2375
2377
  row_sep = ALLOC_N(char, len_row_sep);
2376
2378
  memcpy(row_sep, mark_row_sep, len_row_sep);
2377
2379
  }
2380
+
2381
+ curline++;
2378
2382
  }
2379
- #line 166 "ext/fastcsv/fastcsv.rl"
2383
+ #line 169 "ext/fastcsv/fastcsv.rl"
2380
2384
  {act = 2;}
2381
2385
  goto st13;
2382
2386
  tr54:
@@ -2421,10 +2425,9 @@ tr54:
2421
2425
  {
2422
2426
  unclosed_line = 0;
2423
2427
  }
2424
- #line 117 "ext/fastcsv/fastcsv.rl"
2428
+ #line 119 "ext/fastcsv/fastcsv.rl"
2425
2429
  {
2426
2430
  mark_row_sep = p;
2427
- curline++;
2428
2431
 
2429
2432
  if (d->start == 0 || p == d->start) {
2430
2433
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2449,7 +2452,7 @@ tr54:
2449
2452
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
2450
2453
  FREE;
2451
2454
 
2452
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
2455
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
2453
2456
  }
2454
2457
  }
2455
2458
  else {
@@ -2457,8 +2460,10 @@ tr54:
2457
2460
  row_sep = ALLOC_N(char, len_row_sep);
2458
2461
  memcpy(row_sep, mark_row_sep, len_row_sep);
2459
2462
  }
2463
+
2464
+ curline++;
2460
2465
  }
2461
- #line 166 "ext/fastcsv/fastcsv.rl"
2466
+ #line 169 "ext/fastcsv/fastcsv.rl"
2462
2467
  {act = 2;}
2463
2468
  goto st13;
2464
2469
  tr61:
@@ -2508,12 +2513,11 @@ tr61:
2508
2513
  rb_ary_push(row, field);
2509
2514
  field = Qnil;
2510
2515
  }
2511
- #line 165 "ext/fastcsv/fastcsv.rl"
2516
+ #line 168 "ext/fastcsv/fastcsv.rl"
2512
2517
  {act = 1;}
2513
- #line 117 "ext/fastcsv/fastcsv.rl"
2518
+ #line 119 "ext/fastcsv/fastcsv.rl"
2514
2519
  {
2515
2520
  mark_row_sep = p;
2516
- curline++;
2517
2521
 
2518
2522
  if (d->start == 0 || p == d->start) {
2519
2523
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2538,7 +2542,7 @@ tr61:
2538
2542
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
2539
2543
  FREE;
2540
2544
 
2541
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
2545
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
2542
2546
  }
2543
2547
  }
2544
2548
  else {
@@ -2546,20 +2550,22 @@ tr61:
2546
2550
  row_sep = ALLOC_N(char, len_row_sep);
2547
2551
  memcpy(row_sep, mark_row_sep, len_row_sep);
2548
2552
  }
2553
+
2554
+ curline++;
2549
2555
  }
2550
2556
  goto st13;
2551
2557
  st13:
2552
2558
  if ( ++p == pe )
2553
2559
  goto _test_eof13;
2554
2560
  case 13:
2555
- #line 2556 "ext/fastcsv/fastcsv.c"
2561
+ #line 2562 "ext/fastcsv/fastcsv.c"
2556
2562
  _widec = (*p);
2557
2563
  _widec = (short)(1152 + ((*p) - -128));
2558
2564
  if (
2559
- #line 155 "ext/fastcsv/fastcsv.rl"
2565
+ #line 156 "ext/fastcsv/fastcsv.rl"
2560
2566
  (*p) == quote_char ) _widec += 256;
2561
2567
  if (
2562
- #line 156 "ext/fastcsv/fastcsv.rl"
2568
+ #line 157 "ext/fastcsv/fastcsv.rl"
2563
2569
  (*p) == col_sep ) _widec += 512;
2564
2570
  switch( _widec ) {
2565
2571
  case 1280: goto tr50;
@@ -2629,7 +2635,7 @@ tr27:
2629
2635
  {
2630
2636
  unclosed_line = 0;
2631
2637
  }
2632
- #line 137 "ext/fastcsv/fastcsv.rl"
2638
+ #line 138 "ext/fastcsv/fastcsv.rl"
2633
2639
  {
2634
2640
  if (d->start == 0 || p == d->start) { // same as new_row
2635
2641
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2646,7 +2652,7 @@ tr27:
2646
2652
  rb_yield(row);
2647
2653
  }
2648
2654
  }
2649
- #line 167 "ext/fastcsv/fastcsv.rl"
2655
+ #line 170 "ext/fastcsv/fastcsv.rl"
2650
2656
  {act = 3;}
2651
2657
  goto st14;
2652
2658
  tr29:
@@ -2696,7 +2702,7 @@ tr29:
2696
2702
  rb_ary_push(row, field);
2697
2703
  field = Qnil;
2698
2704
  }
2699
- #line 165 "ext/fastcsv/fastcsv.rl"
2705
+ #line 168 "ext/fastcsv/fastcsv.rl"
2700
2706
  {act = 1;}
2701
2707
  goto st14;
2702
2708
  tr30:
@@ -2746,9 +2752,9 @@ tr30:
2746
2752
  rb_ary_push(row, field);
2747
2753
  field = Qnil;
2748
2754
  }
2749
- #line 165 "ext/fastcsv/fastcsv.rl"
2755
+ #line 168 "ext/fastcsv/fastcsv.rl"
2750
2756
  {act = 1;}
2751
- #line 137 "ext/fastcsv/fastcsv.rl"
2757
+ #line 138 "ext/fastcsv/fastcsv.rl"
2752
2758
  {
2753
2759
  if (d->start == 0 || p == d->start) { // same as new_row
2754
2760
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2816,7 +2822,7 @@ tr53:
2816
2822
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
2817
2823
  FREE;
2818
2824
 
2819
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
2825
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
2820
2826
  }
2821
2827
  }
2822
2828
  else {
@@ -2824,8 +2830,10 @@ tr53:
2824
2830
  row_sep = ALLOC_N(char, len_row_sep);
2825
2831
  memcpy(row_sep, mark_row_sep, len_row_sep);
2826
2832
  }
2833
+
2834
+ curline++;
2827
2835
  }
2828
- #line 137 "ext/fastcsv/fastcsv.rl"
2836
+ #line 138 "ext/fastcsv/fastcsv.rl"
2829
2837
  {
2830
2838
  if (d->start == 0 || p == d->start) { // same as new_row
2831
2839
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -2842,7 +2850,7 @@ tr53:
2842
2850
  rb_yield(row);
2843
2851
  }
2844
2852
  }
2845
- #line 167 "ext/fastcsv/fastcsv.rl"
2853
+ #line 170 "ext/fastcsv/fastcsv.rl"
2846
2854
  {act = 3;}
2847
2855
  goto st14;
2848
2856
  tr59:
@@ -2892,7 +2900,7 @@ tr59:
2892
2900
  rb_ary_push(row, field);
2893
2901
  field = Qnil;
2894
2902
  }
2895
- #line 165 "ext/fastcsv/fastcsv.rl"
2903
+ #line 168 "ext/fastcsv/fastcsv.rl"
2896
2904
  {act = 1;}
2897
2905
  #line 100 "ext/fastcsv/fastcsv.rl"
2898
2906
  {
@@ -2902,7 +2910,7 @@ tr59:
2902
2910
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
2903
2911
  FREE;
2904
2912
 
2905
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
2913
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
2906
2914
  }
2907
2915
  }
2908
2916
  else {
@@ -2910,6 +2918,8 @@ tr59:
2910
2918
  row_sep = ALLOC_N(char, len_row_sep);
2911
2919
  memcpy(row_sep, mark_row_sep, len_row_sep);
2912
2920
  }
2921
+
2922
+ curline++;
2913
2923
  }
2914
2924
  goto st14;
2915
2925
  tr60:
@@ -2959,7 +2969,7 @@ tr60:
2959
2969
  rb_ary_push(row, field);
2960
2970
  field = Qnil;
2961
2971
  }
2962
- #line 165 "ext/fastcsv/fastcsv.rl"
2972
+ #line 168 "ext/fastcsv/fastcsv.rl"
2963
2973
  {act = 1;}
2964
2974
  #line 100 "ext/fastcsv/fastcsv.rl"
2965
2975
  {
@@ -2969,7 +2979,7 @@ tr60:
2969
2979
  if (p - mark_row_sep != len_row_sep || row_sep[0] != *mark_row_sep || (len_row_sep == 2 && row_sep[1] != *(mark_row_sep + 1))) {
2970
2980
  FREE;
2971
2981
 
2972
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
2982
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
2973
2983
  }
2974
2984
  }
2975
2985
  else {
@@ -2977,8 +2987,10 @@ tr60:
2977
2987
  row_sep = ALLOC_N(char, len_row_sep);
2978
2988
  memcpy(row_sep, mark_row_sep, len_row_sep);
2979
2989
  }
2990
+
2991
+ curline++;
2980
2992
  }
2981
- #line 137 "ext/fastcsv/fastcsv.rl"
2993
+ #line 138 "ext/fastcsv/fastcsv.rl"
2982
2994
  {
2983
2995
  if (d->start == 0 || p == d->start) { // same as new_row
2984
2996
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -3000,14 +3012,14 @@ st14:
3000
3012
  if ( ++p == pe )
3001
3013
  goto _test_eof14;
3002
3014
  case 14:
3003
- #line 3004 "ext/fastcsv/fastcsv.c"
3015
+ #line 3016 "ext/fastcsv/fastcsv.c"
3004
3016
  _widec = (*p);
3005
3017
  _widec = (short)(1152 + ((*p) - -128));
3006
3018
  if (
3007
- #line 155 "ext/fastcsv/fastcsv.rl"
3019
+ #line 156 "ext/fastcsv/fastcsv.rl"
3008
3020
  (*p) == quote_char ) _widec += 256;
3009
3021
  if (
3010
- #line 156 "ext/fastcsv/fastcsv.rl"
3022
+ #line 157 "ext/fastcsv/fastcsv.rl"
3011
3023
  (*p) == col_sep ) _widec += 512;
3012
3024
  switch( _widec ) {
3013
3025
  case 1280: goto tr13;
@@ -3074,7 +3086,7 @@ case 14:
3074
3086
  _out: {}
3075
3087
  }
3076
3088
 
3077
- #line 444 "ext/fastcsv/fastcsv.rl"
3089
+ #line 447 "ext/fastcsv/fastcsv.rl"
3078
3090
 
3079
3091
  if (done && cs < raw_parse_first_final) {
3080
3092
  if (d->start == 0 || p == d->start) { // same as new_row
@@ -3100,6 +3112,13 @@ case 14:
3100
3112
  else if (io) {
3101
3113
  have = pe - ts;
3102
3114
  memmove(buf, ts, have);
3115
+ // @see https://github.com/hpricot/hpricot/blob/master/ext/hpricot_scan/hpricot_scan.rl#L92
3116
+ if (d->start > ts) {
3117
+ d->start = buf + (d->start - ts);
3118
+ }
3119
+ if (mark_row_sep > ts) {
3120
+ mark_row_sep = buf + (mark_row_sep - ts);
3121
+ }
3103
3122
  te = buf + (te - ts);
3104
3123
  ts = buf;
3105
3124
  }