Skip to content

Commit

Permalink
2000-06-22
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Jun 22, 2000
1 parent 4b4cad8 commit 44cf56d
Show file tree
Hide file tree
Showing 19 changed files with 194 additions and 74 deletions.
39 changes: 38 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
Thu Jun 22 17:27:46 2000 Yukihiro Matsumoto <[email protected]>

* string.c (rb_str_substr): str[n,m] now returns nil when n equals
to str.size.

Thu Jun 22 13:49:02 2000 Uechi Yasumasa <[email protected]>

* lib/net/ftp.rb: support resume.
* lib/net/ftp.rb: support resuming.

Thu Jun 22 13:37:19 2000 WATANABE Hirofumi <[email protected]>

* eval.c (rb_thread_sleep_forever): merge pause() macro.

Wed Jun 21 08:49:04 2000 Yukihiro Matsumoto <[email protected]>

* eval.c (rb_eval): should not raise exception just by defining
singleton class.

Wed Jun 21 01:18:03 2000 Yukihiro Matsumoto <[email protected]>

* ruby.h: two macros RUBY_DATA_FUNC and RUBY_METHOD_FUNC are added
to make writing C++ extensions easier.

* array.c (rb_ary_dup): internal classes should not be shared by dup.

* hash.c (rb_hash_dup): ditto.

* object.c (rb_obj_dup): ditto.

* string.c (rb_str_dup): ditto.

* error.c (Init_Exception): renamed NotImplementError to
NotImplementedError.

Tue Jun 20 16:22:38 2000 Yukihiro Matsumoto <[email protected]>

* time.c (make_time_t): bug in DST boundary.

Tue Jun 20 10:54:19 2000 WATANABE Hirofumi <[email protected]>

* configure.in: add eval sitedir.
Expand All @@ -16,6 +46,13 @@ Tue Jun 20 06:14:43 2000 Wakou Aoyama <[email protected]>

* lib/net/telnet.rb: ditto.

Tue Jun 20 00:37:45 2000 Yukihiro Matsumoto <[email protected]>

* re.c (rb_reg_kcode_m): Regexp#kcode returns nil for code unfixed
regexp object.

* bignum.c (bigdivmod): bignum zero check was wrong.

Mon Jun 19 10:48:28 2000 Yukihiro Matsumoto <[email protected]>

* variable.c (rb_cvar_set): forgot to add security check for class
Expand Down
6 changes: 5 additions & 1 deletion array.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,13 @@ static VALUE
rb_ary_dup(ary)
VALUE ary;
{
VALUE klass = CLASS_OF(ary);
VALUE dup;

dup = rb_ary_s_create(RARRAY(ary)->len, RARRAY(ary)->ptr, CLASS_OF(ary));
while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
klass = (VALUE)RCLASS(klass)->super;
}
dup = rb_ary_s_create(RARRAY(ary)->len, RARRAY(ary)->ptr, klass);
if (OBJ_TAINTED(ary)) OBJ_TAINT(dup);
return dup;
}
Expand Down
25 changes: 16 additions & 9 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ rb_big_to_i(x)
return bignorm(x);
}

VALUE
rb_dbl2big(d)
static VALUE
dbl2big(d)
double d;
{
unsigned long i = 0;
Expand Down Expand Up @@ -481,7 +481,14 @@ rb_dbl2big(d)
digits[i] = (USHORT)c;
}

return bignorm(z);
return z;
}

VALUE
rb_dbl2big(d)
double d;
{
return bignorm(dbl2big(d));
}

double
Expand Down Expand Up @@ -521,7 +528,7 @@ rb_big_cmp(x, y)
break;

case T_FLOAT:
y = rb_dbl2big(RFLOAT(y)->value);
y = dbl2big(RFLOAT(y)->value);
break;

