cbor 0.5.9.8 → 0.5.10.1
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/README.rdoc +2 -2
- data/ext/cbor/extconf.rb +3 -3
- data/ext/cbor/packer.h +13 -5
- data/ext/cbor/unpacker.c +23 -4
- data/lib/cbor/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 350f51028ed72c54fb5adf9ab595f08e18384cecb8c82d874d195aab6eb16a65
|
4
|
+
data.tar.gz: 1eb340e507d590530f0c2d9a3cfaf723fb9210596a312443e7b2dc95b912614f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30fb71f7d3fce1bbf5f40c84d7ca389a1e30051c186c01553d0be07e784a4029dc27cdf6c01a70dd1a155c6bddd050d21705c642e5df6727633d15b39808d153
|
7
|
+
data.tar.gz: 75783b66fccc0dd03ce323411f81848964e0904805e5eeb9218cc59214d1bfd1a3011df255de2b6a95a92b1d42475d5fb770a0029d6486c6c4060605a3e24f94
|
data/README.rdoc
CHANGED
@@ -16,9 +16,9 @@ Use RubyGems to install:
|
|
16
16
|
gem install cbor
|
17
17
|
|
18
18
|
CBOR is an object representation format defined by the IETF[http://ietf.org].
|
19
|
-
The specification[http://tools.ietf.org/html/
|
19
|
+
The specification[http://tools.ietf.org/html/rfc8949]
|
20
20
|
is an IETF Standards-Track specification
|
21
|
-
and has been published as RFC 7049.
|
21
|
+
and has been published as RFC 8949 (superseding the older RFC 7049).
|
22
22
|
|
23
23
|
This is all based on wonderful work by frsyuki, and I have no idea how
|
24
24
|
to acknowledge him appropriately. This gem is not intended to fork or
|
data/ext/cbor/extconf.rb
CHANGED
@@ -9,7 +9,7 @@ have_func("rb_sym2str", ["ruby.h"])
|
|
9
9
|
have_func("rb_str_intern", ["ruby.h"])
|
10
10
|
have_func("rb_integer_unpack", ["ruby.h"])
|
11
11
|
|
12
|
-
|
12
|
+
append_cflags(%w[-I.. -Wall -O3 -g -std=c99])
|
13
13
|
#$CFLAGS << %[ -DDISABLE_RMEM]
|
14
14
|
#$CFLAGS << %[ -DDISABLE_RMEM_REUSE_INTERNAL_FRAGMENT]
|
15
15
|
#$CFLAGS << %[ -DDISABLE_BUFFER_READ_REFERENCE_OPTIMIZE]
|
@@ -17,9 +17,9 @@ $CFLAGS << %[ -I.. -Wall -O3 -g -std=c99]
|
|
17
17
|
|
18
18
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
19
19
|
# msgpack-ruby doesn't modify data came from RSTRING_PTR(str)
|
20
|
-
|
20
|
+
append_cflags('-DRSTRING_NOT_MODIFIED')
|
21
21
|
# Rubinius C extensions don't grab GVL while rmem is not thread safe
|
22
|
-
|
22
|
+
append_cflags('-DDISABLE_RMEM')
|
23
23
|
end
|
24
24
|
|
25
25
|
if warnflags = CONFIG['warnflags']
|
data/ext/cbor/packer.h
CHANGED
@@ -170,17 +170,25 @@ static inline void msgpack_packer_write_double(msgpack_packer_t* pk, double v)
|
|
170
170
|
msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 5);
|
171
171
|
castbuf.u32 = _msgpack_be_float(castbuf.u32);
|
172
172
|
msgpack_buffer_write_byte_and_data(PACKER_BUFFER_(pk), IB_FLOAT4, castbuf.mem, 4);
|
173
|
-
} else if (v != v) { /* NaN */
|
174
|
-
cbor_encoder_write_head(pk, 0xe0, 0x7e00);
|
175
173
|
} else {
|
176
|
-
msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 9);
|
177
174
|
union {
|
178
175
|
double d;
|
179
176
|
uint64_t u64;
|
180
177
|
char mem[8];
|
181
178
|
} castbuf = { v };
|
182
|
-
|
183
|
-
|
179
|
+
if (v != v && (castbuf.u64 & 0x1fffffffUL) == 0) { /* NaN && can narrow */
|
180
|
+
uint64_t sign = castbuf.u64 >> 63;
|
181
|
+
uint64_t mant = castbuf.u64 & 0xfffffffffffff; /* 52 bits */
|
182
|
+
if ((mant & 0x3ffffffffffUL) == 0) { /* 42 zero bits: narrow to f16 */
|
183
|
+
cbor_encoder_write_head(pk, 0xe0, sign << 15 | 0x7c00 | mant >> 42);
|
184
|
+
} else { /* 29 zero bits (checked above): narrow to f32 */
|
185
|
+
cbor_encoder_write_head(pk, 0xe0, sign << 31 | 0x7f800000 | mant >> 29);
|
186
|
+
}
|
187
|
+
} else { /* can't narrow */
|
188
|
+
msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 9);
|
189
|
+
castbuf.u64 = _msgpack_be_double(castbuf.u64);
|
190
|
+
msgpack_buffer_write_byte_and_data(PACKER_BUFFER_(pk), IB_FLOAT8, castbuf.mem, 8);
|
191
|
+
}
|
184
192
|
}
|
185
193
|
}
|
186
194
|
|
data/ext/cbor/unpacker.c
CHANGED
@@ -417,11 +417,21 @@ static int read_primitive(msgpack_unpacker_t* uk)
|
|
417
417
|
switch (ai) {
|
418
418
|
case AI_2: { // half
|
419
419
|
int exp = (val >> 10) & 0x1f;
|
420
|
-
int mant = val & 0x3ff;
|
420
|
+
int mant = val & 0x3ff; /* 10 bits */
|
421
421
|
double res;
|
422
422
|
if (exp == 0) res = ldexp(mant, -24);
|
423
423
|
else if (exp != 31) res = ldexp11(mant + 1024, exp - 25);
|
424
|
-
else
|
424
|
+
else {
|
425
|
+
if (mant == 0)
|
426
|
+
res = INFINITY;
|
427
|
+
else { /* NAN */
|
428
|
+
union {
|
429
|
+
uint64_t u64;
|
430
|
+
double d;
|
431
|
+
} castbuf = { (val & 0x8000) << 48 | 0x7ff0000000000000UL | (uint64_t)mant << 42 };
|
432
|
+
return object_complete(uk, rb_float_new(castbuf.d));
|
433
|
+
}
|
434
|
+
}
|
425
435
|
return object_complete(uk, rb_float_new(val & 0x8000 ? -res : res));
|
426
436
|
}
|
427
437
|
case AI_4: // float
|
@@ -429,8 +439,17 @@ static int read_primitive(msgpack_unpacker_t* uk)
|
|
429
439
|
union {
|
430
440
|
uint32_t u32;
|
431
441
|
float f;
|
432
|
-
} castbuf = { (uint32_t)val };
|
433
|
-
|
442
|
+
} castbuf = { (uint32_t)val }; /* sets Q to 1 for NAN */
|
443
|
+
if (castbuf.f == castbuf.f) {
|
444
|
+
return object_complete(uk, rb_float_new(castbuf.f));
|
445
|
+
} else { /* NAN */
|
446
|
+
uint64_t mant = val & 0x7fffff; /* 23 bits */
|
447
|
+
union {
|
448
|
+
uint64_t u64;
|
449
|
+
double d;
|
450
|
+
} castbuf1 = { (val & 0x80000000UL) << 32 | 0x7ff0000000000000UL | mant << 29 };
|
451
|
+
return object_complete(uk, rb_float_new(castbuf1.d));
|
452
|
+
}
|
434
453
|
}
|
435
454
|
case AI_8: // double
|
436
455
|
{
|
data/lib/cbor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cbor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann, standing on the tall shoulders of Sadayuki Furuhashi
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-08-07 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -160,7 +159,6 @@ homepage: http://cbor.io/
|
|
160
159
|
licenses:
|
161
160
|
- Apache-2.0
|
162
161
|
metadata: {}
|
163
|
-
post_install_message:
|
164
162
|
rdoc_options: []
|
165
163
|
require_paths:
|
166
164
|
- lib
|
@@ -175,8 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
173
|
- !ruby/object:Gem::Version
|
176
174
|
version: '0'
|
177
175
|
requirements: []
|
178
|
-
rubygems_version: 3.
|
179
|
-
signing_key:
|
176
|
+
rubygems_version: 3.6.2
|
180
177
|
specification_version: 4
|
181
178
|
summary: CBOR, Concise Binary Object Representation.
|
182
179
|
test_files:
|