1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

2000-03-06

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-03-06 04:15:42 +00:00
parent b014cc337e
commit d7b8e448bf
18 changed files with 127 additions and 67 deletions

View file

@ -1,3 +1,30 @@
Mon Mar 6 12:28:37 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* 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 <bugathlon@yahoo.com>.
Sun Mar 5 20:35:45 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* 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 <nobu.nokada@softhome.net>
* 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 <matz@netlab.co.jp>
* range.c (range_initialize): initialization done in `initialize';

View file

@ -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.

View file

@ -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)

21
eval.c
View file

@ -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;

View file

@ -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);

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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

View file

@ -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;
}

View file

@ -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;
}

View file

@ -530,6 +530,9 @@ ip_addrsetup(host, port)
else if (name[0] == '<' && strcmp(name, "<broadcast>") == 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));
}

View file

@ -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

View file

@ -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

View file

@ -40,7 +40,7 @@ class WeakRef<Delegator
ObjectSpace.call_finalizer orig
ObjectSpace.call_finalizer self
ID_MAP[@__id] = [] unless ID_MAP[@__id]
ID_MAP[@__id].concat self.__id__
ID_MAP[@__id].push self.__id__
ID_REV_MAP[self.id] = @__id
end

View file

@ -314,7 +314,9 @@ The variable ruby-indent-level controls the amount of indentation.
(if (or (and (not (bolp))
(progn
(forward-char -1)
(eq ?_ (char-after (point)))))
(setq w (char-after (point)))
(or (eq ?_ w)
(eq ?. w))))
(progn
(goto-char pnt)
(setq w (char-after (point)))
@ -339,7 +341,9 @@ The variable ruby-indent-level controls the amount of indentation.
(or (bolp)
(progn
(forward-char -1)
(not (eq ?_ (char-after (point))))))
(setq w (char-after (point)))
(not (or (eq ?_ w)
(eq ?. w)))))
(goto-char pnt)
(setq w (char-after (point)))
(not (eq ?_ w))
@ -622,12 +626,12 @@ An end of a defun is found by moving forward from the beginning of one."
(setq font-lock-keywords ruby-font-lock-keywords)))
(defun ruby-font-lock-docs (limit)
(if (re-search-forward "^=begin\\s *$" limit t)
(if (re-search-forward "^=begin\\(\\s \\|$\\)" limit t)
(let (beg)
(beginning-of-line)
(setq beg (point))
(forward-line 1)
(if (re-search-forward "^=end\\s *$" limit t)
(if (re-search-forward "^=end\\(\\s \\|$\\)" limit t)
(progn
(set-match-data (list beg (point)))
t)))))
@ -672,12 +676,13 @@ An end of a defun is found by moving forward from the beginning of one."
"until"
"when"
"while"
"yield"
)
"\\|")
"\\)\\>[^_]")
"\\)\\>\\([^_]\\|$\\)")
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))))

3
node.h
View file

@ -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

1
ruby.h
View file

@ -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*));

View file

@ -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