edn_turbo 0.5.1 → 0.5.2

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: 22aa24b410b3f96a61348d2337a09a149c8b9cb2
4
- data.tar.gz: a2acc757c6860c20554eb8193cff4c85f75d7c22
3
+ metadata.gz: 87badf5b6b0c38f6f22fd662b0add51be662a6a2
4
+ data.tar.gz: d9a0b304de6ea51480a9747df4a8d35ad826c246
5
5
  SHA512:
6
- metadata.gz: 6414fa962e6d8b5558d615c5fa54a121edc6ee17f2e6080d81b183806224e6937096c1d43e6f3be58e30b2a383010f43e3c76200cfa774887e406317ba57f0b6
7
- data.tar.gz: 8be7e90de1ad7383a11e5b1613b59be193bdb0e06e9483584bd1459b9b274a45aee486f301b367995eb12da336f41671618eb5aa729a052ef25d8a365c64f6d9
6
+ metadata.gz: 0d717030106eeca177d00eeb26dc58330a0a873c932346d0463bb00e926288b08b5bf4070c5b4240505b8f63eeec675da83c91c163880842c1c9379d409a0429
7
+ data.tar.gz: 0b9e043cfafe56031026861f221302657a07acb6353b8274083affb14d02d9a081ec820b046cac14979ced57d0d6e110db5178d5b54bd13db6319c3c44d926b4
@@ -611,7 +611,7 @@ case 5:
611
611
 
