summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorYukihiro Matsumoto <matz@ruby-lang.org>1995-12-21 00:56:57 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2019-08-17 22:09:32 +0900
commitfca49a8a69a0f6bb4feae74c6cd0e93d7fac8b36 (patch)
tree590a6d2ffcfa31212c1595e34a01d9cda56ba308 /ext
parent8bf1c909dc31fd4bcdc1488cda9fe89a62bc2830 (diff)
version 0.95v0_95
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.95.tar.gz Thu Dec 21 00:56:57 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.95 - fj.sourcesに * eval.c (rb_eval): rescueのロジックをrb_rescue()に一元化. Wed Dec 20 19:30:58 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * Makefile.in: 不要なコンパイルの回避(より完全に). * class.c (singleton_class_new): `single'->`singleton' Tue Dec 19 07:14:33 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * io.c (closed?): IOがcloseされているかどうかを知る述語. * parse.y (primary): 特異メソッドの引数のlex_stateが不適切. * lib/tk.rb: tcl->rubyの変換関数の用意. * ext/extmk.rb.in (install): installの2重コンパイルの回避. * array.c (range_beg_len): range指定の不適切なエラーを訂正. * string.c (str_aref): range指定のバグを削除. * lib/tk.rb (tk_split_list): Tclのリストに対応. Mon Dec 18 09:58:12 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.94 * dln.c (dln_load): HP対応(未確認) * eval.c (Init_Proc): BlockをProcに改名. Sat Dec 16 13:46:14 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * eval.c (rb_eval): retryでイテレータの再実行ができるように. Fri Dec 15 17:14:30 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * eval.c: proc:lambdaの親しみやすい別名 Thu Dec 14 17:21:55 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * eval.c (dyna_var_asgn): イテレータブロック内で最初に初期化された ローカル変数の有効範囲をそのブロック内に限定.これでlambdaと呼べ ないことはない. Wed Dec 13 02:30:58 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * gc.c: autoloadのマークミス. * lib/tk.rb: wishからの複数行の戻り値に対応 * lib/tkcomposite.rb: 複合widget * variable.c (rb_class2path): ICLASSに対応してなかった. * eval.c (ruby_run): exit(0)のバグ Sat Dec 9 01:21:24 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * ext/marshal/marshal.c (dumps|load): 文字列に対する入出力を可能に した(ただし実はファイル経由なのだ). Fri Dec 8 18:29:11 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * ext/marshal/marshal.c: シンボルを一度だけ初期化する. Thu Dec 7 07:58:50 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * parse.y (yylex): 第1引数の正規表現の認識にエラーがあった.同時に 状態数を減らした. * string.c (str_sub): 置換でスキップ幅が大きすぎた. Wed Dec 6 15:14:23 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * string.c (str_sub_method): sub/gsub(!なし)は置換が行なわれなかっ た時,置換前の文字列を返す. Tue Dec 5 00:55:15 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * parse.y (yylex): 括弧を省略した時の引数展開の`*'に対応. * eval.c (ruby_run): EXITハンドラ内での例外に対応. * bignum.c (big_cmp): BignumとFixnumの比較で落ちる. Mon Dec 4 14:21:18 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * parse.y (call_op): コンパイル時の定数式の展開をやめた.労多くし て益少ないと判断したので. Thu Nov 30 01:35:15 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * lib/tk.rb: {Radio,Check}Buttonのvariableの実装. * eval.c (rb_yield_0): Block.callがネストした時のバグ. * io.c (f_select): 常に配列3つをふくむ配列を返すように * lib/tk.rb: fileeventをruby側で実装. Wed Nov 29 17:53:23 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * variable.c (rb_ivar_get): selfを常に指定するように. Tue Nov 14 00:07:29 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * lib/tk.rb: Tk4.0対応 Mon Nov 13 16:23:32 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.93 Thu Nov 9 23:26:01 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * gc.c (gc_mark): モジュールのMixinのマーク忘れ. * parse.y (f_arglist): メソッド定義の引数を括弧で括らなくても良い ようにした. Wed Nov 8 00:17:51 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * eval.c (rb_yield_0): 未初期化のローカル変数があった. * eval.c (rb_eval): pendig signalのチェックをeval実行後に行うよう にした.でないとシグナルの発生と検出が遠く離れてしまう事がある. * parse.y: class文のsuperclass部を定数から式に拡張した. * lib/tk.rb: Tkのほぼ全ウィンドウクラスに対応.キャンバスとテキス ト上のオブジェクトが残っている. Tue Nov 7 08:18:37 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * signal.c (trap): ブロックを指定できるように. Mon Nov 6 16:44:00 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * eval.c (f_caller): 呼出元の情報を得る. * ext/tkutil/tkutil.c: wishのstderr出力を監視することで,エラー処 理を行う. * ext/tkutil/tkutil.c: wishとの通信部をCで記述. Sat Nov 4 01:12:59 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * sample/ruby-mode.el (ruby-calculate-indent): インデントの計算を もう少しスマートにした(正規表現のチェック,継続行のチェック). * eval.c (rb_call): 無限再帰を避けるため,関数のネストレベルの制限 を行なう. * lib/tk.rb: Tkインターフェース.まだ不完全だが. * eval.c (rb_yield_0): 空のBlockのバグ. * sample/ruby-mode.el (ruby-calculate-indent): 行末の演算子による 行継続に対応. Fri Nov 3 12:56:21 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * eval.c (rb_call): 本体が空の関数の実行にバグ. * parse.y (var_extend): 文字列の末尾の変数展開のバグ. * variable.c (rb_gvar_set): traceの評価時にに変数値を与えるように. * eval.c (f_require): ruby scriptのrequireにbug. * variable.c (rb_const_get): モジュールのinclude対策. Thu Oct 19 13:56:06 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * dln.c (dln_load): HP対応でのtypo. Wed Oct 18 17:39:39 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.92 * object.c (krn_type): オブジェクトの動的な型を返すメソッド. Tue Oct 17 00:48:18 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * ruby.c (proc_options): -X オプション.chdirだけを行う. * re.c (reg_search): 漢字コードを途中で変更できるように.コンパイ ル時のコードが変更された時にはマッチの直前に正規表現の再コンパイ ルを行う.定数KCODEから変数$KCODEへ. * parse.y: ()のなかにcompexprを許す. * re.c (reg_search): メモリリークを直した. Fri Oct 13 13:19:19 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * string.c (str_sub): 文字列置換にバグ. * string.c (str_strip_bang): 文字列の後ろの長さの調整が行われてい なかった. * re.c (reg_search): $&, $1...のはローカルに束縛するようになった. 呼び出したメソッドでのマッチは現スコープの$&などの値に影響しない. マッチの情報をスコープ外で得たいときには$~を使って束縛情報を持ち 出す必要がある. Thu Oct 12 00:33:33 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * re.c (reg_search): String:split, String:indexでは$&, $1...が変化 しないようにした. * io.c (rb_str_setter): setterの仕様が変更になっていた. * variable.c (f_trace_var): 第2引数を省略してイテレータとして呼べ るように. Wed Oct 11 11:50:59 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.91 * variable.c (var_setter): 引数が間違っていた.致命的バグ. * io.c (pipe_open): $stderrの値が変更されている時にはそちらを 子プロセスのstderrに設定する. Mon Oct 9 13:06:33 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * object.c (mod_to_s): モジュール内のモジュールは`::'を使った表現 で表示されるように. * variable.c (rb_gvar_set): 代入によるループが発生しないように, trace内での代入ではtraceを評価しない. * struct.c (struct_equal): structのequal判定にクラスの一致を含めた. Sat Oct 7 00:18:32 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * eval.c (rb_eval): defined?の機能を拡張(yieldのチェック,superの 存在など). Fri Oct 6 12:06:47 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.90 * st.c (st_foreach): 要素を削除した時に要素数が変化していなかった. * hash.c (hash_values): バグ修正.keysを返していた…. * parse.y (call_op): defined? の引数では定数の畳み込みを行わない (チェックする前にコンパイルエラーになっては困る). * スコープ生成の一部見直し. Thu Oct 5 00:29:43 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * 関数とクラスの命名規則を変更した.関数名,変数名の全面書き換え. * gc.c (looks_pointerp): ヒープチェックの高速化. * struct.c (Fstruct_aset): 構造体に対する`[]='. (struct_set): 構造体メンバに対する代入. Wed Oct 4 09:54:07 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.89 * eval.c (Frequire): ダイナミックロードのエラーチェックを厳しく. * struct.c: structの構造を完全に書き換えた.以前は順序付きの id->valueの連想配列であったが,今度は構造体毎に新しいクラスを生 成するようにした. * parse.y: `::'の意味をAssocの生成からクラス(モジュール)内の定数ア クセスへ変更. * assoc.c: なくす. Tue Oct 3 13:31:08 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * variable.c (Ftrace_var): trace_var, 大域変数への書き込みhookを設 定する. * variable.c: global_entryの構成を書き換えた.これでtrace_varを実 装できる. * file.c (Ffile_stat): "&"で直前のfstatの結果も参照できるように. Fri Sep 29 14:15:13 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.88 * dln.c (dln_load): AIXとHPに対応したコードを入れた(動作は未確認). * ext/extmk.rb.in: 必要に応じて,定数EXTLIBを定義するように. * dln.c (dln_load): dln独立に書き換える.将来の拡張用. (load_1): dln_a_outにおいてソースコードでライブラリを明示的にロー ドする必要がないように変更した. Thu Sep 28 13:31:37 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * sample/ruby-mode.el: もっとましなhilit19対応(正規表現). Wed Sep 27 04:12:44 1995 Takahasi Mamoru <taka@soum.co.jp> * sample/test.rb: echoで-nを使わないように(SysV対策). * ext/extmk.rb.in: sub -> sub! Tue Sep 26 19:12:42 1995 Yasuo OHBA <jammy@csg.mes.co.jp> * dln.c (dln_find_1): `.', `..'から始まるパスに対応した. Mon Sep 25 12:33:03 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.87 Sat Sep 23 10:00:18 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * eval.c (Fmod_modfunc): メソッドをprivateにし,同時に特異メソッド も定義するメソッド.パッケージ的使い方のモジュール用. Fri Sep 22 11:02:44 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * lib/find.rb: findを提供するライブラリ * variable.c (rb_define_variable): hookの設定を分離. (add_hook): 1変数に対して複数のhookを設定できるように. Thu Sep 21 00:22:11 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * string.c (Fstr_frozen): 文字列が更新不可かどうかをチェックする述 語メソッド. * hash.c (Fhash_aset): keyが文字列の時,キーの内容が変化しないよう に,dupしてfreezeする. Wed Sep 20 16:12:44 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.86 * ext/extmk.rb.in (have_header): キャッシュにバグ. * ext/extmk.rb.in (have_library): 引数の順序が変わった. Thu Sep 14 18:00:59 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * object.c (obj_is_instance_of): is_member_ofから名称変更. Wed Sep 13 15:44:35 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * string.c (Fstr_tr_bang): 範囲外の文字に対する変換バグ. Tue Sep 12 14:27:58 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * file.c (Sfile_expand_path): expand_file_name -> expand_pathに名 称変更. * enum.c (Fenum_member): includes? -> member? に名称変更. * string.c (Fstr_each_byte): StringはByteArrayであるという基本に戻っ て,eachの定義をeach_byteに変更した.今までのeachはeach_lineでア クセスできる. Mon Sep 11 18:31:17 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * file.c (cache_stat): ファイル名として"&"を指定すると直前の stat(2)の結果を再利用するように. Fri Sep 8 14:18:51 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * ruby.texi: `!', `?'に対応してアップデート. * parse.y: defined -> defined? * file.c: FileOpの一文字メソッドをなくす.一文字テストはtestメソッ ドにまかせる. * parse.y (yylex): 変数名の後ろに`?'も許す.述語メソッドの後ろに `?'を追加する. Thu Sep 7 20:01:33 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * string.c: 文字列の中身を更新するメソッドの名前の終りに`!'を付加. `!'の無いバージョンも用意した. * parse.y: 変数名の後ろに`!'を許す. Wed Sep 6 14:12:19 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.85 * string.c (Fstr_dup): 文字列の複製を作る (Fstr_freeze): 文字列の更新不可属性を設定できるように. (Fsub/Fgsub): $_の内容をdupしてから置換を行うように. * ruby.h (CLONESETUP): flagsの状態もコピー Tue Sep 5 01:27:50 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * sample/test.rb: 失敗の検出を厳しく. Fri Aug 25 14:31:02 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * process.c (Ffork): イテレータとしても動作するように. * version 0.84 * signal.c (sig_beg): ハンドラが設定されている時には再設定しない. * ext/extmk.rb.in (create_makefile): shared objectのリンクの際に `-l'オプションを指定するように. * signal.c (trap): `EXIT'で終了処理を行う設定が出来る. Wed Aug 16 00:13:22 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * signal.c (sig_beg): デフォルトではbegin節の中でだけSIGINTを捕捉 するように変更. * io.c (io_ctl): fcntlを持たないシステムにも対応. * 各ディレクトリに分散していたMANIFESTをまとめた.拡張モジュール毎 には必要. * string.c (Sstr_new,str_sub,Fstr_crypt): 引数を自動的に文字列に変 換するように. Sat Aug 12 00:44:02 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * string.c (Fstr_crypt): PD cryptを用意した. Fri Aug 11 14:37:03 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * assoc.c (Fassoc_clone): assocもcloneできるように. * io.c: マクロREAD_DATA_PENDINGの定義を変更(Linux対応) * io.c (io_fptr_finalize): ftprの開放時の処理を指定できるように. Wed Aug 9 16:52:41 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * eval.c (rb_provided): 複数のfeatureをロードすると無限ループに落 ちるという単純な(しかし凶悪な)ミス. * ext/extmk.rb.in (install): dlopen対応を行った.今までdlnにしか十 分に対応していなかった. Tue Aug 8 14:17:06 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.83 Mon Aug 7 12:47:41 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * parse.y: resque -> rescue.恥ずかしいがtypoを残しておくわけには いかないよなあ.なんで今まで気がつかなかったのか…. Thu Aug 3 18:18:05 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * missing/nt.c: NT移植用の関数群をまとめた. * variable.c (rb_const_get): また例外を発生するようにした.defined がある以上例外を発生させない理由がないので(例外が発生した方がタ イプミスの検出などの点で有利). * variable.c (Fautoload): autoloadを実装.今度は使えるか. Mon Jul 31 15:44:21 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * parse.y (arg_ambiguous): 第1引数のあいまいさを警告(-vオプション で有効). * eval.c (rb_eval): `-v'オプションをつけて`def'が呼ばれると不必要 なエラーメッセージが出た. * parse.y (yylex): メソッドの第1引数の判定をもうちょっと賢くした. Fri Jul 28 19:04:43 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * parse.y (yylex): `+/-/['の直前に空白が来るかどうかで動作を変更し た(混乱のもとか?) Wed Jul 26 09:21:23 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.82a * sprintf.c (Fsprintf): `%s'で'\0'を含む文字列に対応. * pack.c (Fpck_pack): packの要素確保のバグ. * eval.c (Floop): 無限ループのイテレータ. * io.c (next_argv): 存在しないファイル名が指定された時のエラー処理 が行われていなかった. Mon Jul 24 17:37:34 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.82 * ext/extmk.rb.in (install): 拡張モジュールをstatic linkする場合は そのモジュールが既にrequireされたのと同じようにfeatureを設定する. これで拡張モジュールの機能が必要な時には(static linkされているか どうかにかかわらず)requireすればよくなる. * eval.c (Frequire): `$"'に格納する文字列をフルパスでなくフィーチャ 名とする.rubyスクリプトをロードした時には`.rb',オブジェクトを ロードした時には`.o'をフィーチャ名に付加する.lispのrequireと provideの働きに(少し)近い. Thu Jul 20 12:50:05 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * Makefile.in (test): make testができるように. * struct.c (struct_new): typo. * eval.c (rb_eval): `defined'を追加.メソッド/変数/定数の定義状態 を知る事が出来る. Wed Jul 19 18:04:01 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.81 Mon Jul 17 14:53:51 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * variable.c (rb_const_get): 未初期化のCONSTANTの値をnilにした.し かし,今後また例外に戻す可能性はある.要はoptionalなクラス/モジュー ルが存在するかチェックしたいだけなんだな. * st.c (int): grow_factorを固定にした(大嶋さんのマシンに対応). Fri Jul 14 00:48:40 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * ext/extmk.rb.in: キャッシュのバグを修正. * parse.y (var_extend): #{$数字}に対応した. * dln.c (dln_load_1): `Init_FILENAME'だけを有効に.`init_*'は今後 実行しない. * ext/etc/etc.c : Etcモジュールを拡張モジュールとして分離.実はNT 対応への布石だったりするかもしれない. Tue Jul 11 17:12:48 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * gcc -Wallで出たwarningを元にソースを変更. * signal.c (trap): typo. Fri Jul 7 10:08:51 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.80 * ruby.texi: texinfo documentを提供.specとruby.1は無くなった. * signal.c (Ftrap): 割込み禁止中の例外発生に対応. * eval.c (Flambda): Blockオブジェクトを返す.Block.newと同義. Thu Jul 6 00:35:03 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * signal.c (Ftrap): SIG_DFLの処理を変更.SIGINTへのデフォルトハン ドラを用意(例外を発生する). * file.c (Sfile_expand_fname): パス名を絶対パスに展開するメソッド. (Sfile_basename): basenameを得るメソッド.拡張子も外せる. (Sfile_dirname): basenameの反対. * eval.c (rb_call): argument評価中の例外発生に対応. * file.c (Ftest): `M', `A', `C'を追加. Tue Jul 4 12:36:33 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * file.c (Ftest): ファイルテスト用メソッド. * ruby.c (proc_options): `-r'オプションを追加. * parse.y (f_args): デフォルト引数を追加. * eval.c (rb_call): 該当する引数が無い時,rest引数の値をnilに. * numeric.c (num_equal): 数値以外との比較で例外が発生していた. FALSEを返すように. * eval.c (masign): 多重代入のrest部の動作がおかしかった. Sat Jun 17 01:03:16 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * parse.y (gettable): 未初期化のローカル変数の参照(独立した識別子) は正式にメソッド呼び出しとした. * parse.y (read_escape): tokenbufを使わないように修正.それにとも ない,`\C-x',`\M-x'などのエスケープ表現を復活.これでドキュメン トと実際の処理系が一致した. Thu Jun 15 15:42:00 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * re.c (re_regcomp): cacheのチェックを改善. Mon Jun 12 18:50:51 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * version 0.79 Sat Jun 10 00:25:01 1995 Yukihiro Matsumoto <matz@caelum.co.jp> * re.c (re_regcomp): cache判定に`$='の値も反映させた. * sample/test.rb: test suite作成. Fri Jun 9 15:58:34 1995 Yukihiro Matsumoto <matz@ix-02> * re.c (re_regcomp): cacheの判定が間違っていた. Fri Jun 9 00:01:35 1995 Yukihiro Matsumoto (matz@dyna) * eval.c (rb_yield): block構造体に初期化していないメンバ(iter)があっ たのでイテレータのネストが正しく動作しなかった. Thu Jun 8 00:59:03 1995 Yukihiro Matsumoto (matz@dyna) * re.c (=~): String以外との比較がFALSEを返すように(例外を発生して いた). * extmk.rb.in: 判定した値をファイルにキャッシュするようにした. * assoc.c (to_a): to_aメソッドが再定義されていなかった. * eval.c (rb_eval): 初期化されていないローカル変数へのアクセスを引 数の無いメソッド呼び出しと解釈する.ただし,(現状では)メソッドが 定義されていない場合,エラーにせず変数未初期化のwaringを出して nilを返している.「ruby -pe print」などが実行できるという意味で はありがたいこの仕様は,しかし今後の検討が必要である.-- メソッ ド呼び出しとするのを止めるか(以前の仕様),いつもメソッド呼び出し とする(未定義ならばエラー)か,今の仕様で行くか. * eval.c (rb_eval): 初期化されていないローカル変数へのアクセスで (evalなどで)初期化された事が分かった時には以後初期化されたローカ ル変数とみなす. Wed Jun 7 11:58:12 1995 Yukihiro Matsumoto <matz@ix-02> * eval.c (rb_fail): 例外処理後も`$!'をクリアしないように. (rb_fail): `$!'変数に最後に改行を追加しない. * io.c (Fprint): privateメソッドに変更.引数を取らない時の動作を変 更(`$_'を出力する). (Fio_print): 出力先指定のprintメソッド. (Fio_printf): 出力先指定のprintfメソッド. * parse.y: not演算子の追加.優先順位の低い`!'演算子. Mon Jun 5 19:00:55 1995 Yukihiro Matsumoto <matz@ix-02> * version 0.78 Fri Jun 2 17:52:03 1995 Yukihiro Matsumoto <matz@ix-02> * ruby.c (proc_options): -Iオプションで`$:'への追加される順番を修 正した. Fri Jun 2 00:36:34 1995 Yukihiro Matsumoto (matz@dyna) * parse.y: while修飾子の動作を通常のwhileと同じにした.ただし, begin式へのwhile修飾子だけはdo..while型のループとなる. Wed May 31 18:36:30 1995 Yukihiro Matsumoto <matz@ix-02> * version 0.77 Mon May 29 18:39:37 1995 Yukihiro Matsumoto <matz@ix-02> * ext/extmk.rb.in (install): 拡張モジュールもインストールできるよ うに. Fri May 26 14:43:01 1995 Yukihiro Matsumoto <matz@ix-02> * process.c (Fsystem): 戻り値をサブプロセスの失敗/成功を表す真偽値 にした.終了ステータスは`$?'で得る. Tue May 23 10:58:11 1995 Yukihiro Matsumoto <matz@ix-02> * string.c (Fstr_upto): 無限ループに陥らないように. * parse.y (cond): `||'などの右辺に制御式が書けるように,条件式がか ならずしも値を持たなくても良いようにした. * ext/marshal/marshal.c: オブジェクトの読み書きをメソッドの再定義 でコントロールできるように.インスタンスが`_dump_to'というメソッ ドを定義している時はそちらを使うように. * ext/extmk.rb.in: static linkも設定できるような仕様にした. ext/Setupというファイルにディレクトリ名を記述するとそのディレク トリに存在するモジュールはstatic linkされる(はず). * eval.c (rb_eval): `..'を文法に組み込み,`..'と`...'の動作をperl に合わせた. Sat May 20 01:22:48 1995 Yukihiro Matsumoto (matz@dyna) * io.c (select): timeout時と割込み時の動作の明確化. Co-authored-by: Takahasi Mamoru <taka@soum.co.jp> Co-authored-by: Yasuo OHBA <jammy@csg.mes.co.jp>
Diffstat (limited to 'ext')
-rw-r--r--ext/MANIFEST3
-rw-r--r--ext/Setup7
-rw-r--r--ext/dbm/MANIFEST5
-rw-r--r--ext/dbm/dbm.c435
-rw-r--r--ext/dbm/dbm.doc107
-rw-r--r--ext/dbm/depend1
-rw-r--r--ext/dbm/extconf.rb4
-rw-r--r--ext/etc/MANIFEST5
-rw-r--r--ext/etc/depend1
-rw-r--r--ext/etc/etc.c260
-rw-r--r--ext/etc/etc.doc73
-rw-r--r--ext/etc/extconf.rb7
-rw-r--r--ext/extmk.rb.in398
-rw-r--r--ext/marshal/MANIFEST4
-rw-r--r--ext/marshal/depend2
-rw-r--r--ext/marshal/marshal.c565
-rw-r--r--ext/marshal/marshal.doc45
-rw-r--r--ext/socket/MANIFEST5
-rw-r--r--ext/socket/depend1
-rw-r--r--ext/socket/extconf.rb6
-rw-r--r--ext/socket/socket.c785
-rw-r--r--ext/socket/socket.doc227
-rw-r--r--ext/tkutil/MANIFEST3
-rw-r--r--ext/tkutil/extconf.rb11
-rw-r--r--ext/tkutil/tkutil.c54
25 files changed, 2921 insertions, 93 deletions
diff --git a/ext/MANIFEST b/ext/MANIFEST
deleted file mode 100644
index 9580b61544e..00000000000
--- a/ext/MANIFEST
+++ /dev/null
@@ -1,3 +0,0 @@
-MANIFEST
-extmk.rb.in
-
diff --git a/ext/Setup b/ext/Setup
new file mode 100644
index 00000000000..93586ea0e6a
--- /dev/null
+++ b/ext/Setup
@@ -0,0 +1,7 @@
+#option nodynamic
+
+#dbm
+#etc
+#marshal
+#socket
+tkutil
diff --git a/ext/dbm/MANIFEST b/ext/dbm/MANIFEST
new file mode 100644
index 00000000000..141b8dd6017
--- /dev/null
+++ b/ext/dbm/MANIFEST
@@ -0,0 +1,5 @@
+MANIFEST
+dbm.c
+dbm.doc
+depend
+extconf.rb
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
new file mode 100644
index 00000000000..dbdd99c0ca6
--- /dev/null
+++ b/ext/dbm/dbm.c
@@ -0,0 +1,435 @@
+/************************************************
+
+ dbm.c -
+
+ $Author: matz $
+ $Date: 1995/01/10 10:42:24 $
+ created at: Mon Jan 24 15:59:52 JST 1994
+
+ Copyright (C) 1995 Yukihiro Matsumoto
+
+************************************************/
+
+#include "ruby.h"
+
+#include <ndbm.h>
+#include <fcntl.h>
+#include <errno.h>
+
+VALUE cDBM;
+static ID id_dbm;
+
+extern VALUE mEnumerable;
+
+static void
+closeddbm()
+{
+ Fail("closed DBM file");
+}
+
+#define GetDBM(obj, dbmp) {\
+ DBM **_dbm;\
+ Get_Data_Struct(obj, id_dbm, DBM*, _dbm);\
+ dbmp = *_dbm;\
+ if (dbmp == Qnil) closeddbm();\
+}
+
+static void
+free_dbm(dbmp)
+ DBM **dbmp;
+{
+ if (*dbmp) dbm_close(*dbmp);
+}
+
+#define MakeDBM(obj, dp) {\
+ DBM **_dbm;\
+ if (!id_dbm) id_dbm = rb_intern("dbm");\
+ Make_Data_Struct(obj,id_dbm,DBM*,Qnil,free_dbm,_dbm);\
+ *_dbm=dp;\
+}
+
+static VALUE
+fdbm_s_open(argc, argv, class)
+ int argc;
+ VALUE *argv;
+ VALUE class;
+{
+ VALUE file, vmode;
+ DBM *dbm, **dbm2;
+ int mode;
+ VALUE obj;
+
+ if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
+ mode = 0666; /* default value */
+ }
+ else if (NIL_P(vmode)) {
+ mode = -1; /* return nil if DB not exist */
+ }
+ else {
+ mode = NUM2INT(vmode);
+ }
+ Check_Type(file, T_STRING);
+
+ dbm = Qnil;
+ if (mode >= 0)
+ dbm = dbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode);
+ if (!dbm)
+ dbm = dbm_open(RSTRING(file)->ptr, O_RDWR, mode);
+ if (!dbm)
+ dbm = dbm_open(RSTRING(file)->ptr, O_RDONLY, mode);
+
+ if (!dbm) {
+ if (mode == -1) return Qnil;
+ rb_sys_fail(RSTRING(file)->ptr);
+ }
+
+ obj = obj_alloc(class);
+ MakeDBM(obj, dbm);
+
+ return obj;
+}
+
+static VALUE
+fdbm_close(obj)
+ VALUE obj;
+{
+ DBM **dbmp;
+
+ Get_Data_Struct(obj, id_dbm, DBM*, dbmp);
+ if (*dbmp == Qnil) Fail("already closed DBM file");
+ dbm_close(*dbmp);
+ *dbmp = Qnil;
+
+ return Qnil;
+}
+
+static VALUE
+fdbm_fetch(obj, keystr)
+ VALUE obj, keystr;
+{
+ datum key, value;
+ DBM *dbm;
+
+ Check_Type(keystr, T_STRING);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
+
+ GetDBM(obj, dbm);
+ value = dbm_fetch(dbm, key);
+ if (value.dptr == Qnil) {
+ return Qnil;
+ }
+ return str_new(value.dptr, value.dsize);
+}
+
+static VALUE
+fdbm_indexes(obj, args)
+ VALUE obj;
+ struct RArray *args;
+{
+ VALUE *p, *pend;
+ struct RArray *new;
+ int i = 0;
+
+ if (!args || args->len == 1 && TYPE(args->ptr) != T_ARRAY) {
+ args = (struct RArray*)rb_to_a(args->ptr[0]);
+ }
+
+ new = (struct RArray*)ary_new2(args->len);
+
+ p = args->ptr; pend = p + args->len;
+ while (p < pend) {
+ new->ptr[i++] = fdbm_fetch(obj, *p++);
+ new->len = i;
+ }
+ return (VALUE)new;
+}
+
+static VALUE
+fdbm_delete(obj, keystr)
+ VALUE obj, keystr;
+{
+ datum key;
+ DBM *dbm;
+
+ Check_Type(keystr, T_STRING);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
+
+ GetDBM(obj, dbm);
+ if (dbm_delete(dbm, key)) {
+ Fail("dbm_delete failed");
+ }
+ return obj;
+}
+
+static VALUE
+fdbm_shift(obj)
+ VALUE obj;
+{
+ datum key, val;
+ DBM *dbm;
+ VALUE keystr, valstr;
+
+ GetDBM(obj, dbm);
+
+ key = dbm_firstkey(dbm);
+ if (!key.dptr) return Qnil;
+ val = dbm_fetch(dbm, key);
+ dbm_delete(dbm, key);
+
+ keystr = str_new(key.dptr, key.dsize);
+ valstr = str_new(val.dptr, val.dsize);
+ return assoc_new(keystr, valstr);
+}
+
+static VALUE
+fdbm_delete_if(obj)
+ VALUE obj;
+{
+ datum key, val;
+ DBM *dbm;
+ VALUE keystr, valstr;
+
+ GetDBM(obj, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ keystr = str_new(key.dptr, key.dsize);
+ valstr = str_new(val.dptr, val.dsize);
+ if (rb_yield(assoc_new(keystr, valstr))
+ && dbm_delete(dbm, key)) {
+ Fail("dbm_delete failed");
+ }
+ }
+ return obj;
+}
+
+static VALUE
+fdbm_clear(obj)
+ VALUE obj;
+{
+ datum key;
+ DBM *dbm;
+
+ GetDBM(obj, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ if (dbm_delete(dbm, key)) {
+ Fail("dbm_delete failed");
+ }
+ }
+ return obj;
+}
+
+static VALUE
+fdbm_store(obj, keystr, valstr)
+ VALUE obj, keystr, valstr;
+{
+ datum key, val;
+ DBM *dbm;
+
+ if (valstr == Qnil) {
+ fdbm_delete(obj, keystr);
+ return Qnil;
+ }
+
+ Check_Type(keystr, T_STRING);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
+ Check_Type(valstr, T_STRING);
+ val.dptr = RSTRING(valstr)->ptr;
+ val.dsize = RSTRING(valstr)->len;
+
+ GetDBM(obj, dbm);
+ if (dbm_store(dbm, key, val, DBM_REPLACE)) {
+ dbm_clearerr(dbm);
+ if (errno == EPERM) rb_sys_fail(Qnil);
+ Fail("dbm_store failed");
+ }
+ return valstr;
+}
+
+static VALUE
+fdbm_length(obj)
+ VALUE obj;
+{
+ datum key;
+ DBM *dbm;
+ int i = 0;
+
+ GetDBM(obj, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ i++;
+ }
+ return INT2FIX(i);
+}
+
+static VALUE
+fdbm_each_value(obj)
+ VALUE obj;
+{
+ datum key, val;
+ DBM *dbm;
+
+ GetDBM(obj, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ rb_yield(str_new(val.dptr, val.dsize));
+ }
+ return obj;
+}
+
+static VALUE
+fdbm_each_key(obj)
+ VALUE obj;
+{
+ datum key;
+ DBM *dbm;
+
+ GetDBM(obj, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ rb_yield(str_new(key.dptr, key.dsize));
+ }
+ return obj;
+}
+
+static VALUE
+fdbm_each_pair(obj)
+ VALUE obj;
+{
+ datum key, val;
+ DBM *dbm;
+ VALUE keystr, valstr;
+
+ GetDBM(obj, dbm);
+
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ keystr = str_new(key.dptr, key.dsize);
+ valstr = str_new(val.dptr, val.dsize);
+ rb_yield(assoc_new(keystr, valstr));
+ }
+
+ return obj;
+}
+
+static VALUE
+fdbm_keys(obj)
+ VALUE obj;
+{
+ datum key;
+ DBM *dbm;
+ VALUE ary;
+
+ ary = ary_new();
+ GetDBM(obj, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ ary_push(ary, str_new(key.dptr, key.dsize));
+ }
+
+ return ary;
+}
+
+static VALUE
+fdbm_values(obj)
+ VALUE obj;
+{
+ datum key, val;
+ DBM *dbm;
+ VALUE ary;
+
+ ary = ary_new();
+ GetDBM(obj, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ ary_push(ary, str_new(val.dptr, val.dsize));
+ }
+
+ return ary;
+}
+
+static VALUE
+fdbm_has_key(obj, keystr)
+ VALUE obj, keystr;
+{
+ datum key, val;
+ DBM *dbm;
+
+ Check_Type(keystr, T_STRING);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
+
+ GetDBM(obj, dbm);
+ val = dbm_fetch(dbm, key);
+ if (val.dptr) return TRUE;
+ return FALSE;
+}
+
+static VALUE
+fdbm_has_value(obj, valstr)
+ VALUE obj, valstr;
+{
+ datum key, val;
+ DBM *dbm;
+
+ Check_Type(valstr, T_STRING);
+ val.dptr = RSTRING(valstr)->ptr;
+ val.dsize = RSTRING(valstr)->len;
+
+ GetDBM(obj, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ if (val.dsize == RSTRING(valstr)->len &&
+ memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static VALUE
+fdbm_to_a(obj)
+ VALUE obj;
+{
+ datum key, val;
+ DBM *dbm;
+ VALUE ary;
+
+ GetDBM(obj, dbm);
+
+ ary = ary_new();
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ ary_push(ary, assoc_new(str_new(key.dptr, key.dsize),
+ str_new(val.dptr, val.dsize)));
+ }
+
+ return ary;
+}
+
+Init_dbm()
+{
+ cDBM = rb_define_class("DBM", cObject);
+ rb_include_module(cDBM, mEnumerable);
+
+ rb_define_singleton_method(cDBM, "open", fdbm_s_open, -1);
+ rb_define_method(cDBM, "close", fdbm_close, 0);
+ rb_define_method(cDBM, "[]", fdbm_fetch, 1);
+ rb_define_method(cDBM, "[]=", fdbm_store, 2);
+ rb_define_method(cDBM, "indexes", fdbm_indexes, -2);
+ rb_define_method(cDBM, "length", fdbm_length, 0);
+ rb_define_alias(cDBM, "size", "length");
+ rb_define_method(cDBM, "each", fdbm_each_pair, 0);
+ rb_define_method(cDBM, "each_value", fdbm_each_value, 0);
+ rb_define_method(cDBM, "each_key", fdbm_each_key, 0);
+ rb_define_method(cDBM, "each_pair", fdbm_each_pair, 0);
+ rb_define_method(cDBM, "keys", fdbm_keys, 0);
+ rb_define_method(cDBM, "values", fdbm_values, 0);
+ rb_define_method(cDBM, "shift", fdbm_shift, 1);
+ rb_define_method(cDBM, "delete", fdbm_delete, 1);
+ rb_define_method(cDBM, "delete_if", fdbm_delete_if, 0);
+ rb_define_method(cDBM, "clear", fdbm_clear, 0);
+ rb_define_method(cDBM, "includes", fdbm_has_key, 1);
+ rb_define_method(cDBM, "has_key", fdbm_has_key, 1);
+ rb_define_method(cDBM, "has_value", fdbm_has_value, 1);
+
+ rb_define_method(cDBM, "to_a", fdbm_to_a, 0);
+}
diff --git a/ext/dbm/dbm.doc b/ext/dbm/dbm.doc
new file mode 100644
index 00000000000..45f174b7aaf
--- /dev/null
+++ b/ext/dbm/dbm.doc
@@ -0,0 +1,107 @@
+.\" dbm.doc - -*- Indented-Text -*- created at: Thu Mar 23 20:28:31 JST 1995
+
+** DBM(饹)
+
+NDBMե򥢥륯饹ǡȤʸǤʤФ
+ʤȤ¤ȡǡե¸ȤƤ
+Dict饹Ʊͤ˰ȤǤ롥NDBMƤʤƥǤ
+Υ饹ʤ
+
+SuperClass: Object
+
+Included Modules: Enumerable
+
+Methods:
+
+ self [key]
+
+ key򥭡Ȥ֤ͤ
+
+ self [key]= value
+
+ key򥭡ȤơvalueǼ롥valueȤnilꤹȡ
+ keyФܤκȤʤ롥
+
+ clear
+
+ DBMեȤˤ롥
+
+ close
+
+ DBMե򥯥롥ʸ㳰ȯ롥
+
+ delete(key)
+
+ key򥭡ȤȤ롥
+
+ delete_if
+
+ Ǥ륤ƥ졼key::valueȤڥͿơ֥
+ ɾͤλܤ롥
+
+ each
+ each_pair
+
+ key::valueʤڥͿ륤ƥ졼
+
+ each_key
+
+ ƤkeyФƷ֤ƥ졼
+
+ each_value
+
+ ƤvalueФƷ֤ƥ졼
+
+ has_key(key)
+ includes(key)
+
+ keyǡ١¸ߤ֤
+
+ has_value(value)
+
+ valueͤȤȤǡ١¸ߤ
+ ֤
+
+ indexes(ary)
+ indexes(key-1, ..., key-n)
+
+ 1ܤηǤʸȤƼơǤ򥭡
+ ȤǤޤ֤2ܤηǤϳưͤ򥭡
+ Ǥޤ֤.
+
+ keys
+
+ ǡ١¸ߤ륭Ƥޤ֤
+
+ length
+ size
+
+ ǡ١Ǥο֤(:ߤμ¸Ǥǿ
+ 뤿˥ǡ١Τǡ빽Ȥ⤤
+ ĤƻȤ.)
+
+ shift
+
+ ǡ١ǤļФ(ǡ١)
+ key::valueȤڥ֤
+
+ to_a
+
+ ǡ١key-valueڥǤȤ֤
+
+ values
+
+ ǡ١¸ߤƤޤ֤
+
+Single Methods:
+
+ open(dbname[, mode])
+
+ dbnameǻꤷǡ١⡼ɤmodeꤷƥץ
+ 롥modeξάͤ0666Ǥ롥modeȤnilꤹȥǡ
+ ١¸ߤʤˤϿ˥ץ󤻤nil֤
+
+-------------------------------------------------------
+Local variables:
+fill-column: 70
+end:
diff --git a/ext/dbm/depend b/ext/dbm/depend
new file mode 100644
index 00000000000..40139962a70
--- /dev/null
+++ b/ext/dbm/depend
@@ -0,0 +1 @@
+dbm.o: dbm.c ../../ruby.h ../../config.h ../../defines.h
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
new file mode 100644
index 00000000000..5105cd662fb
--- /dev/null
+++ b/ext/dbm/extconf.rb
@@ -0,0 +1,4 @@
+have_library("dbm", "dbm_open")
+if have_func("dbm_open")
+ create_makefile("dbm")
+end
diff --git a/ext/etc/MANIFEST b/ext/etc/MANIFEST
new file mode 100644
index 00000000000..a0f521b3864
--- /dev/null
+++ b/ext/etc/MANIFEST
@@ -0,0 +1,5 @@
+MANIFEST
+etc.c
+etc.doc
+depend
+extconf.rb
diff --git a/ext/etc/depend b/ext/etc/depend
new file mode 100644
index 00000000000..5c95ef117ab
--- /dev/null
+++ b/ext/etc/depend
@@ -0,0 +1 @@
+etc.o : etc.c ../../ruby.h ../../config.h ../../defines.h
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
new file mode 100644
index 00000000000..e4e4098f8a8
--- /dev/null
+++ b/ext/etc/etc.c
@@ -0,0 +1,260 @@
+/************************************************
+
+ etc.c -
+
+ $Author: matz $
+ $Date: 1995/01/10 10:42:32 $
+ created at: Tue Mar 22 18:39:19 JST 1994
+
+************************************************/
+
+#include "ruby.h"
+
+#ifdef HAVE_GETPWENT
+#include <pwd.h>
+#endif
+
+#ifdef HAVE_GETGRENT
+#include <grp.h>
+#endif
+
+static VALUE sPasswd, sGroup;
+
+static VALUE
+etc_getlogin(obj)
+ VALUE obj;
+{
+#ifdef HAVE_GETLOGIN
+ char *getlogin();
+ char *login = getlogin();
+#else
+ char *getenv();
+ char *login = getenv("USER");
+#endif
+
+ if (login)
+ return str_new2(login);
+ return Qnil;
+}
+
+#ifdef HAVE_GETPWENT
+static VALUE
+setup_passwd(pwd)
+ struct passwd *pwd;
+{
+ if (pwd == Qnil) rb_sys_fail("/etc/passwd");
+ return struct_new(sPasswd,
+ str_new2(pwd->pw_name),
+ str_new2(pwd->pw_passwd),
+ INT2FIX(pwd->pw_uid),
+ INT2FIX(pwd->pw_gid),
+ str_new2(pwd->pw_gecos),
+ str_new2(pwd->pw_dir),
+ str_new2(pwd->pw_shell),
+#ifdef PW_CHANGE
+ INT2FIX(pwd->pw_change),
+#endif
+#ifdef PW_QUOTA
+ INT2FIX(pwd->pw_quota),
+#endif
+#ifdef PW_AGE
+ INT2FIX(pwd->pw_age),
+#endif
+#ifdef PW_CLASS
+ str_new2(pwd->pw_class),
+#endif
+#ifdef PW_COMMENT
+ str_new2(pwd->pw_comment),
+#endif
+#ifdef PW_EXPIRE
+ INT2FIX(pwd->pw_expire),
+#endif
+ Qnil);
+}
+#endif
+
+static VALUE
+etc_getpwuid(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+#ifdef HAVE_GETPWENT
+ VALUE id;
+ int uid;
+ struct passwd *pwd;
+
+ if (rb_scan_args(argc, argv, "01", &id) == 1) {
+ uid = NUM2INT(id);
+ }
+ else {
+ uid = getuid();
+ }
+ pwd = getpwuid(uid);
+ if (pwd == Qnil) Fail("can't find user for %d", uid);
+ return setup_passwd(pwd);
+#else
+ return Qnil;
+#endif
+}
+
+static VALUE
+etc_getpwnam(obj, nam)
+ VALUE obj, nam;
+{
+#ifdef HAVE_GETPWENT
+ struct passwd *pwd;
+
+ Check_Type(nam, T_STRING);
+ pwd = getpwnam(RSTRING(nam)->ptr);
+ if (pwd == Qnil) Fail("can't find user for %s", RSTRING(nam)->ptr);
+ return setup_passwd(pwd);
+#else
+ return Qnil;
+#endif
+}
+
+static VALUE
+etc_passwd(obj)
+ VALUE obj;
+{
+#ifdef HAVE_GETPWENT
+ struct passwd *pw;
+
+ if (iterator_p()) {
+ setpwent();
+ while (pw = getpwent()) {
+ rb_yield(setup_passwd(pw));
+ }
+ endpwent();
+ return obj;
+ }
+ pw = getpwent();
+ if (pw == Qnil) Fail("can't fetch next -- /etc/passwd");
+ return setup_passwd(pw);
+#else
+ return Qnil;
+#endif
+}
+
+#ifdef HAVE_GETGRENT
+static VALUE
+setup_group(grp)
+ struct group *grp;
+{
+ VALUE mem;
+ char **tbl;
+
+ mem = ary_new();
+ tbl = grp->gr_mem;
+ while (*tbl) {
+ ary_push(mem, str_new2(*tbl));
+ tbl++;
+ }
+ return struct_new(sGroup,
+ str_new2(grp->gr_name),
+ str_new2(grp->gr_passwd),
+ INT2FIX(grp->gr_gid),
+ mem,
+ Qnil);
+}
+#endif
+
+static VALUE
+etc_getgrgid(obj, id)
+ VALUE obj, id;
+{
+#ifdef HAVE_GETGRENT
+ int gid;
+ struct group *grp;
+
+ gid = NUM2INT(id);
+ grp = getgrgid(gid);
+ if (grp == Qnil) Fail("can't find group for %d", gid);
+ return setup_group(grp);
+#else
+ return Qnil;
+#endif
+}
+
+static VALUE
+etc_getgrnam(obj, nam)
+ VALUE obj, nam;
+{
+#ifdef HAVE_GETGRENT
+ struct group *grp;
+
+ Check_Type(nam, T_STRING);
+ grp = getgrnam(RSTRING(nam)->ptr);
+ if (grp == Qnil) Fail("can't find group for %s", RSTRING(nam)->ptr);
+ return setup_group(grp);
+#else
+ return Qnil;
+#endif
+}
+
+static VALUE
+etc_group(obj)
+ VALUE obj;
+{
+#ifdef HAVE_GETGRENT
+ struct group *grp;
+
+ if (iterator_p()) {
+ setgrent();
+ while (grp = getgrent()) {
+ rb_yield(setup_group(grp));
+ }
+ endgrent();
+ return obj;
+ }
+ return setup_group(getgrent());
+#else
+ return Qnil;
+#endif
+}
+
+VALUE mEtc;
+
+void
+Init_etc()
+{
+ mEtc = rb_define_module("Etc");
+
+ rb_define_module_function(mEtc, "getlogin", etc_getlogin, 0);
+
+ rb_define_module_function(mEtc, "getpwuid", etc_getpwuid, -1);
+ rb_define_module_function(mEtc, "getpwnam", etc_getpwnam, 1);
+ rb_define_module_function(mEtc, "passwd", etc_passwd, 0);
+
+ rb_define_module_function(mEtc, "getgrgid", etc_getgrgid, 1);
+ rb_define_module_function(mEtc, "getgrnam", etc_getgrnam, 1);
+ rb_define_module_function(mEtc, "group", etc_group, 0);
+
+ sPasswd = struct_define("Passwd",
+ "name", "passwd", "uid", "gid",
+ "gecos", "dir", "shell",
+#ifdef PW_CHANGE
+ "change",
+#endif
+#ifdef PW_QUOTA
+ "quota",
+#endif
+#ifdef PW_AGE
+ "age",
+#endif
+#ifdef PW_CLASS
+ "class",
+#endif
+#ifdef PW_COMMENT
+ "comment",
+#endif
+#ifdef PW_EXPIRE
+ "expire",
+#endif
+ Qnil);
+
+#ifdef HAVE_GETGRENT
+ sGroup = struct_define("Group", "name", "passwd", "gid", "mem", Qnil);
+#endif
+}
diff --git a/ext/etc/etc.doc b/ext/etc/etc.doc
new file mode 100644
index 00000000000..2af895c9de2
--- /dev/null
+++ b/ext/etc/etc.doc
@@ -0,0 +1,73 @@
+.\" etc.doc - -*- Indented-Text -*- created at: Fri Jul 14 00:47:15 JST 1995
+
+** Etc(⥸塼)
+
+/etcǥ쥯ȥʲξ뤿Υ⥸塼롥饹˥󥯥롼
+ƻȤȤǤ롥
+
+Methods:
+Single Methods:
+
+ getlogin
+
+ ʬlogin֤̾줬Ԥgetpwuid()Ѥ
+ ɤ
+
+ getpwnam(name)
+
+ /etc/passwdե(뤤DBMեNISǡ١)
+ name̾passwdȥ֤ͤpasswd¤
+ ΤǰʲΥФġ
+
+ struct passwd
+ name # 桼̾(ʸ)
+ passwd # ѥ(ʸ)
+ uid # 桼ID()
+ gid # 롼ID()
+ gecos # gecosե(ʸ)
+ dir # ۡǥ쥯ȥ(ʸ)
+ shell # 󥷥(ʸ)
+ # ʹߤΥФϥƥˤäƤ󶡤ʤ
+ change # ѥѹ()
+ quota # ()
+ age # ()
+ class # 桼饹(ʸ)
+ comment # (ʸ)
+ expire # ͭ()
+ end
+
+ ܺ٤getpwnam(3)򻲾ȤΤȡ
+
+ getpwuid([uid])
+
+ uid桼IDȤpasswdȥ֤ͤgetpwnam()
+ ƱͤǤ롥άˤgetuid()ͤѤ롥ܺ٤
+ getpwuid(3)򻲾ȤΤȡ
+
+ getgrgid(gid)
+
+ /etc/groupե(뤤ϡgetpwnam)򸡺gid򥰥롼
+ IDȤ륰롼ץȥ֤ͤgroup¤Τǰʲ
+ Фġ
+
+ struct group
+ name # 롼̾(ʸ)
+ passwd # 롼פΥѥ(ʸ)
+ gid # 롼ID()
+ mem # 롼ץ̾
+ end
+
+ ܺ٤getgrgid(3)򻲾ȤΤȡ
+
+ getgrnam(name)
+
+ nameȤ̾Υ롼ץȥ֤ͤgetgrgid()Ʊ
+ ͤǤ롥ܺ٤getgrnam(3)򻲾ȡ
+
+ group
+
+ ƤΥ롼ץȥ˥뤿Υƥ졼
+
+ passwd
+
+ Ƥpasswdȥ˥뤿Υƥ졼
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
new file mode 100644
index 00000000000..884de93ec89
--- /dev/null
+++ b/ext/etc/extconf.rb
@@ -0,0 +1,7 @@
+have_library("sun", "getpwnam") # NIS (== YP) interface for IRIX 4
+a = have_func("getlogin")
+b = have_func("getpwent")
+c = have_func("getgrent")
+if a or b or c
+ create_makefile("etc")
+end
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index 25bf6b9027c..b61ccd222fa 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -1,10 +1,40 @@
#! /usr/local/bin/ruby
+if $ARGV[0] == 'install'
+ $install = TRUE
+ $ARGV.shift
+end
+
+if $ARGV[0] == 'clean'
+ $clean = TRUE
+ $ARGV.shift
+end
+
+$cache_mod = FALSE;
+$lib_cache = {}
+$func_cache = {}
+$hdr_cache = {}
+
+if File.exists?("config.cache") then
+ f = open("config.cache", "r")
+ while f.gets
+ case $_
+ when /^lib: ([\w_]+) (yes|no)/
+ $lib_cache[$1] = $2
+ when /^func: ([\w_]+) (yes|no)/
+ $func_cache[$1] = $2
+ when /^hdr: (.+) (yes|no)/
+ $hdr_cache[$1] = $2
+ end
+ end
+ f.close
+end
+
def older(file1, file2)
- if !File.exists(file1) then
+ if !File.exists?(file1) then
return TRUE
end
- if !File.exists(file2) then
+ if !File.exists?(file2) then
return FALSE
end
if File.mtime(file1) < File.mtime(file2)
@@ -13,77 +43,144 @@ def older(file1, file2)
return FALSE
end
-if !File.exists("./Makefile") ||
- older("./Makefile", "../extmk.rb") ||
- older("./Makefile", "./extconf.rb") then
+LINK = "@CC@ -o conftest %s %s conftest.c %s > /dev/null 2>&1"
+CPP = "@CPP@ @CPPFLAGS@ %s conftest.c > /dev/null 2>&1"
- LINK = "@CC@ -o conftest @CFLAGS@ @LDFLAGS@ conftest.c %s > /dev/null 2>&1"
- $defs = []
+def have_library(lib, func)
+ if $lib_cache[lib]
+ if $lib_cache[lib] == "yes"
+ if $libs
+ $libs = $libs + " -l" + lib
+ else
+ $libs = "-l" + lib
+ end
+ return TRUE
+ else
+ return FALSE
+ end
+ end
- def have_library(func, lib)
- cfile = open("conftest.c", "w")
- printf cfile, "\
+ cfile = open("conftest.c", "w")
+ printf cfile, "\
int main() { return 0; }
int t() { %s(); return 0; }
", func
- cfile.close
-
- begin
- if system(format(LINK, "-l" + lib)) != 0
- return FALSE
- end
- ensure
- system "/bin/rm -f conftest*"
- end
+ cfile.close
+ begin
if $libs
- $libs = $libs + " -l" + lib
+ libs = "-l" + lib + " " + $libs
else
- $libs = "-l" + lib
+ libs = "-l" + lib
end
- $defs.push(format("-DHAVE_LIB%s", lib.toupper))
- return TRUE
+ if !system(format(LINK, $CFLAGS, $LDFLAGS, libs))
+ $lib_cache[lib] = 'no'
+ $cache_mod = TRUE
+ return FALSE
+ end
+ ensure
+ system "/bin/rm -f conftest*"
end
- def have_func(func)
+ $libs = libs
+ $lib_cache[lib] = 'yes'
+ $cache_mod = TRUE
+ return TRUE
+end
- cfile = open("conftest.c", "w")
- printf cfile, "\
+def have_func(func)
+ if $func_cache[func]
+ if $func_cache[func] == "yes"
+ $defs.push(format("-DHAVE_%s", func.upcase))
+ return TRUE
+ else
+ return FALSE
+ end
+ end
+
+ cfile = open("conftest.c", "w")
+ printf cfile, "\
char %s();
int main() { return 0; }
int t() { %s(); return 0; }
", func, func
- cfile.close
+ cfile.close
- libs = $libs
- libs = "" if libs == nil
+ libs = $libs
+ libs = "" if libs == nil
- begin
- if system(format(LINK, libs)) != 0
- return FALSE
- end
- ensure
- system "/bin/rm -f conftest*"
+ begin
+ if !system(format(LINK, $CFLAGS, $LDFLAGS, libs))
+ $func_cache[func] = 'no'
+ $cache_mod = TRUE
+ return FALSE
end
- $defs.push(format("-DHAVE_%s", func.toupper))
- return TRUE
+ ensure
+ system "/bin/rm -f conftest*"
+ end
+ $defs.push(format("-DHAVE_%s", func.upcase))
+ $func_cache[func] = 'yes'
+ $cache_mod = TRUE
+ return TRUE
+end
+def have_header(header)
+ if $hdr_cache[header]
+ if $hdr_cache[header] == "yes"
+ header.tr!("a-z./\055", "A-Z___")
+ $defs.push(format("-DHAVE_%s", header))
+ return TRUE
+ else
+ return FALSE
+ end
end
- def create_header()
- if $defs.length > 0
- hfile = open("extconf.h", "w")
- for line in $defs
- line =~ /^-D(.*)/
- printf hfile, "#define %s 1\n", $1
- end
- hfile.close
+ cfile = open("conftest.c", "w")
+ printf cfile, "\
+#include <%s>
+", header
+ cfile.close
+
+ begin
+ if !system(format(CPP, $CFLAGS))
+ $hdr_cache[header] = 'no'
+ $cache_mod = TRUE
+ return FALSE
end
+ ensure
+ system "/bin/rm -f conftest*"
end
+ $hdr_cache[header] = 'yes'
+ header.tr!("a-z./\055", "A-Z___")
+ $defs.push(format("-DHAVE_%s", header))
+ $cache_mod = TRUE
+ return TRUE
+end
- def create_makefile(target)
- mfile = open("Makefile", "w")
- printf mfile, "\
+def create_header()
+ if $defs.length > 0
+ hfile = open("extconf.h", "w")
+ for line in $defs
+ line =~ /^-D(.*)/
+ printf hfile, "#define %s 1\n", $1
+ end
+ hfile.close
+ end
+end
+
+def create_makefile(target)
+
+ if $libs and "@DLEXT@" == "o"
+ libs = $libs.split
+ for lib in libs
+ lib.sub!(/-l(.*)/, '"lib\1.a"')
+ end
+ $defs.push(format("-DEXTLIB='%s'", libs.join(",")))
+ end
+ $libs = "" if not $libs
+
+ mfile = open("Makefile", "w")
+ printf mfile, "\
SHELL = /bin/sh
#### Start of system configuration section. ####
@@ -93,84 +190,205 @@ VPATH = @srcdir@
CC = @CC@
-CFLAGS = -I../.. @CCDLFLAGS@ @CFLAGS@ %s
-LDDLFLAGS = @LDDLFLAGS@
-", $defs.join(" ")
+CFLAGS = %s #$CFLAGS %s
+LDSHARED = @LDSHARED@
+", if $static then "" else "@CCDLFLAGS@" end, $defs.join(" ")
- printf mfile, "\
+ printf mfile, "\
prefix = @prefix@
binprefix =
exec_prefix = @exec_prefix@
bindir = $(exec_prefix)/bin
+libdir = @prefix@/lib/ruby
@SET_MAKE@
#### End of system configuration section. ####
"
- printf mfile, "OBJS = "
- if !$objs then
- $objs = Dir["*.c"]
- for f in $objs
- f.sub(/\.c$/, ".o")
- end
+ printf mfile, "LIBS = %s\n", $libs
+ printf mfile, "OBJS = "
+ if !$objs then
+ $objs = Dir["*.c"]
+ for f in $objs
+ f.sub!(/\.c$/, ".o")
end
- printf mfile, $objs.join(" ")
- printf mfile, "\n"
+ end
+ printf mfile, $objs.join(" ")
+ printf mfile, "\n"
- printf mfile, "\
-TARGET = %s.@DLEXT@
+ printf mfile, "\
+TARGET = %s.%s
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
all: $(TARGET)
-clean:; @rm -f *.o *.so
+clean:; @rm -f *.o *.so *.sl
@rm -f Makefile extconf.h conftest.*
@rm -f core ruby *~
realclean: clean
-", target
+", target, if $static then "o" else "@DLEXT@" end
+
+ if !$static
+ printf mfile, "\
+
+install: $(libdir)/$(TARGET)
+
+$(libdir)/$(TARGET): $(TARGET)
+ @test -d $(libdir) || mkdir $(libdir)
+ $(INSTALL_DATA) $(TARGET) $(libdir)/$(TARGET)
+"
+ else
+ printf mfile, "\
- if "@DLEXT@" == "so"
- printf mfile, "\
-.SUFFIXES: .so $(SUFFIXES)
+install:;
+"
+ end
-$(TARGET).so: $(OBJS)
- ld $(LDDLFLAGS) -o $*.so $(OBJS)
+ if !$static && "@DLEXT@" != "o"
+ printf mfile, "\
+$(TARGET): $(OBJS)
+ $(LDSHARED) -o $(TARGET) $(OBJS) $(LIBS)
"
- elsif !File.exists(target + ".c")
- printf mfile, "\
-$(TARGET).o: $(OBJS)
- ld $(LDDLFLAGS) -r $*.o $(OBJS)
+ elsif !File.exists?(target + ".c")
+ printf mfile, "\
+$(TARGET): $(OBJS)
+ ld $(LDDLFLAGS) -r $(TARGET) $(OBJS)
"
+ end
+
+ if File.exists?("depend")
+ dfile = open("depend", "r")
+ printf mfile, "###\n"
+ while line = dfile.gets()
+ printf mfile, "%s", line
end
+ dfile.close
+ end
+ mfile.close
+ if $static
+ $extinit += format("\
+\tInit_%s();\n\
+\trb_provide(\"%s.o\");\n\
+", target, target)
+ $extobjs += format("ext/%s/%s.o ", $static, target)
+ end
+end
- if File.exists("depend")
- dfile = open("depend", "r")
- printf mfile, "###\n"
- while line = dfile.gets()
- printf mfile, "%s", line
+def extmake(target)
+ if $static_ext[target]
+ $static = target
+ else
+ $static = FALSE
+ end
+
+ return if $nodynamic and not $static
+
+ $libs = nil
+ $objs = nil
+ $CFLAGS = "-I../.. @CFLAGS@"
+ $LDFLAGS = "@STATIC@ @LDFLAGS@"
+
+ begin
+ Dir.chdir target
+ if $static_ext.size > 0 ||
+ !File.exists?("./Makefile") ||
+ older("./Makefile", "../Setup") ||
+ older("./Makefile", "../extmk.rb") ||
+ older("./Makefile", "./extconf.rb")
+ then
+ $defs = []
+ if File.exists?("extconf.rb")
+ load "extconf.rb"
+ else
+ create_makefile(target);
+ end
+ end
+ if File.exists?("./Makefile")
+ if $install
+ system "make install"
+ elsif $clean
+ system "make clean"
+ else
+ system "make all"
end
- dfile.close
end
- mfile.close
+ $extlibs += " " + $libs if $static && $libs
+ ensure
+ Dir.chdir ".."
end
+end
- if File.exists("configure") &&
- (!File.exists("config.status") ||
- File.mtime("config.status") < File.mtime("configure")) then
+# get static-link modules
+$static_ext = {}
+if File.file? "./Setup"
+ f = open("./Setup")
+ while f.gets()
+ $_.chop!
+ sub!(/#.*$/, '')
+ continue if /^\s*$/
+ if /^option +nodynamic/
+ $nodynamic = TRUE
+ continue
+ end
+ $static_ext[$_.split[0]] = TRUE
+ end
+ f.close
+end
- system "./configure"
+for d in Dir["*"]
+ File.directory?(d) || continue
+ File.file?(d + "/MANIFEST") || continue
+
+ d = $1 if d =~ /\/([\/]*)$/
+ print "compiling ", d, "\n"
+ extmake(d)
+end
+
+if $cache_mod
+ f = open("config.cache", "w")
+ for k,v in $lib_cache
+ printf f, "lib: %s %s\n", k, v
+ end
+ for k,v in $func_cache
+ printf f, "func: %s %s\n", k, v
end
+ for k,v in $hdr_cache
+ printf f, "hdr: %s %s\n", k, v
+ end
+ f.close
+end
- if File.exists("extconf.rb")
- load "extconf.rb"
- else
- Dir.pwd =~ /[^\/]+$/
- create_makefile($&);
+exit if $install
+if $extobjs
+ if older("extinit.c", "Setup")
+ f = open("extinit.c", "w")
+ printf f, "void Init_ext() {\n"
+ printf f, $extinit
+ printf f, "}\n"
+ f.close
+ end
+ if older("extinit.o", "extinit.c")
+ cmd = "@CC@ @CFLAGS@ -c extinit.c"
+ print cmd, "\n"
+ system cmd or exit 1
end
+ Dir.chdir ".."
+ $extobjs = "ext/extinit.o " + $extobjs
+
+ if older("ruby", "ext/Setup") or older("ruby", "miniruby")
+ `rm -f ruby`
+ end
+ system format('make ruby PROGRAM=ruby EXTOBJS="%s" EXTLIBS="%s"', $extobjs, $extlibs)
+else
+ Dir.chdir ".."
+ `rm -f ruby`
+ `cp miniruby ruby`
end
-system "make all" if File.exists("./Makefile")
#Local variables:
# mode: ruby
diff --git a/ext/marshal/MANIFEST b/ext/marshal/MANIFEST
new file mode 100644
index 00000000000..53b08494842
--- /dev/null
+++ b/ext/marshal/MANIFEST
@@ -0,0 +1,4 @@
+MANIFEST
+depend
+marshal.c
+marshal.doc
diff --git a/ext/marshal/depend b/ext/marshal/depend
new file mode 100644
index 00000000000..c955eb2d59a
--- /dev/null
+++ b/ext/marshal/depend
@@ -0,0 +1,2 @@
+marshal.o: marshal.c ../../ruby.h ../../config.h ../../defines.h ../../io.h \
+ ../../st.h
diff --git a/ext/marshal/marshal.c b/ext/marshal/marshal.c
new file mode 100644
index 00000000000..0b29ad5ab8d
--- /dev/null
+++ b/ext/marshal/marshal.c
@@ -0,0 +1,565 @@
+/************************************************
+
+ marshal.c -
+
+ $Author$
+ $Revision$
+ $Date$
+ created at: Thu Apr 27 16:30:01 JST 1995
+
+************************************************/
+
+#include "ruby.h"
+#include "io.h"
+#include "st.h"
+
+#define TYPE_NIL '0'
+#define TYPE_FIXNUM 'i'
+
+#define TYPE_OBJECT 'o'
+#define TYPE_LINK '@'
+#define TYPE_FLOAT 'f'
+#define TYPE_BIGNUM 'l'
+#define TYPE_STRING '"'
+#define TYPE_REGEXP '/'
+#define TYPE_ARRAY '['
+#define TYPE_HASH '{'
+#define TYPE_STRUCT 'S'
+
+char *rb_class2path();
+VALUE rb_path2class();
+
+static ID s_dump, s_load;
+
+#define w_byte(c, fp) putc((c), fp)
+#define w_bytes(s, n, fp) (w_long((n), fp),fwrite(s, 1, n, fp))
+
+static void
+w_short(x, fp)
+ int x;
+ FILE *fp;
+{
+ w_byte( x & 0xff, fp);
+ w_byte((x>> 8) & 0xff, fp);
+}
+
+static void
+w_long(x, fp)
+ long x;
+ FILE *fp;
+{
+ w_byte((int)( x & 0xff), fp);
+ w_byte((int)((x>> 8) & 0xff), fp);
+ w_byte((int)((x>>16) & 0xff), fp);
+ w_byte((int)((x>>24) & 0xff), fp);
+}
+
+static void
+w_float(d, fp)
+ double d;
+ FILE *fp;
+{
+ char buf[100];
+
+ sprintf(buf, "%.12g", d);
+ w_bytes(buf, strlen(buf), fp);
+}
+
+static void
+w_symbol(id, fp)
+ ID id;
+ FILE *fp;
+{
+ char *sym = rb_id2name(id);
+
+ w_bytes(sym, strlen(sym), fp);
+}
+
+static void w_object();
+extern VALUE cBignum, cStruct;
+
+static int
+hash_each(key, value, fp)
+ VALUE key, value;
+ FILE *fp;
+{
+ w_object(key, fp);
+ w_object(value, fp);
+ return ST_CONTINUE;
+}
+
+static int
+obj_each(id, value, fp)
+ ID id;
+ VALUE value;
+ FILE *fp;
+{
+ w_symbol(id, fp);
+ w_object(value, fp);
+ return ST_CONTINUE;
+}
+
+struct st_table *new_idhash();
+
+static void
+w_object(obj, fp, port, table)
+ VALUE obj, port;
+ FILE *fp;
+ st_table *table;
+{
+ if (obj == Qnil) {
+ w_byte(TYPE_NIL, fp);
+ }
+ else if (FIXNUM_P(obj)) {
+ w_byte(TYPE_FIXNUM, fp);
+ w_long(FIX2INT(obj), fp);
+ }
+ else if (st_lookup(table, obj, 0)) {
+ w_byte(TYPE_LINK, fp);
+ w_long(obj, fp);
+ }
+ else {
+ st_insert(table, obj, 0);
+ switch (BUILTIN_TYPE(obj)) {
+ case T_FLOAT:
+ w_byte(TYPE_FLOAT, fp);
+ w_long(obj, fp);
+ w_float(RFLOAT(obj)->value, fp);
+ break;
+
+ case T_BIGNUM:
+ w_byte(TYPE_BIGNUM, fp);
+ w_long(obj, fp);
+ {
+ char sign = RBIGNUM(obj)->sign?'+':'-';
+ int len = RBIGNUM(obj)->len;
+ USHORT *d = RBIGNUM(obj)->digits;
+
+ w_byte(sign, fp);
+ w_long(len, fp);
+ while (len--) {
+ w_short(d, fp);
+ d++;
+ }
+ }
+ break;
+
+ case T_STRING:
+ w_byte(TYPE_STRING, fp);
+ w_long(obj, fp);
+ w_bytes(RSTRING(obj)->ptr, RSTRING(obj)->len, fp);
+ break;
+
+ case T_REGEXP:
+ w_byte(TYPE_REGEXP, fp);
+ w_long(obj, fp);
+ w_bytes(RREGEXP(obj)->str, RREGEXP(obj)->len, fp);
+ w_byte(FL_TEST(obj, FL_USER1), fp);
+ break;
+
+ case T_ARRAY:
+ w_byte(TYPE_ARRAY, fp);
+ w_long(obj, fp);
+ {
+ int len = RARRAY(obj)->len;
+ VALUE *ptr = RARRAY(obj)->ptr;
+
+ w_long(len, fp);
+ while (len--) {
+ w_object(*ptr, fp, port, table);
+ ptr++;
+ }
+ }
+ break;
+
+ case T_HASH:
+ w_byte(TYPE_HASH, fp);
+ w_long(obj, fp);
+ w_long(RHASH(obj)->tbl->num_entries, fp);
+ st_foreach(RHASH(obj)->tbl, hash_each, fp);
+ break;
+
+ case T_STRUCT:
+ w_byte(TYPE_STRUCT, fp);
+ w_long(obj, fp);
+ {
+ int len = RSTRUCT(obj)->len;
+ char *path = rb_class2path(CLASS_OF(obj));
+ VALUE mem;
+ int i;
+
+ w_bytes(path, strlen(path), fp);
+ w_long(len, fp);
+ mem = rb_ivar_get(CLASS_OF(obj), rb_intern("__member__"));
+ if (mem == Qnil) {
+ Fail("non-initialized struct");
+ }
+ for (i=0; i<len; i++) {
+ w_symbol(FIX2INT(RARRAY(mem)->ptr[i]), fp);
+ w_object(RSTRUCT(obj)->ptr[i], fp, port, table);
+ }
+ }
+ break;
+
+ case T_OBJECT:
+ w_byte(TYPE_OBJECT, fp);
+ w_long(obj, fp);
+ {
+ VALUE class = CLASS_OF(obj);
+ char *path = rb_class2path(class);
+
+ w_bytes(path, strlen(path), fp);
+ if (rb_responds_to(obj, s_dump)) {
+ w_long(-1, fp);
+ rb_funcall(obj, s_dump, 1, port);
+ }
+ else if (ROBJECT(obj)->iv_tbl) {
+ w_long(ROBJECT(obj)->iv_tbl->num_entries, fp);
+ st_foreach(ROBJECT(obj)->iv_tbl, obj_each, fp);
+ }
+ else {
+ w_long(0, fp);
+ }
+ }
+ break;
+
+ default:
+ Fail("can't dump %s", rb_class2name(CLASS_OF(obj)));
+ break;
+ }
+ }
+}
+
+static VALUE
+marshal_dump(self, obj, port)
+ VALUE self, obj, port;
+{
+ extern VALUE cIO;
+ FILE *fp;
+ OpenFile *fptr;
+ st_table *table;
+
+ if (obj_is_kind_of(port, cIO)) {
+ GetOpenFile(port, fptr);
+ if (!(fptr->mode & FMODE_WRITABLE)) {
+ Fail("not opened for writing");
+ }
+ fp = (fptr->f2) ? fptr->f2 : fptr->f;
+ }
+ else {
+ Fail("instance of IO needed");
+ }
+
+ table = new_idhash();
+
+ w_object(obj, fp, port, table);
+
+ st_free_table(table);
+ return Qnil;
+}
+
+static VALUE
+marshal_dumps(self, obj)
+ VALUE self, obj;
+{
+ VALUE str = str_new(0, 0);
+ VALUE port;
+ FILE *fp = Qnil;
+ char buf[BUFSIZ];
+ int n;
+
+ sprintf(buf, "/tmp/rb-mrsr-%x", getpid()^(int)buf);
+ port = file_open(buf, "w");
+ if (!port) rb_sys_fail("tmp file");
+ fp = fopen(buf, "r");
+ if (!fp) rb_sys_fail("tmp file(read)");
+ unlink(buf);
+
+ marshal_dump(self, obj, port);
+ io_close(port);
+
+ while (n = fread(buf, 1, BUFSIZ, fp)) {
+ str_cat(str, buf, n);
+ }
+
+ return str;
+}
+
+#define r_byte(fp) getc(fp)
+
+static int
+r_short(fp)
+ FILE *fp;
+{
+ register short x;
+ x = r_byte(fp);
+ x |= r_byte(fp) << 8;
+ /* XXX If your short is > 16 bits, add sign-extension here!!! */
+ return x;
+}
+
+static long
+r_long(fp)
+ FILE *fp;
+{
+ register long x;
+ x = r_byte(fp);
+ x |= (long)r_byte(fp) << 8;
+ x |= (long)r_byte(fp) << 16;
+ x |= (long)r_byte(fp) << 24;
+ /* XXX If your long is > 32 bits, add sign-extension here!!! */
+ return x;
+}
+#define r_bytes(s, fp) r_bytes0(&s, fp)
+static int
+r_bytes0(s, fp)
+ char **s;
+ FILE *fp;
+{
+ int len = r_long(fp);
+ *s = ALLOC_N(char, len+1);
+
+ fread(*s, 1, len, fp);
+ (*s)[len] = '\0';
+ return len;
+}
+
+static ID
+r_symbol(fp)
+ FILE *fp;
+{
+ char *buf;
+ ID id;
+
+ r_bytes(buf, fp);
+ id = rb_intern(buf);
+ free(buf);
+ return id;
+}
+
+static VALUE
+r_object(fp, port, table)
+ FILE *fp;
+ VALUE port;
+ st_table *table;
+{
+ VALUE v;
+ int type = r_byte(fp);
+ int id;
+
+ switch (type) {
+ case EOF:
+ Fail("EOF read where object expected");
+ return Qnil;
+
+ case TYPE_NIL:
+ return Qnil;
+
+ case TYPE_LINK:
+ if (st_lookup(table, r_long(fp), &v)) {
+ return v;
+ }
+ Fail("corrupted marshal file");
+ break;
+
+ case TYPE_FIXNUM:
+ {
+ int i = r_long(fp);
+ return INT2FIX(i);
+ }
+ }
+
+ id = r_long(fp);
+ switch (type) {
+ case TYPE_FLOAT:
+ {
+ double atof();
+ char *buf;
+
+ r_bytes(buf, fp);
+ v = float_new(atof(buf));
+ free(buf);
+ }
+ break;
+
+ case TYPE_BIGNUM:
+ {
+ int len;
+ USHORT *digits;
+
+ NEWOBJ(big, struct RBignum);
+ OBJSETUP(big, cBignum, T_BIGNUM);
+ big->sign = (r_byte(fp) == '+');
+ big->len = len = r_long(fp);
+ big->digits = digits = ALLOC_N(USHORT, len);
+ while (len--) {
+ *digits++ = r_short(fp);
+ }
+ v = (VALUE)big;
+ }
+ break;
+
+ case TYPE_STRING:
+ {
+ char *buf;
+ int len = r_bytes(buf, fp);
+ v = str_new(buf, len);
+ free(buf);
+ }
+ break;
+
+ case TYPE_REGEXP:
+ {
+ char *buf;
+ int len = r_bytes(buf, fp);
+ int ci = r_byte(fp);
+ v = reg_new(buf, len, ci);
+ free(buf);
+ }
+ break;
+
+ case TYPE_ARRAY:
+ {
+ int len = r_long(fp);
+ v = ary_new2(len);
+ while (len--) {
+ ary_push(v, r_object(fp, port, table));
+ }
+ }
+ break;
+
+ case TYPE_HASH:
+ {
+ int len = r_long(fp);
+
+ v = hash_new();
+ while (len--) {
+ VALUE key = r_object(fp, port, table);
+ VALUE value = r_object(fp, port, table);
+ hash_aset(v, key, value);
+ }
+ }
+ break;
+
+ case TYPE_STRUCT:
+ {
+ VALUE class, mem, values;
+ char *path;
+ int i, len;
+
+ r_bytes(path, fp);
+ class = rb_path2class(path);
+ free(path);
+ mem = rb_ivar_get(class, rb_intern("__member__"));
+ if (mem == Qnil) {
+ Fail("non-initialized struct");
+ }
+ len = r_long(fp);
+
+ values = ary_new();
+ i = 0;
+ while (len--) {
+ ID slot = r_symbol(fp);
+ if (RARRAY(mem)->ptr[i++] != INT2FIX(slot))
+ Fail("struct not compatible");
+ ary_push(values, r_object(fp, port, table));
+ }
+ v = struct_alloc(class, values);
+ }
+ break;
+
+ case TYPE_OBJECT:
+ {
+ VALUE class;
+ int len;
+ char *path;
+
+ r_bytes(path, fp);
+ class = rb_path2class(path);
+ free(path);
+ len = r_long(fp);
+ if (len == -1) {
+ if (rb_responds_to(class, s_load)) {
+ v = rb_funcall(class, s_load, 1, port);
+ }
+ else {
+ Fail("class %s needs to have method `_load_from'",
+ rb_class2name(class));
+ }
+ }
+ else {
+ v = obj_alloc(class);
+ if (len > 0) {
+ while (len--) {
+ ID id = r_symbol(fp);
+ VALUE val = r_object(fp, port, table);
+ rb_ivar_set(v, id, val);
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ Fail("dump format error(0x%x)", type);
+ break;
+ }
+ st_insert(table, id, v);
+ return v;
+}
+
+static VALUE
+marshal_load(self, port)
+ VALUE self, port;
+{
+ extern VALUE cIO;
+ void *fp;
+ VALUE v;
+ OpenFile *fptr;
+ st_table *table;
+
+ if (TYPE(port) == T_STRING) {
+ char buf[32];
+
+ sprintf(buf, "/tmp/rb-mrsw-%x", getpid()^(int)buf);
+ fp = fopen(buf, "w");
+ if (!fp) rb_sys_fail("tmp file");
+ v = file_open(buf, "r");
+ if (!v) rb_sys_fail("tmp file(read)");
+ unlink(buf);
+
+ fwrite(RSTRING(port)->ptr, RSTRING(port)->len, 1, fp);
+ fclose(fp);
+ port = v;
+ }
+ if (obj_is_kind_of(port, cIO)) {
+ GetOpenFile(port, fptr);
+ if (!(fptr->mode & FMODE_READABLE)) {
+ Fail("not opened for reading");
+ }
+ fp = fptr->f;
+ }
+ else {
+ Fail("instance of IO needed");
+ }
+
+ table = new_idhash();
+
+ v = r_object(fp, port, table);
+
+ st_free_table(table);
+
+ return v;
+}
+
+Init_marshal()
+{
+ VALUE mMarshal = rb_define_module("Marshal");
+
+ s_dump = rb_intern("_dump_to");
+ s_load = rb_intern("_load_from");
+ rb_define_module_function(mMarshal, "dump", marshal_dump, 2);
+ rb_define_module_function(mMarshal, "dumps", marshal_dumps, 1);
+ rb_define_module_function(mMarshal, "load", marshal_load, 1);
+ rb_define_module_function(mMarshal, "restore", marshal_load, 1);
+}
diff --git a/ext/marshal/marshal.doc b/ext/marshal/marshal.doc
new file mode 100644
index 00000000000..8c3b63072e2
--- /dev/null
+++ b/ext/marshal/marshal.doc
@@ -0,0 +1,45 @@
+.\" marshal.doc - -*- Indented-Text -*- created at: Tue May 16 12:18:08 JST 1995
+
+** Marshal(⥸塼)
+
+ruby֥Ȥե˽񤭽Фꡤɤߤ٤ꤹ뵡ǽ
+⥸塼롥ʬΥ饹Υ󥹥󥹤񤭽ФǤ뤬ե
+ؤԲǽʥ饹¸ߤ(:IO)Τ褦ʥ饹񤭽Ф
+㳰ȯ롥
+
+Methods:
+Single Methods:
+
+ dump(obj, port)
+
+ objƵŪ˥ե˽񤭽Фե˽񤭽Фʤ饹Υ
+ 󥹥󥹤ե˽񤭽ФȤ㳰ȯ롥ե
+ ˽񤭽Фʤ饹ϰʲ̤ꡥ
+
+ Class, Module, Data
+
+ ޤΥ饹Ū˻ؤ饹(㤨IOΥ֥饹)ʤ
+ 񤭽ФʤportIO(ޤϤΥ֥饹)Υ󥹥󥹤
+ 롥
+
+ Ϥ륪֥Ȥ᥽å`_dump_to'Ƥˤϡե
+ ϤϤΥ᥽åɤȤäƹԤ롥᥽å`_dump_to'ϰ
+ ƽΥե륪֥Ȥ롥󥹥󥹤᥽å
+ `_dump_to'ĥ饹ɬƱեޥåȤɤ᤹ðۥ᥽å
+ `_load_from'ɬפ롥
+
+
+ dumps(obj)
+
+ dump()ե˽񤭽ФΤƱƤޤʸ֤
+
+ load(port)
+
+ port饪֥Ȥɤ߹ơΥ֥ȤƱ֤
+ ĥ֥Ȥ롥portʸIO(ޤϤΥ֥饹)
+ Υ󥹥󥹤Ǥ롥
+
+-------------------------------------------------------
+Local variables:
+fill-column: 70
+end:
diff --git a/ext/socket/MANIFEST b/ext/socket/MANIFEST
new file mode 100644
index 00000000000..836caada416
--- /dev/null
+++ b/ext/socket/MANIFEST
@@ -0,0 +1,5 @@
+MANIFEST
+depend
+extconf.rb
+socket.c
+socket.doc
diff --git a/ext/socket/depend b/ext/socket/depend
new file mode 100644
index 00000000000..e6ede5a4111
--- /dev/null
+++ b/ext/socket/depend
@@ -0,0 +1 @@
+socket.o : socket.c ../../ruby.h ../../config.h ../../defines.h ../../io.h ../../sig.h
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
new file mode 100644
index 00000000000..60d6deeb844
--- /dev/null
+++ b/ext/socket/extconf.rb
@@ -0,0 +1,6 @@
+have_library("inet", "gethostbyname")
+have_library("socket", "socket")
+have_header("sys/un.h")
+if have_func("socket")
+ create_makefile("socket")
+end
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
new file mode 100644
index 00000000000..5671b2762ca
--- /dev/null
+++ b/ext/socket/socket.c
@@ -0,0 +1,785 @@
+/************************************************
+
+ socket.c -
+
+ $Author: matz $
+ $Date: 1995/01/10 10:42:55 $
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+************************************************/
+
+#include "ruby.h"
+#include "io.h"
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <errno.h>
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#else
+#undef AF_UNIX
+#endif
+
+extern VALUE cIO;
+VALUE cBasicSocket;
+VALUE cTCPsocket;
+VALUE cTCPserver;
+#ifdef AF_UNIX
+VALUE cUNIXsocket;
+VALUE cUNIXserver;
+#endif
+VALUE cSocket;
+
+FILE *rb_fdopen();
+char *strdup();
+
+#ifdef NT
+static void
+sock_finalize(fptr)
+ OpenFile *fptr;
+{
+ SOCKET s = fileno(fptr->f);
+ free(fptr->f);
+ free(fptr->f2);
+ closesocket(s);
+}
+#endif
+
+static VALUE
+sock_new(class, fd)
+ VALUE class;
+ int fd;
+{
+ VALUE sock = obj_alloc(class);
+ OpenFile *fp;
+
+ MakeOpenFile(sock, fp);
+#ifdef NT
+ fp->finalize = sock_finalize;
+#endif
+ fp->f = rb_fdopen(fd, "r");
+ setbuf(fp->f, NULL);
+ fp->f2 = rb_fdopen(fd, "w");
+ fp->mode = FMODE_READWRITE|FMODE_SYNC;
+
+ return sock;
+}
+
+static VALUE
+bsock_shutdown(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
+{
+ VALUE howto;
+ int how;
+ OpenFile *fptr;
+
+ rb_scan_args(argc, argv, "01", &howto);
+ if (howto == Qnil)
+ how = 2;
+ else {
+ how = NUM2INT(howto);
+ if (how < 0 && how > 2) how = 2;
+ }
+ GetOpenFile(sock, fptr);
+ if (shutdown(fileno(fptr->f), how) == -1)
+ rb_sys_fail(Qnil);
+
+ return INT2FIX(0);
+}
+
+static VALUE
+bsock_setopt(sock, lev, optname, val)
+ VALUE sock, lev, optname;
+ struct RString *val;
+{
+ int level, option;
+ OpenFile *fptr;
+
+ level = NUM2INT(lev);
+ option = NUM2INT(optname);
+ Check_Type(val, T_STRING);
+
+ GetOpenFile(sock, fptr);
+ if (setsockopt(fileno(fptr->f), level, option, val->ptr, val->len) < 0)
+ rb_sys_fail(fptr->path);
+
+ return INT2FIX(0);
+}
+
+static VALUE
+bsock_getopt(sock, lev, optname)
+ VALUE sock, lev, optname;
+{
+ int level, option, len;
+ struct RString *val;
+ OpenFile *fptr;
+
+ level = NUM2INT(lev);
+ option = NUM2INT(optname);
+ len = 256;
+ val = (struct RString*)str_new(0, len);
+ Check_Type(val, T_STRING);
+
+ GetOpenFile(sock, fptr);
+ if (getsockopt(fileno(fptr->f), level, option, val->ptr, &len) < 0)
+ rb_sys_fail(fptr->path);
+ val->len = len;
+ return (VALUE)val;
+}
+
+static VALUE
+bsock_getsockname(sock)
+ VALUE sock;
+{
+ char buf[1024];
+ int len = sizeof buf;
+ OpenFile *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (getsockname(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
+ rb_sys_fail("getsockname(2)");
+ return str_new(buf, len);
+}
+
+static VALUE
+bsock_getpeername(sock)
+ VALUE sock;
+{
+ char buf[1024];
+ int len = sizeof buf;
+ OpenFile *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (getpeername(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
+ rb_sys_fail("getpeername(2)");
+ return str_new(buf, len);
+}
+
+static VALUE
+open_inet(class, h, serv, server)
+ VALUE class, h, serv;
+ int server;
+{
+ char *host;
+ struct hostent *hostent, _hostent;
+ struct servent *servent, _servent;
+ struct protoent *protoent;
+ struct sockaddr_in sockaddr;
+ int fd, status;
+ int hostaddr, hostaddrPtr[2];
+ int servport;
+ char *syscall;
+ VALUE sock;
+
+ if (h) {
+ Check_Type(h, T_STRING);
+ host = RSTRING(h)->ptr;
+ hostent = gethostbyname(host);
+ if (hostent == NULL) {
+ hostaddr = inet_addr(host);
+ if (hostaddr == -1) {
+ if (server && !strlen(host))
+ hostaddr = INADDR_ANY;
+ else
+ rb_sys_fail(host);
+ }
+ _hostent.h_addr_list = (char **)hostaddrPtr;
+ _hostent.h_addr_list[0] = (char *)&hostaddr;
+ _hostent.h_addr_list[1] = NULL;
+ _hostent.h_length = sizeof(hostaddr);
+ _hostent.h_addrtype = AF_INET;
+ hostent = &_hostent;
+ }
+ }
+ servent = NULL;
+ if (FIXNUM_P(serv)) {
+ servport = FIX2UINT(serv);
+ goto setup_servent;
+ }
+ Check_Type(serv, T_STRING);
+ servent = getservbyname(RSTRING(serv)->ptr, "tcp");
+ if (servent == NULL) {
+ servport = strtoul(RSTRING(serv)->ptr, Qnil, 0);
+ if (servport == -1) Fail("no such servce %s", RSTRING(serv)->ptr);
+ setup_servent:
+ _servent.s_port = servport;
+ _servent.s_proto = "tcp";
+ servent = &_servent;
+ }
+ protoent = getprotobyname(servent->s_proto);
+ if (protoent == NULL) Fail("no such proto %s", servent->s_proto);
+
+ fd = socket(PF_INET, SOCK_STREAM, protoent->p_proto);
+
+ sockaddr.sin_family = AF_INET;
+ if (h == Qnil) {
+ sockaddr.sin_addr.s_addr = INADDR_ANY;
+ }
+ else {
+ memcpy((char *)&(sockaddr.sin_addr.s_addr),
+ (char *) hostent->h_addr_list[0],
+ (size_t) hostent->h_length);
+ }
+ sockaddr.sin_port = servent->s_port;
+
+ if (server) {
+ status = bind(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
+ syscall = "bind(2)";
+ }
+ else {
+ status = connect(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
+ syscall = "connect(2)";
+ }
+
+ if (status < 0) {
+ close (fd);
+ rb_sys_fail(syscall);
+ }
+ if (server) listen(fd, 5);
+
+ /* create new instance */
+ sock = sock_new(class, fd);
+
+ return sock;
+}
+
+static VALUE
+tcp_s_sock_open(class, host, serv)
+ VALUE class, host, serv;
+{
+ Check_Type(host, T_STRING);
+ return open_inet(class, host, serv, 0);
+}
+
+static VALUE
+tcp_svr_s_open(argc, argv, class)
+ int argc;
+ VALUE *argv;
+ VALUE class;
+{
+ VALUE arg1, arg2;
+
+ if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2)
+ return open_inet(class, arg1, arg2, 1);
+ else
+ return open_inet(class, Qnil, arg1, 1);
+}
+
+static VALUE
+s_accept(class, fd, sockaddr, len)
+ VALUE class;
+ int fd;
+ struct sockaddr *sockaddr;
+ int *len;
+{
+ int fd2;
+
+ retry:
+ fd2 = accept(fd, sockaddr, len);
+ if (fd2 < 0) {
+ if (errno == EINTR) goto retry;
+ rb_sys_fail(Qnil);
+ }
+ return sock_new(class, fd2);
+}
+
+static VALUE
+tcp_accept(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+ struct sockaddr_in from;
+ int fromlen;
+
+ GetOpenFile(sock, fptr);
+ fromlen = sizeof(struct sockaddr_in);
+ return s_accept(cTCPsocket, fileno(fptr->f),
+ (struct sockaddr*)&from, &fromlen);
+}
+
+#ifdef AF_UNIX
+static VALUE
+open_unix(class, path, server)
+ VALUE class;
+ struct RString *path;
+ int server;
+{
+ struct sockaddr_un sockaddr;
+ int fd, status;
+ char *syscall;
+ VALUE sock;
+ OpenFile *fptr;
+
+ Check_Type(path, T_STRING);
+ fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) rb_sys_fail("socket(2)");
+
+ sockaddr.sun_family = AF_UNIX;
+ strncpy(sockaddr.sun_path, path->ptr, sizeof(sockaddr.sun_path)-1);
+ sockaddr.sun_path[sizeof(sockaddr.sun_path)-1] = '\0';
+
+ if (server) {
+ status = bind(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
+ syscall = "bind(2)";
+ }
+ else {
+ status = connect(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
+ syscall = "connect(2)";
+ }
+
+ if (status < 0) {
+ close (fd);
+ rb_sys_fail(syscall);
+ }
+
+ if (server) listen(fd, 5);
+
+ sock = sock_new(class, fd);
+ GetOpenFile(sock, fptr);
+ fptr->path = strdup(path->ptr);
+
+ return sock;
+}
+#endif
+
+static VALUE
+tcpaddr(sockaddr)
+ struct sockaddr_in *sockaddr;
+{
+ VALUE family, port, addr;
+ VALUE ary;
+ struct hostent *hostent;
+
+ family = str_new2("AF_INET");
+ hostent = gethostbyaddr((char*)&sockaddr->sin_addr.s_addr,
+ sizeof(sockaddr->sin_addr),
+ AF_INET);
+ if (hostent) {
+ addr = str_new2(hostent->h_name);
+ }
+ else {
+ char buf[16];
+ char *a = (char*)&sockaddr->sin_addr;
+ sprintf(buf, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
+ addr = str_new2(buf);
+ }
+ port = INT2FIX(sockaddr->sin_port);
+ ary = ary_new3(3, family, port, addr);
+
+ return ary;
+}
+
+static VALUE
+tcp_addr(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+ struct sockaddr_in addr;
+ int len = sizeof addr;
+
+ GetOpenFile(sock, fptr);
+
+ if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
+ rb_sys_fail("getsockname(2)");
+ return tcpaddr(&addr);
+}
+
+static VALUE
+tcp_peeraddr(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+ struct sockaddr_in addr;
+ int len = sizeof addr;
+
+ GetOpenFile(sock, fptr);
+
+ if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
+ rb_sys_fail("getsockname(2)");
+ return tcpaddr(&addr);
+}
+
+#ifdef AF_UNIX
+static VALUE
+unix_s_sock_open(sock, path)
+ VALUE sock, path;
+{
+ return open_unix(sock, path, 0);
+}
+
+static VALUE
+unix_path(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (fptr->path == Qnil) {
+ struct sockaddr_un addr;
+ int len = sizeof(addr);
+ if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
+ rb_sys_fail(Qnil);
+ fptr->path = strdup(addr.sun_path);
+ }
+ return str_new2(fptr->path);
+}
+
+static VALUE
+unix_svr_s_open(class, path)
+ VALUE class, path;
+{
+ return open_unix(class, path, 1);
+}
+
+static VALUE
+unix_accept(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+ struct sockaddr_un from;
+ int fromlen;
+
+ GetOpenFile(sock, fptr);
+ fromlen = sizeof(struct sockaddr_un);
+ return s_accept(cUNIXsocket, fileno(fptr->f),
+ (struct sockaddr*)&from, &fromlen);
+}
+
+static VALUE
+unixaddr(sockaddr)
+ struct sockaddr_un *sockaddr;
+{
+ return assoc_new(str_new2("AF_UNIX"),str_new2(sockaddr->sun_path));
+}
+
+static VALUE
+unix_addr(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+ struct sockaddr_un addr;
+ int len = sizeof addr;
+
+ GetOpenFile(sock, fptr);
+
+ if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
+ rb_sys_fail("getsockname(2)");
+ return unixaddr(&addr);
+}
+
+static VALUE
+unix_peeraddr(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+ struct sockaddr_un addr;
+ int len = sizeof addr;
+
+ GetOpenFile(sock, fptr);
+
+ if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
+ rb_sys_fail("getsockname(2)");
+ return unixaddr(&addr);
+}
+#endif
+
+static void
+setup_domain_and_type(domain, dv, type, tv)
+ VALUE domain, type;
+ int *dv, *tv;
+{
+ char *ptr;
+
+ if (TYPE(domain) == T_STRING) {
+ ptr = RSTRING(domain)->ptr;
+ if (strcmp(ptr, "PF_INET") == 0)
+ *dv = PF_INET;
+#ifdef PF_UNIX
+ else if (strcmp(ptr, "PF_UNIX") == 0)
+ *dv = PF_UNIX;
+#endif
+#ifdef PF_IMPLINK
+ else if (strcmp(ptr, "PF_IMPLINK") == 0)
+ *dv = PF_IMPLINK;
+#endif
+#ifdef PF_AX25
+ else if (strcmp(ptr, "PF_AX25") == 0)
+ *dv = PF_AX25;
+#endif
+#ifdef PF_IPX
+ else if (strcmp(ptr, "PF_IPX") == 0)
+ *dv = PF_IPX;
+#endif
+ else
+ Fail("Unknown socket domain %s", ptr);
+ }
+ else {
+ *dv = NUM2INT(domain);
+ }
+ if (TYPE(type) == T_STRING) {
+ ptr = RSTRING(type)->ptr;
+ if (strcmp(ptr, "SOCK_STREAM") == 0)
+ *tv = SOCK_STREAM;
+ else if (strcmp(ptr, "SOCK_DGRAM") == 0)
+ *tv = SOCK_DGRAM;
+#ifdef SOCK_RAW
+ else if (strcmp(ptr, "SOCK_RAW") == 0)
+ *tv = SOCK_RAW;
+#endif
+#ifdef SOCK_SEQPACKET
+ else if (strcmp(ptr, "SOCK_SEQPACKET") == 0)
+ *tv = SOCK_SEQPACKET;
+#endif
+#ifdef SOCK_RDM
+ else if (strcmp(ptr, "SOCK_RDM") == 0)
+ *tv = SOCK_RDM;
+#endif
+#ifdef SOCK_PACKET
+ else if (strcmp(ptr, "SOCK_PACKET") == 0)
+ *tv = SOCK_PACKET;
+#endif
+ else
+ Fail("Unknown socket type %s", ptr);
+ }
+ else {
+ *tv = NUM2INT(type);
+ }
+}
+
+static VALUE
+sock_s_open(class, domain, type, protocol)
+ VALUE class, domain, type, protocol;
+{
+ int fd;
+ int d, t;
+
+ setup_domain_and_type(domain, &d, type, &t);
+ fd = socket(d, t, NUM2INT(protocol));
+ if (fd < 0) rb_sys_fail("socke(2)");
+ return sock_new(class, fd);
+}
+
+static VALUE
+sock_s_for_fd(class, fd)
+ VALUE class, fd;
+{
+ return sock_new(class, NUM2INT(fd));
+}
+
+static VALUE
+sock_s_socketpair(class, domain, type, protocol)
+ VALUE class, domain, type, protocol;
+{
+ int fd;
+ int d, t, sp[2];
+
+ setup_domain_and_type(domain, &d, type, &t);
+ if (socketpair(d, t, NUM2INT(protocol), sp) < 0)
+ rb_sys_fail("socketpair(2)");
+
+ return assoc_new(sock_new(class, sp[0]), sock_new(class, sp[1]));
+}
+
+static VALUE
+sock_connect(sock, addr)
+ VALUE sock;
+ struct RString *addr;
+{
+ OpenFile *fptr;
+
+ Check_Type(addr, T_STRING);
+ str_modify(addr);
+
+ GetOpenFile(sock, fptr);
+ if (connect(fileno(fptr->f), (struct sockaddr*)addr->ptr, addr->len) < 0)
+ rb_sys_fail("connect(2)");
+
+ return INT2FIX(0);
+}
+
+static VALUE
+sock_bind(sock, addr)
+ VALUE sock;
+ struct RString *addr;
+{
+ OpenFile *fptr;
+
+ Check_Type(addr, T_STRING);
+ str_modify(addr);
+
+ GetOpenFile(sock, fptr);
+ if (bind(fileno(fptr->f), (struct sockaddr*)addr->ptr, addr->len) < 0)
+ rb_sys_fail("bind(2)");
+
+ return INT2FIX(0);
+}
+
+static VALUE
+sock_listen(sock, log)
+ VALUE sock, log;
+{
+ OpenFile *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (listen(fileno(fptr->f), NUM2INT(log)) < 0)
+ rb_sys_fail("listen(2)");
+
+ return INT2FIX(0);
+}
+
+static VALUE
+sock_accept(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+ VALUE addr, sock2;
+ char buf[1024];
+ int len = sizeof buf;
+
+ GetOpenFile(sock, fptr);
+ sock2 = s_accept(cSocket,fileno(fptr->f),(struct sockaddr*)buf,&len);
+
+ return assoc_new(sock2, str_new(buf, len));
+}
+
+static VALUE
+sock_send(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
+{
+ struct RString *msg, *to;
+ VALUE flags;
+ OpenFile *fptr;
+ FILE *f;
+ int fd, n;
+
+ rb_scan_args(argc, argv, "21", &msg, &flags, &to);
+
+ Check_Type(msg, T_STRING);
+
+ GetOpenFile(sock, fptr);
+ f = fptr->f2?fptr->f2:fptr->f;
+ fd = fileno(f);
+ if (to) {
+ Check_Type(to, T_STRING);
+ n = sendto(fd, msg->ptr, msg->len, NUM2INT(flags),
+ (struct sockaddr*)to->ptr, to->len);
+ }
+ else {
+ n = send(fd, msg->ptr, msg->len, NUM2INT(flags));
+ }
+ if (n < 0) {
+ rb_sys_fail("send(2)");
+ }
+ return INT2FIX(n);
+}
+
+static VALUE
+s_recv(sock, argc, argv, from)
+ VALUE sock;
+ int argc;
+ VALUE *argv;
+ int from;
+{
+ OpenFile *fptr;
+ FILE f;
+ struct RString *str;
+ char buf[1024];
+ int fd, alen = sizeof buf;
+ VALUE len, flg;
+ int flags;
+
+ rb_scan_args(argc, argv, "11", &len, &flg);
+
+ if (flg == Qnil) flags = 0;
+ else flags = NUM2INT(flg);
+
+ str = (struct RString*)str_new(0, NUM2INT(len));
+
+ GetOpenFile(sock, fptr);
+ fd = fileno(fptr->f);
+ if ((str->len = recvfrom(fd, str->ptr, str->len, flags,
+ (struct sockaddr*)buf, &alen)) < 0) {
+ rb_sys_fail("recvfrom(2)");
+ }
+
+ if (from)
+ return assoc_new(str, str_new(buf, alen));
+ else
+ return (VALUE)str;
+}
+
+static VALUE
+sock_recv(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
+{
+ return s_recv(sock, argc, argv, 0);
+}
+
+static VALUE
+sock_recvfrom(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
+{
+ return s_recv(sock, argc, argv, 1);
+}
+
+Init_socket ()
+{
+ cBasicSocket = rb_define_class("BasicSocket", cIO);
+ rb_undef_method(cBasicSocket, "new");
+ rb_define_method(cBasicSocket, "shutdown", bsock_shutdown, -1);
+ rb_define_method(cBasicSocket, "setopt", bsock_setopt, 3);
+ rb_define_method(cBasicSocket, "getopt", bsock_getopt, 2);
+ rb_define_method(cBasicSocket, "getsockname", bsock_getsockname, 0);
+ rb_define_method(cBasicSocket, "getpeername", bsock_getpeername, 0);
+
+ cTCPsocket = rb_define_class("TCPsocket", cBasicSocket);
+ rb_define_singleton_method(cTCPsocket, "open", tcp_s_sock_open, 2);
+ rb_define_singleton_method(cTCPsocket, "new", tcp_s_sock_open, 2);
+ rb_define_method(cTCPsocket, "addr", tcp_addr, 0);
+ rb_define_method(cTCPsocket, "peeraddr", tcp_peeraddr, 0);
+
+ cTCPserver = rb_define_class("TCPserver", cTCPsocket);
+ rb_define_singleton_method(cTCPserver, "open", tcp_svr_s_open, -1);
+ rb_define_singleton_method(cTCPserver, "new", tcp_svr_s_open, -1);
+ rb_define_method(cTCPserver, "accept", tcp_accept, 0);
+
+#ifdef AF_UNIX
+ cUNIXsocket = rb_define_class("UNIXsocket", cBasicSocket);
+ rb_define_singleton_method(cUNIXsocket, "open", unix_s_sock_open, 1);
+ rb_define_singleton_method(cUNIXsocket, "new", unix_s_sock_open, 1);
+ rb_define_method(cUNIXsocket, "path", unix_path, 0);
+ rb_define_method(cUNIXsocket, "addr", unix_addr, 0);
+ rb_define_method(cUNIXsocket, "peeraddr", unix_peeraddr, 0);
+
+ cUNIXserver = rb_define_class("UNIXserver", cUNIXsocket);
+ rb_define_singleton_method(cUNIXserver, "open", unix_svr_s_open, 1);
+ rb_define_singleton_method(cUNIXserver, "new", unix_svr_s_open, 1);
+ rb_define_method(cUNIXserver, "accept", unix_accept, 0);
+#endif
+
+ cSocket = rb_define_class("Socket", cBasicSocket);
+ rb_define_singleton_method(cSocket, "open", sock_s_open, 3);
+ rb_define_singleton_method(cSocket, "new", sock_s_open, 3);
+ rb_define_singleton_method(cSocket, "for_fd", sock_s_for_fd, 1);
+
+ rb_define_method(cSocket, "connect", sock_connect, 1);
+ rb_define_method(cSocket, "bind", sock_bind, 1);
+ rb_define_method(cSocket, "listen", sock_listen, 1);
+ rb_define_method(cSocket, "accept", sock_accept, 0);
+
+ rb_define_method(cSocket, "send", sock_send, -1);
+ rb_define_method(cSocket, "recv", sock_recv, -1);
+ rb_define_method(cSocket, "recvfrom", sock_recv, -1);
+
+ rb_define_singleton_method(cSocket, "socketpair", sock_s_socketpair, 3);
+}
diff --git a/ext/socket/socket.doc b/ext/socket/socket.doc
new file mode 100644
index 00000000000..aa5bfedbff9
--- /dev/null
+++ b/ext/socket/socket.doc
@@ -0,0 +1,227 @@
+.\" socket.doc - -*- Indented-Text -*- created at: Thu Mar 23 20:29:02 JST 1995
+
+** Socket(饹)
+
+SuperClass: BasicSocket
+
+åȤΤΤФ륷ƥॳ٥Υ󶡤륯饹
+PerlΥåȤФ륢Ʊ٥εǽ󶡤Ƥ롥Υ
+Ǥϥåȥɥ쥹pack줿ʸǡꤹ롥UDPåȤϤ
+Υ饹ȤäѤ롥
+
+Methods:
+
+ accept
+
+ ³դơ³Ф륽åȤȥɥ쥹
+ ڥ֤accept(2)򻲾ȡ
+
+ bind(addr)
+
+ bind(2)ƱƯ򤹤롥addrpack줿åȥɥ쥹¤
+ ΤǤ롥
+
+ connect(addr)
+
+ connect(2)ƱƯ򤹤롥addrpack줿åȥɥ쥹
+ ¤ΤǤ롥
+
+ listen(backlog)
+
+ listen(2)ƱƯ򤹤롥
+
+ recv(len[, flags])
+
+ åȤǡꡤʸȤ֤lenϼ
+ Ĺꤹ롥flagsˤĤƤrecv(2)򻲾ȡflagsΥ
+ եͤ0Ǥ롥
+
+ recvfrom(len[, flags])
+
+ recvƱͤ˥åȤǡ뤬ͤʸ
+ ꥽åȤΥɥ쥹ΥڥǤ롥ˤĤƤrecvƱ͡
+
+ send(mesg, flags[, to])
+
+ åȤ𤷤ƥǡ롥flags˴ؤƤsend(2)򻲾Ȥλ
+ connectƤʤåȤФƤǤtoꤹɬ
+ פ롥ºݤäǡĹ֤
+
+Single Methods:
+
+ open(domain, type, protocol)
+ new(domain, type, protocol)
+
+ åȤ롥domaintypeprotocolϥ󥯥롼
+ եƤͤǻꤹ롥domaintype˴ؤ
+ ϡʸǻǤ뤬٤Ƥ򥫥СƤݾڤϤʤ
+
+ socketpair(domain, type, protocol)
+
+ åȤΥڥ֤λ openƱǤ롥
+
+** BasicSocket(饹)
+
+åȤɽݥ饹Ūʥåϥ֥饹롥
+㤨Х󥿡ͥåȥɥᥤξTCPsocketѤ롥
+
+SuperClass: IO
+
+Methods:
+
+ getopt(level, optname)
+
+ åȤΥץ롥getsockopt(2)򻲾ȤΤȡ
+ ץƤޤʸ֤
+
+ getpeername
+
+ ³ΥåȤξ롥ѥå줿sockaddr¤
+ ٥˥פʸ֤롥getpeername(2)򻲾ȤΤȡ
+
+ getsockname
+
+ åȤξ롥ѥå줿sockaddr¤Τ٥˥
+ ʸ֤롥getsockname(2)򻲾ȤΤȡ
+
+ setopt(level, optname, optval)
+
+ åȤΥץꤹ롥setsockopt(2)򻲾ȤΤȡ
+
+ shutdown(how)
+
+ åȤΰʹߤ³λ롥how0Ǥʹߤμ
+ how1Ǥϡʹߤݤ롥how2λˤϡ
+ ʹߤȤ˵ݤ롥shutdown(2)򻲾ȡ
+
+** TCPserver(饹)
+
+TCP/IPȥ꡼෿³Υ¦ΥåȤΥ饹Υ饹ˤä
+ñ˥åȤѤФΥץߥ󥰤Ǥ롥㤨echo
+ФϰʲΤ褦ˤʤ롥
+
+ gs = TCPserver.open(4444)
+ socks = [gs]
+
+ while TRUE
+ nsock = select(socks);
+ if nsock == nil; continue end
+ for s in nsock[0]
+ if s == gs
+ socks.push(s.accept)
+ else
+ if s.eof
+ s.close
+ socks.delete(s)
+ else
+ str = s.gets
+ s.write(str)
+ end
+ end
+ end
+ end
+
+SuperClass: TCPsocket
+
+Methods:
+
+ accept
+
+ 饤Ȥ³׵դ³TCPsocketΥ
+ 󥹤֤
+
+Single Methods:
+
+ new([host, ]service)
+ open([host, ]service)
+
+ service/etc/services(ޤNIS)ϿƤ륵ӥ̾
+ ݡֹǻꤹ롥hostꤷϻꤷۥȤ
+ ³դ롥άƤΥۥȤ³׵
+ 롥
+
+** TCPsocket
+
+󥿡ͥåȥɥᥤΥȥ꡼෿åȤΥ饹̾IO饹
+֥饹ƱͤϤǤ롥Υ饹ˤäƥåȤѤ
+饤Ȥñ˵ҤǤ롥桼Ϥ򤽤ΤޤޥФž
+ϰʲΤ褦ˤʤ롥
+
+ s = TCPsocket("localhost", 4444)
+ while gets()
+ s.write($_)
+ print(s.read)
+ end
+
+SuperClass: BasicSocket
+
+Methods:
+
+ addr
+
+ åȤ³ɽ֤γǤ1
+ ʸ "AF_INET"2Ǥportֹ桤3ǤۥȤɽʸ
+ Ǥ롥
+
+ peeraddr
+
+ ³襽åȤξɽ֤γǤ
+ addr᥽åɤ֤ƱǤ롥
+
+Single Methods:
+
+ open(host, service)
+ new(host, service)
+
+ hostǻꤷۥȤserviceǻꤷݡȤ³
+ Ȥ֤hostϥۥ̾ޤϥ󥿡ͥåȥɥ쥹򼨤ʸ
+ service/etc/services(ޤNIS)ϿƤ륵
+ ̾ݡֹǤ롥
+
+** UNIXserver
+
+UNIXȥ꡼෿³Υ¦ΥåȤΥ饹
+
+SuperClass: UNIXsocket
+
+Methods:
+
+ accept
+
+ 饤Ȥ³׵դ³UNIXsocketΥ
+ 󥹤֤
+
+** UNIXsocket
+
+UNIXɥᥤΥȥ꡼෿åȤΥ饹̾IO饹Υ֥饹
+ƱͤϤǤ롥
+
+SuperClass: BasicSocket
+
+Methods:
+
+ addr
+
+ åȤ³ɽ֤γǤ1
+ ʸ "AF_UNIX"2ǤpathǤ롥
+
+ path
+
+ UNIXåȤΥѥ֤
+
+ peeraddr
+
+ ³襽åȤξɽ֤γǤ
+ addr᥽åɤ֤ƱǤ롥
+
+Single Methods:
+
+ open(path)
+ new(path)
+
+ pathǻꤷѥ̾Ѥ³åȤ֤
+
+-------------------------------------------------------
+Local variables:
+fill-column: 70
+end:
diff --git a/ext/tkutil/MANIFEST b/ext/tkutil/MANIFEST
new file mode 100644
index 00000000000..98df4663b3a
--- /dev/null
+++ b/ext/tkutil/MANIFEST
@@ -0,0 +1,3 @@
+MANIFEST
+extconf.rb
+tkutil.c
diff --git a/ext/tkutil/extconf.rb b/ext/tkutil/extconf.rb
new file mode 100644
index 00000000000..b61a7ac01c8
--- /dev/null
+++ b/ext/tkutil/extconf.rb
@@ -0,0 +1,11 @@
+for dir in ENV['PATH'].split(':')
+ if File.exists? "#{dir}/wish"
+ $CFLAGS = $CFLAGS + " -DWISHPATH=" + "'\"#{dir}/wish\"'"
+ have_wish = TRUE
+ break
+ end
+end
+
+if have_wish and have_func('pipe')
+ create_makefile("tkutil")
+end
diff --git a/ext/tkutil/tkutil.c b/ext/tkutil/tkutil.c
new file mode 100644
index 00000000000..2b74b254c22
--- /dev/null
+++ b/ext/tkutil/tkutil.c
@@ -0,0 +1,54 @@
+/************************************************
+
+ tk.c -
+
+ $Author: matz $
+ $Date: 1995/11/03 00:47:55 $
+ created at: Fri Nov 3 00:47:54 JST 1995
+
+************************************************/
+
+#include "ruby.h"
+
+static VALUE
+tk_eval_cmd(argc, argv)
+ int argc;
+ VALUE argv[];
+{
+ VALUE cmd, rest;
+
+ rb_scan_args(argc, argv, "1*", &cmd, &rest);
+ rb_eval_cmd(cmd, rest);
+ return Qnil;
+}
+
+static VALUE
+tk_yield(obj)
+ VALUE obj;
+{
+ rb_yield_0(obj, obj);
+}
+
+static VALUE
+tk_s_new(argc, argv, class)
+ int argc;
+ VALUE *argv;
+ VALUE class;
+{
+ VALUE obj = obj_alloc(class);
+
+ rb_funcall2(obj, rb_intern("initialize"), argc, argv);
+ if (iterator_p()) tk_yield(obj);
+ return obj;
+}
+
+Init_tkutil()
+{
+ VALUE mTK = rb_define_module("TkUtil");
+ VALUE cTK = rb_define_class("TkKernel", cObject);
+
+ rb_define_const(mTK, "WISH_PATH", str_new2(WISHPATH));
+ rb_define_singleton_method(mTK, "eval_cmd", tk_eval_cmd, -1);
+
+ rb_define_singleton_method(cTK, "new", tk_s_new, -1);
+}