mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* process.c (proc_getpgrp): prohibit for $SAFE=2.
[ruby-dev:24899] * process.c (get_pid): ditto. [ruby-dev:24904] * process.c (get_ppid): ditto. * array.c (rb_ary_delete): defer rb_ary_modify() until actual modification. [ruby-dev:24901] * parse.y (newline_node): should not use FL_SET. [ruby-dev:24874] * parse.y (string_content): should not use FL_UNSET. * node.h (NODE_NEWLINE): remove unused bit to utilize flag field in nodes. * string.c (rb_str_splice): move rb_str_modify() after StringValue(), which may alter the receiver. [ruby-dev:24878] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1fff70f8b3
commit
db8a49614f
5 changed files with 73 additions and 57 deletions
26
ChangeLog
26
ChangeLog
|
|
@ -1,3 +1,15 @@
|
|||
Thu Nov 18 00:21:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* process.c (proc_getpgrp): prohibit for $SAFE=2.
|
||||
[ruby-dev:24899]
|
||||
|
||||
* process.c (get_pid): ditto. [ruby-dev:24904]
|
||||
|
||||
* process.c (get_ppid): ditto.
|
||||
|
||||
* array.c (rb_ary_delete): defer rb_ary_modify() until actual
|
||||
modification. [ruby-dev:24901]
|
||||
|
||||
Thu Nov 18 10:10:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c, rubyio.h (rb_io_modenum_flags): exported.
|
||||
|
|
@ -9,6 +21,15 @@ Wed Nov 17 23:42:40 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
|
|||
|
||||
* test/ruby/test_settracefunc.rb: added. [ruby-dev:24884]
|
||||
|
||||
Wed Nov 17 13:56:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y (newline_node): should not use FL_SET. [ruby-dev:24874]
|
||||
|
||||
* parse.y (string_content): should not use FL_UNSET.
|
||||
|
||||
* node.h (NODE_NEWLINE): remove unused bit to utilize flag field
|
||||
in nodes.
|
||||
|
||||
Wed Nov 17 13:09:40 2004 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* {bcc32,win32,wince}/Makefile.sub (test): should build ruby.exe
|
||||
|
|
@ -20,6 +41,11 @@ Wed Nov 17 04:33:01 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
|||
|
||||
* bignum.c (rb_big2ulong_pack): new function to pack Bignums.
|
||||
|
||||
Wed Nov 17 03:42:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_splice): move rb_str_modify() after
|
||||
StringValue(), which may alter the receiver. [ruby-dev:24878]
|
||||
|
||||
Tue Nov 16 23:45:07 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* numeric.c (flo_divmod): protect float values from GC by
|
||||
|
|
|
|||
26
array.c
26
array.c
|
|
@ -270,7 +270,6 @@ rb_ary_initialize(argc, argv, ary)
|
|||
long len;
|
||||
VALUE size, val;
|
||||
|
||||
rb_ary_modify(ary);
|
||||
if (rb_scan_args(argc, argv, "02", &size, &val) == 0) {
|
||||
RARRAY(ary)->len = 0;
|
||||
if (rb_block_given_p()) {
|
||||
|
|
@ -294,6 +293,7 @@ rb_ary_initialize(argc, argv, ary)
|
|||
if (len > 0 && len * (long)sizeof(VALUE) <= len) {
|
||||
rb_raise(rb_eArgError, "array size too big");
|
||||
}
|
||||
rb_ary_modify(ary);
|
||||
if (len > RARRAY(ary)->aux.capa) {
|
||||
REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
|
||||
RARRAY(ary)->aux.capa = len;
|
||||
|
|
@ -352,7 +352,6 @@ rb_ary_store(ary, idx, val)
|
|||
long idx;
|
||||
VALUE val;
|
||||
{
|
||||
rb_ary_modify(ary);
|
||||
if (idx < 0) {
|
||||
idx += RARRAY(ary)->len;
|
||||
if (idx < 0) {
|
||||
|
|
@ -361,6 +360,7 @@ rb_ary_store(ary, idx, val)
|
|||
}
|
||||
}
|
||||
|
||||
rb_ary_modify(ary);
|
||||
if (idx >= RARRAY(ary)->aux.capa) {
|
||||
long new_capa = RARRAY(ary)->aux.capa / 2;
|
||||
|
||||
|
|
@ -938,7 +938,7 @@ rb_ary_to_ary(obj)
|
|||
}
|
||||
|
||||
static void
|
||||
rb_ary_update(ary, beg, len, rpl)
|
||||
rb_ary_splice(ary, beg, len, rpl)
|
||||
VALUE ary;
|
||||
long beg, len;
|
||||
VALUE rpl;
|
||||
|
|
@ -1045,7 +1045,7 @@ rb_ary_aset(argc, argv, ary)
|
|||
if (SYMBOL_P(argv[1])) {
|
||||
rb_raise(rb_eTypeError, "Symbol as subarray length");
|
||||
}
|
||||
rb_ary_update(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
|
||||
rb_ary_splice(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
|
||||
return argv[2];
|
||||
}
|
||||
if (argc != 2) {
|
||||
|
|
@ -1060,7 +1060,7 @@ rb_ary_aset(argc, argv, ary)
|
|||
}
|
||||
if (rb_range_beg_len(argv[0], &beg, &len, RARRAY(ary)->len, 1)) {
|
||||
/* check if idx is Range */
|
||||
rb_ary_update(ary, beg, len, argv[1]);
|
||||
rb_ary_splice(ary, beg, len, argv[1]);
|
||||
return argv[1];
|
||||
}
|
||||
|
||||
|
|
@ -1102,7 +1102,7 @@ rb_ary_insert(argc, argv, ary)
|
|||
}
|
||||
|
||||
if (argc == 1) return ary;
|
||||
rb_ary_update(ary, pos, 0, rb_ary_new4(argc - 1, argv + 1));
|
||||
rb_ary_splice(ary, pos, 0, rb_ary_new4(argc - 1, argv + 1));
|
||||
return ary;
|
||||
}
|
||||
|
||||
|
|
@ -1849,7 +1849,6 @@ rb_ary_delete(ary, item)
|
|||
{
|
||||
long i1, i2;
|
||||
|
||||
rb_ary_modify(ary);
|
||||
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
|
||||
VALUE e = RARRAY(ary)->ptr[i1];
|
||||
|
||||
|
|
@ -1866,6 +1865,7 @@ rb_ary_delete(ary, item)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
rb_ary_modify(ary);
|
||||
if (RARRAY(ary)->len > i2) {
|
||||
RARRAY(ary)->len = i2;
|
||||
if (i2 * 2 < RARRAY(ary)->aux.capa &&
|
||||
|
|
@ -1886,13 +1886,13 @@ rb_ary_delete_at(ary, pos)
|
|||
long i, len = RARRAY(ary)->len;
|
||||
VALUE del;
|
||||
|
||||
rb_ary_modify(ary);
|
||||
if (pos >= len) return Qnil;
|
||||
if (pos < 0) {
|
||||
pos += len;
|
||||
if (pos < 0) return Qnil;
|
||||
}
|
||||
|
||||
rb_ary_modify(ary);
|
||||
del = RARRAY(ary)->ptr[pos];
|
||||
for (i = pos + 1; i < len; i++, pos++) {
|
||||
RARRAY(ary)->ptr[pos] = RARRAY(ary)->ptr[i];
|
||||
|
|
@ -1957,7 +1957,6 @@ rb_ary_slice_bang(argc, argv, ary)
|
|||
VALUE arg1, arg2;
|
||||
long pos, len;
|
||||
|
||||
rb_ary_modify(ary);
|
||||
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
|
||||
pos = NUM2LONG(arg1);
|
||||
len = NUM2LONG(arg2);
|
||||
|
|
@ -1966,7 +1965,7 @@ rb_ary_slice_bang(argc, argv, ary)
|
|||
pos = RARRAY(ary)->len + pos;
|
||||
}
|
||||
arg2 = rb_ary_subseq(ary, pos, len);
|
||||
rb_ary_update(ary, pos, len, Qnil); /* Qnil/rb_ary_new2(0) */
|
||||
rb_ary_splice(ary, pos, len, Qnil); /* Qnil/rb_ary_new2(0) */
|
||||
return arg2;
|
||||
}
|
||||
|
||||
|
|
@ -2338,7 +2337,7 @@ rb_ary_concat(x, y)
|
|||
{
|
||||
y = to_ary(y);
|
||||
if (RARRAY(y)->len > 0) {
|
||||
rb_ary_update(x, RARRAY(x)->len, 0, y);
|
||||
rb_ary_splice(x, RARRAY(x)->len, 0, y);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
|
@ -2754,8 +2753,6 @@ rb_ary_uniq_bang(ary)
|
|||
VALUE hash, v, vv;
|
||||
long i, j;
|
||||
|
||||
rb_ary_modify(ary);
|
||||
|
||||
hash = ary_make_hash(ary, 0);
|
||||
|
||||
if (RARRAY(ary)->len == RHASH(hash)->tbl->num_entries) {
|
||||
|
|
@ -2886,7 +2883,7 @@ flatten(ary, idx, ary2, memo)
|
|||
rb_raise(rb_eArgError, "tried to flatten recursive array");
|
||||
}
|
||||
rb_ary_push(memo, id);
|
||||
rb_ary_update(ary, idx, 1, ary2);
|
||||
rb_ary_splice(ary, idx, 1, ary2);
|
||||
while (i < lim) {
|
||||
VALUE tmp;
|
||||
|
||||
|
|
@ -2924,7 +2921,6 @@ rb_ary_flatten_bang(ary)
|
|||
int mod = 0;
|
||||
VALUE memo = Qnil;
|
||||
|
||||
rb_ary_modify(ary);
|
||||
while (i<RARRAY(ary)->len) {
|
||||
VALUE ary2 = RARRAY(ary)->ptr[i];
|
||||
VALUE tmp;
|
||||
|
|
|
|||
|
|
@ -715,6 +715,7 @@ flo_divmod(x, y)
|
|||
VALUE x, y;
|
||||
{
|
||||
double fy, div, mod;
|
||||
volatile VALUE a, b;
|
||||
|
||||
switch (TYPE(y)) {
|
||||
case T_FIXNUM:
|
||||
|
|
@ -730,9 +731,9 @@ flo_divmod(x, y)
|
|||
return rb_num_coerce_bin(x, y);
|
||||
}
|
||||
flodivmod(RFLOAT(x)->value, fy, &div, &mod);
|
||||
x = rb_float_new(div);
|
||||
y = rb_float_new(mod);
|
||||
return rb_assoc_new(x, y);
|
||||
a = rb_float_new(div);
|
||||
b = rb_float_new(mod);
|
||||
return rb_assoc_new(a, b);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
54
process.c
54
process.c
|
|
@ -124,6 +124,7 @@ static VALUE S_Tms;
|
|||
static VALUE
|
||||
get_pid()
|
||||
{
|
||||
rb_secure(2);
|
||||
return INT2FIX(getpid());
|
||||
}
|
||||
|
||||
|
|
@ -147,6 +148,7 @@ get_pid()
|
|||
static VALUE
|
||||
get_ppid()
|
||||
{
|
||||
rb_secure(2);
|
||||
#ifdef _WIN32
|
||||
return INT2FIX(0);
|
||||
#else
|
||||
|
|
@ -724,6 +726,7 @@ proc_wait(argc, argv)
|
|||
VALUE vpid, vflags;
|
||||
int pid, flags, status;
|
||||
|
||||
rb_secure(2);
|
||||
flags = 0;
|
||||
rb_scan_args(argc, argv, "02", &vpid, &vflags);
|
||||
if (argc == 0) {
|
||||
|
|
@ -798,6 +801,7 @@ proc_waitall()
|
|||
VALUE result;
|
||||
int pid, status;
|
||||
|
||||
rb_secure(2);
|
||||
result = rb_ary_new();
|
||||
#ifdef NO_WAITPID
|
||||
if (pid_tbl) {
|
||||
|
|
@ -899,6 +903,7 @@ static VALUE
|
|||
proc_detach(obj, pid)
|
||||
VALUE pid;
|
||||
{
|
||||
rb_secure(2);
|
||||
return rb_detach_process(NUM2INT(pid));
|
||||
}
|
||||
|
||||
|
|
@ -1590,6 +1595,7 @@ proc_getpgrp()
|
|||
{
|
||||
int pgrp;
|
||||
|
||||
rb_secure(2);
|
||||
#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)
|
||||
pgrp = getpgrp();
|
||||
if (pgrp < 0) rb_sys_fail(0);
|
||||
|
|
@ -1617,12 +1623,13 @@ proc_getpgrp()
|
|||
static VALUE
|
||||
proc_setpgrp()
|
||||
{
|
||||
rb_secure(2);
|
||||
/* check for posix setpgid() first; this matches the posix */
|
||||
/* getpgrp() above. It appears that configure will set SETPGRP_VOID */
|
||||
/* even though setpgrp(0,0) would be prefered. The posix call avoids */
|
||||
/* this confusion. */
|
||||
#ifdef HAVE_SETPGID
|
||||
if (setpgid(0,0) < 0) rb_sys_fail(0);
|
||||
if (setpgid(0,0) < 0) rb_sys_fail(0);
|
||||
#elif defined(HAVE_SETPGRP) && defined(SETPGRP_VOID)
|
||||
if (setpgrp() < 0) rb_sys_fail(0);
|
||||
#else
|
||||
|
|
@ -1647,8 +1654,10 @@ proc_getpgid(obj, pid)
|
|||
VALUE obj, pid;
|
||||
{
|
||||
#if defined(HAVE_GETPGID) && !defined(__CHECKER__)
|
||||
int i = getpgid(NUM2INT(pid));
|
||||
int i;
|
||||
|
||||
rb_secure(2);
|
||||
i = getpgid(NUM2INT(pid));
|
||||
if (i < 0) rb_sys_fail(0);
|
||||
return INT2NUM(i);
|
||||
#else
|
||||
|
|
@ -1756,6 +1765,7 @@ proc_getpriority(obj, which, who)
|
|||
#ifdef HAVE_GETPRIORITY
|
||||
int prio, iwhich, iwho;
|
||||
|
||||
rb_secure(2);
|
||||
iwhich = NUM2INT(which);
|
||||
iwho = NUM2INT(who);
|
||||
|
||||
|
|
@ -2314,6 +2324,7 @@ p_sys_issetugid(obj)
|
|||
VALUE obj;
|
||||
{
|
||||
#if defined HAVE_ISSETUGID
|
||||
rb_secure(2);
|
||||
if (issetugid()) {
|
||||
return Qtrue;
|
||||
} else {
|
||||
|
|
@ -3454,26 +3465,18 @@ Init_process()
|
|||
rb_define_module_function(rb_mProcGID, "rid", proc_getgid, 0);
|
||||
rb_define_module_function(rb_mProcUID, "eid", proc_geteuid, 0);
|
||||
rb_define_module_function(rb_mProcGID, "eid", proc_getegid, 0);
|
||||
rb_define_module_function(rb_mProcUID, "change_privilege",
|
||||
p_uid_change_privilege, 1);
|
||||
rb_define_module_function(rb_mProcGID, "change_privilege",
|
||||
p_gid_change_privilege, 1);
|
||||
rb_define_module_function(rb_mProcUID, "grant_privilege",
|
||||
p_uid_grant_privilege, 1);
|
||||
rb_define_module_function(rb_mProcGID, "grant_privilege",
|
||||
p_gid_grant_privilege, 1);
|
||||
rb_define_module_function(rb_mProcUID, "change_privilege", p_uid_change_privilege, 1);
|
||||
rb_define_module_function(rb_mProcGID, "change_privilege", p_gid_change_privilege, 1);
|
||||
rb_define_module_function(rb_mProcUID, "grant_privilege", p_uid_grant_privilege, 1);
|
||||
rb_define_module_function(rb_mProcGID, "grant_privilege", p_gid_grant_privilege, 1);
|
||||
rb_define_alias(rb_mProcUID, "eid=", "grant_privilege");
|
||||
rb_define_alias(rb_mProcGID, "eid=", "grant_privilege");
|
||||
rb_define_module_function(rb_mProcUID, "re_exchange", p_uid_exchange, 0);
|
||||
rb_define_module_function(rb_mProcGID, "re_exchange", p_gid_exchange, 0);
|
||||
rb_define_module_function(rb_mProcUID, "re_exchangeable?",
|
||||
p_uid_exchangeable, 0);
|
||||
rb_define_module_function(rb_mProcGID, "re_exchangeable?",
|
||||
p_gid_exchangeable, 0);
|
||||
rb_define_module_function(rb_mProcUID, "sid_available?",
|
||||
p_uid_have_saved_id, 0);
|
||||
rb_define_module_function(rb_mProcGID, "sid_available?",
|
||||
p_gid_have_saved_id, 0);
|
||||
rb_define_module_function(rb_mProcUID, "re_exchangeable?", p_uid_exchangeable, 0);
|
||||
rb_define_module_function(rb_mProcGID, "re_exchangeable?", p_gid_exchangeable, 0);
|
||||
rb_define_module_function(rb_mProcUID, "sid_available?", p_uid_have_saved_id, 0);
|
||||
rb_define_module_function(rb_mProcGID, "sid_available?", p_gid_have_saved_id, 0);
|
||||
rb_define_module_function(rb_mProcUID, "switch", p_uid_switch, 0);
|
||||
rb_define_module_function(rb_mProcGID, "switch", p_gid_switch, 0);
|
||||
|
||||
|
|
@ -3493,15 +3496,10 @@ Init_process()
|
|||
rb_define_module_function(rb_mProcID_Syscall, "seteuid", p_sys_seteuid, 1);
|
||||
rb_define_module_function(rb_mProcID_Syscall, "setegid", p_sys_setegid, 1);
|
||||
|
||||
rb_define_module_function(rb_mProcID_Syscall, "setreuid",
|
||||
p_sys_setreuid, 2);
|
||||
rb_define_module_function(rb_mProcID_Syscall, "setregid",
|
||||
p_sys_setregid, 2);
|
||||
rb_define_module_function(rb_mProcID_Syscall, "setreuid", p_sys_setreuid, 2);
|
||||
rb_define_module_function(rb_mProcID_Syscall, "setregid", p_sys_setregid, 2);
|
||||
|
||||
rb_define_module_function(rb_mProcID_Syscall, "setresuid",
|
||||
p_sys_setresuid, 3);
|
||||
rb_define_module_function(rb_mProcID_Syscall, "setresgid",
|
||||
p_sys_setresgid, 3);
|
||||
rb_define_module_function(rb_mProcID_Syscall, "issetugid",
|
||||
p_sys_issetugid, 0);
|
||||
rb_define_module_function(rb_mProcID_Syscall, "setresuid", p_sys_setresuid, 3);
|
||||
rb_define_module_function(rb_mProcID_Syscall, "setresgid", p_sys_setresgid, 3);
|
||||
rb_define_module_function(rb_mProcID_Syscall, "issetugid", p_sys_issetugid, 0);
|
||||
}
|
||||
|
|
|
|||
17
string.c
17
string.c
|
|
@ -795,8 +795,8 @@ VALUE
|
|||
rb_str_append(str, str2)
|
||||
VALUE str, str2;
|
||||
{
|
||||
rb_str_modify(str);
|
||||
StringValue(str2);
|
||||
rb_str_modify(str);
|
||||
if (RSTRING(str2)->len > 0) {
|
||||
if (FL_TEST(str, STR_ASSOC)) {
|
||||
long len = RSTRING(str)->len+RSTRING(str2)->len;
|
||||
|
|
@ -1640,6 +1640,7 @@ rb_str_splice(str, beg, len, val)
|
|||
}
|
||||
|
||||
StringValue(val);
|
||||
rb_str_modify(str);
|
||||
if (len < RSTRING(val)->len) {
|
||||
/* expand string */
|
||||
RESIZE_CAPA(str, RSTRING(str)->len + RSTRING(val)->len - len + 1);
|
||||
|
|
@ -1649,6 +1650,7 @@ rb_str_splice(str, beg, len, val)
|
|||
memmove(RSTRING(str)->ptr + beg + RSTRING(val)->len,
|
||||
RSTRING(str)->ptr + beg + len,
|
||||
RSTRING(str)->len - (beg + len));
|
||||
rb_str_modify(str);
|
||||
}
|
||||
if (RSTRING(str)->len < beg && len < 0) {
|
||||
MEMZERO(RSTRING(str)->ptr + RSTRING(str)->len, char, -len);
|
||||
|
|
@ -1669,7 +1671,6 @@ rb_str_update(str, beg, len, val)
|
|||
long beg, len;
|
||||
VALUE val;
|
||||
{
|
||||
rb_str_modify(str);
|
||||
rb_str_splice(str, beg, len, val);
|
||||
}
|
||||
|
||||
|
|
@ -1703,7 +1704,6 @@ rb_str_subpat_set(str, re, nth, val)
|
|||
}
|
||||
end = RMATCH(match)->END(nth);
|
||||
len = end - start;
|
||||
rb_str_modify(str);
|
||||
rb_str_splice(str, start, len, val);
|
||||
}
|
||||
|
||||
|
|
@ -1796,7 +1796,6 @@ rb_str_aset_m(argc, argv, str)
|
|||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
rb_str_modify(str);
|
||||
if (argc == 3) {
|
||||
if (TYPE(argv[0]) == T_REGEXP) {
|
||||
rb_str_subpat_set(str, argv[0], NUM2INT(argv[1]), argv[2]);
|
||||
|
|
@ -1835,7 +1834,6 @@ rb_str_insert(str, idx, str2)
|
|||
{
|
||||
long pos = NUM2LONG(idx);
|
||||
|
||||
rb_str_modify(str);
|
||||
if (pos == -1) {
|
||||
pos = RSTRING(str)->len;
|
||||
}
|
||||
|
|
@ -2088,7 +2086,7 @@ str_gsub(argc, argv, str, bang)
|
|||
rb_match_busy(match);
|
||||
val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
|
||||
str_mod_check(str, sp, slen);
|
||||
str_frozen_check(str);
|
||||
if (bang) str_frozen_check(str);
|
||||
rb_backref_set(match);
|
||||
}
|
||||
else {
|
||||
|
|
@ -2727,7 +2725,6 @@ rb_str_upcase_bang(str)
|
|||
char *s, *send;
|
||||
int modify = 0;
|
||||
|
||||
rb_str_modify(str);
|
||||
s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
|
||||
while (s < send) {
|
||||
if (ismbchar(*s)) {
|
||||
|
|
@ -2752,6 +2749,7 @@ rb_str_upcase_bang(str)
|
|||
* Returns a copy of <i>str</i> with all lowercase letters replaced with their
|
||||
* uppercase counterparts. The operation is locale insensitive---only
|
||||
* characters ``a'' to ``z'' are affected.
|
||||
rb_str_modify(str);
|
||||
*
|
||||
* "hEllO".upcase #=> "HELLO"
|
||||
*/
|
||||
|
|
@ -2840,7 +2838,6 @@ rb_str_capitalize_bang(str)
|
|||
char *s, *send;
|
||||
int modify = 0;
|
||||
|
||||
rb_str_modify(str);
|
||||
if (RSTRING(str)->len == 0 || !RSTRING(str)->ptr) return Qnil;
|
||||
s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
|
||||
if (ISLOWER(*s)) {
|
||||
|
|
@ -2898,7 +2895,6 @@ rb_str_swapcase_bang(str)
|
|||
char *s, *send;
|
||||
int modify = 0;
|
||||
|
||||
rb_str_modify(str);
|
||||
s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
|
||||
while (s < send) {
|
||||
if (ismbchar(*s)) {
|
||||
|
|
@ -3864,8 +3860,8 @@ rb_str_chomp_bang(argc, argv, str)
|
|||
rs = rb_rs;
|
||||
if (rs == rb_default_rs) {
|
||||
smart_chomp:
|
||||
rb_str_modify(str);
|
||||
if (RSTRING(str)->ptr[len-1] == '\n') {
|
||||
rb_str_modify(str);
|
||||
RSTRING(str)->len--;
|
||||
if (RSTRING(str)->len > 0 &&
|
||||
RSTRING(str)->ptr[RSTRING(str)->len-1] == '\r') {
|
||||
|
|
@ -3873,7 +3869,6 @@ rb_str_chomp_bang(argc, argv, str)
|
|||
}
|
||||
}
|
||||
else if (RSTRING(str)->ptr[len-1] == '\r') {
|
||||
rb_str_modify(str);
|
||||
RSTRING(str)->len--;
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue