[macruby-changes] [1608] MacRuby/branches/experimental/io.c
source_changes at macosforge.org
source_changes at macosforge.org
Wed May 27 08:42:36 PDT 2009
Revision: 1608
http://trac.macosforge.org/projects/ruby/changeset/1608
Author: pthomson at apple.com
Date: 2009-05-27 08:42:34 -0700 (Wed, 27 May 2009)
Log Message:
-----------
Fixed a misunderstanding of the FMODE constants in io_from_spawning_new_process.
Modified Paths:
--------------
MacRuby/branches/experimental/io.c
Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c 2009-05-27 05:36:47 UTC (rev 1607)
+++ MacRuby/branches/experimental/io.c 2009-05-27 15:42:34 UTC (rev 1608)
@@ -51,8 +51,6 @@
static ID id_write, id_read, id_getc, id_flush, id_encode, id_readpartial;
-struct timeval rb_time_interval(VALUE);
-
struct argf {
VALUE filename, current_file;
int gets_lineno;
@@ -67,15 +65,6 @@
#define argf_of(obj) (*(struct argf *)DATA_PTR(obj))
#define ARGF argf_of(argf)
-// static int
-// is_socket(int fd, const char *path)
-// {
-// struct stat sbuf;
-// if (fstat(fd, &sbuf) < 0)
-// rb_sys_fail(path);
-// return S_ISSOCK(sbuf.st_mode);
-// }
-
static int
convert_mode_string_to_fmode(VALUE rstr)
{
@@ -1241,7 +1230,7 @@
return bstr;
}
-/*
+/*
* call-seq:
* ios.lineno => integer
*
@@ -1948,15 +1937,14 @@
posix_spawn_file_actions_t actions;
int fmode = convert_mode_string_to_fmode(mode);
- int readable = ((fmode & FMODE_READABLE) || (fmode & FMODE_READWRITE));
- int writable = ((fmode & FMODE_WRITABLE) || (fmode & FMODE_READWRITE));
- assert(readable || writable);
if (pipe(fd) < 0) {
posix_spawn_file_actions_destroy(&actions);
rb_sys_fail("pipe() failed.");
}
- if (readable) {
+ // Confusingly enough, FMODE_WRITABLE means 'write-only'
+ // and FMODE_READABLE means 'read-only'.
+ if (fmode != FMODE_WRITABLE) {
r = _CFReadStreamCreateFromFileDescriptor(NULL, fd[0]);
if (r != NULL) {
CFReadStreamOpen(r);
@@ -1966,7 +1954,7 @@
io_struct->readStream = NULL;
}
}
- if (writable) {
+ if (fmode != FMODE_READABLE) {
w = _CFWriteStreamCreateFromFileDescriptor(NULL, fd[0]);
if (w != NULL) {
CFWriteStreamOpen(w);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090527/71cc4af4/attachment.html>
More information about the macruby-changes
mailing list