diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | error.c | 43 | ||||
-rw-r--r-- | eval.c | 21 | ||||
-rw-r--r-- | ext/extmk.rb.in | 6 | ||||
-rw-r--r-- | file.c | 83 | ||||
-rw-r--r-- | io.c | 106 | ||||
-rw-r--r-- | lib/mkmf.rb | 6 | ||||
-rw-r--r-- | version.h | 4 |
9 files changed, 176 insertions, 116 deletions
@@ -1,3 +1,24 @@ +Tue May 12 17:38:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * experimental release 1.1b9_18. + +Tue May 12 11:38:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * error.c (syserr_errno): returns errno of the SystemCallError. + + * error.c (rb_sys_fail): saves errno in the Exception. + + * error.c (set_syserr): no need to protect syserr_list. + + * error.c (rb_sys_fail): no more bufsize limit. + + * error.c (set_syserr): integer value of errno can be accessed by + Errno::EXXX::Errno. + +Sun May 10 03:10:33 1998 WATANABE Tetsuya <tetsu@jpn.hp.com> + + * io.c (io_tell etc.): moved from File class to IO class. + Fri May 8 12:26:37 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * pack.c (pack_unpack): should be unsigned int (was signed int). diff --git a/Makefile.in b/Makefile.in index cbf1eeec54..562948f382 100644 --- a/Makefile.in +++ b/Makefile.in @@ -11,7 +11,7 @@ PURIFY = @SET_MAKE@ prefix = @prefix@ -CFLAGS = @CFLAGS@ -I@includedir@ -I@srcdir@ +CFLAGS = @CFLAGS@ -I@srcdir@ -I@includedir@ LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@ LIBS = @LIBS@ $(EXTLIBS) MISSING = @LIBOBJS@ @ALLOCA@ @@ -409,15 +409,24 @@ static VALUE *syserr_list; extern int sys_nerr; #endif -static void +static VALUE set_syserr(i, name) int i; char *name; { + VALUE error = rb_define_class_under(mErrno, name, eSystemCallError); + rb_define_const(error, "Errno", INT2FIX(i)); if (i <= sys_nerr) { - syserr_list[i] = rb_define_class_under(mErrno, name, eSystemCallError); - rb_global_variable(&syserr_list[i]); + syserr_list[i] = error; } + return error; +} + +static VALUE +syserr_errno(self) + VALUE self; +{ + return rb_iv_get(self, "errno"); } static void init_syserr(); @@ -555,29 +564,43 @@ rb_sys_fail(mesg) #ifndef NT char *strerror(); #endif - char buf[BUFSIZ]; + char *err; + char *buf; extern int errno; int n = errno; + VALUE ee; - if (RTEST(mesg)) - sprintf(buf, "%s - %s", strerror(errno), mesg); - else - sprintf(buf, "%s", strerror(errno)); + err = strerror(errno); + if (mesg) { + buf = ALLOCA_N(char, strlen(err)+strlen(mesg)+1); + sprintf(buf, "%s - %s", err, mesg); + } + else { + buf = ALLOCA_N(char, strlen(err)+1); + sprintf(buf, "%s", err); + } errno = 0; if (n > sys_nerr || !syserr_list[n]) { char name[6]; sprintf(name, "E%03d", n); - set_syserr(n, name); + ee = set_syserr(n, name); } - rb_raise(exc_new2(syserr_list[n], buf)); + else { + ee = syserr_list[n]; + } + ee = exc_new2(ee, buf); + rb_iv_set(ee, "errno", INT2FIX(n)); + rb_raise(ee); } static void init_syserr() { eSystemCallError = rb_define_class("SystemCallError", eStandardError); + rb_define_method(eSystemCallError, "errno", syserr_errno, 0); + mErrno = rb_define_module("Errno"); syserr_list = ALLOC_N(VALUE, sys_nerr+1); MEMZERO(syserr_list, VALUE, sys_nerr+1); @@ -286,8 +286,8 @@ rb_export_method(klass, name, noex) } } -static VALUE -method_boundp(klass, id, ex) +int +rb_method_boundp(klass, id, ex) VALUE klass; ID id; int ex; @@ -302,17 +302,6 @@ method_boundp(klass, id, ex) return FALSE; } -int -rb_method_boundp(klass, id, ex) - VALUE klass; - ID id; - int ex; -{ - if (method_boundp(klass, id, ex)) - return TRUE; - return FALSE; -} - void rb_attr(klass, id, read, write, ex) VALUE klass; @@ -1333,8 +1322,8 @@ is_defined(self, node, buf) case NODE_SUPER: case NODE_ZSUPER: if (the_frame->last_func == 0) return 0; - else if (method_boundp(RCLASS(the_frame->last_class)->super, - the_frame->last_func, 1)) { + else if (rb_method_boundp(RCLASS(the_frame->last_class)->super, + the_frame->last_func, 1)) { if (nd_type(node) == NODE_SUPER) { return arg_defined(self, node->nd_args, buf, "super"); } @@ -1359,7 +1348,7 @@ is_defined(self, node, buf) return 0; } check_bound: - if (method_boundp(val, node->nd_mid, nd_type(node)== NODE_CALL)) { + if (rb_method_boundp(val, node->nd_mid, nd_type(node)== NODE_CALL)) { return arg_defined(self, node->nd_args, buf, "method"); } break; diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index 5aba725301..a788030eb2 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -62,8 +62,8 @@ CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '') else CFLAGS = "@CFLAGS@" end -LINK = "@CC@ -o conftest -I#{$topdir} " + CFLAGS + " %s @LDFLAGS@ %s conftest.c @LIBS@ %s" -CPP = "@CPP@ @CPPFLAGS@ -I#{$topdir} " + CFLAGS + " %s conftest.c" +LINK = "@CC@ -o conftest -I#{$topdir} -I@includedir@ " + CFLAGS + " %s @LDFLAGS@ %s conftest.c @LIBS@ %s" +CPP = "@CPP@ @CPPFLAGS@ -I#{$topdir} -I@includedir@ " + CFLAGS + " %s conftest.c" if /win32|djgpp|mingw32|m68k-human/i =~ PLATFORM $null = open("nul", "w") @@ -240,7 +240,7 @@ hdrdir = #{$topdir} CC = @CC@ prefix = @prefix@ -CFLAGS = %s -I@includedir@ -I#{$topdir} %s #$CFLAGS %s +CFLAGS = %s -I#{$topdir} -I@includedir@ %s #$CFLAGS %s DLDFLAGS = @DLDFLAGS@ #$LDFLAGS LDSHARED = @LDSHARED@ ", if $static then "" else "@CCDLFLAGS@" end, CFLAGS, $defs.join(" ") @@ -179,74 +179,6 @@ apply2files(func, vargs, arg) } static VALUE -file_tell(obj) - VALUE obj; -{ - OpenFile *fptr; - long pos; - - GetOpenFile(obj, fptr); - pos = ftell(fptr->f); - if (ferror(fptr->f) != 0) rb_sys_fail(fptr->path); - - return int2inum(pos); -} - -static VALUE -file_seek(obj, offset, ptrname) - VALUE obj, offset, ptrname; -{ - OpenFile *fptr; - long pos; - - GetOpenFile(obj, fptr); - pos = fseek(fptr->f, NUM2INT(offset), NUM2INT(ptrname)); - if (pos != 0) rb_sys_fail(fptr->path); - clearerr(fptr->f); - - return INT2FIX(0); -} - -static VALUE -file_set_pos(obj, offset) - VALUE obj, offset; -{ - OpenFile *fptr; - long pos; - - GetOpenFile(obj, fptr); - pos = fseek(fptr->f, NUM2INT(offset), 0); - if (pos != 0) rb_sys_fail(fptr->path); - clearerr(fptr->f); - - return INT2NUM(pos); -} - -static VALUE -file_rewind(obj) - VALUE obj; -{ - OpenFile *fptr; - - GetOpenFile(obj, fptr); - if (fseek(fptr->f, 0L, 0) != 0) rb_sys_fail(fptr->path); - clearerr(fptr->f); - - return INT2FIX(0); -} - -static VALUE -file_eof(obj) - VALUE obj; -{ - OpenFile *fptr; - - GetOpenFile(obj, fptr); - if (feof(fptr->f) == 0) return FALSE; - return TRUE; -} - -static VALUE file_path(obj) VALUE obj; { @@ -325,7 +257,7 @@ file_s_stat(obj, fname) } static VALUE -file_stat(obj) +io_stat(obj) VALUE obj; { OpenFile *fptr; @@ -1694,7 +1626,7 @@ Init_File() rb_define_method(cFile, "reopen", file_reopen, -1); - rb_define_method(cFile, "stat", file_stat, 0); + rb_define_method(cIO, "stat", io_stat, 0); /* this is IO's method */ rb_define_method(cFile, "lstat", file_lstat, 0); rb_define_method(cFile, "atime", file_atime, 0); @@ -1705,17 +1637,6 @@ Init_File() rb_define_method(cFile, "chown", file_chown, 2); rb_define_method(cFile, "truncate", file_truncate, 1); - rb_define_method(cFile, "tell", file_tell, 0); - rb_define_method(cFile, "seek", file_seek, 2); - - rb_define_method(cFile, "rewind", file_rewind, 0); - - rb_define_method(cFile, "pos", file_tell, 0); - rb_define_method(cFile, "pos=", file_set_pos, 1); - - rb_define_method(cFile, "eof", file_eof, 0); - rb_define_method(cFile, "eof?", file_eof, 0); - rb_define_method(cFile, "flock", file_flock, 1); mConst = rb_define_module_under(cFile, "Constants"); @@ -206,6 +206,63 @@ io_flush(io) } static VALUE +io_tell(io) + VALUE io; +{ + OpenFile *fptr; + long pos; + + GetOpenFile(io, fptr); + pos = ftell(fptr->f); + if (ferror(fptr->f) != 0) rb_sys_fail(fptr->path); + + return int2inum(pos); +} + +static VALUE +io_seek(io, offset, ptrname) + VALUE io, offset, ptrname; +{ + OpenFile *fptr; + long pos; + + GetOpenFile(io, fptr); + pos = fseek(fptr->f, NUM2INT(offset), NUM2INT(ptrname)); + if (pos != 0) rb_sys_fail(fptr->path); + clearerr(fptr->f); + + return INT2FIX(0); +} + +static VALUE +io_set_pos(io, offset) + VALUE io, offset; +{ + OpenFile *fptr; + long pos; + + GetOpenFile(io, fptr); + pos = fseek(fptr->f, NUM2INT(offset), 0); + if (pos != 0) rb_sys_fail(fptr->path); + clearerr(fptr->f); + + return INT2NUM(pos); +} + +static VALUE +io_rewind(io) + VALUE io; +{ + OpenFile *fptr; + + GetOpenFile(io, fptr); + if (fseek(fptr->f, 0L, 0) != 0) rb_sys_fail(fptr->path); + clearerr(fptr->f); + + return INT2FIX(0); +} + +static VALUE io_eof(io) VALUE io; { @@ -1722,6 +1779,40 @@ f_readline(argc, argv) } static VALUE +f_tell() +{ + return io_tell(file); +} + +static VALUE +f_seek(self, offset, ptrname) + VALUE self, offset, ptrname; +{ + if (!next_argv()) { + ArgError("no stream to seek"); + } + + return io_seek(file, offset, ptrname); +} + +static VALUE +f_set_pos(self, offset) + VALUE self, offset; +{ + if (!next_argv()) { + ArgError("no stream to pos"); + } + + return io_set_pos(file, offset); +} + +static VALUE +f_rewind() +{ + return io_rewind(file); +} + +static VALUE f_eof() { if (init_p == 0 && !next_argv()) @@ -2426,6 +2517,11 @@ Init_IO() rb_define_global_function("puts", f_puts, -1); rb_define_global_function("gets", f_gets_method, -1); rb_define_global_function("readline", f_readline, -1); + rb_define_global_function("tell", f_tell, 0); + rb_define_global_function("seek", f_seek, 2); + rb_define_global_function("rewind", f_rewind, 0); + rb_define_global_function("pos", f_tell, 0); + rb_define_global_function("pos=", f_set_pos, 1); rb_define_global_function("eof", f_eof, 0); rb_define_global_function("eof?", f_eof, 0); rb_define_global_function("getc", f_getc, 0); @@ -2498,6 +2594,11 @@ Init_IO() rb_define_method(cIO, "ungetc",io_ungetc, 1); rb_define_method(cIO, "<<", io_addstr, 1); rb_define_method(cIO, "flush", io_flush, 0); + rb_define_method(cIO, "tell", io_tell, 0); + rb_define_method(cIO, "seek", io_seek, 2); + rb_define_method(cIO, "rewind", io_rewind, 0); + rb_define_method(cIO, "pos", io_tell, 0); + rb_define_method(cIO, "pos=", io_set_pos, 1); rb_define_method(cIO, "eof", io_eof, 0); rb_define_method(cIO, "eof?", io_eof, 0); @@ -2544,6 +2645,11 @@ Init_IO() rb_define_singleton_method(argf, "readline", f_readline, -1); rb_define_singleton_method(argf, "getc", arg_getc, 0); rb_define_singleton_method(argf, "readchar", arg_readchar, 0); + rb_define_singleton_method(argf, "tell", f_tell, 0); + rb_define_singleton_method(argf, "seek", f_seek, 2); + rb_define_singleton_method(argf, "rewind", f_rewind, 0); + rb_define_singleton_method(argf, "pos", f_tell, 0); + rb_define_singleton_method(argf, "pos=", f_set_pos, 1); rb_define_singleton_method(argf, "eof", f_eof, 0); rb_define_singleton_method(argf, "eof?", f_eof, 0); rb_define_singleton_method(argf, "ungetc", f_ungetc, 1); diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 7651fc2589..4221e98b92 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -57,8 +57,8 @@ if /win32|djgpp|mingw32|m68k-human/i =~ PLATFORM else $null = open("/dev/null", "w") end -LINK = "#{CONFIG['CC']} -o conftest -I#{CONFIG['includedir']} -I#{$srcdir} #{CFLAGS} %s #{CONFIG['LDFLAGS']} %s conftest.c #{CONFIG['LIBS']} %s" -CPP = "#{CONFIG['CPP']} -E -I#{CONFIG['includedir']} -I#{$srcdir} #{CFLAGS} %s conftest.c" +LINK = "#{CONFIG['CC']} -o conftest -I#{$srcdir} -I#{CONFIG['includedir']} #{CFLAGS} %s #{CONFIG['LDFLAGS']} %s conftest.c #{CONFIG['LIBS']} %s" +CPP = "#{CONFIG['CPP']} -E -I#{$srcdir} -I#{CONFIG['includedir']} #{CFLAGS} %s conftest.c" $orgerr = $stderr.dup $orgout = $stdout.dup @@ -257,7 +257,7 @@ hdrdir = #{$hdrdir} CC = gcc prefix = #{CONFIG["prefix"]} -CFLAGS = #{CONFIG["CCDLFLAGS"]} -I#{CONFIG["includedir"]} -I#{$hdrdir} #{CFLAGS} #{$CFLAGS} #{$defs.join(" ")} +CFLAGS = #{CONFIG["CCDLFLAGS"]} -I#{$hdrdir} -I#{CONFIG["includedir"]} #{CFLAGS} #{$CFLAGS} #{$defs.join(" ")} DLDFLAGS = #{CONFIG["DLDFLAGS"]} #{$LDFLAGS} LDSHARED = #{CONFIG["LDSHARED"]} @@ -1,2 +1,2 @@ -#define RUBY_VERSION "1.1b9_17" -#define VERSION_DATE "98/05/06" +#define RUBY_VERSION "1.1b9_18" +#define VERSION_DATE "98/05/12" |