1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (str_gsub): string modify check no longer based on

tmplock.  [ruby-dev:24706]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-11-04 12:27:57 +00:00
parent e4a65e4427
commit 67ae0fb9ac
3 changed files with 17 additions and 11 deletions

View file

@ -1,3 +1,8 @@
Thu Nov 4 21:25:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): string modify check no longer based on
tmplock. [ruby-dev:24706]
Thu Nov 4 21:13:48 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c(typelib_file_from_typelib): search "win16"

View file

@ -1303,8 +1303,7 @@ static VALUE
unixsock_connect_internal(arg)
struct unixsock_arg *arg;
{
return (VALUE)ruby_connect(arg->fd, arg->sockaddr, sizeof(*arg->sockaddr),
0);
return (VALUE)ruby_connect(arg->fd, arg->sockaddr, sizeof(*arg->sockaddr), 0);
}
static VALUE
@ -1984,18 +1983,21 @@ sock_connect(sock, addr)
VALUE sock, addr;
{
OpenFile *fptr;
int fd;
int fd, n;
StringValue(addr);
rb_str_modify(addr);
GetOpenFile(sock, fptr);
fd = fileno(fptr->f);
if (ruby_connect(fd, (struct sockaddr*)RSTRING(addr)->ptr, RSTRING(addr)->len, 0) < 0) {
rb_str_locktmp(addr);
n = ruby_connect(fd, (struct sockaddr*)RSTRING(addr)->ptr, RSTRING(addr)->len, 0);
rb_str_unlocktmp(addr);
if (n < 0) {
rb_sys_fail("connect(2)");
}
return INT2FIX(0);
return INT2FIX(n);
}
static VALUE

View file

@ -464,7 +464,6 @@ str_independent(str)
VALUE str;
{
if (FL_TEST(str, STR_TMPLOCK)) {
FL_UNSET(str, STR_TMPLOCK);
rb_raise(rb_eRuntimeError, "can't modify string; temporarily locked");
}
if (OBJ_FROZEN(str)) rb_error_frozen("string");
@ -2045,9 +2044,9 @@ str_gsub(argc, argv, str, bang)
VALUE pat, val, repl, match, dest;
struct re_registers *regs;
long beg, n;
long offset, blen, len;
long offset, blen, slen, len;
int iter = 0;
char *buf, *bp, *cp;
char *buf, *bp, *sp, *cp;
int tainted = 0;
if (argc == 1 && rb_block_given_p()) {
@ -2074,9 +2073,9 @@ str_gsub(argc, argv, str, bang)
dest = rb_str_new5(str, 0, blen);
buf = RSTRING(dest)->ptr;
bp = buf;
cp = RSTRING(str)->ptr;
sp = cp = RSTRING(str)->ptr;
slen = RSTRING(str)->len;
rb_str_locktmp(str);
rb_str_locktmp(dest);
while (beg >= 0) {
n++;
@ -2085,7 +2084,7 @@ str_gsub(argc, argv, str, bang)
if (iter) {
rb_match_busy(match);
val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
str_mod_check(dest, buf, blen);
str_mod_check(str, sp, slen);
rb_backref_set(match);
}
else {