Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/v1_1r@175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Apr 20, 1998
1 parent 4d99c39 commit bea8088
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 50 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
@@ -1,9 +1,25 @@
Mon Apr 20 06:23:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>

* variable.c (mod_remove_const): new method.

Sat Apr 18 03:53:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>

* hash.c (hash_each_with_index): removed. use Enumerable's
each_with_index instead.

* class.c (rb_include_module): check for super modules, since
module's included modules may be changed.

Fri Apr 17 11:58:30 1998 NAGAI Hidetoshi <nagai@dumbo.ai.kyutech.ac.jp>

* ext/tcltklib/tcltklib.c (lib_mainloop): thread and interrupt check.

Fri Apr 17 11:06:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>

* eval.c (find_file): try to fopen() to check whether file exists.

* ruby.c (load_file): ditto.

* struct.c (struct_aset): struct member can be set by member name.

Fri Apr 17 00:47:19 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
Expand Down
13 changes: 8 additions & 5 deletions class.c
Expand Up @@ -217,31 +217,34 @@ rb_include_module(klass, module)
VALUE p;

if (NIL_P(module)) return;
if (klass == module) return;

switch (TYPE(module)) {
case T_MODULE:
case T_CLASS:
case T_ICLASS:
break;
default:
Check_Type(module, T_MODULE);
}

if (klass == module) return;
rb_clear_cache();

while (module) {
/* ignore if the module included already in superclasses */
for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) {
if (BUILTIN_TYPE(p) == T_ICLASS &&
RCLASS(p)->m_tbl == RCLASS(module)->m_tbl)
RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
if (RCLASS(module)->super) {
rb_include_module(p, RCLASS(module)->super);
}
return;
}
}

RCLASS(klass)->super =
include_class_new(module, RCLASS(klass)->super);
klass = RCLASS(klass)->super;
module = RCLASS(module)->super;
}
rb_clear_cache();
}

VALUE
Expand Down
14 changes: 9 additions & 5 deletions dln.c
Expand Up @@ -1260,15 +1260,15 @@ dln_load(file)
flags = BIND_DEFERRED;
lib = shl_load(file, flags, 0);
if (lib == NULL) {
rb_sys_fail(file);
extern int errno;
LoadError("%s - %s", strerror(errno), file);
}
shl_findsym(&lib, buf, TYPE_PROCEDURE, (void*)&init_fct);
if (init_fct == NULL) {
shl_findsym(&lib, buf, TYPE_UNDEFINED, (void*)&init_fct);
if (init_fct == NULL) {
extern int errno;
errno = ENOSYM;
rb_sys_fail(file);
LoadError("%s - %s", strerror(ENOSYM), file);
}
}
(*init_fct)();
Expand Down Expand Up @@ -1414,7 +1414,7 @@ dln_find_1(fname, path, exe_flag)
return fname;
#if defined(MSDOS) || defined(NT) || defined(__human68k__)
if (fname[0] == '\\') return fname;
if (fname[1] == ':') return fname;
if (strlen(fname) > 2 && fname[1] == ':') return fname;
if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
return fname;
#endif
Expand Down Expand Up @@ -1446,7 +1446,11 @@ dln_find_1(fname, path, exe_flag)
** take the path literally.
*/

