yeptris 0.6.41.0-aarch64-linux → 0.6.42.0-aarch64-linux

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: 5353bd36130f48f70c8825b21e60564dafc3078e1702e186e00389be89ad2bb0
4
- data.tar.gz: f1ca7bf67a3e99b23339e5d60a4a5331c60aa859d9ad49208cfe74a5236bc61a
3
+ metadata.gz: 62d8538a7f4972f34331da2f7086cd4f4d862098b2bef50de94ee872cf547a2b
4
+ data.tar.gz: f2694fed34d15d6e50b2cf981c3b77b5779feb8ecd849ac99b70eb5974077cd2
5
5
  SHA512:
6
- metadata.gz: 72ee0c7302cfe878192a677b793836ed879039e783624f323ab54c5a5a11e2e37d82cedd2f3635f3da6830e71c9967cbc3a2737055f2677cbc08fa82a9dad453
7
- data.tar.gz: 94add9c22c40c61de42fa34e8d2bb359475b20f8c270cc3a57c120594a237e28857bfe44202709f7b2f3fee7341fd887b511c6f09d002fb963bc1971675b35e8
6
+ metadata.gz: 7c532b8562ff38606e54c6012e9c0a696b3077536ca32692dc89b699b495ebde176c1c2ba2da15cdbc3d172570c0e47e4b755739b93f8a0d117d8f5cb8a2fe34
7
+ data.tar.gz: b71c6049dbb1568f69f4d4099f965c921fa0b650fb3a7b255b87634f1f478474f173248901acbbf767a4ef714aafc6620eef8df9bc2a16e54642f021d71a7e42
@@ -11,8 +11,8 @@
11
11
 
12
12
  #define YEPTRIS_VERSION_MAJOR 0
13
13
  #define YEPTRIS_VERSION_MINOR 6
14
- #define YEPTRIS_VERSION_PATCH 41
15
- #define YEPTRIS_VERSION_STRING "0.6.41"
14
+ #define YEPTRIS_VERSION_PATCH 42
15
+ #define YEPTRIS_VERSION_STRING "0.6.42"
16
16
 
17
17
  #ifdef __cplusplus
18
18
  extern "C" {
data/lib/yeptris.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Yeptris
4
4
  # The gem's version lives in the parent namespace's file — the last
5
5
  # internal require (yeptris/version) retired with it.
6
- VERSION = "0.6.41.0".freeze
6
+ VERSION = "0.6.42.0".freeze
7
7
 
8
8
  # Informational notices are OPT-IN (yeptris-ruby#217): consumers
9
9
  # embed yeptris inside CLIs that assert clean stderr, and a
data/libyeptris.so CHANGED
Binary file
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(yeptris
6
- VERSION 0.6.41
6
+ VERSION 0.6.42
7
7
  DESCRIPTION "Ultra-fast YAML 1.2 parser, emitter and streamer in C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -293,8 +293,15 @@ YEPTRIS_API char* yeptris_serialize_json(YeptrisDocument handle, size_t* len) {
293
293
  if (em.w.canonical && !yep_nametab_init(&em.canon_names, yep_system_allocator())) {
294
294
  return NULL;
295
295
  }
296
- size_t need = yep_emit_run(&em, 1);
297
- char* out = malloc(need + 1);
296
+ /* #739: ONE wet pass into a growable buffer — the dry exact-sizing
297
+ * pass priced ~2x on the json lane (the #352 slice-2 pattern);
298
+ * the estimate starts at the input size (+64) and doubles on
299
+ * demand, shrink-to-fit at the end. */
300
+ size_t est = em.doc->dom->input_len + 64;
301
+ if (est < 256) {
302
+ est = 256;
303
+ }
304
+ char* out = (char*)malloc(est);
298
305
  if (out == NULL) {
299
306
  if (em.canon_names.sys != NULL) {
300
307
  yep_nametab_free(&em.canon_names);
@@ -302,7 +309,24 @@ YEPTRIS_API char* yeptris_serialize_json(YeptrisDocument handle, size_t* len) {
302
309
  return NULL;
303
310
  }
304
311
  em.w.p = out;
312
+ em.w.cap = est;
313
+ em.w.grow = 1;
305
314
  size_t wrote = yep_emit_run(&em, 0);
315
+ em.w.grow = 0;
316
+ out = em.w.p; /* wr_grow reallocs through w->p — the local is stale */
317
+ if (em.w.oom || em.w.unserializable) {
318
+ free(out);
319
+ if (em.canon_names.sys != NULL) {
320
+ yep_nametab_free(&em.canon_names);
321
+ }
322
+ return NULL;
323
+ }
324
+ if (em.w.cap - (wrote + 1) > em.w.cap / 8) {
325
+ char* tight = (char*)realloc(out, wrote + 1);
326
+ if (tight != NULL) {
327
+ out = tight;
328
+ }
329
+ }
306
330
  if (em.canon_names.sys != NULL) {
307
331
  yep_nametab_free(&em.canon_names);
308
332
  }
@@ -912,6 +912,9 @@ static void emit_node(yep_emitter* em, uint32_t id, int parent_col, int as_key);
912
912
  * written). Conservative factor-4 estimate for every expandable
913
913
  * byte — overestimating only takes the (always-legal) explicit form. */
914
914
  static int key_written_over_limit(yep_writer* w, const yep_dnode* kn) {
915
+ if (w->json) {
916
+ return 0; /* JSON has no simple-key law: every key writes (#739) */
917
+ }
915
918
  uint64_t est = 2; /* the quotes */
916
919
  yep_view kv_ = wv(w, kn->value);
917
920
  const unsigned char* q = (const unsigned char*)kv_.p;
@@ -1207,10 +1207,18 @@ static yep_view e_resolve_tag_raw(yep_engine* e, yep_view tag) {
1207
1207
  if (tag.len == 1 && tag.p[0] == '!') {
1208
1208
  return tag;
1209
1209
  }
1210
- /* longest matching handle wins */
1210
+ /* longest matching handle wins; a redefined PRIMARY ('%TAG ! ...')
1211
+ * cannot capture a '!!'-led tag — the secondary handle resolves
1212
+ * through its own entry or the fixed tag:yaml.org,2002: default
1213
+ * (spec 6.8.2.2; libyaml: "%TAG ! !p/" + "!!i" is
1214
+ * tag:yaml.org,2002:i, the nightly's round 52, crash-763bb852) */
1215
+ int secondary = tag.len >= 2 && tag.p[0] == '!' && tag.p[1] == '!';
1211
1216
  int best = -1;
1212
1217
  uint32_t best_len = 0;
1213
1218
  for (int i = 0; i < e->tagmap_n; i++) {
1219
+ if (secondary && e->tagmap[i].handle.len == 1) {
1220
+ continue;
1221
+ }
1214
1222
  if (tag.len >= e->tagmap[i].handle.len && e->tagmap[i].handle.len > best_len &&
1215
1223
  memcmp(tag.p, e->tagmap[i].handle.p, e->tagmap[i].handle.len) == 0) {
1216
1224
  best = i;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.41.0
4
+ version: 0.6.42.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Ribose Inc.