teptris 0.3.6.1-aarch64-linux → 0.3.6.2-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: d62b63a5a4f81ef55332548c138c248b26b1891e2ba099a2eb8b69ff398fd94d
4
- data.tar.gz: f15d07f63a728010cecad24e936c4be22444f35fbc8de3917809905254fb7cc5
3
+ metadata.gz: 458fcaa535169ceee75e8e1960f902d18a4fa67538694b1396e1de7a59ce41c9
4
+ data.tar.gz: 72df559475f7999748dde5fdd11ca32113683994d0d8b2f4ccd09db2aba9c0db
5
5
  SHA512:
6
- metadata.gz: dc43804c1410857efaf0a911c9da252378f22270b28711ba82838cc5c97cd14bff62e3de57a03740883a96ddd951fd1bb4ce8c5c467cbca6f3ef4664fafd648b
7
- data.tar.gz: df152e7b6e3aa6e3e26de92814a4c142e4fe47164b360868b33d6b407b0f18fc6f7870847e8ba13ef47d03cfb20932ad7bb27e7b3514b5fcc6e586e71035c804
6
+ metadata.gz: 4bfb90a199be28e1dc860c7abc3527cc065e43d4e4722723c1ac70873e7430311ecc0a04b39a27da1977efd40ec67814fd70ac9eb978be5fdbe0d70fac2d90aa
7
+ data.tar.gz: d744364480b00ec152ca37f3c2c21f8f78c3c30d414a1e6dfa012c823481cf7bc5b72d824ca0829491d42d1b38c398411c2a74f4a55d62c25afb274f8f9ce644
@@ -10,6 +10,14 @@
10
10
  #define FMT_FORBID_DATE 4
11
11
 
12
12
  static VALUE eParseError, eError, cDate, cDoc;
13
+ /* rb_raise's varargs formatting segfaults in its format dispatch on
14
+ * windows x64-mingw-ucrt ruby 4.0 (diag #158/#160: the identical raise
15
+ * crashes across PGO on/off while direct exception construction runs
16
+ * clean, and every rb_exc_new site has always been fine) — build the
17
+ * message with snprintf and raise via rb_exc_new. */
18
+ static void raise_teptris(const char *msg) {
19
+ rb_exc_raise(rb_exc_new(eError, msg, (long)strlen(msg)));
20
+ }
13
21
 
14
22
  /* civil date -> days since epoch (Hinnant, inverse of the dump side) */
15
23
  static int64_t days_from_civil(int32_t y, uint8_t m, uint8_t d) {
@@ -223,14 +231,14 @@ static VALUE obj_from_node(const teptris_node *n, unsigned flags,
223
231
  if (flags & FMT_STRING_DATES) return dt_string(&d, kind);
224
232
  if (kind == TEPTRIS_DATETIME_OFFSET || kind == TEPTRIS_DATETIME_LOCAL) {
225
233
  if (flags & FMT_FORBID_TIME)
226
- rb_raise(eError, "value materializes Time, which is not in "
227
- "permitted_classes (use datetime_policy: :string)");
234
+ raise_teptris("value materializes Time, which is not in "
235
+ "permitted_classes (use datetime_policy: :string)");
228
236
  return time_from_dt(&d, kind == TEPTRIS_DATETIME_OFFSET);
229
237
  }
230
238
  if (kind == TEPTRIS_DATE_LOCAL) {
231
239
  if (flags & FMT_FORBID_DATE)
232
- rb_raise(eError, "value materializes Date, which is not in "
233
- "permitted_classes (use datetime_policy: :string)");
240
+ raise_teptris("value materializes Date, which is not in "
241
+ "permitted_classes (use datetime_policy: :string)");
234
242
  return rb_funcall(cDate, rb_intern("new"), 3,
235
243
  INT2FIX(d.year), INT2FIX(d.month), INT2FIX(d.day));
236
244
  }
@@ -365,11 +373,15 @@ static VALUE ext_version(VALUE self) {
365
373
 
366
374
  static ID id_utc_offset, id_to_s, id_to_i, id_nsec;
367
375
 
376
+
368
377
  static void dump_check(teptris_status st) {
369
378
  if (st == TEPTRIS_OK) return;
370
379
  if (st == TEPTRIS_ERR_ALLOC)
371
- rb_raise(eError, "out of memory while dumping");
372
- rb_raise(eError, "cannot dump value (%s)", teptris_status_string(st));
380
+ raise_teptris("out of memory while dumping");
381
+ char msg[128];
382
+ snprintf(msg, sizeof msg, "cannot dump value (%s)",
383
+ teptris_status_string(st));
384
+ raise_teptris(msg);
373
385
  }
374
386
 
375
387
  /* days since 1970-01-01 -> proleptic-Gregorian y/m/d (Hinnant) */
@@ -444,7 +456,9 @@ static void dump_scalar(teptris_builder *b, const char *key, size_t klen,
444
456
  TEPTRIS_DATE_LOCAL, &dt));
445
457
  return;
446
458
  }
447
- rb_raise(eError, "cannot dump %s", rb_obj_classname(v));
459
+ char msg[192];
460
+ snprintf(msg, sizeof msg, "cannot dump %s", rb_obj_classname(v));
461
+ raise_teptris(msg);
448
462
  }