if (*dp == '~' && (l == 1 || dp[1] == '/')) {
if (*dp == '~' && (l == 1 ||
#if defined(MSDOS) || defined(NT) || defined(__human68k__)
dp[1] == '\\' ||
#endif
dp[1] == '/')) {
char *home;

home = getenv("HOME");
Expand Down
30 changes: 22 additions & 8 deletions eval.c
Expand Up @@ -3982,6 +3982,18 @@ mod_module_eval(argc, argv, mod)

VALUE rb_load_path;

static int
is_absolute_path(path)
char *path;
{
if (path[0] == '/') return 1;
#if defined(MSDOS) || defined(NT) || defined(__human68k__)
if (path[0] == '\\') return 1;
if (strlen(path) > 2 && path[1] == ':') return 1;
#endif
return 0;
}

static char*
find_file(file)
char *file;
Expand All @@ -3990,11 +4002,13 @@ find_file(file)
VALUE vpath;
char *path;

if (file[0] == '/') return file;
#if defined(MSDOS) || defined(NT) || defined(__human68k__)
if (file[0] == '\\') return file;
if (file[1] == ':') return file;
#endif
if (is_absolute_path(file)) {
FILE *f = fopen(file, "r");

if (f == NULL) return 0;
fclose(f);
return file;
}

if (rb_load_path) {
int i;
Expand Down Expand Up @@ -4603,9 +4617,9 @@ Init_eval()
rb_define_method(cModule, "module_eval", mod_module_eval, -1);
rb_define_method(cModule, "class_eval", mod_module_eval, -1);

rb_define_method(cModule, "remove_method", mod_remove_method, 1);
rb_define_method(cModule, "undef_method", mod_undef_method, 1);
rb_define_method(cModule, "alias_method", mod_alias_method, 2);
rb_define_private_method(cModule, "remove_method", mod_remove_method, 1);
rb_define_private_method(cModule, "undef_method", mod_undef_method, 1);
rb_define_private_method(cModule, "alias_method", mod_alias_method, 2);

rb_define_singleton_method(cModule, "nesting", mod_nesting, 0);
rb_define_singleton_method(cModule, "constants", mod_s_constants, 0);
Expand Down
5 changes: 2 additions & 3 deletions ext/extmk.rb.in
Expand Up @@ -223,7 +223,6 @@ def create_makefile(target)
end
$defs.push(format("-DEXTLIB='%s'", libs.join(",")))
end
$libs = "" unless $libs

$srcdir = $topdir + "/ext/" + target
mfile = open("Makefile", "w")
Expand Down Expand Up @@ -352,9 +351,9 @@ def extmake(target)

return if $nodynamic and not $static

$local_libs = nil
$libs = nil
$objs = nil
$libs = "-lc"
$local_libs = nil # to be assigned in extconf.rb
$CFLAGS = nil
$LDFLAGS = nil

Expand Down
6 changes: 5 additions & 1 deletion file.c
Expand Up @@ -1188,7 +1188,11 @@ file_s_expand_path(obj, fname)

p = buf;
if (s[0] == '~') {
if (s[1] == '/' || s[1] == '\0') {
if (s[1] == '/' ||
#if defined(MSDOS) || defined(NT) || defined(__human68k__)
s[1] == '\\' ||
#endif
s[1] == '\0') {
char *dir = getenv("HOME");

if (!dir) {
Expand Down
16 changes: 2 additions & 14 deletions hash.c
Expand Up @@ -526,14 +526,11 @@ hash_each_key(hash)
}

static int
each_pair_i(key, value, rev)
each_pair_i(key, value)
VALUE key, value;
{
if (key == Qnil) return ST_CONTINUE;
if (rev)
rb_yield(assoc_new(value, key));
else
rb_yield(assoc_new(key, value));
rb_yield(assoc_new(key, value));
return ST_CONTINUE;
}

Expand All @@ -545,14 +542,6 @@ hash_each_pair(hash)
return hash;
}

static VALUE
hash_each_with_index(hash)
VALUE hash;
{
hash_foreach(hash, each_pair_i, 1);
return hash;
}

static int
to_a_i(key, value, ary)
VALUE key, value, ary;
Expand Down Expand Up @@ -1149,7 +1138,6 @@ Init_Hash()
rb_define_method(cHash,"each_value", hash_each_value, 0);
rb_define_method(cHash,"each_key", hash_each_key, 0);
rb_define_method(cHash,"each_pair", hash_each_pair, 0);
rb_define_method(cHash,"each_with_index", hash_each_with_index, 0);

rb_define_method(cHash,"keys", hash_keys, 0);
rb_define_method(cHash,"values", hash_values, 0);
Expand Down
1 change: 0 additions & 1 deletion lib/cgi-lib.rb
@@ -1,4 +1,3 @@
#!/usr/local/bin/ruby
#
# Get CGI String
#
Expand Down
1 change: 0 additions & 1 deletion lib/getopts.rb
@@ -1,4 +1,3 @@
#!/usr/local/bin/ruby
#
# getopts.rb -
# $Release Version: $
Expand Down
1 change: 0 additions & 1 deletion lib/matrix.rb
@@ -1,4 +1,3 @@
#!/usr/local/bin/ruby
#
# matrix.rb -
# $Release Version: 1.0$
Expand Down
1 change: 0 additions & 1 deletion lib/parsearg.rb
@@ -1,4 +1,3 @@
#!/usr/local/bin/ruby
#
# parsearg.rb - parse arguments
# $Release Version: $
Expand Down
3 changes: 1 addition & 2 deletions lib/pstore.rb
@@ -1,5 +1,4 @@
#!/usr/local/bin/ruby

#
# How to use:
#
# db = PStore.new("/tmp/foo")
Expand Down
7 changes: 3 additions & 4 deletions lib/tracer.rb
@@ -1,9 +1,8 @@
#!/usr/local/bin/ruby
#
# tracer.rb -
# $Release Version: 0.2$
# $Revision: 1.6 $
# $Date: 1998/02/02 08:12:02 $
# $Revision: 1.1.1.1.4.1 $
# $Date: 1998/02/03 10:02:57 $
# by Keiju ISHITSUKA(Nippon Rational Inc.)
#
# --
Expand All @@ -15,7 +14,7 @@
# tracer main class
#
class Tracer
RCS_ID='-$Id: tracer.rb,v 1.6 1998/02/02 08:12:02 keiju Exp keiju $-'
RCS_ID='-$Id: tracer.rb,v 1.1.1.1.4.1 1998/02/03 10:02:57 matz Exp $-'

MY_FILE_NAME = caller(0)[0].scan(/^(.*):[0-9]+$/)[0]

Expand Down
5 changes: 4 additions & 1 deletion object.c
Expand Up @@ -704,6 +704,7 @@ obj_private_methods(obj)

VALUE obj_instance_variables();
VALUE obj_remove_instance_variable();
VALUE mod_remove_const();

static VALUE
f_integer(obj, arg)
Expand Down Expand Up @@ -938,7 +939,8 @@ Init_Object()
rb_define_method(mKernel, "protected_methods", obj_protected_methods, 0);
rb_define_method(mKernel, "private_methods", obj_private_methods, 0);
rb_define_method(mKernel, "instance_variables", obj_instance_variables, 0);
rb_define_method(mKernel, "remove_instance_variable", obj_remove_instance_variable, 0);
rb_define_private_method(mKernel, "remove_instance_variable",
obj_remove_instance_variable, 0);

rb_define_method(mKernel, "instance_of?", obj_is_instance_of, 1);
rb_define_method(mKernel, "kind_of?", obj_is_kind_of, 1);
Expand Down Expand Up @@ -997,6 +999,7 @@ Init_Object()
rb_define_method(cModule, "const_get", mod_const_get, 1);
rb_define_method(cModule, "const_set", mod_const_set, 2);
rb_define_method(cModule, "const_defined?", mod_const_defined, 1);
rb_define_private_method(cModule, "remove_const", mod_remove_const, 1);
rb_define_private_method(cModule, "method_added", obj_dummy, 1);

rb_define_method(cClass, "new", class_new_instance, -1);
Expand Down
7 changes: 7 additions & 0 deletions ruby.c
Expand Up @@ -445,6 +445,13 @@ load_file(fname, script)
f = rb_stdin;
}
else {
FILE *fp = fopen(fname, "r");

if (fp == NULL) {
LoadError("No such file to load -- %s", fname);
}
fclose(fp);

f = file_open(fname, "r");
}

Expand Down
28 changes: 25 additions & 3 deletions variable.c
Expand Up @@ -786,10 +786,10 @@ VALUE
obj_remove_instance_variable(obj, name)
VALUE obj, name;
{
VALUE val;
VALUE val = Qnil;
ID id = rb_to_id(name);

if (rb_ivar_defined(obj, id)) {
if (!rb_is_instance_id(id)) {
NameError("`%s' is not an instance variable", rb_id2name(id));
}

Expand All @@ -806,7 +806,7 @@ obj_remove_instance_variable(obj, name)
rb_class2name(CLASS_OF(obj)));
break;
}
return obj;
return val;
}

VALUE
Expand Down Expand Up @@ -889,6 +889,28 @@ const_i(key, value, ary)
return ST_CONTINUE;
}

VALUE
mod_remove_const(mod, name)
VALUE mod, name;
{
ID id = rb_to_id(name);
VALUE val;

if (!rb_is_const_id(id)) {
NameError("`%s' is not constant", rb_id2name(id));
}

if (RCLASS(mod)->iv_tbl && st_delete(ROBJECT(mod)->iv_tbl, &id, &val)) {
return val;
}
if (rb_const_defined_at(mod, id)) {
NameError("cannot remove %s::%s",
rb_class2name(mod), rb_id2name(id));
}
NameError("constant %s::%s not defined",
rb_class2name(mod), rb_id2name(id));
}

static int
autoload_i(key, name, ary)
ID key;
Expand Down

0 comments on commit bea8088

Please sign in to comment.