fastcsv 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/fastcsv/fastcsv.c +51 -68
- data/ext/fastcsv/fastcsv.rl +10 -23
- data/fastcsv.gemspec +1 -1
- data/lib/fastcsv.rb +4 -0
- data/spec/fastcsv_spec.rb +1 -0
- data/test/csv/test_csv_parsing.rb +10 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5c917e36ec5bc0f784fa36281e33e23a14784c3
|
4
|
+
data.tar.gz: 38ac5f6dc7c494759b98c06b4879c54770e088d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfcc78d6223c83a270b658921a334e70f58dc600d380935d3baf27e980c0881cfcc5018af08adbb5f039f839aa52c153f161013fa1ae544f74c5968fac1daf86
|
7
|
+
data.tar.gz: 0e7c462ec4f1d41174885faa9af6fd93db533cb143e1403fa7dc0b3fa18bc8e6a69a4e3db3697ee798f430d3af5191f31d9c2eee04f6e9e2e40edcccb0ca45dc
|
data/ext/fastcsv/fastcsv.c
CHANGED
@@ -24,9 +24,6 @@ if (enc2 != NULL) { \
|
|
24
24
|
#define FREE \
|
25
25
|
if (buf != NULL) { \
|
26
26
|
free(buf); \
|
27
|
-
} \
|
28
|
-
if (row_sep != NULL) { \
|
29
|
-
free(row_sep); \
|
30
27
|
}
|
31
28
|
|
32
29
|
static VALUE cClass, cParser, eError;
|
@@ -38,11 +35,11 @@ typedef struct {
|
|
38
35
|
} Data;
|
39
36
|
|
40
37
|
|
41
|
-
#line
|
38
|
+
#line 152 "ext/fastcsv/fastcsv.rl"
|
42
39
|
|
43
40
|
|
44
41
|
|
45
|
-
#line
|
42
|
+
#line 43 "ext/fastcsv/fastcsv.c"
|
46
43
|
static const int raw_parse_start = 4;
|
47
44
|
static const int raw_parse_first_final = 4;
|
48
45
|
static const int raw_parse_error = 0;
|
@@ -50,7 +47,7 @@ static const int raw_parse_error = 0;
|
|
50
47
|
static const int raw_parse_en_main = 4;
|
51
48
|
|
52
49
|
|
53
|
-
#line
|
50
|
+
#line 155 "ext/fastcsv/fastcsv.rl"
|
54
51
|
|
55
52
|
// 16 kB
|
56
53
|
#define BUFSIZE 16384
|
@@ -83,11 +80,11 @@ static void rb_io_ext_int_to_encs(rb_encoding *ext, rb_encoding *intern, rb_enco
|
|
83
80
|
|
84
81
|
static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
85
82
|
int cs, act, have = 0, curline = 1, io = 0;
|
86
|
-
char *ts = 0, *te = 0, *buf = 0, *eof = 0
|
83
|
+
char *ts = 0, *te = 0, *buf = 0, *eof = 0;
|
87
84
|
|
88
85
|
VALUE port, opts, r_encoding;
|
89
86
|
VALUE row = rb_ary_new(), field = Qnil, bufsize = Qnil;
|
90
|
-
int done = 0, unclosed_line = 0,
|
87
|
+
int done = 0, unclosed_line = 0, buffer_size = 0, taint = 0;
|
91
88
|
rb_encoding *enc = NULL, *enc2 = NULL, *encoding = NULL;
|
92
89
|
|
93
90
|
Data *d;
|
@@ -225,6 +222,8 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
225
222
|
encoding = rb_enc_get(r_encoding);
|
226
223
|
}
|
227
224
|
|
225
|
+
// In case #raw_parse is called multiple times on the same parser. Note that
|
226
|
+
// using IO methods on a re-used parser can cause segmentation faults.
|
228
227
|
rb_ivar_set(self, s_row, Qnil);
|
229
228
|
|
230
229
|
buffer_size = BUFSIZE;
|
@@ -244,7 +243,7 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
244
243
|
}
|
245
244
|
|
246
245
|
|
247
|
-
#line
|
246
|
+
#line 247 "ext/fastcsv/fastcsv.c"
|
248
247
|
{
|
249
248
|
cs = raw_parse_start;
|
250
249
|
ts = 0;
|
@@ -252,12 +251,12 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
252
251
|
act = 0;
|
253
252
|
}
|
254
253
|
|
255
|
-
#line
|
254
|
+
#line 350 "ext/fastcsv/fastcsv.rl"
|
256
255
|
|
257
256
|
while (!done) {
|
258
257
|
VALUE str;
|
259
258
|
char *p, *pe;
|
260
|
-
int len, space = buffer_size - have, tokstart_diff, tokend_diff, start_diff
|
259
|
+
int len, space = buffer_size - have, tokstart_diff, tokend_diff, start_diff;
|
261
260
|
|
262
261
|
if (io) {
|
263
262
|
if (space == 0) {
|
@@ -265,7 +264,6 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
265
264
|
tokstart_diff = ts - buf;
|
266
265
|
tokend_diff = te - buf;
|
267
266
|
start_diff = d->start - buf;
|
268
|
-
mark_row_sep_diff = mark_row_sep - buf;
|
269
267
|
|
270
268
|
buffer_size += BUFSIZE;
|
271
269
|
REALLOC_N(buf, char, buffer_size);
|
@@ -275,7 +273,6 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
275
273
|
ts = buf + tokstart_diff;
|
276
274
|
te = buf + tokend_diff;
|
277
275
|
d->start = buf + start_diff;
|
278
|
-
mark_row_sep = buf + mark_row_sep_diff;
|
279
276
|
}
|
280
277
|
p = buf + have;
|
281
278
|
|
@@ -314,7 +311,7 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
314
311
|
|
315
312
|
pe = p + len;
|
316
313
|
|
317
|
-
#line
|
314
|
+
#line 315 "ext/fastcsv/fastcsv.c"
|
318
315
|
{
|
319
316
|
if ( p == pe )
|
320
317
|
goto _test_eof;
|
@@ -333,7 +330,7 @@ tr0:
|
|
333
330
|
}
|
334
331
|
goto st4;
|
335
332
|
tr5:
|
336
|
-
#line
|
333
|
+
#line 46 "ext/fastcsv/fastcsv.rl"
|
337
334
|
{
|
338
335
|
if (p == ts) {
|
339
336
|
// Unquoted empty fields are nil, not "", in Ruby.
|
@@ -344,16 +341,16 @@ tr5:
|
|
344
341
|
ENCODE;
|
345
342
|
}
|
346
343
|
}
|
347
|
-
#line
|
344
|
+
#line 92 "ext/fastcsv/fastcsv.rl"
|
348
345
|
{
|
349
346
|
rb_ary_push(row, field);
|
350
347
|
field = Qnil;
|
351
348
|
}
|
352
|
-
#line
|
349
|
+
#line 148 "ext/fastcsv/fastcsv.rl"
|
353
350
|
{te = p+1;}
|
354
351
|
goto st4;
|
355
352
|
tr9:
|
356
|
-
#line
|
353
|
+
#line 120 "ext/fastcsv/fastcsv.rl"
|
357
354
|
{
|
358
355
|
if (d->start == 0 || p == d->start) {
|
359
356
|
rb_ivar_set(self, s_row, rb_str_new2(""));
|
@@ -370,41 +367,28 @@ tr9:
|
|
370
367
|
rb_yield(row);
|
371
368
|
}
|
372
369
|
}
|
373
|
-
#line
|
370
|
+
#line 150 "ext/fastcsv/fastcsv.rl"
|
374
371
|
{te = p+1;}
|
375
372
|
goto st4;
|
376
373
|
tr12:
|
377
|
-
#line
|
374
|
+
#line 92 "ext/fastcsv/fastcsv.rl"
|
378
375
|
{
|
379
376
|
rb_ary_push(row, field);
|
380
377
|
field = Qnil;
|
381
378
|
}
|
382
|
-
#line
|
379
|
+
#line 148 "ext/fastcsv/fastcsv.rl"
|
383
380
|
{te = p+1;}
|
384
381
|
goto st4;
|
385
382
|
tr15:
|
386
|
-
#line
|
383
|
+
#line 150 "ext/fastcsv/fastcsv.rl"
|
387
384
|
{te = p;p--;}
|
388
385
|
goto st4;
|
389
386
|
tr16:
|
390
|
-
#line
|
387
|
+
#line 97 "ext/fastcsv/fastcsv.rl"
|
391
388
|
{
|
392
389
|
d->start = p;
|
393
|
-
|
394
|
-
if (len_row_sep) {
|
395
|
-
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)) {
|
396
|
-
FREE;
|
397
|
-
|
398
|
-
rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
|
399
|
-
}
|
400
|
-
}
|
401
|
-
else {
|
402
|
-
len_row_sep = p - mark_row_sep;
|
403
|
-
row_sep = ALLOC_N(char, p - mark_row_sep);
|
404
|
-
memcpy(row_sep, mark_row_sep, p - mark_row_sep);
|
405
|
-
}
|
406
390
|
}
|
407
|
-
#line
|
391
|
+
#line 149 "ext/fastcsv/fastcsv.rl"
|
408
392
|
{te = p;p--;}
|
409
393
|
goto st4;
|
410
394
|
st4:
|
@@ -417,7 +401,7 @@ st4:
|
|
417
401
|
case 4:
|
418
402
|
#line 1 "NONE"
|
419
403
|
{ts = p;}
|
420
|
-
#line
|
404
|
+
#line 405 "ext/fastcsv/fastcsv.c"
|
421
405
|
switch( (*p) ) {
|
422
406
|
case 0: goto tr13;
|
423
407
|
case 10: goto tr3;
|
@@ -441,7 +425,7 @@ case 1:
|
|
441
425
|
tr2:
|
442
426
|
#line 1 "NONE"
|
443
427
|
{te = p+1;}
|
444
|
-
#line
|
428
|
+
#line 46 "ext/fastcsv/fastcsv.rl"
|
445
429
|
{
|
446
430
|
if (p == ts) {
|
447
431
|
// Unquoted empty fields are nil, not "", in Ruby.
|
@@ -452,7 +436,7 @@ tr2:
|
|
452
436
|
ENCODE;
|
453
437
|
}
|
454
438
|
}
|
455
|
-
#line
|
439
|
+
#line 120 "ext/fastcsv/fastcsv.rl"
|
456
440
|
{
|
457
441
|
if (d->start == 0 || p == d->start) {
|
458
442
|
rb_ivar_set(self, s_row, rb_str_new2(""));
|
@@ -469,14 +453,14 @@ tr2:
|
|
469
453
|
rb_yield(row);
|
470
454
|
}
|
471
455
|
}
|
472
|
-
#line
|
456
|
+
#line 150 "ext/fastcsv/fastcsv.rl"
|
473
457
|
{act = 3;}
|
474
458
|
goto st5;
|
475
459
|
st5:
|
476
460
|
if ( ++p == pe )
|
477
461
|
goto _test_eof5;
|
478
462
|
case 5:
|
479
|
-
#line
|
463
|
+
#line 464 "ext/fastcsv/fastcsv.c"
|
480
464
|
switch( (*p) ) {
|
481
465
|
case 0: goto tr2;
|
482
466
|
case 10: goto tr3;
|
@@ -486,7 +470,7 @@ case 5:
|
|
486
470
|
}
|
487
471
|
goto st1;
|
488
472
|
tr3:
|
489
|
-
#line
|
473
|
+
#line 46 "ext/fastcsv/fastcsv.rl"
|
490
474
|
{
|
491
475
|
if (p == ts) {
|
492
476
|
// Unquoted empty fields are nil, not "", in Ruby.
|
@@ -497,10 +481,8 @@ tr3:
|
|
497
481
|
ENCODE;
|
498
482
|
}
|
499
483
|
}
|
500
|
-
#line
|
484
|
+
#line 101 "ext/fastcsv/fastcsv.rl"
|
501
485
|
{
|
502
|
-
mark_row_sep = p;
|
503
|
-
|
504
486
|
curline++;
|
505
487
|
|
506
488
|
if (d->start == 0 || p == d->start) {
|
@@ -520,10 +502,8 @@ tr3:
|
|
520
502
|
}
|
521
503
|
goto st6;
|
522
504
|
tr10:
|
523
|
-
#line
|
505
|
+
#line 101 "ext/fastcsv/fastcsv.rl"
|
524
506
|
{
|
525
|
-
mark_row_sep = p;
|
526
|
-
|
527
507
|
curline++;
|
528
508
|
|
529
509
|
if (d->start == 0 || p == d->start) {
|
@@ -546,10 +526,10 @@ st6:
|
|
546
526
|
if ( ++p == pe )
|
547
527
|
goto _test_eof6;
|
548
528
|
case 6:
|
549
|
-
#line
|
529
|
+
#line 530 "ext/fastcsv/fastcsv.c"
|
550
530
|
goto tr16;
|
551
531
|
tr4:
|
552
|
-
#line
|
532
|
+
#line 46 "ext/fastcsv/fastcsv.rl"
|
553
533
|
{
|
554
534
|
if (p == ts) {
|
555
535
|
// Unquoted empty fields are nil, not "", in Ruby.
|
@@ -560,10 +540,8 @@ tr4:
|
|
560
540
|
ENCODE;
|
561
541
|
}
|
562
542
|
}
|
563
|
-
#line
|
543
|
+
#line 101 "ext/fastcsv/fastcsv.rl"
|
564
544
|
{
|
565
|
-
mark_row_sep = p;
|
566
|
-
|
567
545
|
curline++;
|
568
546
|
|
569
547
|
if (d->start == 0 || p == d->start) {
|
@@ -583,10 +561,8 @@ tr4:
|
|
583
561
|
}
|
584
562
|
goto st7;
|
585
563
|
tr11:
|
586
|
-
#line
|
564
|
+
#line 101 "ext/fastcsv/fastcsv.rl"
|
587
565
|
{
|
588
|
-
mark_row_sep = p;
|
589
|
-
|
590
566
|
curline++;
|
591
567
|
|
592
568
|
if (d->start == 0 || p == d->start) {
|
@@ -609,14 +585,14 @@ st7:
|
|
609
585
|
if ( ++p == pe )
|
610
586
|
goto _test_eof7;
|
611
587
|
case 7:
|
612
|
-
#line
|
588
|
+
#line 589 "ext/fastcsv/fastcsv.c"
|
613
589
|
if ( (*p) == 10 )
|
614
590
|
goto st6;
|
615
591
|
goto tr16;
|
616
592
|
tr13:
|
617
593
|
#line 1 "NONE"
|
618
594
|
{te = p+1;}
|
619
|
-
#line
|
595
|
+
#line 46 "ext/fastcsv/fastcsv.rl"
|
620
596
|
{
|
621
597
|
if (p == ts) {
|
622
598
|
// Unquoted empty fields are nil, not "", in Ruby.
|
@@ -627,7 +603,7 @@ tr13:
|
|
627
603
|
ENCODE;
|
628
604
|
}
|
629
605
|
}
|
630
|
-
#line
|
606
|
+
#line 120 "ext/fastcsv/fastcsv.rl"
|
631
607
|
{
|
632
608
|
if (d->start == 0 || p == d->start) {
|
633
609
|
rb_ivar_set(self, s_row, rb_str_new2(""));
|
@@ -644,14 +620,14 @@ tr13:
|
|
644
620
|
rb_yield(row);
|
645
621
|
}
|
646
622
|
}
|
647
|
-
#line
|
623
|
+
#line 150 "ext/fastcsv/fastcsv.rl"
|
648
624
|
{act = 3;}
|
649
625
|
goto st8;
|
650
626
|
st8:
|
651
627
|
if ( ++p == pe )
|
652
628
|
goto _test_eof8;
|
653
629
|
case 8:
|
654
|
-
#line
|
630
|
+
#line 631 "ext/fastcsv/fastcsv.c"
|
655
631
|
switch( (*p) ) {
|
656
632
|
case 10: goto tr15;
|
657
633
|
case 13: goto tr15;
|
@@ -660,7 +636,7 @@ case 8:
|
|
660
636
|
}
|
661
637
|
goto st1;
|
662
638
|
tr14:
|
663
|
-
#line
|
639
|
+
#line 38 "ext/fastcsv/fastcsv.rl"
|
664
640
|
{
|
665
641
|
unclosed_line = curline;
|
666
642
|
}
|
@@ -669,7 +645,7 @@ st2:
|
|
669
645
|
if ( ++p == pe )
|
670
646
|
goto _test_eof2;
|
671
647
|
case 2:
|
672
|
-
#line
|
648
|
+
#line 649 "ext/fastcsv/fastcsv.c"
|
673
649
|
switch( (*p) ) {
|
674
650
|
case 0: goto st0;
|
675
651
|
case 34: goto tr8;
|
@@ -679,7 +655,7 @@ st0:
|
|
679
655
|
cs = 0;
|
680
656
|
goto _out;
|
681
657
|
tr8:
|
682
|
-
#line
|
658
|
+
#line 57 "ext/fastcsv/fastcsv.rl"
|
683
659
|
{
|
684
660
|
if (p == ts) {
|
685
661
|
field = rb_enc_str_new("", 0, encoding);
|
@@ -714,7 +690,7 @@ tr8:
|
|
714
690
|
}
|
715
691
|
}
|
716
692
|
}
|
717
|
-
#line
|
693
|
+
#line 42 "ext/fastcsv/fastcsv.rl"
|
718
694
|
{
|
719
695
|
unclosed_line = 0;
|
720
696
|
}
|
@@ -723,7 +699,7 @@ st3:
|
|
723
699
|
if ( ++p == pe )
|
724
700
|
goto _test_eof3;
|
725
701
|
case 3:
|
726
|
-
#line
|
702
|
+
#line 703 "ext/fastcsv/fastcsv.c"
|
727
703
|
switch( (*p) ) {
|
728
704
|
case 0: goto tr9;
|
729
705
|
case 10: goto tr10;
|
@@ -757,9 +733,16 @@ case 3:
|
|
757
733
|
_out: {}
|
758
734
|
}
|
759
735
|
|
760
|
-
#line
|
736
|
+
#line 409 "ext/fastcsv/fastcsv.rl"
|
761
737
|
|
762
738
|
if (done && cs < raw_parse_first_final) {
|
739
|
+
if (d->start == 0 || p == d->start) {
|
740
|
+
rb_ivar_set(self, s_row, rb_str_new2(""));
|
741
|
+
}
|
742
|
+
else if (p > d->start) {
|
743
|
+
rb_ivar_set(self, s_row, rb_str_new(d->start, p - d->start));
|
744
|
+
}
|
745
|
+
|
763
746
|
FREE;
|
764
747
|
|
765
748
|
if (unclosed_line) {
|
data/ext/fastcsv/fastcsv.rl
CHANGED
@@ -22,9 +22,6 @@ if (enc2 != NULL) { \
|
|
22
22
|
#define FREE \
|
23
23
|
if (buf != NULL) { \
|
24
24
|
free(buf); \
|
25
|
-
} \
|
26
|
-
if (row_sep != NULL) { \
|
27
|
-
free(row_sep); \
|
28
25
|
}
|
29
26
|
|
30
27
|
static VALUE cClass, cParser, eError;
|
@@ -99,24 +96,9 @@ typedef struct {
|
|
99
96
|
|
100
97
|
action mark_row {
|
101
98
|
d->start = p;
|
102
|
-
|
103
|
-
if (len_row_sep) {
|
104
|
-
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)) {
|
105
|
-
FREE;
|
106
|
-
|
107
|
-
rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
|
108
|
-
}
|
109
|
-
}
|
110
|
-
else {
|
111
|
-
len_row_sep = p - mark_row_sep;
|
112
|
-
row_sep = ALLOC_N(char, p - mark_row_sep);
|
113
|
-
memcpy(row_sep, mark_row_sep, p - mark_row_sep);
|
114
|
-
}
|
115
99
|
}
|
116
100
|
|
117
101
|
action new_row {
|
118
|
-
mark_row_sep = p;
|
119
|
-
|
120
102
|
curline++;
|
121
103
|
|
122
104
|
if (d->start == 0 || p == d->start) {
|
@@ -202,11 +184,11 @@ static void rb_io_ext_int_to_encs(rb_encoding *ext, rb_encoding *intern, rb_enco
|
|
202
184
|
|
203
185
|
static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
204
186
|
int cs, act, have = 0, curline = 1, io = 0;
|
205
|
-
char *ts = 0, *te = 0, *buf = 0, *eof = 0
|
187
|
+
char *ts = 0, *te = 0, *buf = 0, *eof = 0;
|
206
188
|
|
207
189
|
VALUE port, opts, r_encoding;
|
208
190
|
VALUE row = rb_ary_new(), field = Qnil, bufsize = Qnil;
|
209
|
-
int done = 0, unclosed_line = 0,
|
191
|
+
int done = 0, unclosed_line = 0, buffer_size = 0, taint = 0;
|
210
192
|
rb_encoding *enc = NULL, *enc2 = NULL, *encoding = NULL;
|
211
193
|
|
212
194
|
Data *d;
|
@@ -369,7 +351,7 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
369
351
|
while (!done) {
|
370
352
|
VALUE str;
|
371
353
|
char *p, *pe;
|
372
|
-
int len, space = buffer_size - have, tokstart_diff, tokend_diff, start_diff
|
354
|
+
int len, space = buffer_size - have, tokstart_diff, tokend_diff, start_diff;
|
373
355
|
|
374
356
|
if (io) {
|
375
357
|
if (space == 0) {
|
@@ -377,7 +359,6 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
377
359
|
tokstart_diff = ts - buf;
|
378
360
|
tokend_diff = te - buf;
|
379
361
|
start_diff = d->start - buf;
|
380
|
-
mark_row_sep_diff = mark_row_sep - buf;
|
381
362
|
|
382
363
|
buffer_size += BUFSIZE;
|
383
364
|
REALLOC_N(buf, char, buffer_size);
|
@@ -387,7 +368,6 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
387
368
|
ts = buf + tokstart_diff;
|
388
369
|
te = buf + tokend_diff;
|
389
370
|
d->start = buf + start_diff;
|
390
|
-
mark_row_sep = buf + mark_row_sep_diff;
|
391
371
|
}
|
392
372
|
p = buf + have;
|
393
373
|
|
@@ -428,6 +408,13 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
428
408
|
%% write exec;
|
429
409
|
|
430
410
|
if (done && cs < raw_parse_first_final) {
|
411
|
+
if (d->start == 0 || p == d->start) {
|
412
|
+
rb_ivar_set(self, s_row, rb_str_new2(""));
|
413
|
+
}
|
414
|
+
else if (p > d->start) {
|
415
|
+
rb_ivar_set(self, s_row, rb_str_new(d->start, p - d->start));
|
416
|
+
}
|
417
|
+
|
431
418
|
FREE;
|
432
419
|
|
433
420
|
if (unclosed_line) {
|
data/fastcsv.gemspec
CHANGED
data/lib/fastcsv.rb
CHANGED
data/spec/fastcsv_spec.rb
CHANGED
@@ -147,6 +147,7 @@ RSpec.shared_examples 'a CSV parser' do
|
|
147
147
|
it 'should raise an error on mixed row separators' do
|
148
148
|
csv = "foo\rbar\nbaz\r\n"
|
149
149
|
expect{CSV.parse(csv)}.to raise_error(CSV::MalformedCSVError, 'Unquoted fields do not allow \r or \n (line 2).')
|
150
|
+
skip
|
150
151
|
expect{FastCSV.parse(csv)}.to raise_error(FastCSV::MalformedCSVError, 'Unquoted fields do not allow \r or \n (line 2).')
|
151
152
|
end
|
152
153
|
|
@@ -160,16 +160,16 @@ class TestCSV::Parsing < TestCSV
|
|
160
160
|
assert_equal(6, lines.size)
|
161
161
|
assert_match(/\Aline,4/, lines.find { |l| l =~ /some\rjunk/ })
|
162
162
|
|
163
|
-
csv = FastCSV.new(bad_data)
|
164
|
-
begin
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
rescue FastCSV::MalformedCSVError
|
170
|
-
|
171
|
-
|
172
|
-
end
|
163
|
+
# csv = FastCSV.new(bad_data)
|
164
|
+
# begin
|
165
|
+
# loop do
|
166
|
+
# assert_not_nil(csv.shift)
|
167
|
+
# assert_send([csv.lineno, :<, 5]) # FIXME 4
|
168
|
+
# end
|
169
|
+
# rescue FastCSV::MalformedCSVError
|
170
|
+
# assert_equal( "Unquoted fields do not allow \\r or \\n (line 4).",
|
171
|
+
# $!.message )
|
172
|
+
# end
|
173
173
|
|
174
174
|
assert_raise(FastCSV::MalformedCSVError) { FastCSV.parse_line('1,2,"3...') }
|
175
175
|
|