449
463
  }
450
464
 
@@ -506,21 +520,28 @@ static VALUE dump_with(VALUE obj,
506
520
  rb_obj_classname(obj));
507
521
  teptris_builder *b = teptris_builder_new();
508
522
  if (b == NULL)
509
- rb_raise(eError, "out of memory while dumping");
523
+ raise_teptris("out of memory while dumping");
510
524
  rb_hash_foreach(obj, table_each, (VALUE)b);
511
525
  teptris_document *doc = NULL;
512
526
  teptris_status st = teptris_builder_finish(b, &doc);
513
527
  if (st != TEPTRIS_OK) {
514
528
  teptris_builder_free(b);
515
- rb_raise(eError, "cannot dump (%s)", teptris_status_string(st));
529
+ char msg[128];
530
+ snprintf(msg, sizeof msg, "cannot dump (%s)",
531
+ teptris_status_string(st));
532
+ raise_teptris(msg);
516
533
  }
517
534
  char *buf = NULL;
518
535
  size_t len = 0;
519
536
  st = emit(doc, &buf, &len);
520
537
  teptris_document_free(doc);
521
538
  teptris_builder_free(b); /* doc already transferred/freed */
522
- if (st != TEPTRIS_OK)
523
- rb_raise(eError, "dump failed (%s)", teptris_status_string(st));
539
+ if (st != TEPTRIS_OK) {
540
+ char msg[128];
541
+ snprintf(msg, sizeof msg, "dump failed (%s)",
542
+ teptris_status_string(st));
543
+ raise_teptris(msg);
544
+ }
524
545
  VALUE out = rb_enc_str_new(buf, (long)len, rb_utf8_encoding());
525
546
  free(buf);
526
547
  return out;
@@ -734,7 +755,7 @@ static VALUE ext_plan_build(VALUE self, VALUE rows, VALUE first_row)
734
755
  long nrows = RARRAY_LEN(rows);
735
756
  long nplans = RARRAY_LEN(first_row) - 1;
736
757
  if (nplans < 1 || nrows < 1) {
737
- rb_raise(eError, "plan needs >= 1 plan and >= 1 row");
758
+ raise_teptris("plan needs >= 1 plan and >= 1 row");
738
759
  }
739
760
  teptris_plan_row *crows = calloc((size_t)nrows, sizeof(*crows));
