ccsv_ext 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32c73086c2a4707bc50f2875e3078068d17ccf96b834056ce54b0a49711703c0
4
- data.tar.gz: 894d3045d2d97b4fa503889eb714b204eb6e2ac1d2c442fed1f0c75d4e411d5a
3
+ metadata.gz: b6ecf36f3972b479d1accbac32aa5b7601e09189de26a61aaa49a8573dc5cbd9
4
+ data.tar.gz: e100dee658a5894f0fe80b48cdc969f5cdcb824d4d04b21354ad2141e87146e4
5
5
  SHA512:
6
- metadata.gz: 2e3c0c6c330f69058d7f36571821bb1b31b430dc5dc4dae23585182044c981af7f7a2d10c109ad11e321acd3236423d88059392aa636a55d668d282184e915fc
7
- data.tar.gz: 0d7a9b74c25f24a39f16e342260fa88ba910f306f68b3741441170bf29d87ff62e0cc3d7920bd1916fcadda24ddf6f1bebf9c273a20b50d6f10d7a2a434fdd59
6
+ metadata.gz: fc5511efb546720d71ad0a0702ef46b4a32a321073ab4d03794dcce6eb47e4f935578d03fd5404a065cf121664cdbe1e36b77ec3567159a53596fa9bd7a30fae
7
+ data.tar.gz: 2a50a21b1c7a45ad886188f548e11fedec8e6e00e225f3cf6d6e643c6242d82db82d4a440aba02bae32876c7b0af0e3e509f40541759aeb78f83a90907bc73f9
@@ -5,13 +5,16 @@ static VALUE rb_cC;
5
5
 
6
6
  /* Ccsv.parse_line(string ,delimiter) */
7
7
 
8
- #define MAX_INTERVALS 1024
9
-
10
8
  static VALUE parse_line(VALUE self, VALUE str, VALUE delimiter) {
11
9
  char *line = RSTRING_PTR(str);
12
10
  char *delim = RSTRING_PTR(delimiter);
13
11
  int len = RSTRING_LEN(str);
14
- char token[MAX_INTERVALS * 5];
12
+ char *token = (char *) malloc(len + 1);
13
+ VALUE ary = rb_ary_new();
14
+
15
+ /* if token == NULL - exit */
16
+ if (token == NULL)
17
+ return ary;
15
18
 
16
19
  /* chomp! */
17
20
  if(line[len] == EOL){
@@ -20,10 +23,9 @@ static VALUE parse_line(VALUE self, VALUE str, VALUE delimiter) {
20
23
  line[len] = '\0';
21
24
  }
22
25
 
23
- VALUE ary = rb_ary_new();
24
-
25
26
  /* skip empty line */
26
27
  if (len < 2) {
28
+ free(token);
27
29
  return ary;
28
30
  }
29
31
 
@@ -59,6 +61,7 @@ static VALUE parse_line(VALUE self, VALUE str, VALUE delimiter) {
59
61
  else if (line[i - 1] != EOL)
60
62
  rb_ary_push(ary, rb_enc_str_new(&token[0], strlen(&token[0]), rb_utf8_encoding()));
61
63
 
64
+ free(token);
62
65
  rb_ary_dup(ary);
63
66
  }
64
67
 
Binary file
@@ -1,3 +1,3 @@
1
1
  class CcsvExt
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ccsv_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Golushko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-20 00:00:00.000000000 Z
11
+ date: 2019-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler