supplement 2.31 → 2.31.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +2 -2
  4. data/lib/supplement.c +17 -20
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ecb9754ff9168f112f5cc9535bdd6fa1dd1877cb7eb4738757a32854a56c325
4
- data.tar.gz: 983d0b6c6c91258fd74eb0e6fe31f16124654e730d750a09105fe66873086915
3
+ metadata.gz: dff470072491d922eb1edfa3e305fad6323caa366f83379f10065de3c8ce5a84
4
+ data.tar.gz: a69fc76a288c99a345e583029fac4678ec591aaa6edd50cf896e77a498147cef
5
5
  SHA512:
6
- metadata.gz: 31724b42dca923848441e648d91757c58bb212a63d91a3613fbedb760b6894f64d432bfb30de89f95fbba93002b9e316283efab175ef747e162ca174ac25e3c4
7
- data.tar.gz: 5f9e2ff5d368ea29e22bc2218c22b2261b582a8d81724ae5fb48f841fd1c6d77d3367950a68372a74fd8287a8b51b08ba0c7e7635d5bed296619362103f2f5bb
6
+ metadata.gz: cabaaa436d3f1e3a7bfae57e47c2df42980e8011a1f2a745be79489bbbdc164e8ef7a89c420369a0128e743618303649b396f045351009c5e3b85cca1e60e740
7
+ data.tar.gz: e5de3d55afe67a240d8efbf35198bed3ca114ef143c1e5a91d221b63ee3c5eea367b76548a250010bcc8eca420cc287f0305f612fb075c746ad267fd3a5ca168
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  # BSD-2-clause license, extended by language use conditions
2
2
 
3
- Copyright (C) 2009-2025, Bertram Scharpf <software@bertram-scharpf.de>.
3
+ Copyright (C) 2009-2026, Bertram Scharpf <software@bertram-scharpf.de>.
4
4
  All rights reserved.
5
5
 
6
6
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # supplement 2.31 -- Useful Ruby enhancements
1
+ # supplement 2.31.1 -- Useful Ruby enhancements
2
2
 
3
3
  Some simple Ruby extensions.
4
4
 
@@ -48,7 +48,7 @@ one of them to be included into the Ruby standard.
48
48
 
49
49
  ## Copyright
50
50
 
51
- * (C) 2009-2025 Bertram Scharpf <software@bertram-scharpf.de>
51
+ * (C) 2009-2026 Bertram Scharpf <software@bertram-scharpf.de>
52
52
  * License: [BSD-2-Clause+](./LICENSE)
53
53
  * Repository: [ruby-supplement](https://github.com/BertramScharpf/ruby-supplement)
54
54
 
data/lib/supplement.c CHANGED
@@ -12,7 +12,6 @@
12
12
 
13
13
 
14
14
  static long supplement_args_len_default( int, VALUE *);
15
- static void supplement_make_ellipse( void);
16
15
  static void supplement_ary_assure_notempty( VALUE);
17
16
  static VALUE supplement_index_blk( VALUE);
18
17
  static VALUE supplement_index_ref( VALUE, VALUE);
@@ -21,8 +20,7 @@ static VALUE supplement_rindex_ref( VALUE, VALUE);
21
20
  static VALUE supplement_do_unumask( VALUE);
22
21
 
23
22
 
24
- static VALUE supplement_ellipse = Qnil;
25
- static long supplement_len_ell = 0;
23
+ static const char *supplement_ellipse = "...";
26
24
 
27
25
  static ID id_delete_at = 0;
28
26
  static ID id_cmp = 0;
@@ -413,15 +411,6 @@ supplement_args_len_default( int argc, VALUE *argv)
413
411
  return r;
414
412
  }
415
413
 
416
- void
417
- supplement_make_ellipse( void)
418
- {
419
- if (!NIL_P( supplement_ellipse))
420
- return;
421
- supplement_ellipse = rb_str_new2( "...");
422
- supplement_len_ell = rb_str_strlen( supplement_ellipse);
423
- }
424
-
425
414
  /*
426
415
  * call-seq:
427
416
  * axe( n = 80) -> str
@@ -443,14 +432,19 @@ rb_str_axe( int argc, VALUE *argv, VALUE str)
443
432
  if (newlen < 0)
444
433
  return Qnil;
445
434
 
435
+
446
436
  oldlen = rb_str_strlen( str);
447
437
  if (newlen < oldlen) {
448
- supplement_make_ellipse();
449
- if (newlen >= supplement_len_ell) {
450
- ret = rb_str_substr( str, 0, newlen - supplement_len_ell);
451
- rb_str_append( ret, supplement_ellipse);
438
+ VALUE ell;
439
+ long le;
440
+
441
+ ell = rb_str_new2( supplement_ellipse);
442
+ le = rb_str_strlen( ell);
443
+ if (newlen >= le) {
444
+ ret = rb_str_substr( str, 0, newlen - le);
445
+ rb_str_append( ret, ell);
452
446
  } else
453
- ret = rb_str_substr( supplement_ellipse, 0, newlen);
447
+ ret = rb_str_substr( ell, 0, newlen);
454
448
  } else
455
449
  ret = str;
456
450
  return ret;
@@ -484,12 +478,15 @@ rb_str_axe_bang( int argc, VALUE *argv, VALUE str)
484
478
 
485
479
  oldlen = rb_str_strlen( str);
486
480
  if (newlen < oldlen) {
481
+ VALUE ell;
482
+ long le;
487
483
  long re;
488
484
 
489
485
  rb_str_update( str, newlen, oldlen - newlen, rb_str_new( NULL, 0));
490
- supplement_make_ellipse();
491
- re = newlen < supplement_len_ell ? newlen : supplement_len_ell;
492
- rb_str_update( str, newlen - re, re, rb_str_substr( supplement_ellipse, 0, re));
486
+ ell = rb_str_new2( supplement_ellipse);
487
+ le = rb_str_strlen( ell);
488
+ re = newlen < le ? newlen : le;
489
+ rb_str_update( str, newlen - re, re, rb_str_substr( ell, 0, re));
493
490
  return str;
494
491
  } else
495
492
  return Qnil;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supplement
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.31'
4
+ version: 2.31.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf