supplement 2.19 → 2.21
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/LICENSE +1 -1
- data/README +1 -1
- data/lib/mkrf_conf +13 -32
- data/lib/process.c +1 -5
- data/lib/supplement/filesys.h +1 -5
- data/lib/supplement/itimer.h +1 -5
- data/lib/supplement/locked.c +17 -27
- data/lib/supplement/locked.h +1 -5
- data/lib/supplement/socket.c +1 -5
- data/lib/supplement/socket.h +1 -5
- data/lib/supplement/terminal.c +20 -26
- data/lib/supplement/terminal.h +1 -5
- data/lib/supplement.c +37 -175
- data/lib/supplement.h +3 -11
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7195670e7cd62225ea949b29536edf23349f53688ad4bb85f2aae7e90497cef9
|
4
|
+
data.tar.gz: 61b52622f92b881337daf310681533758245f61b9939997caf018088e0f00547
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fecc23c00a4981a04cd4193297ff84f768b2b37d98e471a36a86e7af062197ddbe4977f9d44c0f2f979b22dddfc4c28d889189e7c029cc0a7a4f6eb6b5b474b
|
7
|
+
data.tar.gz: 1e8e2585b26e5fa445d370b169a7ba73d08b42bec9399bf6b4ade2b90fc4fc0885d766a24c26705899bc176cf15d71d6b27645f3723ee1eff743bb2ce9a68016
|
data/LICENSE
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= supplement Ruby Gem
|
2
2
|
|
3
3
|
|
4
|
-
Copyright (C) 2009-
|
4
|
+
Copyright (C) 2009-2024, Bertram Scharpf <software@bertram-scharpf.de>.
|
5
5
|
All rights reserved.
|
6
6
|
|
7
7
|
Redistribution and use in source and binary forms, with or without
|
data/README
CHANGED
data/lib/mkrf_conf
CHANGED
@@ -10,42 +10,23 @@ Autorake.configure {
|
|
10
10
|
|
11
11
|
extending_ruby
|
12
12
|
|
13
|
-
if RUBY_VERSION < "
|
14
|
-
if RUBY_VERSION < "2.
|
15
|
-
|
16
|
-
|
17
|
-
enable :array_select_bang
|
18
|
-
enable :file_size
|
19
|
-
if RUBY_VERSION < "1.9" then
|
20
|
-
enable :string_ord
|
21
|
-
enable :string_clear
|
22
|
-
if RUBY_VERSION < "1.8.7" then
|
23
|
-
enable :array_index_with_block
|
24
|
-
enable :kernel_tap
|
25
|
-
enable :string_start_with
|
26
|
-
enable :thread_exclusive
|
27
|
-
end
|
28
|
-
end
|
13
|
+
if RUBY_VERSION < "3.3" then
|
14
|
+
if RUBY_VERSION < "2.7" then
|
15
|
+
if RUBY_VERSION < "2.6" then
|
16
|
+
enable :dir_children
|
29
17
|
end
|
18
|
+
else
|
19
|
+
enable :super_kwargs
|
30
20
|
end
|
31
|
-
|
32
|
-
enable :super_kwargs
|
21
|
+
enable :old_io_functions
|
33
22
|
end
|
34
23
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
else
|
42
|
-
have_header "ruby/ruby.h"
|
43
|
-
have_header "ruby/st.h"
|
44
|
-
have_header "ruby/io.h"
|
45
|
-
have_header "ruby/re.h"
|
46
|
-
|
47
|
-
have_function "rb_thread_wait_for"
|
48
|
-
end
|
24
|
+
have_header "ruby/ruby.h"
|
25
|
+
have_header "ruby/st.h"
|
26
|
+
have_header "ruby/io.h"
|
27
|
+
have_header "ruby/re.h"
|
28
|
+
|
29
|
+
have_function "rb_thread_wait_for"
|
49
30
|
|
50
31
|
have_function "cbrt"
|
51
32
|
|
data/lib/process.c
CHANGED
data/lib/supplement/filesys.h
CHANGED
@@ -5,11 +5,7 @@
|
|
5
5
|
#ifndef __SUPPLEMENT_FILESYS_H__
|
6
6
|
#define __SUPPLEMENT_FILESYS_H__
|
7
7
|
|
8
|
-
#
|
9
|
-
#include <ruby.h>
|
10
|
-
#elif HAVE_HEADER_RUBY_RUBY_H
|
11
|
-
#include <ruby/ruby.h>
|
12
|
-
#endif
|
8
|
+
#include <ruby/ruby.h>
|
13
9
|
|
14
10
|
|
15
11
|
extern VALUE rb_fsstat_s_alloc( VALUE);
|
data/lib/supplement/itimer.h
CHANGED
@@ -5,11 +5,7 @@
|
|
5
5
|
#ifndef __SUPPLEMENT_ITIMER_H__
|
6
6
|
#define __SUPPLEMENT_ITIMER_H__
|
7
7
|
|
8
|
-
#
|
9
|
-
#include <ruby.h>
|
10
|
-
#elif HAVE_HEADER_RUBY_RUBY_H
|
11
|
-
#include <ruby/ruby.h>
|
12
|
-
#endif
|
8
|
+
#include <ruby/ruby.h>
|
13
9
|
|
14
10
|
|
15
11
|
extern VALUE rb_process_setitimer( int, VALUE *, VALUE);
|
data/lib/supplement/locked.c
CHANGED
@@ -4,11 +4,7 @@
|
|
4
4
|
|
5
5
|
#include "locked.h"
|
6
6
|
|
7
|
-
#
|
8
|
-
#include <rubyio.h>
|
9
|
-
#elif HAVE_HEADER_RUBY_IO_H
|
10
|
-
#include <ruby/io.h>
|
11
|
-
#endif
|
7
|
+
#include <ruby/io.h>
|
12
8
|
|
13
9
|
#include <sys/file.h>
|
14
10
|
|
@@ -32,9 +28,7 @@
|
|
32
28
|
VALUE
|
33
29
|
rb_locked_init( int argc, VALUE *argv, VALUE self)
|
34
30
|
{
|
35
|
-
#ifdef
|
36
|
-
OpenFile *fptr;
|
37
|
-
#else
|
31
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
38
32
|
rb_io_t *fptr;
|
39
33
|
#endif
|
40
34
|
#ifdef HAVE_FUNC_RB_THREAD_WAIT_FOR
|
@@ -42,19 +36,26 @@ rb_locked_init( int argc, VALUE *argv, VALUE self)
|
|
42
36
|
#endif
|
43
37
|
int op;
|
44
38
|
|
39
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
40
|
+
GetOpenFile( self, fptr);
|
41
|
+
#endif
|
42
|
+
|
45
43
|
#ifdef FEATURE_SUPER_KWARGS
|
46
44
|
rb_call_super_kw(argc, argv, RB_PASS_CALLED_KEYWORDS);
|
47
45
|
#else
|
48
46
|
rb_call_super( argc, argv);
|
49
47
|
#endif
|
50
|
-
GetOpenFile( self, fptr);
|
51
48
|
|
49
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
52
50
|
op = fptr->mode & FMODE_WRITABLE ? LOCK_EX : LOCK_SH;
|
53
|
-
op |= LOCK_NB;
|
54
|
-
#ifdef HAVE_HEADER_RUBY_H
|
55
|
-
while (flock( fileno( fptr->f), op) < 0) {
|
56
51
|
#else
|
52
|
+
op = rb_io_mode( self) & FMODE_WRITABLE ? LOCK_EX : LOCK_SH;
|
53
|
+
#endif
|
54
|
+
op |= LOCK_NB;
|
55
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
57
56
|
while (flock( fptr->fd, op) < 0) {
|
57
|
+
#else
|
58
|
+
while (flock( rb_io_descriptor( self), op) < 0) {
|
58
59
|
#endif
|
59
60
|
static ID id_lock_failed = 0;
|
60
61
|
|
@@ -81,10 +82,10 @@ rb_locked_init( int argc, VALUE *argv, VALUE self)
|
|
81
82
|
}
|
82
83
|
break;
|
83
84
|
default:
|
84
|
-
#ifdef
|
85
|
-
rb_sys_fail( fptr->path);
|
86
|
-
#else
|
85
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
87
86
|
rb_sys_fail_str( fptr->pathv);
|
87
|
+
#else
|
88
|
+
rb_sys_fail_str( rb_io_path( self));
|
88
89
|
#endif
|
89
90
|
break;
|
90
91
|
}
|
@@ -103,18 +104,7 @@ rb_locked_init( int argc, VALUE *argv, VALUE self)
|
|
103
104
|
VALUE
|
104
105
|
rb_locked_close( VALUE self)
|
105
106
|
{
|
106
|
-
|
107
|
-
OpenFile *fptr;
|
108
|
-
#else
|
109
|
-
rb_io_t *fptr;
|
110
|
-
#endif
|
111
|
-
|
112
|
-
GetOpenFile( self, fptr);
|
113
|
-
#ifdef HAVE_HEADER_RUBY_H
|
114
|
-
flock( fileno( fptr->f), LOCK_UN);
|
115
|
-
#else
|
116
|
-
flock( fptr->fd, LOCK_UN);
|
117
|
-
#endif
|
107
|
+
flock( rb_io_descriptor( self), LOCK_UN);
|
118
108
|
rb_call_super( 0, NULL);
|
119
109
|
return Qnil;
|
120
110
|
}
|
data/lib/supplement/locked.h
CHANGED
@@ -5,11 +5,7 @@
|
|
5
5
|
#ifndef __SUPPLEMENT_FILESYS_H__
|
6
6
|
#define __SUPPLEMENT_FILESYS_H__
|
7
7
|
|
8
|
-
#
|
9
|
-
#include <ruby.h>
|
10
|
-
#elif HAVE_HEADER_RUBY_RUBY_H
|
11
|
-
#include <ruby/ruby.h>
|
12
|
-
#endif
|
8
|
+
#include <ruby/ruby.h>
|
13
9
|
|
14
10
|
VALUE rb_locked_init( int argc, VALUE *argv, VALUE self);
|
15
11
|
VALUE rb_locked_close( VALUE self);
|
data/lib/supplement/socket.c
CHANGED
data/lib/supplement/socket.h
CHANGED
data/lib/supplement/terminal.c
CHANGED
@@ -4,11 +4,7 @@
|
|
4
4
|
|
5
5
|
#include "terminal.h"
|
6
6
|
|
7
|
-
#
|
8
|
-
#include <rubyio.h>
|
9
|
-
#elif HAVE_HEADER_RUBY_IO_H
|
10
|
-
#include <ruby/io.h>
|
11
|
-
#endif
|
7
|
+
#include <ruby/io.h>
|
12
8
|
|
13
9
|
#include <sys/ioctl.h>
|
14
10
|
#include <termios.h>
|
@@ -17,10 +13,12 @@ static VALUE io_unget( VALUE);
|
|
17
13
|
static VALUE io_reset( VALUE);
|
18
14
|
|
19
15
|
|
20
|
-
#
|
21
|
-
#define
|
16
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
17
|
+
#define RB_FAIL_PATH( io, fptr) ((fptr)->pathv)
|
18
|
+
#define RB_IO_VAR( io, fptr) fptr
|
22
19
|
#else
|
23
|
-
#define
|
20
|
+
#define RB_FAIL_PATH( io, fptr) rb_io_path( io)
|
21
|
+
#define RB_IO_VAR( io, fptr) io
|
24
22
|
#endif
|
25
23
|
|
26
24
|
/*
|
@@ -35,30 +33,28 @@ static VALUE io_reset( VALUE);
|
|
35
33
|
VALUE
|
36
34
|
rb_io_unget( int argc, VALUE *argv, VALUE io)
|
37
35
|
{
|
38
|
-
#
|
39
|
-
OpenFile *fptr;
|
40
|
-
#else
|
36
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
41
37
|
rb_io_t *fptr;
|
42
38
|
#endif
|
43
39
|
int fd;
|
44
40
|
struct termios oldtio, newtio;
|
45
41
|
void *v[5];
|
46
42
|
|
43
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
47
44
|
GetOpenFile( io, fptr);
|
48
|
-
#ifndef RUBY_VM
|
49
|
-
fd = fileno( fptr->f);
|
50
|
-
#else
|
51
45
|
fd = fptr->fd;
|
46
|
+
#else
|
47
|
+
fd = rb_io_descriptor( io);
|
52
48
|
#endif
|
53
49
|
|
54
50
|
if (tcgetattr( fd, &oldtio) < 0)
|
55
|
-
|
51
|
+
rb_sys_fail_str( RB_FAIL_PATH( io, fptr));
|
56
52
|
newtio = oldtio;
|
57
53
|
newtio.c_iflag &= ~ICRNL;
|
58
54
|
if (tcsetattr( fd, TCSANOW, &newtio) < 0)
|
59
|
-
|
55
|
+
rb_sys_fail_str( RB_FAIL_PATH( io, fptr));
|
60
56
|
|
61
|
-
v[0] = &fd, v[1] = fptr, v[2] = &oldtio,
|
57
|
+
v[0] = &fd, v[1] = (void *) RB_IO_VAR( io, fptr), v[2] = &oldtio,
|
62
58
|
v[3] = &argc, v[4] = (void *) argv;
|
63
59
|
return rb_ensure( io_unget, (VALUE) v, io_reset, (VALUE) v);
|
64
60
|
}
|
@@ -80,7 +76,7 @@ io_unget( VALUE v)
|
|
80
76
|
p = RSTRING_PTR(str);
|
81
77
|
for (i = RSTRING_LEN(str); i; --i, ++p)
|
82
78
|
if (ioctl( *(int *) vp[0], TIOCSTI, p) < 0)
|
83
|
-
|
79
|
+
rb_sys_fail_str( RB_FAIL_PATH( (VALUE) vp[1], (rb_io_t *) vp[1]));
|
84
80
|
}
|
85
81
|
return Qnil;
|
86
82
|
}
|
@@ -91,7 +87,7 @@ io_reset( VALUE v)
|
|
91
87
|
void **vp = (void **) v;
|
92
88
|
|
93
89
|
if (tcsetattr( *(int *) vp[0], TCSANOW, (struct termios *) vp[2]) < 0)
|
94
|
-
|
90
|
+
rb_sys_fail_str( RB_FAIL_PATH( (VALUE) vp[1], (rb_io_t *) vp[1]));
|
95
91
|
|
96
92
|
return Qnil;
|
97
93
|
}
|
@@ -109,24 +105,22 @@ io_reset( VALUE v)
|
|
109
105
|
VALUE
|
110
106
|
rb_io_wingeom( VALUE self)
|
111
107
|
{
|
112
|
-
#
|
113
|
-
OpenFile *fptr;
|
114
|
-
#else
|
108
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
115
109
|
rb_io_t *fptr;
|
116
110
|
#endif
|
117
111
|
int fd;
|
118
112
|
struct winsize w;
|
119
113
|
VALUE r;
|
120
114
|
|
115
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
121
116
|
GetOpenFile( self, fptr);
|
122
|
-
#ifndef RUBY_VM
|
123
|
-
fd = fileno( fptr->f);
|
124
|
-
#else
|
125
117
|
fd = fptr->fd;
|
118
|
+
#else
|
119
|
+
fd = rb_io_descriptor( self);
|
126
120
|
#endif
|
127
121
|
|
128
122
|
if (ioctl( fd, TIOCGWINSZ, &w) < 0)
|
129
|
-
|
123
|
+
rb_sys_fail_str( RB_FAIL_PATH( self, fptr));
|
130
124
|
r = rb_ary_new2( 4);
|
131
125
|
rb_ary_store( r, 0, INT2NUM( w.ws_col));
|
132
126
|
rb_ary_store( r, 1, INT2NUM( w.ws_row));
|
data/lib/supplement/terminal.h
CHANGED
@@ -5,11 +5,7 @@
|
|
5
5
|
#ifndef __SUPPLEMENT_TERMINAL_H__
|
6
6
|
#define __SUPPLEMENT_TERMINAL_H__
|
7
7
|
|
8
|
-
#
|
9
|
-
#include <ruby.h>
|
10
|
-
#elif HAVE_HEADER_RUBY_RUBY_H
|
11
|
-
#include <ruby/ruby.h>
|
12
|
-
#endif
|
8
|
+
#include <ruby/ruby.h>
|
13
9
|
|
14
10
|
|
15
11
|
extern VALUE rb_io_unget( int, VALUE *, VALUE);
|
data/lib/supplement.c
CHANGED
@@ -6,21 +6,9 @@
|
|
6
6
|
|
7
7
|
#include "process.h"
|
8
8
|
|
9
|
-
#
|
10
|
-
|
11
|
-
#
|
12
|
-
#include <ruby/st.h>
|
13
|
-
#endif
|
14
|
-
#if HAVE_HEADER_RUBYIO_H
|
15
|
-
#include <rubyio.h>
|
16
|
-
#elif HAVE_HEADER_RUBY_IO_H
|
17
|
-
#include <ruby/io.h>
|
18
|
-
#endif
|
19
|
-
#if HAVE_HEADER_RE_H
|
20
|
-
#include <re.h>
|
21
|
-
#elif HAVE_HEADER_RUBY_RE_H
|
22
|
-
#include <ruby/re.h>
|
23
|
-
#endif
|
9
|
+
#include <ruby/st.h>
|
10
|
+
#include <ruby/io.h>
|
11
|
+
#include <ruby/re.h>
|
24
12
|
|
25
13
|
#ifdef FEATURE_THREAD_EXCLUSIVE
|
26
14
|
#ifdef HAVE_HEADER_RUBYSIG_H
|
@@ -29,13 +17,6 @@
|
|
29
17
|
#endif
|
30
18
|
|
31
19
|
|
32
|
-
#ifdef HAVE_HEADER_RUBY_H
|
33
|
-
/* Oh what a bug! */
|
34
|
-
#define R_MATCH( obj) RMATCH( obj)
|
35
|
-
#else
|
36
|
-
#endif
|
37
|
-
|
38
|
-
|
39
20
|
static VALUE supplement_index_blk( VALUE);
|
40
21
|
static VALUE supplement_index_ref( VALUE, VALUE);
|
41
22
|
static VALUE supplement_rindex_blk( VALUE);
|
@@ -44,10 +25,6 @@ static VALUE supplement_rindex_ref( VALUE, VALUE);
|
|
44
25
|
static VALUE supplement_index_val( VALUE, VALUE);
|
45
26
|
static VALUE supplement_rindex_val( VALUE, VALUE);
|
46
27
|
#endif
|
47
|
-
#ifdef FEATURE_ARRAY_SELECT_BANG
|
48
|
-
static VALUE supplement_reject( VALUE);
|
49
|
-
static VALUE supplement_invert_yield( VALUE);
|
50
|
-
#endif
|
51
28
|
static VALUE supplement_do_unumask( VALUE);
|
52
29
|
#ifdef FEATURE_THREAD_EXCLUSIVE
|
53
30
|
static VALUE bsruby_set_thread_critical( VALUE);
|
@@ -58,9 +35,6 @@ static VALUE bsruby_set_thread_critical( VALUE);
|
|
58
35
|
static ID id_delete_at;
|
59
36
|
static ID id_cmp;
|
60
37
|
static ID id_eqq;
|
61
|
-
#ifdef FEATURE_ARRAY_SELECT_BANG
|
62
|
-
static ID id_reject_bang;
|
63
|
-
#endif
|
64
38
|
static ID id_mkdir;
|
65
39
|
static ID id_index;
|
66
40
|
|
@@ -189,6 +163,33 @@ rb_krn_with( VALUE obj)
|
|
189
163
|
}
|
190
164
|
|
191
165
|
|
166
|
+
/*
|
167
|
+
* Document-class: Module
|
168
|
+
*/
|
169
|
+
|
170
|
+
/*
|
171
|
+
* call-seq:
|
172
|
+
* plain_name -> str
|
173
|
+
*
|
174
|
+
* The last part of a `::`-separated Module name path.
|
175
|
+
*/
|
176
|
+
|
177
|
+
VALUE
|
178
|
+
rb_module_plain_name( VALUE cls)
|
179
|
+
{
|
180
|
+
VALUE n;
|
181
|
+
VALUE i;
|
182
|
+
|
183
|
+
n = rb_str_dup( rb_funcall( cls, rb_intern( "name"), 0));
|
184
|
+
i = rb_funcall( n, rb_intern( "rindex"), 1, rb_str_new( "::", 2));
|
185
|
+
if (!NIL_P( i)) {
|
186
|
+
i = rb_funcall( i, rb_intern( "+"), 1, INT2FIX( 2));
|
187
|
+
rb_funcall( n, rb_intern( "slice!"), 2, INT2FIX( 0), i);
|
188
|
+
}
|
189
|
+
return n;
|
190
|
+
}
|
191
|
+
|
192
|
+
|
192
193
|
/*
|
193
194
|
* Document-class: NilClass
|
194
195
|
*/
|
@@ -301,11 +302,7 @@ rb_str_eat( int argc, VALUE *argv, VALUE str)
|
|
301
302
|
int l;
|
302
303
|
int r;
|
303
304
|
|
304
|
-
#ifdef HAVE_HEADER_RUBY_H
|
305
|
-
n = l = RSTRING_LEN( str);
|
306
|
-
#else
|
307
305
|
n = l = rb_str_strlen( str);
|
308
|
-
#endif
|
309
306
|
if (rb_scan_args( argc, argv, "01", &val) == 1) {
|
310
307
|
if (!NIL_P( val)) {
|
311
308
|
int v = NUM2INT( val);
|
@@ -318,17 +315,6 @@ rb_str_eat( int argc, VALUE *argv, VALUE str)
|
|
318
315
|
}
|
319
316
|
}
|
320
317
|
rb_str_modify( str);
|
321
|
-
#ifdef HAVE_HEADER_RUBY_H
|
322
|
-
if (n > 0) {
|
323
|
-
r = l - n;
|
324
|
-
val = rb_str_new5( str, RSTRING_PTR( str), n);
|
325
|
-
memmove( RSTRING_PTR( str), RSTRING_PTR( str) + n, r);
|
326
|
-
} else {
|
327
|
-
r = l + n;
|
328
|
-
val = rb_str_new5( str, RSTRING_PTR( str) + r, -n);
|
329
|
-
}
|
330
|
-
RSTRING_LEN( str) = r;
|
331
|
-
#else
|
332
318
|
if (n > 0) {
|
333
319
|
r = 0;
|
334
320
|
} else if (n < 0) {
|
@@ -339,7 +325,6 @@ rb_str_eat( int argc, VALUE *argv, VALUE str)
|
|
339
325
|
val = rb_str_substr( str, r, n);
|
340
326
|
if (!NIL_P(val))
|
341
327
|
rb_str_update( str, r, n, rb_str_new( NULL, 0));
|
342
|
-
#endif
|
343
328
|
return val;
|
344
329
|
}
|
345
330
|
|
@@ -361,27 +346,17 @@ VALUE
|
|
361
346
|
rb_str_cut_bang( VALUE str, VALUE len)
|
362
347
|
{
|
363
348
|
int l;
|
364
|
-
#ifdef HAVE_HEADER_RUBY_H
|
365
|
-
#else
|
366
349
|
int n;
|
367
|
-
#endif
|
368
350
|
|
369
351
|
rb_str_modify( str);
|
370
352
|
l = NUM2INT( len);
|
371
353
|
if (l < 0)
|
372
354
|
l = 0;
|
373
|
-
#ifdef HAVE_HEADER_RUBY_H
|
374
|
-
if (l < RSTRING_LEN( str)) {
|
375
|
-
RSTRING_LEN( str) = l;
|
376
|
-
return str;
|
377
|
-
}
|
378
|
-
#else
|
379
355
|
n = rb_str_strlen( str);
|
380
356
|
if (l < n) {
|
381
357
|
rb_str_update( str, l, n - l, rb_str_new( NULL, 0));
|
382
358
|
return str;
|
383
359
|
}
|
384
|
-
#endif
|
385
360
|
return Qnil;
|
386
361
|
}
|
387
362
|
|
@@ -449,11 +424,7 @@ rb_str_rest( int argc, VALUE *argv, VALUE str)
|
|
449
424
|
beg = rb_scan_args( argc, argv, "01", &n) == 1 ? NUM2LONG( n) : 1;
|
450
425
|
if (beg < 0)
|
451
426
|
beg = 0;
|
452
|
-
#ifdef HAVE_HEADER_RUBY_H
|
453
|
-
l = RSTRING_LEN( str);
|
454
|
-
#else
|
455
427
|
l = rb_str_strlen( str);
|
456
|
-
#endif
|
457
428
|
return rb_str_substr( str, beg, l - beg);
|
458
429
|
}
|
459
430
|
|
@@ -474,11 +445,7 @@ rb_str_tail( int argc, VALUE *argv, VALUE str)
|
|
474
445
|
long l, beg, len;
|
475
446
|
|
476
447
|
len = rb_scan_args( argc, argv, "01", &n) == 1 ? NUM2LONG( n) : 1;
|
477
|
-
#ifdef HAVE_HEADER_RUBY_H
|
478
|
-
l = RSTRING_LEN( str);
|
479
|
-
#else
|
480
448
|
l = rb_str_strlen( str);
|
481
|
-
#endif
|
482
449
|
beg = l - len;
|
483
450
|
if (beg < 0)
|
484
451
|
beg = 0, len = l;
|
@@ -541,11 +508,8 @@ rb_str_starts_with_p( VALUE str, VALUE oth)
|
|
541
508
|
char *s, *o;
|
542
509
|
VALUE ost;
|
543
510
|
|
544
|
-
#ifdef HAVE_HEADER_RUBY_H
|
545
|
-
#else
|
546
511
|
if (!rb_str_comparable( str, oth))
|
547
512
|
return Qnil;
|
548
|
-
#endif
|
549
513
|
ost = rb_string_value( &oth);
|
550
514
|
i = RSTRING_LEN( ost);
|
551
515
|
if (i > RSTRING_LEN( str))
|
@@ -556,11 +520,7 @@ rb_str_starts_with_p( VALUE str, VALUE oth)
|
|
556
520
|
if (*s != *o)
|
557
521
|
return Qnil;
|
558
522
|
}
|
559
|
-
#ifdef HAVE_HEADER_RUBY_H
|
560
|
-
return INT2FIX( RSTRING_LEN( ost));
|
561
|
-
#else
|
562
523
|
return INT2FIX( rb_str_strlen( ost));
|
563
|
-
#endif
|
564
524
|
}
|
565
525
|
|
566
526
|
|
@@ -584,11 +544,8 @@ rb_str_ends_with_p( VALUE str, VALUE oth)
|
|
584
544
|
char *s, *o;
|
585
545
|
VALUE ost;
|
586
546
|
|
587
|
-
#ifdef HAVE_HEADER_RUBY_H
|
588
|
-
#else
|
589
547
|
if (!rb_str_comparable( str, oth))
|
590
548
|
return Qnil;
|
591
|
-
#endif
|
592
549
|
ost = rb_string_value( &oth);
|
593
550
|
i = RSTRING_LEN( ost);
|
594
551
|
if (i > RSTRING_LEN( str))
|
@@ -598,11 +555,7 @@ rb_str_ends_with_p( VALUE str, VALUE oth)
|
|
598
555
|
for (; i; i--)
|
599
556
|
if (*--s != *--o)
|
600
557
|
return Qnil;
|
601
|
-
#ifdef HAVE_HEADER_RUBY_H
|
602
|
-
return INT2FIX( RSTRING_LEN( str) - RSTRING_LEN( ost));
|
603
|
-
#else
|
604
558
|
return INT2FIX( rb_str_strlen( str) - rb_str_strlen( ost));
|
605
|
-
#endif
|
606
559
|
}
|
607
560
|
|
608
561
|
#ifdef FEATURE_STRING_ORD
|
@@ -650,21 +603,13 @@ rb_str_axe( int argc, VALUE *argv, VALUE str)
|
|
650
603
|
if (newlen < 0)
|
651
604
|
return Qnil;
|
652
605
|
|
653
|
-
#ifdef HAVE_HEADER_RUBY_H
|
654
|
-
oldlen = RSTRING_LEN( str);
|
655
|
-
#else
|
656
606
|
oldlen = rb_str_strlen( str);
|
657
|
-
#endif
|
658
607
|
if (newlen < oldlen) {
|
659
608
|
VALUE ell;
|
660
609
|
long e;
|
661
610
|
|
662
611
|
ell = rb_str_new2( "...");
|
663
|
-
#ifdef HAVE_HEADER_RUBY_H
|
664
|
-
e = RSTRING_LEN( ell);
|
665
|
-
#else
|
666
612
|
e = rb_str_strlen( ell);
|
667
|
-
#endif
|
668
613
|
if (newlen > e) {
|
669
614
|
ret = rb_str_substr( str, 0, newlen - e);
|
670
615
|
rb_str_append( ret, ell);
|
@@ -1124,42 +1069,6 @@ supplement_rindex_val( VALUE ary, VALUE val)
|
|
1124
1069
|
|
1125
1070
|
#endif
|
1126
1071
|
|
1127
|
-
#ifdef FEATURE_ARRAY_SELECT_BANG
|
1128
|
-
|
1129
|
-
/*
|
1130
|
-
* Document-method: select!
|
1131
|
-
*
|
1132
|
-
* call-seq:
|
1133
|
-
* select! { |x| ... } -> ary
|
1134
|
-
*
|
1135
|
-
* Remove all items for that the block returns +nil+ or +false+.
|
1136
|
-
*
|
1137
|
-
*/
|
1138
|
-
|
1139
|
-
VALUE
|
1140
|
-
rb_ary_select_bang( VALUE self)
|
1141
|
-
{
|
1142
|
-
return rb_iterate( &supplement_reject, self,
|
1143
|
-
&supplement_invert_yield, Qnil);
|
1144
|
-
}
|
1145
|
-
|
1146
|
-
VALUE
|
1147
|
-
supplement_reject( VALUE obj)
|
1148
|
-
{
|
1149
|
-
if (!id_reject_bang)
|
1150
|
-
id_reject_bang = rb_intern( "reject!");
|
1151
|
-
return rb_funcall( obj, id_reject_bang, 0);
|
1152
|
-
}
|
1153
|
-
|
1154
|
-
VALUE
|
1155
|
-
supplement_invert_yield( VALUE elem)
|
1156
|
-
{
|
1157
|
-
return NIL_P( rb_yield( elem)) ? Qtrue : Qfalse;
|
1158
|
-
}
|
1159
|
-
|
1160
|
-
#endif
|
1161
|
-
|
1162
|
-
|
1163
1072
|
|
1164
1073
|
/*
|
1165
1074
|
* Document-class: Hash
|
@@ -1187,51 +1096,11 @@ rb_hash_notempty_p( VALUE hash)
|
|
1187
1096
|
* Document-class: File
|
1188
1097
|
*/
|
1189
1098
|
|
1190
|
-
|
1191
|
-
#ifdef FEATURE_FILE_SIZE
|
1192
|
-
|
1193
1099
|
/*
|
1194
1100
|
* call-seq:
|
1195
|
-
*
|
1196
|
-
*
|
1197
|
-
*
|
1198
|
-
* <code>file.stat.size</code>. This constitutes consistency with
|
1199
|
-
* <code>StringIO</code>.
|
1200
|
-
*
|
1201
|
-
* file.size #=> 16384
|
1202
|
-
*/
|
1203
|
-
|
1204
|
-
VALUE
|
1205
|
-
rb_file_size( VALUE obj)
|
1206
|
-
{
|
1207
|
-
#ifdef HAVE_HEADER_RUBY_H
|
1208
|
-
OpenFile *fptr;
|
1209
|
-
#else
|
1210
|
-
rb_io_t *fptr;
|
1211
|
-
#endif
|
1212
|
-
struct stat st;
|
1213
|
-
|
1214
|
-
GetOpenFile( obj, fptr);
|
1215
|
-
#ifdef HAVE_HEADER_RUBY_H
|
1216
|
-
if (fstat( fileno( fptr->f), &st) == -1) {
|
1217
|
-
rb_sys_fail( fptr->path);
|
1218
|
-
}
|
1219
|
-
#else
|
1220
|
-
if (fstat( fptr->fd, &st) == -1) {
|
1221
|
-
rb_sys_fail_str( fptr->pathv);
|
1222
|
-
}
|
1223
|
-
#endif
|
1224
|
-
return INT2FIX( st.st_size);
|
1225
|
-
}
|
1226
|
-
|
1227
|
-
#endif
|
1228
|
-
|
1229
|
-
|
1230
|
-
/*
|
1231
|
-
* call-seq:
|
1232
|
-
* umask() -> int
|
1233
|
-
* umask( int) -> int
|
1234
|
-
* umask( int) { ... } -> obj
|
1101
|
+
* File.umask() -> int
|
1102
|
+
* File.umask( int) -> int
|
1103
|
+
* File.umask( int) { ... } -> obj
|
1235
1104
|
*
|
1236
1105
|
* Returns the current umask value for this process. If the optional
|
1237
1106
|
* argument is given, set the umask to that value and return the
|
@@ -1283,7 +1152,7 @@ supplement_do_unumask( VALUE v)
|
|
1283
1152
|
|
1284
1153
|
/*
|
1285
1154
|
* call-seq:
|
1286
|
-
* current() -> dir
|
1155
|
+
* Dir.current() -> dir
|
1287
1156
|
*
|
1288
1157
|
* Current directory as a Dir object.
|
1289
1158
|
*
|
@@ -1299,7 +1168,7 @@ rb_dir_s_current( VALUE dir)
|
|
1299
1168
|
|
1300
1169
|
/*
|
1301
1170
|
* call-seq:
|
1302
|
-
* mkdir!( path, modes = nil) -> str or nil
|
1171
|
+
* Dir.mkdir!( path, modes = nil) -> str or nil
|
1303
1172
|
*
|
1304
1173
|
* Make a directory and all subdirectories if needed.
|
1305
1174
|
*
|
@@ -1548,6 +1417,8 @@ void Init_supplement( void)
|
|
1548
1417
|
rb_define_method( rb_mKernel, "tap!", rb_krn_tap_bang, 0);
|
1549
1418
|
rb_define_method( rb_mKernel, "with", rb_krn_with, 0);
|
1550
1419
|
|
1420
|
+
rb_define_method( rb_cModule, "plain_name", rb_module_plain_name, 0);
|
1421
|
+
|
1551
1422
|
rb_define_method( rb_cNilClass, "notempty?", rb_nil_notempty_p, 0);
|
1552
1423
|
rb_define_method( rb_cNilClass, "nonzero?", rb_nil_notempty_p, 0);
|
1553
1424
|
rb_define_method( rb_cNilClass, "each_line", rb_nil_each_line, 0);
|
@@ -1591,15 +1462,9 @@ void Init_supplement( void)
|
|
1591
1462
|
rb_define_method( rb_cArray, "index", rb_ary_index, -1);
|
1592
1463
|
rb_define_method( rb_cArray, "rindex", rb_ary_rindex, -1);
|
1593
1464
|
#endif
|
1594
|
-
#ifdef FEATURE_ARRAY_SELECT_BANG
|
1595
|
-
rb_define_method( rb_cArray, "select!", rb_ary_select_bang, 0);
|
1596
|
-
#endif
|
1597
1465
|
|
1598
1466
|
rb_define_method( rb_cHash, "notempty?", rb_hash_notempty_p, 0);
|
1599
1467
|
|
1600
|
-
#ifdef FEATURE_FILE_SIZE
|
1601
|
-
rb_define_method( rb_cFile, "size", rb_file_size, 0);
|
1602
|
-
#endif
|
1603
1468
|
rb_define_singleton_method( rb_cFile, "umask", rb_file_s_umask, -1);
|
1604
1469
|
|
1605
1470
|
rb_define_singleton_method( rb_cDir, "current", rb_dir_s_current, 0);
|
@@ -1628,9 +1493,6 @@ void Init_supplement( void)
|
|
1628
1493
|
id_delete_at = rb_intern( "delete_at");
|
1629
1494
|
id_cmp = rb_intern( "<=>");
|
1630
1495
|
id_eqq = 0;
|
1631
|
-
#ifdef FEATURE_ARRAY_SELECT_BANG
|
1632
|
-
id_reject_bang = 0;
|
1633
|
-
#endif
|
1634
1496
|
id_mkdir = 0;
|
1635
1497
|
id_index = 0;
|
1636
1498
|
|
data/lib/supplement.h
CHANGED
@@ -6,11 +6,7 @@
|
|
6
6
|
#ifndef __SUPPELEMENT_H__
|
7
7
|
#define __SUPPELEMENT_H__
|
8
8
|
|
9
|
-
#
|
10
|
-
#include <ruby.h>
|
11
|
-
#elif HAVE_HEADER_RUBY_RUBY_H
|
12
|
-
#include <ruby/ruby.h>
|
13
|
-
#endif
|
9
|
+
#include <ruby/ruby.h>
|
14
10
|
|
15
11
|
|
16
12
|
extern VALUE rb_obj_new_string( VALUE);
|
@@ -21,6 +17,8 @@ extern VALUE rb_krn_tap( VALUE);
|
|
21
17
|
extern VALUE rb_krn_tap_bang( VALUE);
|
22
18
|
extern VALUE rb_krn_with( VALUE);
|
23
19
|
|
20
|
+
extern VALUE rb_module_plain_name( VALUE);
|
21
|
+
|
24
22
|
extern VALUE rb_nil_notempty_p( VALUE);
|
25
23
|
extern VALUE rb_nil_each_line( VALUE);
|
26
24
|
|
@@ -60,15 +58,9 @@ extern VALUE rb_ary_rpick( int, VALUE *, VALUE);
|
|
60
58
|
extern VALUE rb_ary_index( int, VALUE *, VALUE);
|
61
59
|
extern VALUE rb_ary_rindex( int, VALUE *, VALUE);
|
62
60
|
#endif
|
63
|
-
#ifdef FEATURE_ARRAY_SELECT_BANG
|
64
|
-
extern VALUE rb_ary_select_bang( VALUE);
|
65
|
-
#endif
|
66
61
|
|
67
62
|
extern VALUE rb_hash_notempty_p( VALUE);
|
68
63
|
|
69
|
-
#ifdef FEATURE_FILE_SIZE
|
70
|
-
extern VALUE rb_file_size( VALUE);
|
71
|
-
#endif
|
72
64
|
extern VALUE rb_file_s_umask( int, VALUE *, VALUE);
|
73
65
|
extern VALUE rb_dir_s_current( VALUE);
|
74
66
|
extern VALUE rb_dir_s_mkdir_bang( int, VALUE *, VALUE);
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: supplement
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.21'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '13.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '13.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: autorake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2'
|
33
|
+
version: '2.18'
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2'
|
40
|
+
version: '2.18'
|
27
41
|
description: 'Simple methods that didn''t manage to become part of standard Ruby.
|
28
42
|
|
29
43
|
'
|
@@ -73,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
87
|
requirements:
|
74
88
|
- - ">="
|
75
89
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
90
|
+
version: 2.0.0
|
77
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
92
|
requirements:
|
79
93
|
- - ">="
|