summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-23 06:53:19 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-23 06:53:19 +0000
commitc384393dcb4b11f083f62071e2c098b7beeb4fd2 (patch)
treeba9d1eb2468dcc8cd82953070f6a3748b6eb58a2
parent313f260ee254f0353a18dbc4733cdc436ee5fb18 (diff)
use to_io
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--README29
-rw-r--r--config.guess4
-rw-r--r--io.c43
-rw-r--r--string.c4
5 files changed, 65 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index a2de4ca..64ad423 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Apr 22 23:27:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (select_get_io): get IO object by `to_io'.
+
+ * io.c (io_to_io): method to retrieve IO object, from delegating
+ object for example.
+
Wed Apr 22 16:52:37 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* experimental release 1.1b9_14.
diff --git a/README b/README
index d41fb9f..ab2fd69 100644
--- a/README
+++ b/README
@@ -31,16 +31,19 @@ This is what you need to do to compile and install Ruby:
2. Edit defines.h if you need. Probably this step will not need.
- 3. Remove comment mark(#) before the module names from ext/Setup, if
- you want to link modules statically.
+ 3. Remove comment mark(#) before the module names from ext/Setup (or
+ add module names if not present), if you want to link modules
+ statically.
- If you want to link all the extension modules, remove comment
- mark from the line "#option nodynamic".
+ If you don't want to compile non static extension modules
+ (probably on architectures which does not allow dynamic loading),
+ remove comment mark from the line "#option nodynamic" in
+ ext/Setup.
4. Run make.
- 5. Optionally, run 'make test' to check that the compiled Ruby
- interpreter works well. If you see the message "test succeeded",
+ 5. Optionally, run 'make test' to check whether the compiled Ruby
+ interpreter works well. If you see the message "test succeeded",
your Ruby works as it should (hopefully).
6. Run 'make install'
@@ -61,12 +64,13 @@ You can redistribute it and/or modify it under either the terms of the GPL
2. You may modify your copy of the software in any way, provided that
you do at least ONE of the following:
- a) place your modifications in the Public Domain or otherwise make them
- Freely Available, such as by posting said modifications to Usenet
- or an equivalent medium, or by allowing the author to include your
- modifications in the software.
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
- b) use the modified software only within your corporation or organization.
+ b) use the modified software only within your corporation or
+ organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided.
@@ -84,8 +88,7 @@ You can redistribute it and/or modify it under either the terms of the GPL
the software.
c) give non-standard executables non-standard names, with
- instructions on where to get the original software
- distribution.
+ instructions on where to get the original software distribution.
d) make other distribution arrangements with the author.
diff --git a/config.guess b/config.guess
index 1915100..cb7bb28 100644
--- a/config.guess
+++ b/config.guess
@@ -567,11 +567,11 @@ EOF
objdump --private-headers dummy | \
grep ld.so.1 > /dev/null
if test "$?" = 0 ; then
- LIBC="libc1"
+ LIBC="-libc1"
fi
fi
rm -f dummy.s dummy
- echo ${UNAME_MACHINE}-unknown-linux-{LIBC} ; exit 0
+ echo ${UNAME_MACHINE}-unknown-linux${LIBC} ; exit 0
elif test "${UNAME_MACHINE}" = "mips" ; then
cat >dummy.c <<EOF
main(argc, argv)
diff --git a/io.c b/io.c
index bd35ae7..4350a9a 100644
--- a/io.c
+++ b/io.c
@@ -267,6 +267,13 @@ io_fileno(io)
return INT2FIX(fd);
}
+static VALUE
+io_to_io(io)
+ VALUE io;
+{
+ return io;
+}
+
/* reading functions */
#ifndef S_ISREG
@@ -1161,6 +1168,17 @@ f_open(argc, argv)
return port;
}
+static VALUE
+io_get_io(io)
+ VALUE io;
+{
+ if (TYPE(io) != T_FILE) {
+ io = rb_funcall(io, rb_intern("to_io"), 0, 0);
+ Check_Type(io, T_FILE);
+ }
+ return io;
+}
+
#ifndef NT
extern char *strdup();
#endif
@@ -1190,7 +1208,7 @@ io_reopen(io, nfile)
int fd;
GetOpenFile(io, fptr);
- Check_Type(nfile, T_FILE);
+ nfile = io_get_io(nfile);
GetOpenFile(nfile, orig);
if (orig->f2) {
@@ -1827,8 +1845,9 @@ f_select(argc, argv, obj)
rp = &rset;
FD_ZERO(rp);
for (i=0; i<RARRAY(read)->len; i++) {
- Check_Type(RARRAY(read)->ptr[i], T_FILE);
- GetOpenFile(RARRAY(read)->ptr[i], fptr);
+ VALUE io = io_get_io(RARRAY(read)->ptr[i]);
+
+ GetOpenFile(io, fptr);
FD_SET(fileno(fptr->f), rp);
if (READ_DATA_PENDING(fptr->f)) { /* check for buffered data */
pending++;
@@ -1849,8 +1868,9 @@ f_select(argc, argv, obj)
wp = &wset;
FD_ZERO(wp);
for (i=0; i<RARRAY(write)->len; i++) {
- Check_Type(RARRAY(write)->ptr[i], T_FILE);
- GetOpenFile(RARRAY(write)->ptr[i], fptr);
+ VALUE io = io_get_io(RARRAY(write)->ptr[i]);
+
+ GetOpenFile(io, fptr);
FD_SET(fileno(fptr->f), wp);
if (max > fileno(fptr->f)) max = fileno(fptr->f);
if (fptr->f2) {
@@ -1867,8 +1887,9 @@ f_select(argc, argv, obj)
ep = &eset;
FD_ZERO(ep);
for (i=0; i<RARRAY(except)->len; i++) {
- Check_Type(RARRAY(except)->ptr[i], T_FILE);
- GetOpenFile(RARRAY(except)->ptr[i], fptr);
+ VALUE io = io_get_io(RARRAY(except)->ptr[i]);
+
+ GetOpenFile(io, fptr);
FD_SET(fileno(fptr->f), ep);
if (max < fileno(fptr->f)) max = fileno(fptr->f);
if (fptr->f2) {
@@ -2239,6 +2260,12 @@ arg_fileno()
}
static VALUE
+arg_to_io()
+{
+ return file;
+}
+
+static VALUE
arg_read(argc, argv)
int argc;
VALUE *argv;
@@ -2458,6 +2485,7 @@ Init_IO()
rb_define_method(cIO, "fileno", io_fileno, 0);
rb_define_alias(cIO, "to_i", "fileno");
+ rb_define_method(cIO, "to_io", io_to_io, 0);
rb_define_method(cIO, "sync", io_sync, 0);
rb_define_method(cIO, "sync=", io_set_sync, 1);
@@ -2507,6 +2535,7 @@ Init_IO()
rb_define_singleton_method(argf, "fileno", arg_fileno, 0);
rb_define_singleton_method(argf, "to_i", arg_fileno, 0);
+ rb_define_singleton_method(argf, "to_io", arg_to_io, 0);
rb_define_singleton_method(argf, "each", arg_each_line, -1);
rb_define_singleton_method(argf, "each_line", arg_each_line, -1);
rb_define_singleton_method(argf, "each_byte", arg_each_byte, 0);
diff --git a/string.c b/string.c
index 45c01c6..f99ffce 100644
--- a/string.c
+++ b/string.c
@@ -148,6 +148,8 @@ str_clone(orig)
str = str_new3(RSTRING(orig)->orig);
else
str = str_new(RSTRING(orig)->ptr, RSTRING(orig)->len);
+ if (RSTRING(orig)->orig && FL_TEST(orig, STR_NO_ORIG))
+ RSTRING(str)->orig = RSTRING(orig)->orig;
CLONESETUP(str, orig);
return str;
}
@@ -158,6 +160,8 @@ str_dup(str)
{
VALUE s = str_new(RSTRING(str)->ptr, RSTRING(str)->len);
if (str_tainted(str)) s = str_taint(s);
+ if (RSTRING(str)->orig && FL_TEST(str, STR_NO_ORIG))
+ RSTRING(s)->orig = RSTRING(str)->orig;
return s;
}