зеркало из https://github.com/github/ruby.git
* array.c (rb_ary_and): should not push frozen key string.
* array.c (rb_ary_or): ditto. * eval.c (rb_thread_schedule): should save context before raising deadlock, saved context for current thread might be obsolete. * time.c (make_time_t): non DST timezone shift supported (hopefully). * time.c (make_time_t): strict range detection for negative time_t. * signal.c: SIGINFO added. * eval.c (rb_ensure): should not SEGV when prot_tag is NULL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
59d82a928a
Коммит
f84f4aa6b3
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
Tue May 15 17:46:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_and): should not push frozen key string.
|
||||
|
||||
* array.c (rb_ary_or): ditto.
|
||||
|
||||
Mon May 14 13:50:22 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_thread_schedule): should save context before raising
|
||||
deadlock, saved context for current thread might be obsolete.
|
||||
|
||||
* time.c (make_time_t): non DST timezone shift supported (hopefully).
|
||||
|
||||
* time.c (make_time_t): strict range detection for negative time_t.
|
||||
|
||||
Mon May 14 11:54:20 2001 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* signal.c: SIGINFO added.
|
||||
|
||||
Mon May 14 08:57:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_ensure): should not SEGV when prot_tag is NULL.
|
||||
|
||||
Sun May 13 23:51:14 2001 Usaku Nakamura <usa@osb.att.ne.jp>
|
||||
|
||||
* win32/resource.rb: Modify copyright in resource script.
|
||||
|
|
64
array.c
64
array.c
|
@ -739,11 +739,26 @@ inspect_join(ary, arg)
|
|||
return rb_ary_join(arg[0], arg[1]);
|
||||
}
|
||||
|
||||
static long
|
||||
str_cpy(str, idx, str2)
|
||||
VALUE str;
|
||||
long idx;
|
||||
VALUE str2;
|
||||
{
|
||||
long len = idx + RSTRING(str2)->len;
|
||||
|
||||
if (RSTRING(str)->len < len) {
|
||||
rb_str_resize(str, len);
|
||||
}
|
||||
memcpy(RSTRING(str)->ptr+idx, RSTRING(str2)->ptr, RSTRING(str2)->len);
|
||||
return len;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_ary_join(ary, sep)
|
||||
VALUE ary, sep;
|
||||
{
|
||||
long i;
|
||||
long len, i, j;
|
||||
int taint = 0;
|
||||
VALUE result, tmp;
|
||||
|
||||
|
@ -751,30 +766,21 @@ rb_ary_join(ary, sep)
|
|||
if (OBJ_TAINTED(ary)) taint = 1;
|
||||
if (OBJ_TAINTED(sep)) taint = 1;
|
||||
|
||||
tmp = RARRAY(ary)->ptr[0];
|
||||
if (OBJ_TAINTED(tmp)) taint = 1;
|
||||
switch (TYPE(tmp)) {
|
||||
case T_STRING:
|
||||
result = rb_str_dup(tmp);
|
||||
break;
|
||||
case T_ARRAY:
|
||||
if (rb_inspecting_p(tmp)) {
|
||||
result = rb_str_new2("[...]");
|
||||
len = 1;
|
||||
for (i=0; i<RARRAY(ary)->len; i++) {
|
||||
if (TYPE(RARRAY(ary)->ptr[i]) == T_STRING) {
|
||||
len += RSTRING(RARRAY(ary)->ptr[i])->len;
|
||||
}
|
||||
else {
|
||||
VALUE args[2];
|
||||
|
||||
args[0] = tmp;
|
||||
args[1] = sep;
|
||||
result = rb_protect_inspect(inspect_join, ary, (VALUE)args);
|
||||
len += 10;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = rb_str_dup(rb_obj_as_string(tmp));
|
||||
break;
|
||||
}
|
||||
if (!NIL_P(sep) && TYPE(sep) == T_STRING) {
|
||||
len += RSTRING(sep)->len * RARRAY(ary)->len - 1;
|
||||
}
|
||||
result = rb_str_new(0, len);
|
||||
|
||||
for (i=1; i<RARRAY(ary)->len; i++) {
|
||||
for (i=0, j=0; i<RARRAY(ary)->len; i++) {
|
||||
tmp = RARRAY(ary)->ptr[i];
|
||||
switch (TYPE(tmp)) {
|
||||
case T_STRING:
|
||||
|
@ -794,10 +800,11 @@ rb_ary_join(ary, sep)
|
|||
default:
|
||||
tmp = rb_obj_as_string(tmp);
|
||||
}
|
||||
if (!NIL_P(sep)) rb_str_append(result, sep);
|
||||
rb_str_append(result, tmp);
|
||||
if (i > 0 && !NIL_P(sep)) j = str_cpy(result, j, sep);
|
||||
j = str_cpy(result, j, tmp);
|
||||
if (OBJ_TAINTED(tmp)) taint = 1;
|
||||
}
|
||||
rb_str_resize(result, j);
|
||||
|
||||
if (taint) OBJ_TAINT(result);
|
||||
return result;
|
||||
|
@ -1291,8 +1298,6 @@ VALUE
|
|||
rb_ary_concat(x, y)
|
||||
VALUE x, y;
|
||||
{
|
||||
long ylen;
|
||||
|
||||
y = to_ary(y);
|
||||
if (RARRAY(y)->len > 0) {
|
||||
rb_ary_update(x, RARRAY(x)->len, 0, y);
|
||||
|
@ -1498,7 +1503,7 @@ rb_ary_and(ary1, ary2)
|
|||
for (i=0; i<RARRAY(ary1)->len; i++) {
|
||||
VALUE v = RARRAY(ary1)->ptr[i];
|
||||
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
|
||||
rb_ary_push(ary3, v);
|
||||
rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1520,13 +1525,13 @@ rb_ary_or(ary1, ary2)
|
|||
for (i=0; i<RARRAY(ary1)->len; i++) {
|
||||
v = RARRAY(ary1)->ptr[i];
|
||||
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
|
||||
rb_ary_push(ary3, v);
|
||||
rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
|
||||
}
|
||||
}
|
||||
for (i=0; i<RARRAY(ary2)->len; i++) {
|
||||
v = RARRAY(ary2)->ptr[i];
|
||||
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
|
||||
rb_ary_push(ary3, v);
|
||||
rb_ary_push(ary3, RARRAY(ary2)->ptr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1548,10 +1553,11 @@ rb_ary_uniq_bang(ary)
|
|||
p = q = RARRAY(ary)->ptr;
|
||||
end = p + RARRAY(ary)->len;
|
||||
while (p < end) {
|
||||
VALUE v = *p++;
|
||||
VALUE v = *p;
|
||||
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
|
||||
*q++ = v;
|
||||
*q++ = *p;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
RARRAY(ary)->len = (q - RARRAY(ary)->ptr);
|
||||
|
||||
|
|
3
dir.c
3
dir.c
|
@ -598,8 +598,7 @@ remove_backslashes(p)
|
|||
|
||||
while (p < pend) {
|
||||
if (*p == '\\') {
|
||||
*p++;
|
||||
if (p == pend) break;
|
||||
if (++p == pend) break;
|
||||
}
|
||||
*t++ = *p++;
|
||||
}
|
||||
|
|
1
dln.c
1
dln.c
|
@ -1501,6 +1501,7 @@ dln_load(file)
|
|||
failed:
|
||||
rb_loaderror("%s - %s", dln_strerror(), file);
|
||||
#endif
|
||||
return 0; /* dummy return */
|
||||
}
|
||||
|
||||
static char *dln_find_1();
|
||||
|
|
17
eval.c
17
eval.c
|
@ -4004,9 +4004,9 @@ rb_ensure(b_proc, data1, e_proc, data2)
|
|||
result = (*b_proc)(data1);
|
||||
}
|
||||
POP_TAG();
|
||||
retval = prot_tag->retval; /* save retval */
|
||||
retval = prot_tag ? prot_tag->retval : Qnil; /* save retval */
|
||||
(*e_proc)(data2);
|
||||
return_value(retval);
|
||||
if (prot_tag) return_value(retval);
|
||||
|
||||
if (state) JUMP_TAG(state);
|
||||
return result;
|
||||
|
@ -7551,6 +7551,7 @@ rb_thread_schedule()
|
|||
next->gid = 0;
|
||||
rb_thread_ready(next);
|
||||
next->status = THREAD_TO_KILL;
|
||||
rb_thread_save_context(curr_thread);
|
||||
rb_thread_deadlock();
|
||||
}
|
||||
next->wait_for = 0;
|
||||
|
@ -8338,8 +8339,20 @@ rb_thread_stop_p(thread)
|
|||
static void
|
||||
rb_thread_wait_other_threads()
|
||||
{
|
||||
rb_thread_t th;
|
||||
int found;
|
||||
|
||||
/* wait other threads to terminate */
|
||||
while (curr_thread != curr_thread->next) {
|
||||
found = 0;
|
||||
FOREACH_THREAD(th) {
|
||||
if (th != curr_thread && th->status != THREAD_STOPPED) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
END_FOREACH(th);
|
||||
if (!found) return;
|
||||
rb_thread_schedule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ Init_md5()
|
|||
rb_define_singleton_method(cMD5, "md5", md5i_new, -1);
|
||||
|
||||
rb_define_method(cMD5, "update", md5i_update, 1);
|
||||
rb_define_method(cMD5, "<<", md5i_update, 1);
|
||||
rb_define_method(cMD5, "digest", md5i_digest, 0);
|
||||
rb_define_method(cMD5, "hexdigest", md5i_hexdigest, 0);
|
||||
rb_define_method(cMD5, "clone", md5i_clone, 0);
|
||||
|
|
2
hash.c
2
hash.c
|
@ -893,7 +893,6 @@ rb_f_getenv(obj, name)
|
|||
VALUE obj, name;
|
||||
{
|
||||
char *nam, *env;
|
||||
int len;
|
||||
|
||||
StringValue(name);
|
||||
nam = RSTRING(name)->ptr;
|
||||
|
@ -1105,7 +1104,6 @@ rb_f_setenv(obj, nm, val)
|
|||
VALUE obj, nm, val;
|
||||
{
|
||||
char *name, *value;
|
||||
int nlen, vlen;
|
||||
|
||||
if (rb_safe_level() >= 4) {
|
||||
rb_raise(rb_eSecurityError, "cannot change environment variable");
|
||||
|
|
1
intern.h
1
intern.h
|
@ -327,6 +327,7 @@ VALUE rb_str_concat _((VALUE, VALUE));
|
|||
int rb_str_hash _((VALUE));
|
||||
int rb_str_cmp _((VALUE, VALUE));
|
||||
VALUE rb_str_upto _((VALUE, VALUE, int));
|
||||
void rb_str_update _((VALUE, long, long, VALUE));
|
||||
VALUE rb_str_inspect _((VALUE));
|
||||
VALUE rb_str_split _((VALUE, const char*));
|
||||
void rb_str_associate _((VALUE, VALUE));
|
||||
|
|
5
io.c
5
io.c
|
@ -344,8 +344,6 @@ rb_io_seek_m(argc, argv, io)
|
|||
{
|
||||
VALUE offset, ptrname;
|
||||
int whence;
|
||||
OpenFile *fptr;
|
||||
long pos;
|
||||
|
||||
rb_scan_args(argc, argv, "11", &offset, &ptrname);
|
||||
if (argc == 1) whence = SEEK_SET;
|
||||
|
@ -1959,7 +1957,6 @@ static VALUE
|
|||
rb_io_clone(io)
|
||||
VALUE io;
|
||||
{
|
||||
VALUE klass;
|
||||
OpenFile *fptr, *orig;
|
||||
int fd;
|
||||
char *mode;
|
||||
|
@ -3082,7 +3079,7 @@ rb_io_s_pipe()
|
|||
{
|
||||
#ifndef __human68k__
|
||||
int pipes[2];
|
||||
VALUE r, w, ary;
|
||||
VALUE r, w;
|
||||
|
||||
#ifdef NT
|
||||
if (_pipe(pipes, 1024, O_BINARY) == -1)
|
||||
|
|
|
@ -32,6 +32,7 @@ module Open3
|
|||
|
||||
exec(*cmd)
|
||||
}
|
||||
exit!
|
||||
}
|
||||
|
||||
pw[0].close
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# $Date$
|
||||
# by Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
#
|
||||
# Copyright (C) 2001 Yukihiro Matsumoto
|
||||
# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
|
||||
# Copyright (C) 2000 Information-technology Promotion Agency, Japan
|
||||
#
|
||||
|
@ -74,7 +75,10 @@ class Mutex
|
|||
retry
|
||||
end
|
||||
Thread.critical = false
|
||||
t.run if t
|
||||
begin
|
||||
t.run if t
|
||||
rescue ThreadError
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -160,17 +164,19 @@ class Queue
|
|||
ensure
|
||||
Thread.critical = false
|
||||
end
|
||||
t.run if t
|
||||
end
|
||||
def enq(obj)
|
||||
push(obj)
|
||||
begin
|
||||
t.run if t
|
||||
rescue ThreadError
|
||||
end
|
||||
end
|
||||
alias << push
|
||||
alias enq push
|
||||
|
||||
def pop(non_block=false)
|
||||
Thread.critical = true
|
||||
begin
|
||||
loop do
|
||||
if @que.length == 0
|
||||
if @que.empty?
|
||||
if non_block
|
||||
raise ThreadError, "queue empty"
|
||||
end
|
||||
|
@ -184,17 +190,15 @@ class Queue
|
|||
Thread.critical = false
|
||||
end
|
||||
end
|
||||
def shift(non_block=false)
|
||||
pop(non_block)
|
||||
end
|
||||
alias deq shift
|
||||
alias shift pop
|
||||
alias deq pop
|
||||
|
||||
def empty?
|
||||
@que.length == 0
|
||||
@que.empty?
|
||||
end
|
||||
|
||||
def clear
|
||||
@que.replace([])
|
||||
@que.clear
|
||||
end
|
||||
|
||||
def length
|
||||
|
@ -223,7 +227,7 @@ class SizedQueue<Queue
|
|||
|
||||
def max=(max)
|
||||
Thread.critical = true
|
||||
if max >= @max
|
||||
if max <= @max
|
||||
@max = max
|
||||
Thread.critical = false
|
||||
else
|
||||
|
@ -251,8 +255,10 @@ class SizedQueue<Queue
|
|||
end
|
||||
super
|
||||
end
|
||||
alias << push
|
||||
|
||||
def pop(*args)
|
||||
retval = super
|
||||
Thread.critical = true
|
||||
if @que.length < @max
|
||||
begin
|
||||
|
@ -263,9 +269,12 @@ class SizedQueue<Queue
|
|||
ensure
|
||||
Thread.critical = false
|
||||
end
|
||||
t.run if t
|
||||
begin
|
||||
t.run if t
|
||||
rescue ThreadError
|
||||
end
|
||||
end
|
||||
super
|
||||
retval
|
||||
end
|
||||
|
||||
def num_waiting
|
||||
|
|
1
object.c
1
object.c
|
@ -16,6 +16,7 @@
|
|||
#include "st.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
VALUE rb_mKernel;
|
||||
VALUE rb_cObject;
|
||||
|
|
1
parse.y
1
parse.y
|
@ -19,6 +19,7 @@
|
|||
#include "st.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define ID_SCOPE_SHIFT 3
|
||||
#define ID_SCOPE_MASK 0x07
|
||||
|
|
|
@ -716,7 +716,6 @@ rb_f_exec(argc, argv)
|
|||
VALUE *argv;
|
||||
{
|
||||
VALUE prog = 0;
|
||||
int i;
|
||||
|
||||
if (argc == 0) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
|
|
6
re.c
6
re.c
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "ruby.h"
|
||||
#include "re.h"
|
||||
#include <ctype.h>
|
||||
|
||||
static VALUE rb_eRegexpError;
|
||||
|
||||
|
@ -776,9 +777,6 @@ match_aref(argc, argv, match)
|
|||
VALUE match;
|
||||
{
|
||||
VALUE idx, rest;
|
||||
struct re_registers *regs;
|
||||
char *ptr;
|
||||
int i;
|
||||
|
||||
rb_scan_args(argc, argv, "11", &idx, &rest);
|
||||
|
||||
|
@ -1103,8 +1101,6 @@ static int
|
|||
rb_reg_get_kcode(re)
|
||||
VALUE re;
|
||||
{
|
||||
int kcode;
|
||||
|
||||
switch (RBASIC(re)->flags & KCODE_MASK) {
|
||||
case KCODE_NONE:
|
||||
return 16;
|
||||
|
|
3
signal.c
3
signal.c
|
@ -162,6 +162,9 @@ static struct signals {
|
|||
#endif
|
||||
#ifdef SIGSOUND
|
||||
"SOUND", SIGSOUND,
|
||||
#endif
|
||||
#ifdef SIGINFO
|
||||
"INFO", SIGINFO,
|
||||
#endif
|
||||
NULL, 0,
|
||||
};
|
||||
|
|
2
st.c
2
st.c
|
@ -112,7 +112,7 @@ static int
|
|||
new_size(size)
|
||||
int size;
|
||||
{
|
||||
int i, newsize;
|
||||
int i;
|
||||
|
||||
#if 1
|
||||
for (i=3; i<31; i++) {
|
||||
|
|
18
string.c
18
string.c
|
@ -428,14 +428,16 @@ rb_str_resize(str, len)
|
|||
VALUE str;
|
||||
long len;
|
||||
{
|
||||
rb_str_modify(str);
|
||||
if (len != RSTRING(str)->len) {
|
||||
rb_str_modify(str);
|
||||
|
||||
if (len >= 0) {
|
||||
if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {
|
||||
REALLOC_N(RSTRING(str)->ptr, char, len + 1);
|
||||
if (len >= 0) {
|
||||
if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {
|
||||
REALLOC_N(RSTRING(str)->ptr, char, len + 1);
|
||||
}
|
||||
RSTRING(str)->len = len;
|
||||
RSTRING(str)->ptr[len] = '\0'; /* sentinel */
|
||||
}
|
||||
RSTRING(str)->len = len;
|
||||
RSTRING(str)->ptr[len] = '\0'; /* sentinel */
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
@ -956,7 +958,7 @@ rb_str_aref_m(argc, argv, str)
|
|||
return rb_str_aref(str, argv[0]);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
rb_str_update(str, beg, len, val)
|
||||
VALUE str;
|
||||
long beg;
|
||||
|
@ -1515,9 +1517,7 @@ VALUE
|
|||
rb_str_inspect(str)
|
||||
VALUE str;
|
||||
{
|
||||
long len;
|
||||
char *p, *pend;
|
||||
char *q, *qend;
|
||||
VALUE result = rb_str_new2("\"");
|
||||
char s[5];
|
||||
|
||||
|
|
23
time.c
23
time.c
|
@ -328,8 +328,6 @@ make_time_t(tptr, utc_p)
|
|||
guess += (tptr->tm_sec - tm->tm_sec);
|
||||
#ifndef NEGATIVE_TIME_T
|
||||
if (guess < 0) goto out_of_range;
|
||||
#else
|
||||
if (oguess > 365 * 24 * 3600 && guess < 0) goto out_of_range;
|
||||
#endif
|
||||
|
||||
if (!utc_p) { /* localtime zone adjust */
|
||||
|
@ -362,17 +360,32 @@ make_time_t(tptr, utc_p)
|
|||
tm = localtime(&guess);
|
||||
if (!tm) goto error;
|
||||
if (lt.tm_isdst != tm->tm_isdst || tptr->tm_hour != tm->tm_hour) {
|
||||
oguess = guess - 3600;
|
||||
tm = localtime(&oguess);
|
||||
time_t tmp = guess - 3600;
|
||||
tm = localtime(&tmp);
|
||||
if (!tm) goto error;
|
||||
if (tptr->tm_hour == tm->tm_hour) {
|
||||
guess = oguess;
|
||||
guess = tmp;
|
||||
}
|
||||
else if (lt.tm_isdst == tm->tm_isdst) {
|
||||
tmp = guess + 3600;
|
||||
tm = localtime(&tmp);
|
||||
if (!tm) goto error;
|
||||
if (tptr->tm_hour == tm->tm_hour) {
|
||||
guess = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tptr->tm_min != tm->tm_min) {
|
||||
guess += (tptr->tm_min - tm->tm_min) * 60;
|
||||
}
|
||||
#ifndef NEGATIVE_TIME_T
|
||||
if (guess < 0) goto out_of_range;
|
||||
#endif
|
||||
}
|
||||
#ifdef NEGATIVE_TIME_T
|
||||
if (oguess > 365 * 24 * 3600 && guess < 0) goto out_of_range;
|
||||
if (guess > 365 * 24 * 3600 && oguess < 0) goto out_of_range;
|
||||
#endif
|
||||
|
||||
return guess;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define RUBY_VERSION "1.7.0"
|
||||
#define RUBY_RELEASE_DATE "2001-05-11"
|
||||
#define RUBY_RELEASE_DATE "2001-05-16"
|
||||
#define RUBY_VERSION_CODE 170
|
||||
#define RUBY_RELEASE_CODE 20010511
|
||||
#define RUBY_RELEASE_CODE 20010516
|
||||
|
|
Загрузка…
Ссылка в новой задаче