From d7b8e448bfd29042f64ed3535dc21014b9259088 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 6 Mar 2000 04:15:42 +0000 Subject: 2000-03-06 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 27 +++++++++++++++++++++++++ README.EXT | 25 +++++++++++++---------- README.EXT.jp | 53 +++++++++++++++++++++++-------------------------- eval.c | 21 ++++++++++++++++++++ ext/Win32API/Win32API.c | 11 ++++------ ext/curses/curses.c | 2 -- ext/dbm/dbm.c | 1 - ext/extmk.rb.in | 6 +++++- ext/gdbm/gdbm.c | 1 - ext/md5/md5init.c | 1 - ext/socket/socket.c | 6 ++++++ lib/cgi.rb | 5 +++-- lib/pstore.rb | 4 ++++ lib/weakref.rb | 2 +- misc/ruby-mode.el | 21 ++++++++++++-------- node.h | 3 --- ruby.h | 1 + version.h | 4 ++-- 18 files changed, 127 insertions(+), 67 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0c836c335..9aa1d4478c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +Mon Mar 6 12:28:37 2000 Yukihiro Matsumoto + + * ext/socket/socket.c (ip_addrsetup): should check length of hostname. + + * ext/socket/socket.c (ip_addrsetup): check newline at the end of + hostname. These fixes suggested by Muvaw Pnazte . + +Sun Mar 5 20:35:45 2000 WATANABE Hirofumi + + * ext/Win32API/Win32API.c (Win32API_initialize): should call + LoadLibrary() everytime and should assign the hdll to Win32API + object(protect the hdll from GC). + +Sun Mar 5 18:49:06 2000 Nakada.Nobuyoshi + + * misc/ruby-mode.el (ruby-parse-region): not treat method `begin' + and `end' as reserved words. + + * misc/ruby-mode.el (ruby-font-lock-docs): ignore after `=begin' + and `=end'. + + * misc/ruby-mode.el (ruby-font-lock-keywords, hilit-set-mode-patterns): + added `yield' to keywords. + + * misc/ruby-mode.el (ruby-font-lock-keywords, hilit-set-mode-patterns): + matches keywords at end of buffer. + Tue Feb 29 01:08:26 2000 Yukihiro Matsumoto * range.c (range_initialize): initialization done in `initialize'; diff --git a/README.EXT b/README.EXT index 68726b793d..cd0be84b56 100644 --- a/README.EXT +++ b/README.EXT @@ -67,7 +67,7 @@ data-types, the code will be like: break; default: /* raise exception */ - Fail("not valid value"); + rb_raise(rb_eTypeError, "not valid value"); break; } @@ -203,6 +203,11 @@ To define class or module, use functions below: These functions return the newly created class or module. You may want to save this reference into the variable to use later. +To define nested class or module, use functions below: + + VALUE rb_define_class_under(VALUE outer, char *name, VALUE super) + VALUE rb_define_module_under(VALUE outer, char *name) + 2.1.2 Method/singleton method definition To define methods or singleton methods, use functions below: @@ -387,9 +392,9 @@ The prototypes of the getter and setter functions are as following: To wrapping and objectify the C pointer as Ruby object (so called DATA), use Data_Wrap_Struct(). - Data_Wrap_Struct(klass,mark,free,ptr) + Data_Wrap_Struct(klass, mark, free, ptr) -Data_Wrap_Struct() returns a created DATA object. The class argument +Data_Wrap_Struct() returns a created DATA object. The klass argument is the class for the DATA object. The mark argument is the function to mark Ruby objects pointed by this data. The free argument is the function to free the pointer allocation. The functions, mark and @@ -484,7 +489,7 @@ struct dbmdata { }; -obj = Data_Make_Struct(klass,struct dbmdata,0,free_dbm,dbmp); +obj = Data_Make_Struct(klass, struct dbmdata, 0, free_dbm, dbmp); -- This code wraps dbmdata structure into Ruby object. We avoid wrapping @@ -598,7 +603,7 @@ not be done. If the file named depend exists, Makefile will include that file to check dependency. You can make this file by invoking - % gcc -MM *.c > depend + % gcc -MM *.c > depend It's no harm. Prepare it. @@ -657,8 +662,6 @@ ruby language core utility functions dln.c - fnmatch.c - glob.c regex.c st.c util.c @@ -681,9 +684,11 @@ class library file.c hash.c io.c + marshal.c math.c numeric.c pack.c + prec.c process.c random.c range.c @@ -779,11 +784,11 @@ Defines a read-only global variable. Works just like rb_define_variable(), except defined variable is read-only. void rb_define_virtual_variable(char *name, - VALUE (*getter)(), VALUE (*setter)()) + VALUE (*getter)(), VALUE (*setter)()) Defines a virtual variable, whose behavior is defined by pair of C functions. The getter function is called when the variable is -referred. The setter function is called when the value is set to the +referred. The setter function is called when the value is set to the variable. The prototype for getter/setter functions are: VALUE getter(ID id) @@ -874,7 +879,7 @@ Returns the name corresponding ID. Returns the name of the class. - int rb_respond_to(VALUE object, ID id) + int rb_respond_to(VALUE object, ID id) Returns true if the object reponds to the message specified by id. diff --git a/README.EXT.jp b/README.EXT.jp index 6a049d0222..419d7e37a7 100644 --- a/README.EXT.jp +++ b/README.EXT.jp @@ -73,7 +73,7 @@ ruby.h break; default: /* 例外を発生させる */ - TypeError("not valid value"); + rb_raise(rb_eTypeError, "not valid value"); break; } @@ -252,7 +252,7 @@ Ruby メソッドや特異メソッドを定義するには以下の関数を使います. - void rb_define_method(VALUE class, char *name, + void rb_define_method(VALUE klass, char *name, VALUE (*func)(), int argc) void rb_define_singleton_method(VALUE object, char *name, @@ -277,8 +277,8 @@ argc メソッドを定義する関数はもう二つあります.ひとつはprivateメ ソッドを定義する関数で,引数はrb_define_method()と同じです. - void rb_define_private_method(VALUE class, char *name, - VALUE (*func)(), int argc) + void rb_define_private_method(VALUE klass, char *name, + VALUE (*func)(), int argc) privateメソッドとは関数形式でしか呼び出すことの出来ないメソッ ドです. @@ -312,7 +312,7 @@ private 拡張ライブラリが必要な定数はあらかじめ定義しておいた方が良い でしょう.定数を定義する関数は二つあります. - void rb_define_const(VALUE class, char *name, VALUE val) + void rb_define_const(VALUE klass, char *name, VALUE val) void rb_define_global_const(char *name, VALUE val) 前者は特定のクラス/モジュールに属する定数を定義するもの,後 @@ -467,11 +467,11 @@ Ruby Dataオブジェクトを生成して構造体をRubyオブジェクトにカプセル 化するためには,以下のマクロを使います. - Data_Wrap_Struct(class,mark,free,ptr) + Data_Wrap_Struct(klass, mark, free, ptr) このマクロの戻り値は生成されたDataオブジェクトです. -classはこのDataオブジェクトのクラスです.ptrはカプセル化する +klassはこのDataオブジェクトのクラスです.ptrはカプセル化する Cの構造体へのポインタです.markはこの構造体がRubyのオブジェ クトへの参照がある時に使う関数です.そのような参照を含まない 時には0を指定します. @@ -484,11 +484,11 @@ free Cの構造体の割当とDataオブジェクトの生成を同時に行うマクロと して以下のものが提供されています. - Data_Make_Struct(class, type, mark, free, sval) + Data_Make_Struct(klass, type, mark, free, sval) このマクロの戻り値は生成されたDataオブジェクトです. -class, mark, freeはData_Wrap_Structと同じ働きをします.type +klass, mark, freeはData_Wrap_Structと同じ働きをします.type は割り当てるC構造体の型です.割り当てられた構造体は変数sval に代入されます.この変数の型は (type*) である必要があります. @@ -588,7 +588,7 @@ struct dbmdata { }; -obj = Data_Make_Struct(class,struct dbmdata,0,free_dbm,dbmp); +obj = Data_Make_Struct(klass, struct dbmdata, 0, free_dbm, dbmp); -- ここではdbmstruct構造体へのポインタをDataにカプセル化してい @@ -633,10 +633,10 @@ fdbm_delete(obj, keystr) -- static VALUE -fdbm_s_open(argc, argv, class) +fdbm_s_open(argc, argv, klass) int argc; VALUE *argv; - VALUE class; + VALUE klass; { : if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) { @@ -712,7 +712,7 @@ Makefile もし,ディレクトリにdependというファイルが存在すれば, Makefileが依存関係をチェックしてくれます. - % gcc -MM *.c > depend + % gcc -MM *.c > depend などで作ることが出来ます.あって損は無いでしょう. @@ -793,8 +793,6 @@ Ruby ユーティリティ関数 dln.c - fnmatch.c - glob.c regex.c st.c util.c @@ -821,6 +819,7 @@ Ruby math.c numeric.c pack.c + prec.c process.c random.c range.c @@ -860,7 +859,7 @@ Qfalse ** Cデータのカプセル化 -Data_Wrap_Struct(VALUE class, void (*mark)(), void (*free)(), void *sval) +Data_Wrap_Struct(VALUE klass, void (*mark)(), void (*free)(), void *sval) Cの任意のポインタをカプセル化したRubyオブジェクトを返す.こ のポインタがRubyからアクセスされなくなった時,freeで指定した @@ -868,7 +867,7 @@ Data_Wrap_Struct(VALUE class, void (*mark)(), void (*free)(), void *sval) ジェクトを指している場合,markに指定する関数でマークする必要 がある. -Data_Make_Struct(class, type, mark, free, sval) +Data_Make_Struct(klass, type, mark, free, sval) type型のメモリをmallocし,変数svalに代入した後,それをカプセ ル化したデータを返すマクロ. @@ -915,7 +914,7 @@ VALUE rb_define_module_under(VALUE module, char *name, VALUE super) 新しいRubyモジュールを定義し,moduleの定数として定義する. -void rb_include_module(VALUE class, VALUE module) +void rb_include_module(VALUE klass, VALUE module) モジュールをインクルードする.classがすでにmoduleをインク ルードしている時には何もしない(多重インクルードの禁止). @@ -974,7 +973,7 @@ void rb_define_global_const(char *name, VALUE val) ** メソッド定義 -rb_define_method(VALUE class, char *name, VALUE (*func)(), int argc) +rb_define_method(VALUE klass, char *name, VALUE (*func)(), int argc) メソッドを定義する.argcはselfを除く引数の数.argcが-1の時, 関数には引数の数(selfを含まない)を第1引数, 引数の配列を第2 @@ -982,17 +981,17 @@ rb_define_method(VALUE class, char *name, VALUE (*func)(), int argc) 第1引数がself, 第2引数がargs(argsは引数を含むRubyの配列)と いう形式で与えられる. -rb_define_private_method(VALUE class, char *name, VALUE (*func)(), int argc) +rb_define_private_method(VALUE klass, char *name, VALUE (*func)(), int argc) privateメソッドを定義する.引数はrb_define_method()と同じ. -rb_define_singleton_method(VALUE class, char *name, VALUE (*func)(), int argc) +rb_define_singleton_method(VALUE klass, char *name, VALUE (*func)(), int argc) 特異メソッドを定義する.引数はrb_define_method()と同じ. rb_scan_args(int argc, VALUE *argv, char *fmt, ...) - argc,argv形式で与えられた引数を分解する.fmtは必須引数の数, + argc, argv形式で与えられた引数を分解する.fmtは必須引数の数, 付加引数の数, 残りの引数があるかを指定する文字列で, "数字 数字*"という形式である. 2 番目の数字と"*"はそれぞれ省略可 能である.必須引数が一つもない場合は0を指定する.第3引数以 @@ -1009,7 +1008,7 @@ VALUE rb_funcall(VALUE recv, ID mid, int narg, ...) VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv) - メソッド呼び出し.引数をargc,argv形式で渡す. + メソッド呼び出し.引数をargc, argv形式で渡す. VALUE rb_eval_string(char *str) @@ -1023,9 +1022,9 @@ char *rb_id2name(ID id) IDに対応する文字列を返す(デバッグ用). -char *rb_class2name(VALUE class) +char *rb_class2name(VALUE klass) - classの名前を返す(デバッグ用).classが名前を持たない時には, + クラスの名前を返す(デバッグ用).クラスが名前を持たない時には, 祖先を遡って名前を持つクラスの名前を返す. int rb_respond_to(VALUE obj, ID id) @@ -1134,7 +1133,6 @@ find_library(lib, func, path...) 関数funcを定義しているライブラリlibの存在を -Lpath を追加 しながらチェックする.ライブラリが見付かった時,trueを返す. - 結果をキャッシュしない. have_func(func) @@ -1150,8 +1148,7 @@ have_header(header) find_header(header) ヘッダファイルの存在を -Ipath を追加しながらチェックする. - ヘッダファイルが見付かった時trueを返す.結果をキャッシュし - ない. + ヘッダファイルが見付かった時trueを返す. create_makefile(target) diff --git a/eval.c b/eval.c index d32a365640..66910fb9c0 100644 --- a/eval.c +++ b/eval.c @@ -4300,6 +4300,27 @@ rb_funcall3(recv, mid, argc, argv) return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0); } +VALUE +rb_call_super(argc, argv) + int argc; + VALUE *argv; +{ + VALUE result; + + if (ruby_frame->last_class == 0) { + rb_raise(rb_eNameError, "superclass method `%s' disabled", + rb_id2name(ruby_frame->last_func)); + } + + PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT); + result = rb_call(RCLASS(ruby_frame->last_class)->super, + ruby_frame->self, ruby_frame->last_func, + argc, argv, 3); + POP_ITER(); + + return result; +} + static VALUE backtrace(lev) int lev; diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c index 38268d0474..433d13abeb 100644 --- a/ext/Win32API/Win32API.c +++ b/ext/Win32API/Win32API.c @@ -52,13 +52,10 @@ Win32API_initialize(self, dllname, proc, import, export) int len; int ex; - hdll = GetModuleHandle(RSTRING(dllname)->ptr); - if (!hdll) { - hdll = LoadLibrary(RSTRING(dllname)->ptr); - if (!hdll) - rb_raise(rb_eRuntimeError, "LoadLibrary: %s\n", RSTRING(dllname)->ptr); - Data_Wrap_Struct(self, 0, Win32API_FreeLibrary, hdll); - } + hdll = LoadLibrary(RSTRING(dllname)->ptr); + if (!hdll) + rb_raise(rb_eRuntimeError, "LoadLibrary: %s\n", RSTRING(dllname)->ptr); + rb_iv_set(self, "__hdll__", Data_Wrap_Struct(self, 0, Win32API_FreeLibrary, hdll)); hproc = GetProcAddress(hdll, RSTRING(proc)->ptr); if (!hproc) { str = rb_str_new3(proc); diff --git a/ext/curses/curses.c b/ext/curses/curses.c index b0e2ef5bc7..db620654bd 100644 --- a/ext/curses/curses.c +++ b/ext/curses/curses.c @@ -424,7 +424,6 @@ window_s_new(class, h, w, top, left) wclear(window); win = prep_window(class, window); args[0] = h; args[1] = w; args[2] = top; args[3] = left; - rb_obj_call_init(win, 4, args); return win; } @@ -448,7 +447,6 @@ window_subwin(obj, h, w, top, left) NUM2INT(top), NUM2INT(left)); win = prep_window(cWindow, window); args[0] = h; args[1] = w; args[2] = top; args[3] = left; - rb_obj_call_init(win, 4, args); return win; } diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c index 2aeede2672..c68c5b427e 100644 --- a/ext/dbm/dbm.c +++ b/ext/dbm/dbm.c @@ -91,7 +91,6 @@ fdbm_s_open(argc, argv, klass) obj = Data_Make_Struct(klass,struct dbmdata,0,free_dbm,dbmp); dbmp->di_dbm = dbm; dbmp->di_size = -1; - rb_obj_call_init(obj, argc, argv); return obj; } diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index e2c5d5bd3f..cae02d576f 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -560,7 +560,11 @@ def extmake(target) elsif $clean system "#{$make} clean" else - system "#{$make} all" or exit + unless system "#{$make} all" + if ENV["MAKEFLAGS"] != "k" and ENV["MFLAGS"] != "-k" + exit + end + end end end if $static diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c index 116b19d18e..b4d8212717 100644 --- a/ext/gdbm/gdbm.c +++ b/ext/gdbm/gdbm.c @@ -88,7 +88,6 @@ fgdbm_s_open(argc, argv, klass) obj = Data_Make_Struct(klass,struct dbmdata,0,free_dbm,dbmp); dbmp->di_dbm = dbm; dbmp->di_size = -1; - rb_obj_call_init(obj, argc, argv); return obj; } diff --git a/ext/md5/md5init.c b/ext/md5/md5init.c index 552a407c6d..f3dafed336 100644 --- a/ext/md5/md5init.c +++ b/ext/md5/md5init.c @@ -95,7 +95,6 @@ md5_new(argc, argv, class) if (!NIL_P(arg)) { md5_update(obj, arg); } - rb_obj_call_init(obj, argc, argv); return obj; } diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 7838b151a3..ac79d89134 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -530,6 +530,9 @@ ip_addrsetup(host, port) else if (name[0] == '<' && strcmp(name, "") == 0) { mkinetaddr(INADDR_BROADCAST, hbuf, sizeof(hbuf)); } + else if (strlen(name) > sizeof(hbuf)-1) { + rb_raise(rb_eArgError, "hostname too long (%d)", strlen(name)); + } else { strcpy(hbuf, name); } @@ -551,6 +554,9 @@ ip_addrsetup(host, port) hints.ai_socktype = SOCK_DGRAM; error = getaddrinfo(hostp, portp, &hints, &res); if (error) { + if (hostp && hostp[strlen(hostp)-1] == '\n') { + rb_raise(rb_eSocket, "newline at the end of hostname"); + } rb_raise(rb_eSocket, "%s", gai_strerror(error)); } diff --git a/lib/cgi.rb b/lib/cgi.rb index e2ba3141bc..b973904997 100644 --- a/lib/cgi.rb +++ b/lib/cgi.rb @@ -648,10 +648,12 @@ convert string charset, and set language to "ja". =end def Cookie::parse(raw_cookie) cookies = Hash.new([]) + return cookies unless raw_cookie raw_cookie.split('; ').each do |pairs| name, values = pairs.split('=',2) name = CGI::unescape(name) + values ||= "" values = values.split('&').filter{|v| CGI::unescape(v) } if cookies.has_key?(name) cookies[name].value.push(*values) @@ -877,8 +879,7 @@ convert string charset, and set language to "ja". ) end - @cookies = CGI::Cookie::parse((env_table['HTTP_COOKIE'] or - env_table['COOKIE'] or "")) + @cookies = CGI::Cookie::parse((env_table['HTTP_COOKIE'] or env_table['COOKIE'])) end private :initialize_query diff --git a/lib/pstore.rb b/lib/pstore.rb index 9ea9ab3660..05fa5dccc7 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -52,6 +52,10 @@ class PStore in_transaction @table[name] = value end + def delete(name) + in_transaction + @table.delete name + end def roots in_transaction diff --git a/lib/weakref.rb b/lib/weakref.rb index c6fe8cd21b..18b530f2ae 100644 --- a/lib/weakref.rb +++ b/lib/weakref.rb @@ -40,7 +40,7 @@ class WeakRef[^_]") + "\\)\\>\\([^_]\\|$\\)") 2) ;; variables - '("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(nil\\|self\\|true\\|false\\)\\b[^_]" + '("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(nil\\|self\\|true\\|false\\)\\b\\([^_]\\|$\\)" 2 font-lock-variable-name-face) ;; variables '("[$@].\\(\\w\\|_\\)*" @@ -708,8 +713,8 @@ An end of a defun is found by moving forward from the beginning of one." ("^\\s *\\(require\\|load\\).*$" nil include) ("^\\s *\\(include\\|alias\\|undef\\).*$" nil decl) ("^\\s *\\<\\(class\\|def\\|module\\)\\>" "[)\n;]" defun) - ("[^_]\\<\\(begin\\|case\\|else\\|elsif\\|end\\|ensure\\|for\\|if\\|unless\\|rescue\\|then\\|when\\|while\\|until\\|do\\)\\>[^_]" 1 defun) - ("[^_]\\<\\(and\\|break\\|next\\|raise\\|fail\\|in\\|not\\|or\\|redo\\|retry\\|return\\|super\\|yield\\|catch\\|throw\\|self\\|nil\\)\\>[^_]" 1 keyword) + ("[^_]\\<\\(begin\\|case\\|else\\|elsif\\|end\\|ensure\\|for\\|if\\|unless\\|rescue\\|then\\|when\\|while\\|until\\|do\\|yield\\)\\>\\([^_]\\|$\\)" 1 defun) + ("[^_]\\<\\(and\\|break\\|next\\|raise\\|fail\\|in\\|not\\|or\\|redo\\|retry\\|return\\|super\\|yield\\|catch\\|throw\\|self\\|nil\\)\\>\\([^_]\\|$\\)" 1 keyword) ("\\$\\(.\\|\\sw+\\)" nil type) ("[$@].[a-zA-Z_0-9]*" nil struct) ("^__END__" nil label)))) diff --git a/node.h b/node.h index 1f44ba0fff..a7ee1a0d14 100644 --- a/node.h +++ b/node.h @@ -325,9 +325,6 @@ typedef struct RNode { #define NEW_PREEXE(b) NEW_SCOPE(b) #define NEW_POSTEXE() rb_node_newnode(NODE_POSTEXE,0,0,0) -NODE *rb_node_newnode(); -VALUE rb_method_booundp(); - #define NOEX_PUBLIC 0 #define NOEX_UNDEF 1 #define NOEX_CFUNC 1 diff --git a/ruby.h b/ruby.h index 1eaf92eb3f..7dcfac1ea6 100644 --- a/ruby.h +++ b/ruby.h @@ -422,6 +422,7 @@ VALUE rb_funcall __((VALUE, ID, int, ...)); VALUE rb_funcall2 _((VALUE, ID, int, VALUE*)); VALUE rb_funcall3 _((VALUE, ID, int, VALUE*)); int rb_scan_args __((int, VALUE*, const char*, ...)); +VALUE rb_call_super _((int, VALUE*)); VALUE rb_gv_set _((const char*, VALUE)); VALUE rb_gv_get _((const char*)); diff --git a/version.h b/version.h index 5f193a2e17..e59402222b 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.5.2" -#define RUBY_RELEASE_DATE "2000-02-29" +#define RUBY_RELEASE_DATE "2000-03-06" #define RUBY_VERSION_CODE 152 -#define RUBY_RELEASE_CODE 20000229 +#define RUBY_RELEASE_CODE 20000306 -- cgit v1.2.3