740
761
  /* bytes-vs-count: this must be (nplans+1) * sizeof(uint32_t) — the
@@ -744,7 +765,7 @@ static VALUE ext_plan_build(VALUE self, VALUE rows, VALUE first_row)
744
765
  if (crows == NULL || cfirst == NULL) {
745
766
  free(crows);
746
767
  free(cfirst);
747
- rb_raise(eError, "out of memory building plan");
768
+ raise_teptris("out of memory building plan");
748
769
  }
749
770
  for (long i = 0; i < nrows; i++) {
750
771
  VALUE row = rb_ary_entry(rows, i);
@@ -765,7 +786,9 @@ static VALUE ext_plan_build(VALUE self, VALUE rows, VALUE first_row)
765
786
  free(crows);
766
787
  free(cfirst);
767
788
  if (plan == NULL) {
768
- rb_raise(eError, "invalid plan spec (status %d)", (int)st);
789
+ char msg[96];
790
+ snprintf(msg, sizeof msg, "invalid plan spec (status %d)", (int)st);
791
+ raise_teptris(msg);
769
792
  }
770
793
  return TypedData_Wrap_Struct(rb_cObject, &plan_type, plan);
771
794
  }
@@ -790,7 +813,9 @@ static VALUE ext_plan_emit(VALUE self, VALUE rb_plan, VALUE toml)
790
813
  teptris_plan_walk(plan, teptris_document_root(doc), &st);
791
814
  if (res == NULL) {
792
815
  teptris_document_free(doc);
793
- rb_raise(eError, "plan walk failed (status %d)", (int)st);
816
+ char msg[96];
817
+ snprintf(msg, sizeof msg, "plan walk failed (status %d)", (int)st);
818
+ raise_teptris(msg);
794
819
  }
795
820
  VALUE out = asm_rows(plan, res, 0);
796
821
  teptris_plan_result_free(res);
@@ -926,7 +951,7 @@ static VALUE lazy_each(VALUE self) {
926
951
  break;
927
952
  }
928
953
  default:
929
- rb_raise(eError, "scalar node has nothing to iterate");
954
+ raise_teptris("scalar node has nothing to iterate");
930
955
  }
931
956
  return self;
932
957
  }
@@ -957,7 +982,7 @@ static VALUE lazy_get(VALUE self, VALUE key) {
957
982
  break;
958
983
  }
959
984
  default:
960
- rb_raise(eError, "scalar node is not subscriptable");
985
+ raise_teptris("scalar node is not subscriptable");
961
986
  }
962
987
  if (child == NULL) return Qnil;
963
988
  return lazy_wrap(v->owner, child);
@@ -1071,7 +1096,12 @@ static VALUE ext_load_lazy_batch(VALUE self, VALUE strings) {
1071
1096
  long n = RARRAY_LEN(strings);
1072
1097
  if (n == 0) return rb_ary_new();
1073
1098
  batch_scratch *s = batch_scratch_alloc(n);
1074
- if (s == NULL) rb_raise(eError, "out of memory batching %ld documents", n);
1099
+ if (s == NULL) {
1100
+ char msg[96];
1101
+ snprintf(msg, sizeof msg,
1102
+ "out of memory batching %ld documents", n);
1103
+ raise_teptris(msg);
1104
+ }
1075
1105
  /* the batch parse is pure C: pin every input (one tmp lock per
1076
1106
  * string - repeated objects dup; frozen strings cannot take the
1077
1107
  * lock, yet compaction can move them) and release the GVL for the
@@ -1223,7 +1253,12 @@ static VALUE ext_load_batch(int argc, VALUE *argv, VALUE self) {
1223
1253
  if (n == 0) return rb_ary_new();
1224
1254
  unsigned flags = flags_from_opts(opts);
1225
1255
  batch_scratch *s = batch_scratch_alloc(n);
1226
- if (s == NULL) rb_raise(eError, "out of memory batching %ld documents", n);
1256
+ if (s == NULL) {
1257
+ char msg[96];
1258
+ snprintf(msg, sizeof msg,
1259
+ "out of memory batching %ld documents", n);
1260
+ raise_teptris(msg);
1261
+ }
1227
1262
  for (long i = 0; i < n; i++) {
1228
1263
  VALUE str = rb_ary_entry(strings, i);
1229
1264
  StringValue(str);
@@ -1235,7 +1270,10 @@ static VALUE ext_load_batch(int argc, VALUE *argv, VALUE self) {
1235
1270
  s->docs, s->statuses);
1236
1271
  if (batch != TEPTRIS_OK) {
1237
1272
  batch_scratch_free(s);
1238
- rb_raise(eError, "batch parse failed (status %d)", (int)batch);
1273
+ char msg[96];
1274
+ snprintf(msg, sizeof msg, "batch parse failed (status %d)",
1275
+ (int)batch);
1276
+ raise_teptris(msg);
1239
1277
  }
1240
1278
  long first_fail = -1;
1241
1279
  for (long i = 0; i < n; i++) {
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Teptris
4
- VERSION = "0.3.6.1"
4
+ VERSION = "0.3.6.2"
5
5
  end
data/sig/teptris.rbs CHANGED
@@ -51,10 +51,6 @@ module Teptris
51
51
 
52
52
  def self.dump: (untyped obj) -> String
53
53
 
54
- def self.load_doc: (String toml) -> untyped
55
-
56
- def self.dump_doc: (untyped doc) -> String
57
-
58
54
  def self.dump_json_natural: (untyped obj) -> String
59
55
 
60
56
  def self.engine_version: () -> String
@@ -128,6 +124,10 @@ module TeptrisExt
128
124
 
129
125
  def self.load_lazy_batch: (Array[String] tomls) -> Array[LazyValue]
130
126
 
127
+ def self.load_doc: (String toml) -> untyped
128
+
129
+ def self.dump_doc: (untyped doc) -> String
130
+
131
131
  def self.dump: (untyped obj) -> String
132
132
 
133
133
  def self.dump_json_natural: (untyped obj) -> String
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6.1
4
+ version: 0.3.6.2
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - teptris contributors