[macruby-changes] [1211] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 27 13:11:10 PDT 2009
Revision: 1211
http://trac.macosforge.org/projects/ruby/changeset/1211
Author: pthomson at apple.com
Date: 2009-03-27 13:11:09 -0700 (Fri, 27 Mar 2009)
Log Message:
-----------
Put in calls to rb_last_status_set so that lrz can reimplement it.
Modified Paths:
--------------
MacRuby/branches/experimental/include/ruby/io.h
MacRuby/branches/experimental/io.c
Modified: MacRuby/branches/experimental/include/ruby/io.h
===================================================================
--- MacRuby/branches/experimental/include/ruby/io.h 2009-03-27 19:40:37 UTC (rev 1210)
+++ MacRuby/branches/experimental/include/ruby/io.h 2009-03-27 20:11:09 UTC (rev 1211)
@@ -60,6 +60,16 @@
#define FMODE_TRUNC 0x00000800
#define FMODE_TEXTMODE 0x00001000
+
+#ifndef SEEK_CUR
+# define SEEK_SET 0
+# define SEEK_CUR 1
+# define SEEK_END 2
+#endif
+
+#define FMODE_SYNCWRITE (FMODE_SYNC|FMODE_WRITABLE)
+
+
VALUE rb_io_taint_check(VALUE);
NORETURN(void rb_eof_error(void));
Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c 2009-03-27 19:40:37 UTC (rev 1210)
+++ MacRuby/branches/experimental/io.c 2009-03-27 20:11:09 UTC (rev 1211)
@@ -1,4 +1,4 @@
-/**********************************************************************
+ /**********************************************************************
io.c -
@@ -300,6 +300,33 @@
return convert_fmode_to_oflags(convert_mode_string_to_fmode(s));
}
+static inline int
+convert_oflags_to_fmode(int mode)
+{
+ int flags = 0;
+
+ switch (mode & (O_RDONLY|O_WRONLY|O_RDWR)) {
+ case O_RDONLY:
+ flags = FMODE_READABLE;
+ break;
+ case O_WRONLY:
+ flags = FMODE_WRITABLE;
+ break;
+ case O_RDWR:
+ flags = FMODE_READWRITE;
+ break;
+ }
+
+ if (mode & O_APPEND) {
+ flags |= FMODE_APPEND;
+ }
+ if (mode & O_CREAT) {
+ flags |= FMODE_CREATE;
+ }
+
+ return flags;
+}
+
void
rb_eof_error(void)
{
@@ -363,42 +390,6 @@
|| CFWriteStreamGetStatus(io_struct->writeStream) == kCFStreamStatusOpen);
}
-#define FMODE_PREP (1<<16)
-#define IS_PREP_STDIO(f) ((f)->mode & FMODE_PREP)
-#define PREP_STDIO_NAME(f) ((f)->path)
-
-static inline int
-rb_io_modenum_flags(int mode)
-{
- int flags = 0;
-
- switch (mode & (O_RDONLY|O_WRONLY|O_RDWR)) {
- case O_RDONLY:
- flags = FMODE_READABLE;
- break;
- case O_WRONLY:
- flags = FMODE_WRITABLE;
- break;
- case O_RDWR:
- flags = FMODE_READWRITE;
- break;
- }
-
- if (mode & O_APPEND) {
- flags |= FMODE_APPEND;
- }
- if (mode & O_CREAT) {
- flags |= FMODE_CREATE;
- }
-#ifdef O_BINARY
- if (mode & O_BINARY) {
- flags |= FMODE_BINMODE;
- }
-#endif
-
- return flags;
-}
-
/*
* call-seq:
* IO.try_convert(obj) -> io or nil
@@ -416,14 +407,6 @@
rb_notimplement();
}
-#ifndef SEEK_CUR
-# define SEEK_SET 0
-# define SEEK_CUR 1
-# define SEEK_END 2
-#endif
-
-#define FMODE_SYNCWRITE (FMODE_SYNC|FMODE_WRITABLE)
-
static VALUE
io_alloc(VALUE klass, SEL sel)
{
@@ -485,8 +468,6 @@
io_struct->sync = mode & FMODE_SYNC;
}
-int macruby_pclose(FILE *iop);
-
static void
io_struct_close(rb_io_t *io_struct, bool close_read, bool close_write)
{
@@ -497,10 +478,10 @@
CFWriteStreamClose(io_struct->writeStream);
}
if (io_struct->fp != NULL) {
- const int status = macruby_pclose(io_struct->fp);
- io_struct->fp = NULL;
- // TODO find out the real pid instead of passing -1
- rb_last_status_set(status, -1);
+ const int status = macruby_pclose(io_struct->fp);
+ io_struct->fp = NULL;
+ rb_last_status_set(status, io_struct->pid);
+ io_struct->pid = -1;
}
}
@@ -1785,7 +1766,7 @@
if (path != NULL && strcmp(path, "-") != 0) {
klass = rb_cFile;
}
- return prep_io(fd, rb_io_modenum_flags(mode), klass);
+ return prep_io(fd, convert_oflags_to_fmode(mode), klass);
}
static VALUE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090327/2f0a16f8/attachment-0001.html>
More information about the macruby-changes
mailing list