summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-20 05:55:38 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-20 05:55:38 +0000
commit5a1e96b22aa6759bde56ff9667759b44e9f6fa28 (patch)
tree956063703940ef9f3d450768628584dc08f97c42
parent4c97b921f2f6d71d7a3f2c0b2c0c089b15686973 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog16
-rw-r--r--class.c13
-rw-r--r--dln.c14
-rw-r--r--eval.c30
-rw-r--r--ext/extmk.rb.in5
-rw-r--r--file.c6
-rw-r--r--hash.c16
-rw-r--r--lib/cgi-lib.rb1
-rw-r--r--lib/getopts.rb1
-rw-r--r--lib/matrix.rb1
-rw-r--r--lib/parsearg.rb1
-rw-r--r--lib/pstore.rb3
-rw-r--r--lib/tracer.rb7
-rw-r--r--object.c5
-rw-r--r--ruby.c7
-rw-r--r--variable.c28
16 files changed, 104 insertions, 50 deletions
diff --git a/ChangeLog b/ChangeLog
index 5c8b1f8ad3c..05dfaab21aa 100644
--- a/ChangeLog
+++ b/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>
diff --git a/class.c b/class.c
index 40db68beb26..1f8bccc109a 100644
--- a/class.c
+++ b/class.c
@@ -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
diff --git a/dln.c b/dln.c
index ed20087b6a5..56dc7a6bf16 100644
--- a/dln.c
+++ b/dln.c
@@ -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)();
@@ -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
@@ -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");
diff --git a/eval.c b/eval.c
index e2905deb018..7c3d8d07d6e 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
@@ -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;
@@ -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);
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index 0dae66b8743..161eb7b4f43 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -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")
@@ -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
diff --git a/file.c b/file.c
index 20189a3e6a2..2865ef68997 100644
--- a/file.c
+++ b/file.c
@@ -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) {
diff --git a/hash.c b/hash.c
index 2569b425176..e1f5939e775 100644
--- a/hash.c
+++ b/hash.c
@@ -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;
}
@@ -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;
@@ -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);
diff --git a/lib/cgi-lib.rb b/lib/cgi-lib.rb
index 00be8992f40..2407c6b3889 100644
--- a/lib/cgi-lib.rb
+++ b/lib/cgi-lib.rb
@@ -1,4 +1,3 @@
-#!/usr/local/bin/ruby
#
# Get CGI String
#
diff --git a/lib/getopts.rb b/lib/getopts.rb
index 1862f560805..9e1e8a2cf69 100644
--- a/lib/getopts.rb
+++ b/lib/getopts.rb
@@ -1,4 +1,3 @@
-#!/usr/local/bin/ruby
#
# getopts.rb -
# $Release Version: $
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 175981379fa..631b6547b32 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -1,4 +1,3 @@
-#!/usr/local/bin/ruby
#
# matrix.rb -
# $Release Version: 1.0$
diff --git a/lib/parsearg.rb b/lib/parsearg.rb
index fa4dbdefcc8..b9f41d5e5f2 100644
--- a/lib/parsearg.rb
+++ b/lib/parsearg.rb
@@ -1,4 +1,3 @@
-#!/usr/local/bin/ruby
#
# parsearg.rb - parse arguments
# $Release Version: $
diff --git a/lib/pstore.rb b/lib/pstore.rb
index 86f086d2264..2a0bc11e489 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -1,5 +1,4 @@
-#!/usr/local/bin/ruby
-
+#
# How to use:
#
# db = PStore.new("/tmp/foo")
diff --git a/lib/tracer.rb b/lib/tracer.rb
index ef03fe09c90..032557d10cb 100644
--- a/lib/tracer.rb
+++ b/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.)
#
# --
@@ -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]
diff --git a/object.c b/object.c
index 09545441ec9..41acb4d021d 100644
--- a/object.c
+++ b/object.c
@@ -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)
@@ -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);
@@ -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);
diff --git a/ruby.c b/ruby.c
index 72866e14155..1459ada1cf2 100644
--- a/ruby.c
+++ b/ruby.c
@@ -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");
}
diff --git a/variable.c b/variable.c
index ef4b49e60dc..d676995450d 100644
--- a/variable.c
+++ b/variable.c
@@ -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));
}
@@ -806,7 +806,7 @@ obj_remove_instance_variable(obj, name)
rb_class2name(CLASS_OF(obj)));
break;
}
- return obj;
+ return val;
}
VALUE
@@ -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;