fastcsv 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -104,7 +104,7 @@ typedef struct {
104
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
105
  FREE;
106
106
 
107
- rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline - 1);
107
+ rb_raise(eError, "Unquoted fields do not allow \\r or \\n (line %d).", curline);
108
108
  }
109
109
  }
110
110
  else {
@@ -112,11 +112,12 @@ typedef struct {
112
112
  row_sep = ALLOC_N(char, len_row_sep);
113
113
  memcpy(row_sep, mark_row_sep, len_row_sep);
114
114
  }
115
+
116
+ curline++;
115
117
  }
116
118
 
117
119
  action new_row {
118
120
  mark_row_sep = p;
119
- curline++;
120
121
 
121
122
  if (d->start == 0 || p == d->start) {
122
123
  rb_ivar_set(self, s_row, rb_str_new2(""));
@@ -160,6 +161,8 @@ typedef struct {
160
161
  field = unquoted | quoted;
161
162
 
162
163
  # @see Ragel Guide: 6.3 Scanners
164
+ # > Entering
165
+ # % Leaving
163
166
  # An unquoted field can be zero-length.
164
167
  main := |*
165
168
  field col_sep;
@@ -466,6 +469,13 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
466
469
  else if (io) {
467
470
  have = pe - ts;
468
471
  memmove(buf, ts, have);
472
+ // @see https://github.com/hpricot/hpricot/blob/master/ext/hpricot_scan/hpricot_scan.rl#L92
473
+ if (d->start > ts) {
474
+ d->start = buf + (d->start - ts);
475
+ }
476
+ if (mark_row_sep > ts) {
477
+ mark_row_sep = buf + (mark_row_sep - ts);
478
+ }
469
479
  te = buf + (te - ts);
470
480
  ts = buf;
471
481
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "fastcsv"
5
- s.version = '0.0.5'
5
+ s.version = '0.0.6'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["James McKinney"]
8
8
  s.homepage = "https://github.com/jpmckinney/fastcsv"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastcsv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James McKinney
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.2.0
145
+ rubygems_version: 2.2.2
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: A fast Ragel-based CSV parser, compatible with Ruby's CSV