edn_turbo 0.5.1 → 0.5.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 +4 -4
- data/ext/edn_turbo/edn_parser.cc +1 -1
- data/ext/edn_turbo/edn_parser.h +1 -1
- data/ext/edn_turbo/edn_parser.rl +1 -1
- data/ext/edn_turbo/edn_parser_util.cc +8 -4
- data/ext/edn_turbo/edn_parser_util.h +1 -1
- data/ext/edn_turbo/edn_parser_util_unicode.cc +1 -1
- data/ext/edn_turbo/main.cc +12 -9
- data/lib/edn_turbo/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87badf5b6b0c38f6f22fd662b0add51be662a6a2
|
4
|
+
data.tar.gz: d9a0b304de6ea51480a9747df4a8d35ad826c246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d717030106eeca177d00eeb26dc58330a0a873c932346d0463bb00e926288b08b5bf4070c5b4240505b8f63eeec675da83c91c163880842c1c9379d409a0429
|
7
|
+
data.tar.gz: 0b9e043cfafe56031026861f221302657a07acb6353b8274083affb14d02d9a081ec820b046cac14979ced57d0d6e110db5178d5b54bd13db6319c3c44d926b4
|
data/ext/edn_turbo/edn_parser.cc
CHANGED
@@ -611,7 +611,7 @@ case 5:
|
|
611
611
|
|
612
612
|
if (cs >= EDN_keyword_first_final) {
|
613
613
|
std::string buf;
|
614
|
-
|
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()));
|
data/ext/edn_turbo/edn_parser.h
CHANGED
@@ -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
|
-
|
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;
|
data/ext/edn_turbo/edn_parser.rl
CHANGED
@@ -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
|
-
|
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 = (
|
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
|
-
|
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 {
|
@@ -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,
|
21
|
+
bool to_utf8(const char *s, uint32_t len, std::string& rslt)
|
22
22
|
{
|
23
23
|
icu::UnicodeString ustr(s, len);
|
24
24
|
|
data/ext/edn_turbo/main.cc
CHANGED
@@ -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(
|
37
|
-
delete
|
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
|
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
|
-
|
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,
|
170
|
+
sigaction(SIGINT, &a, NULL);
|
168
171
|
|
169
172
|
// pass things back as utf-8
|
170
173
|
if (!setlocale( LC_ALL, "" )) {
|
data/lib/edn_turbo/version.rb
CHANGED
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.
|
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-
|
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.
|
117
|
+
rubygems_version: 2.5.2
|
118
118
|
signing_key:
|
119
119
|
specification_version: 3
|
120
120
|
summary: Read EDN files
|