teptris 0.3.0.1-x86_64-linux → 0.3.3.1-x86_64-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: b50c43c2805a632eb24c401f978aebf8b4c7782fd5dfc4cd0527347e3117a43c
4
- data.tar.gz: b1d85f6fddd5a09d1c5e81bf80ab4534531553c14501bb40d1063f95f47b42d4
3
+ metadata.gz: 60434cd3e8d75ae731271a425b1c2ce5c1fa4b6a26393da8751cf3299deb548e
4
+ data.tar.gz: 0cda957d0893f9a125eea5beab5bea03c350a184ea5add3c02dca0bea519cc71
5
5
  SHA512:
6
- metadata.gz: 13de9896ef76a8bd6371fbf2d6338802134e21f6d59a0b415e7f233cbacbd57bcd1744f6e8ed2bc1cf456dcd1b87b90b6b4a8a820793ad9d9e2a1a185361492f
7
- data.tar.gz: 8864c9247fd94fe0bdfd50f5a288f14d3b3229570af1268e20047338d43e43bb785fe18d8d0acac9ca434dd9452841dfafa807976b3a859d7d1595b616ca74a0
6
+ metadata.gz: 8ef7b1307749939cf98a165dd5d36acfd7b2cbc229b4c09c5a7a4ce15188f65e04265fa0a4eb48597ce9b695b00036e9d96ec966bc7b1ebf82420eda55706a5a
7
+ data.tar.gz: 7bc9c5ef57829d671fdb2cf3daba67da135770f5417b525dc8d3473530638860f959faacd9a6e504cd42c559007462122ff17a4d016aea242483733c67d1e23e
@@ -1,4 +1,4 @@
1
- # libteptris 0.3.0 — vendored source
1
+ # libteptris 0.3.3 — vendored source
2
2
 
3
3
  This directory carries the COMPLETE C source of the engine this
4
4
  gem's extension was built from (the packaging doctrine: compiled