default:
Expand Down Expand Up @@ -553,7 +560,7 @@ rb_big_eq(x, y)
case T_BIGNUM:
break;
case T_FLOAT:
y = rb_dbl2big(RFLOAT(y)->value);
y = dbl2big(RFLOAT(y)->value);
break;
default:
return Qfalse;
Expand Down Expand Up @@ -894,7 +901,7 @@ bigdivmod(x, y, div, mod, modulo)
if (modulo && RBIGNUM(x)->sign != RBIGNUM(y)->sign) {
long len = ny;
zds = BDIGITS(*mod);
while (len-- && !zds[len]);
while (len && !zds[len]) len--;
if (len > 0) {
*mod = bigadd(*mod, y, 1);
return;
Expand Down Expand Up @@ -946,7 +953,7 @@ rb_big_modulo(x, y, modulo)
break;

case T_FLOAT:
y = rb_dbl2big(RFLOAT(y)->value);
y = dbl2big(RFLOAT(y)->value);
break;

default:
Expand Down Expand Up @@ -983,7 +990,7 @@ rb_big_divmod(x, y)
break;

case T_FLOAT:
y = rb_dbl2big(RFLOAT(y)->value);
y = dbl2big(RFLOAT(y)->value);
break;

case T_BIGNUM:
Expand All @@ -994,7 +1001,7 @@ rb_big_divmod(x, y)
}
bigdivmod(x, y, &div, &mod, 1);

return rb_assoc_new(div, mod);;
return rb_assoc_new(div, mod);
}

VALUE
Expand Down
1 change: 1 addition & 0 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ rb_singleton_class(obj)
else {
FL_UNSET(klass, FL_TAINT);
}
if (OBJ_FROZEN(obj)) OBJ_FREEZE(klass);

return klass;
}
Expand Down
3 changes: 2 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,8 @@ test "$program_suffix" != NONE &&
RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
RUBY_LIB_PREFIX="${prefix}/lib/ruby"
RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}"
sitedir='${prefix}/lib/ruby/site_ruby'
#sitedir='${prefix}/lib/ruby/site_ruby'
sitedir="${prefix}/lib/ruby/site_ruby"
AC_ARG_WITH(sitedir,
[--with-sitedir=DIR site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
[sitedir=$withval])
Expand Down
4 changes: 3 additions & 1 deletion error.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,9 @@ Init_Exception()
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);
rb_eNameError = rb_define_class("NameError", rb_eScriptError);
rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
rb_eNotImpError = rb_define_class("NotImplementError", rb_eScriptError);
rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);
/* backward compatibility -- will be removed in the future */
rb_define_global_const("NotImplementError", rb_eNotImpError);

rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
rb_eSecurityError = rb_define_class("SecurityError", rb_eStandardError);
Expand Down
27 changes: 25 additions & 2 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,28 @@ rb_mod_s_constants()
return ary;
}

static void
frozen_class_p(klass)
VALUE klass;
{
char *desc = "something(?!)";

if (OBJ_FROZEN(klass)) {
if (FL_TEST(klass, FL_SINGLETON))
desc = "object";
else {
switch (TYPE(klass)) {
case T_MODULE:
case T_ICLASS:
desc = "module"; break;
case T_CLASS:
desc = "class"; break;
}
}
rb_error_frozen(desc);
}
}

