summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/ruby.c b/ruby.c
index 0b4d486ec8..e36e585b85 100644
--- a/ruby.c
+++ b/ruby.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Aug 10 12:47:31 JST 1993
- Copyright (C) 1993-1999 Yukihiro Matsumoto
+ Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
@@ -176,8 +176,11 @@ rubylib_mangle(s, l)
strcpy(ret + newl, s + oldl);
return ret;
}
+#define rubylib_mangled_path(s, l) rb_str_new2(rubylib_mangle((s), (l)))
+#define rubylib_mangled_path2(s) rb_str_new2(rubylib_mangle((s), 0))
#else
-#define rubylib_mangle(s, l) (s)
+#define rubylib_mangled_path(s, l) rb_str_new((s), (l))
+#define rubylib_mangled_path2(s) rb_str_new2(s)
#endif
static void
@@ -202,18 +205,18 @@ addpath(path)
while (*p) {
while (*p == sep) p++;
if (s = strchr(p, sep)) {
- rb_ary_push(ary, rb_str_new(rubylib_mangle(p, (int)(s-p)), (int)(s-p)));
+ rb_ary_push(ary, rubylib_mangled_path(p, (int)(s-p)));
p = s + 1;
}
else {
- rb_ary_push(ary, rb_str_new2(rubylib_mangle(p, 0)));
+ rb_ary_push(ary, rubylib_mangled_path2(p));
break;
}
}
rb_load_path = rb_ary_plus(ary, rb_load_path);
}
else {
- rb_ary_unshift(rb_load_path, rb_str_new2(rubylib_mangle(path, 0)));
+ rb_ary_unshift(rb_load_path, rubylib_mangled_path2(path));
}
}
@@ -389,7 +392,10 @@ proc_options(argcp, argvp)
s = argv[1];
argc--,argv++;
}
- if (*s && chdir(s) < 0) {
+ if (!s || !*s) {
+ rb_fatal("Can't chdir");
+ }
+ if (chdir(s) < 0) {
rb_fatal("Can't chdir to %s", s);
}
break;
@@ -677,7 +683,11 @@ load_file(fname, script)
}
}
}
- else if (!NIL_P(c)) {
+ else if (NIL_P(c)) {
+ rb_io_close(f);
+ return;
+ }
+ else {
rb_io_ungetc(f, c);
}
}