@@ -11,6 +11,10 @@ extern "C" {
11
11
 
12
12
  #define TEPTRIS_PLAN_ABI_VERSION 1
13
13
 
14
+ /* walk_table recurses per NESTED level; plans deeper than this are
15
+ * rejected at build (the parser and builder share the 512 ceiling). */
16
+ #define TEPTRIS_PLAN_MAX_DEPTH 512
17
+
14
18
  typedef struct teptris_plan teptris_plan;
15
19
  typedef struct teptris_plan_result teptris_plan_result;
16
20
 
@@ -4,6 +4,6 @@
4
4
  #define TEPTRIS_VERSION_MAJOR 0
5
5
  #define TEPTRIS_VERSION_MINOR 3
6
6
  #define TEPTRIS_VERSION_PATCH 0
7
- #define TEPTRIS_VERSION_STRING "0.3.0"
7
+ #define TEPTRIS_VERSION_STRING "0.3.3"
8
8
 
9
9
  #endif /* TEPTRIS_VERSION_H */
@@ -146,8 +146,10 @@ teptris_status teptris_dom_table_insert_slot(teptris_document *doc,
146
146
  if (ne == NULL) {
147
147
  return TEPTRIS_ERR_ALLOC;
148
148
  }
149
- memcpy(ne, t->as.table.entries,
150
- t->as.table.len * sizeof(teptris_entry));
149
+ if (t->as.table.len > 0) {
150
+ memcpy(ne, t->as.table.entries,
151
+ t->as.table.len * sizeof(teptris_entry));
152
+ }
151
153
  t->as.table.entries = ne;
152
154
  }
153
155
  t->as.table.cap = ncap;
@@ -181,8 +183,10 @@ teptris_status teptris_dom_array_push(teptris_document *doc, teptris_node *a,
181
183
  if (ni == NULL) {
182
184
  return TEPTRIS_ERR_ALLOC;
183
185
  }
184
- memcpy(ni, a->as.array.items,
185
- a->as.array.len * sizeof(teptris_node *));
186
+ if (a->as.array.len > 0) {
187
+ memcpy(ni, a->as.array.items,
188
+ a->as.array.len * sizeof(teptris_node *));
189
+ }
186
190
  a->as.array.items = ni;
187
191
  }
188
192
  a->as.array.cap = ncap;
@@ -7,6 +7,7 @@
7
7
  #include <string.h>
8
8
 
9
9
  #include "teptris/dom/dom.h"
10
+ #include <stdio.h>
10
11
  #include "teptris/plan.h"
11
12
 
12
13
  typedef struct plan_row {
@@ -86,6 +87,46 @@ teptris_plan *teptris_plan_build(const teptris_plan_spec *spec,
86
87
  p->rows[i].kind = r->kind;
87
88
  p->rows[i].sub = r->sub;
88
89
  }
90
+ /* Depth gate (rows are validated above: sub < plan_count). BFS
91
+ * from the root relaxes depths in one ascending pass — sub-plans
92
+ * always lay out after their parent. walk_table recurses per
93
+ * NESTED level, so an unbounded hostile plan would crash the
94
+ * host's stack; the parser and builder share the 512 ceiling. */
95
+ /* entries, not bytes — the byte-sized malloc here is the same
96
+ * overflow the ruby plan_build hit (documented there) */
97
+ uint32_t *depths = malloc(p->plan_count * sizeof(*depths));
98
+ if (depths == NULL) {
99
+ teptris_plan_free(p);
100
+ *status = TEPTRIS_ERR_ALLOC;
101
+ return NULL;
102
+ }
103
+ memset(depths, 0, p->plan_count * sizeof(*depths));
104
+ for (uint32_t pi = 0; pi < p->plan_count; pi++) {
105
+ uint32_t lo = p->first_row[pi];
106
+ uint32_t hi = p->first_row[pi + 1];
107
+ for (uint32_t ri = lo; ri < hi; ri++) {
108
+ if (p->rows[ri].kind == TEPTRIS_PLAN_NESTED) {
109
+ uint32_t sub = p->rows[ri].sub;
110
+ if (depths[sub] <= depths[pi] + 1) {
111
+ depths[sub] = depths[pi] + 1;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ int too_deep = 0;
117
+ for (uint32_t pi = 0; pi < p->plan_count; pi++) {
118
+ fprintf(stderr, "DBG depths[%u]=%u first=%u\n", pi, depths[pi],
119
+ p->first_row[pi]);
120
+ if (depths[pi] > TEPTRIS_PLAN_MAX_DEPTH) {
121
+ too_deep = 1;
122
+ }
123
+ }
124
+ free(depths);
125
+ if (too_deep) {
126
+ teptris_plan_free(p);
127
+ *status = TEPTRIS_ERR_ARG;
128
+ return NULL;
129
+ }
89
130
  *status = TEPTRIS_OK;
90
131
  return p;
91
132
  }
@@ -438,7 +438,9 @@ static void build_value(teptris_builder *b, VALUE v) {
438
438
  }
439
439
  }
440
440
 
441
- static VALUE ext_dump(VALUE self, VALUE obj) {
441
+ static VALUE dump_with(VALUE obj,
442
+ teptris_status (*emit)(const teptris_document *,
443
+ char **, size_t *)) {
442
444
  if (!RB_TYPE_P(obj, T_HASH))
443
445
  rb_raise(rb_eArgError, "cannot dump %s (root must be a Hash)",
444
446
  rb_obj_classname(obj));
@@ -454,7 +456,7 @@ static VALUE ext_dump(VALUE self, VALUE obj) {
454
456
  }
455
457
  char *buf = NULL;
456
458
  size_t len = 0;
457
- st = teptris_document_emit(doc, &buf, &len);
459
+ st = emit(doc, &buf, &len);
458
460
  teptris_document_free(doc);
459
461
  teptris_builder_free(b); /* doc already transferred/freed */
460
462
  if (st != TEPTRIS_OK)
@@ -464,6 +466,17 @@ static VALUE ext_dump(VALUE self, VALUE obj) {
464
466
  return out;
465
467
  }
466
468
 
469
+ static VALUE ext_dump(VALUE self, VALUE obj) {
470
+ return dump_with(obj, teptris_document_emit);
471
+ }
472
+
473
+ /* Natural JSON (engine 0.3.0): real numbers, booleans, RFC 3339
474
+ * datetime strings — the mappings Teptris.dump_json_natural
475
+ * documents. Non-finite floats become null. */
476
+ static VALUE ext_dump_json_natural(VALUE self, VALUE obj) {
477
+ return dump_with(obj, teptris_document_emit_json_natural);
478
+ }
479
+
467
480
  /* ------------------------------------------------- plan-walk (teptris#46) */
468
481
 
469
482
  static void plan_free(void *p) { teptris_plan_free((teptris_plan *)p); }
@@ -1213,6 +1226,8 @@ void Init_teptris_ext(void) {
1213
1226
  rb_define_method(cLazyValue, "to_a", lazy_to, 0);
1214
1227
  rb_define_method(cLazyValue, "value", lazy_to, 0);
1215
1228
  rb_define_module_function(m, "dump", ext_dump, 1);
1229
+ rb_define_module_function(m, "dump_json_natural", ext_dump_json_natural,
1230
+ 1);
1216
1231
  rb_define_module_function(m, "engine_version", ext_version, 0);
1217
1232
  rb_define_module_function(m, "plan_build", ext_plan_build, 2);
1218
1233
  rb_define_module_function(m, "plan_emit", ext_plan_emit, 2);
Binary file
Binary file
Binary file
data/lib/teptris/toml.rb CHANGED
@@ -150,6 +150,13 @@ module Teptris::TOML
150
150
  TeptrisExt.dump(obj)
151
151
  end
152
152
 
153
+ # Natural JSON (engine 0.3.0): real numbers, booleans, RFC 3339
154
+ # datetime strings. Non-finite floats become null — the same
155
+ # documented lossy mapping as teptris.h's natural-JSON contract.
156
+ def dump_json_natural(obj)
157
+ TeptrisExt.dump_json_natural(obj)
158
+ end
159
+
153
160
  private
154
161
 
155
162
  def _validate_batch!(input, safe_load, datetime_policy, kind: :strings)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Teptris
4
- VERSION = "0.3.0.1"
4
+ VERSION = "0.3.3.1"
5
5
  end
data/sig/teptris.rbs CHANGED
@@ -49,6 +49,8 @@ module Teptris
49
49
 
50
50
  def self.dump: (untyped obj) -> String
51
51
 
52
+ def self.dump_json_natural: (untyped obj) -> String
53
+
52
54
  def self.engine_version: () -> String
53
55
 
54
56
  def self._validate_batch!: (untyped input, untyped safe_load,
@@ -122,6 +124,8 @@ module TeptrisExt
122
124
 
123
125
  def self.dump: (untyped obj) -> String
124
126
 
127
+ def self.dump_json_natural: (untyped obj) -> String
128
+
125
129
  def self.engine_version: () -> String
126
130
 
127
131
  def self.plan_build: (Array[[String, Integer, Integer]] rows,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.1
4
+ version: 0.3.3.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - teptris contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-07 00:00:00.000000000 Z
11
+ date: 2026-10-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A native C extension over libteptris, a C99 TOML 1.1 parser/emitter.
14
14
  API shape mirrors the tomlib gem.