void
rb_undef(klass, id)
VALUE klass;
Expand All @@ -1434,7 +1456,7 @@ rb_undef(klass, id)
if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
rb_raise(rb_eSecurityError, "Insecure: can't undef");
}
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
frozen_class_p(klass);
body = search_method(ruby_class, id, &origin);
if (!body || !body->nd_body) {
char *s0 = " class";
Expand Down Expand Up @@ -1476,6 +1498,7 @@ rb_alias(klass, name, def)
VALUE origin;
NODE *orig, *body;

frozen_class_p(klass);
if (name == def) return;
if (klass == rb_cObject) {
rb_secure(4);
Expand Down Expand Up @@ -2757,6 +2780,7 @@ rb_eval(self, n)
if (ruby_class == rb_cObject && node->nd_mid == init) {
rb_warn("re-defining Object#initialize may cause infinite loop");
}
frozen_class_p(ruby_class);
body = search_method(ruby_class, node->nd_mid, &origin);
if (body){
if (RTEST(ruby_verbose) && ruby_class == origin) {
Expand Down Expand Up @@ -2975,7 +2999,6 @@ rb_eval(self, n)
}
if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass))
rb_raise(rb_eSecurityError, "Insecure: can't extend object");
if (OBJ_FROZEN(klass)) rb_error_frozen("object");
if (FL_TEST(CLASS_OF(klass), FL_SINGLETON)) {
rb_clear_cache();
}
Expand Down
30 changes: 16 additions & 14 deletions ext/extmk.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -218,28 +218,30 @@ SRC
return true
end

def have_func(func)
def have_func(func, header=nil)
libs = $libs

if /mswin32|mingw/ =~ RUBY_PLATFORM
r = try_link(<<"SRC", libs)
src =
if /mswin32|mingw/ =~ RUBY_PLATFORM
r = <<"SRC"
#include <windows.h>
#include <winsock.h>
SRC
else
""
end
unless header.nil?
src << <<"SRC"
#include <#{header}>
SRC
end
r = try_link(src + <<"SRC", libs)
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
unless r
r = try_link(<<"SRC", libs)
#include <windows.h>
#include <winsock.h>
unless r
r = try_link(src + <<"SRC", libs)
int main() { return 0; }
int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
SRC
end
else
r = try_link(<<"SRC", libs)
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
end
unless r
Expand Down
11 changes: 11 additions & 0 deletions ext/md5/md5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ Methods:

returns have value of the added strings as a 16 bytes string.

hexdigest

returns have value of the added strings as an 32 bytes ASCII
string. This method is equal to:

def hexdigest
ret = ''
digest.each_byte {|i| ret << sprintf('%02x', i) }
ret
end

update(str)

Update the MD5 object with the string. Repeated calls are
Expand Down
12 changes: 12 additions & 0 deletions ext/md5/md5.txt.jp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ Methods:
���ޤǤ��ɲä���ʸ������Ф���ϥå����ͤ�16�Х���Ĺ��ʸ�����
�֤���

hexdigest

���ޤǤ��ɲä���ʸ������Ф���ϥå����ͤ�ASCII�����ɤ�Ȥä�
16�ʿ�����򼨤�'fe5c2235f48d2bcc911afabea23cd5aa'�Τ褦��32ʸ��
��ʸ����˥��󥳡��ɤ����֤���Ruby�ǽ񤯤Ȱʲ���Ʊ����

def hexdigest
ret = ''
digest.each_byte {|i| ret << sprintf('%02x', i) }
ret
end

update(str)

MD5���֥������Ȥ�ʸ������ɲä��롣ʣ����update��Ƥ֤��Ȥ�ʸ
Expand Down
7 changes: 6 additions & 1 deletion hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,13 @@ static VALUE
rb_hash_dup(hash)
VALUE hash;
{
VALUE klass = CLASS_OF(hash);

NEWOBJ(dup, struct RHash);
OBJSETUP(dup, CLASS_OF(hash), T_HASH);
while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
klass = (VALUE)RCLASS(klass)->super;
}
OBJSETUP(dup, klass, T_HASH);

dup->iter_lev = 0;
dup->ifnone = RHASH(hash)->ifnone;
Expand Down
30 changes: 16 additions & 14 deletions lib/mkmf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,31 +210,33 @@ def find_library(lib, func, *paths)
return true
end

def have_func(func)
def have_func(func, header=nil)
printf "checking for %s()... ", func
STDOUT.flush

libs = $libs

if /mswin32|mingw/ =~ RUBY_PLATFORM
r = try_link(<<"SRC", libs)
src =
if /mswin32|mingw/ =~ RUBY_PLATFORM
r = <<"SRC"
#include <windows.h>
#include <winsock.h>
SRC
else
""
end
unless header.nil?
src << <<"SRC"
#include <#{header}>
SRC
end
r = try_link(src + <<"SRC", libs)
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
unless r
r = try_link(<<"SRC", libs)
#include <windows.h>
#include <winsock.h>
unless r
r = try_link(src + <<"SRC", libs)
int main() { return 0; }
int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
SRC
end
else
r = try_link(<<"SRC", libs)
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
end
unless r
Expand Down
4 changes: 3 additions & 1 deletion marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,9 @@ w_object(obj, arg, limit)
char *path;

if (FL_TEST(klass, FL_SINGLETON)) {
rb_raise(rb_eTypeError, "singleton can't be dumped");
if (RCLASS(klass)->m_tbl->num_entries > 0) {
rb_raise(rb_eTypeError, "singleton can't be dumped");
}
}
path = rb_class2name(klass);
w_unique(path, arg);
Expand Down
Loading

0 comments on commit 44cf56d

Please sign in to comment.