612
612
  if (cs >= EDN_keyword_first_final) {
613
613
  std::string buf;
614
- uint32_t len = p - p_save;
614
+ uintmax_t len = p - p_save;
615
615
  // don't include leading ':' because the ruby symbol will handle it
616
616
  buf.append(p_save + 1, len - 1);
617
617
  v = ID2SYM(rb_intern(buf.c_str()));
@@ -60,7 +60,7 @@ namespace edn
60
60
  FILE* core_io; // for IO streams
61
61
  VALUE read_io; // for non-core IO that responds to read()
62
62
  char* io_buffer;
63
- uintmax_t io_buffer_len;
63
+ uint32_t io_buffer_len;
64
64
  std::size_t line_number;
65
65
  std::vector<VALUE> discard;
66
66
  std::stack<std::vector<VALUE>* > metadata;
@@ -280,7 +280,7 @@ const char* edn::Parser::parse_keyword(const char *p, const char *pe, VALUE& v)
280
280
 
281
281
  if (cs >= EDN_keyword_first_final) {
282
282
  std::string buf;
283
- uint32_t len = p - p_save;
283
+ uintmax_t len = p - p_save;
284
284
  // don't include leading ':' because the ruby symbol will handle it
285
285
  buf.append(p_save + 1, len - 1);
286
286
  v = ID2SYM(rb_intern(buf.c_str()));
@@ -148,7 +148,11 @@ namespace edn
148
148
  // set the buffer to read from
149
149
  if (str_buf.length() > 0) {
150
150
  // first time when io_buffer is NULL, pe & p = 0
151
- uintmax_t new_length = ((uintmax_t) (pe - p)) + str_buf.length();
151
+ uintmax_t new_length = (pe - p) + str_buf.length();
152
+ if (new_length > (((uintmax_t) 1 << 32) - 1)) {
153
+ // icu -> 32-bit. TODO: handle
154
+ rb_raise(rb_eRuntimeError, "Unsupported string buffer length");
155
+ }
152
156
  char* start = NULL;
153
157
 
154
158
  // allocate or extend storage needed
@@ -169,7 +173,7 @@ namespace edn
169
173
 
170
174
  // and copy
171
175
  memcpy(start, str_buf.c_str(), str_buf.length());
172
- io_buffer_len = new_length;
176
+ io_buffer_len = (uint32_t) new_length;
173
177
 
174
178
  // set ragel state
175
179
  p = io_buffer;
@@ -209,7 +213,7 @@ namespace edn
209
213
  private:
210
214
  VALUE receiver;
211
215
  ID method;
212
- VALUE count;
216
+ int count;
213
217
  VALUE args[2];
214
218
  };
215
219
 
@@ -302,7 +306,7 @@ namespace edn
302
306
  std::string buf;
303
307
 
304
308
  if (encode) {
305
- if (!util::to_utf8(p_start, p_end - p_start, buf))
309
+ if (!util::to_utf8(p_start, (uint32_t) (p_end - p_start), buf))
306
310
  return false;
307
311
  }
308
312
  else {
@@ -6,6 +6,6 @@ namespace edn
6
6
  {
7
7
  namespace util
8
8
  {
9
- bool to_utf8(const char *s, std::size_t len, std::string& rslt);
9
+ bool to_utf8(const char *s, uint32_t len, std::string& rslt);
10
10
  }
11
11
  }
@@ -18,7 +18,7 @@ namespace edn
18
18
  //
19
19
  // unescapes any values that need to be replaced, saves it to utf8
20
20
  //
21
- bool to_utf8(const char *s, std::size_t len, std::string& rslt)
21
+ bool to_utf8(const char *s, uint32_t len, std::string& rslt)
22
22
  {
23
23
  icu::UnicodeString ustr(s, len);
24
24
 
@@ -8,8 +8,6 @@
8
8
 
9
9
  #include "edn_parser.h"
10
10
 
11
-
12
-
13
11
  namespace edn {
14
12
 
15
13
  VALUE rb_mEDNT;
@@ -33,12 +31,19 @@ namespace edn {
33
31
 
34
32
  //
35
33
  // Wrappers to hook the class w/ the C-api.
36
- static void delete_parser(edn::Parser *ptr) {
37
- delete ptr;
34
+ static void delete_parser(void* p_ptr) {
35
+ delete reinterpret_cast<edn::Parser*>(p_ptr);
38
36
  }
39
37
 
38
+ static const rb_data_type_t parser_data_type = {
39
+ "edn_turbo::Parser",
40
+ {0, delete_parser, 0, {0}},
41
+ 0, 0,
42
+ RUBY_TYPED_FREE_IMMEDIATELY,
43
+ };
44
+
40
45
  static VALUE wrap_parser_ptr(VALUE klass, edn::Parser* ptr) {
41
- return Data_Wrap_Struct(klass, 0, delete_parser, ptr);
46
+ return TypedData_Wrap_Struct(klass, &parser_data_type, ptr);
42
47
  }
43
48
 
44
49
  static VALUE alloc_obj(VALUE self){
@@ -48,7 +53,7 @@ namespace edn {
48
53
  static inline Parser* get_parser(VALUE self)
49
54
  {
50
55
  Parser *p;
51
- Data_Get_Struct( self, edn::Parser, p );
56
+ TypedData_Get_Struct( self, edn::Parser, &parser_data_type, p );
52
57
  return p;
53
58
  }
54
59
  static VALUE set_source(VALUE self, VALUE data);
@@ -57,8 +62,6 @@ namespace edn {
57
62
  // Called by the constructor - sets the source if passed.
58
63
  static VALUE initialize(int argc, VALUE* argv, VALUE self)
59
64
  {
60
- Parser* p = get_parser(self);
61
-
62
65
  if (argc > 0) {
63
66
  set_source( self, argv[0] );
64
67
  }
@@ -164,7 +167,7 @@ void Init_edn_turbo(void)
164
167
  a.sa_handler = edn::die;
165
168
  sigemptyset(&a.sa_mask);
166
169
  a.sa_flags = 0;
167
- sigaction(SIGINT, &a, 0);
170
+ sigaction(SIGINT, &a, NULL);
168
171
 
169
172
  // pass things back as utf-8
170
173
  if (!setlocale( LC_ALL, "" )) {
@@ -1,4 +1,4 @@
1
1
  module EDNT
2
- VERSION = '0.5.1'
3
- RELEASE_DATE = '2017-05-31'
2
+ VERSION = '0.5.2'
3
+ RELEASE_DATE = '2017-06-29'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edn_turbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Porras
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-31 00:00:00.000000000 Z
11
+ date: 2017-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: edn
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project:
117
- rubygems_version: 2.4.5.1
117
+ rubygems_version: 2.5.2
118
118
  signing_key:
119
119
  specification_version: 3
120
120
  summary: Read EDN files