summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-10 10:09:49 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-10 10:09:49 +0000
commit4af06a86de87b9f12751fb155d10c1f9e453097a (patch)
treee3c9324afa79d453f6dc8c32c9d3c6922cde8c39
parent882c18e65ef38342cd2dc0d4cd5e643439c30a77 (diff)
1.1b9_10 pre0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--Makefile.in16
-rw-r--r--array.c1
-rw-r--r--dir.c30
-rw-r--r--sample/inf-ruby.el19
5 files changed, 66 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 82696a47eb..ff6c517244 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Wed Apr 8 17:24:11 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * dir.c (dir_s_open): can be called with block (like IO#open).
+
+ * dir.c (dir_s_chdir): print directory path on error.
+
+ * dir.c (dir_s_chroot): ditto
+
+ * dir.c (Init_Dir): needed to override `new'.
+
Thu Apr 9 18:24:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* experimental release 1.1b9_09.
diff --git a/Makefile.in b/Makefile.in
index 7ef78b30bc..a84da25f3f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -169,24 +169,24 @@ x68.o: @srcdir@/missing/x68.c
# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
###
-parse.o : parse.y ruby.h defines.h config.h intern.h env.h node.h st.h regex.h lex.c
+parse.o: parse.y ruby.h config.h defines.h intern.h env.h node.h st.h regex.h util.h lex.c
###
array.o: array.c ruby.h config.h defines.h intern.h
bignum.o: bignum.c ruby.h config.h defines.h intern.h
class.o: class.c ruby.h config.h defines.h intern.h node.h st.h
compar.o: compar.c ruby.h config.h defines.h intern.h
dir.o: dir.c ruby.h config.h defines.h intern.h
-dln.o: dln.c config.h defines.h dln.h st.h
+dln.o: dln.c config.h defines.h dln.h
dmyext.o: dmyext.c
enum.o: enum.c ruby.h config.h defines.h intern.h
error.o: error.c ruby.h config.h defines.h intern.h env.h
-eval.o: eval.c ruby.h config.h defines.h intern.h env.h node.h sig.h st.h dln.h
+eval.o: eval.c ruby.h config.h defines.h intern.h node.h env.h sig.h st.h dln.h
file.o: file.c ruby.h config.h defines.h intern.h io.h sig.h
-gc.o: gc.c ruby.h config.h defines.h intern.h env.h sig.h st.h node.h re.h regex.h
-hash.o: hash.c ruby.h config.h defines.h intern.h st.h
+gc.o: gc.c ruby.h config.h defines.h intern.h sig.h st.h node.h env.h re.h regex.h
+hash.o: hash.c ruby.h config.h defines.h intern.h st.h sig.h
inits.o: inits.c ruby.h config.h defines.h intern.h
io.o: io.c ruby.h config.h defines.h intern.h io.h sig.h
-main.o: main.c
+main.o: main.c ruby.h config.h defines.h intern.h
marshal.o: marshal.c ruby.h config.h defines.h intern.h io.h sig.h st.h
math.o: math.c ruby.h config.h defines.h intern.h
numeric.o: numeric.c ruby.h config.h defines.h intern.h
@@ -203,6 +203,6 @@ st.o: st.c config.h st.h
string.o: string.c ruby.h config.h defines.h intern.h re.h regex.h
struct.o: struct.c ruby.h config.h defines.h intern.h
time.o: time.c ruby.h config.h defines.h intern.h
-util.o: util.c ruby.h defines.h intern.h config.h util.h
-variable.o: variable.c ruby.h config.h defines.h intern.h env.h st.h
+util.o: util.c ruby.h config.h defines.h intern.h util.h
+variable.o: variable.c ruby.h config.h defines.h intern.h env.h node.h st.h
version.o: version.c ruby.h config.h defines.h intern.h version.h
diff --git a/array.c b/array.c
index 626d83cab5..b517fa3abb 100644
--- a/array.c
+++ b/array.c
@@ -1299,6 +1299,7 @@ Init_Array()
rb_define_method(cArray, "uniq!", ary_uniq_bang, 0);
rb_define_method(cArray, "uniq", ary_uniq, 0);
+ rb_define_method(cArray, "compact", ary_compact, 0);
rb_define_method(cArray, "compact!", ary_compact_bang, 0);
rb_define_method(cArray, "nitems", ary_nitems, 0);
diff --git a/dir.c b/dir.c
index a0186f0221..e2a6fd45ba 100644
--- a/dir.c
+++ b/dir.c
@@ -59,6 +59,8 @@ free_dir(dir)
if (dir) closedir(dir);
}
+static VALUE dir_close _((VALUE));
+
static VALUE
dir_s_open(dir_class, dirname)
VALUE dir_class, dirname;
@@ -81,6 +83,9 @@ dir_s_open(dir_class, dirname)
obj = Data_Wrap_Struct(dir_class, 0, free_dir, dirp);
+ if (iterator_p())
+ rb_ensure(rb_yield, obj, dir_close, obj);
+
return obj;
}
@@ -95,6 +100,23 @@ dir_closed()
if (dirp == NULL) dir_closed();\
}
+#if 0
+static VALUE
+dir_read(dir)
+ VALUE dir;
+{
+ DIR *dirp;
+ struct dirent *dp;
+
+ GetDIR(dir, dirp);
+ dp = readdir(dirp);
+ if (dp)
+ return str_taint(str_new(dp->d_name, NAMLEN(dp)));
+ else
+ return Qnil;
+}
+#endif
+
static VALUE
dir_each(dir)
VALUE dir;
@@ -190,7 +212,7 @@ dir_s_chdir(argc, argv, obj)
}
if (chdir(dist) < 0)
- rb_sys_fail(0);
+ rb_sys_fail(dist);
return INT2FIX(0);
}
@@ -220,7 +242,7 @@ dir_s_chroot(dir, path)
Check_SafeStr(path);
if (chroot(RSTRING(path)->ptr) == -1)
- rb_sys_fail(0);
+ rb_sys_fail(RSTRING(path)->ptr);
return INT2FIX(0);
#else
@@ -402,9 +424,13 @@ Init_Dir()
rb_include_module(cDir, mEnumerable);
+ rb_define_singleton_method(cDir, "new", dir_s_open, 1);
rb_define_singleton_method(cDir, "open", dir_s_open, 1);
rb_define_singleton_method(cDir, "foreach", dir_foreach, 1);
+#if 0
+ rb_define_method(cDir,"read", dir_read, 0);
+#endif
rb_define_method(cDir,"each", dir_each, 0);
rb_define_method(cDir,"rewind", dir_rewind, 0);
rb_define_method(cDir,"tell", dir_tell, 0);
diff --git a/sample/inf-ruby.el b/sample/inf-ruby.el
index c7d5d363d7..317bf21d5f 100644
--- a/sample/inf-ruby.el
+++ b/sample/inf-ruby.el
@@ -146,6 +146,25 @@ so it only valid in rbc."
(re-search-backward P)
))
+(if (not (functionp 'replace-in-string))
+ ;; simple version of replace-in-string in XEmacs
+ (defun replace-in-string (str regexp newtext)
+ "Replace all matches in STR for REGEXP with NEWTEXT string,
+ and returns the new string."
+ (let ((rtn-str "")
+ (start 0)
+ (special)
+ match prev-start)
+ (while (setq match (string-match regexp str start))
+ (setq prev-start start
+ start (match-end 0)
+ rtn-str
+ (concat
+ rtn-str
+ (substring str prev-start match) newtext)))
+ (concat rtn-str (substring str start))))
+)
+
(defun ruby-get-old-input ()
"Snarf the sexp ending at point"
(save-excursion