diff options
author | Yukihiro Matsumoto <[email protected]> | 1996-12-24 15:20:58 +0900 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2019-08-17 22:09:32 +0900 |
commit | 554b989ba1623b9f6a0b76f00824c83a23fbcbc1 (patch) | |
tree | 71f06227fe259bebaa5ca4bf05cc398184bced68 /sample | |
parent | fca49a8a69a0f6bb4feae74c6cd0e93d7fac8b36 (diff) |
version 0.99.4-961224v0_99_4_961224
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.99.4-961224.tar.gz
Tue Dec 24 15:20:58 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.4-961224
* configure.in: charがunsignedかどうかもチェック
* regex.c (SIGN_EXTEND_CHAR): __CHAR_UNSIGNED__にも対応
* pack.c (pack_unpack): 明示的にsigned charを指定.
Mon Dec 23 14:41:23 1996 Yukihiro Matsumoto <[email protected]>
* ruby.c (load_file): 標準入力からのスクリプトで一時ファイルを使わ
ないように
* object.c (f_integer): `0x', `0'などでbaseを解釈するように.
Fri Dec 20 01:44:39 1996 Yukihiro Matsumoto <[email protected]>
* Makefile.in (flock.o): flockに対応
Thu Dec 19 20:13:32 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.4-961219
Wed Dec 18 00:06:48 1996 Yukihiro Matsumoto <[email protected]>
* glob.c (glob_filename): strrchrがマクロの場合に対応
* configure.in: <sys/select.h>をチェック
* ext/kconv/kconv.c: 1.62ベースに
* ext/kconv/kconv.c: Kconvモジュール
* string.c (str_substr): lenが元の文字列より長い時に対応
* parse.y (iterator): 「$bar do .. end」などは許さないように
* parse.y (iterator): FID(foo!,foo?)をdo形式のイテレータにできる.
* missing/flock.c (flock): lockf()を使って代替
* file.c (file_flock): flockを実装
Tue Dec 17 12:13:38 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.4-961217
Fri Dec 13 02:05:03 1996 Yukihiro Matsumoto <[email protected]>
* configure.in: RUBYLIBのカレントを後回し(@mix/awk offline)
* dln.c: AIXに対応した?(@mix/awk offline)
* eval.c (thread_schedule): critical sectionでも明示的なコンテキス
トスイッチは起きないとまずい
* re.c (reg_search): matchに失敗した時に$~をnilに.
* re.c (reg_search): 毎回matchを生成するように
Thu Dec 12 17:03:30 1996 Yukihiro Matsumoto <[email protected]>
* numeric.c (flo_to_s): 2.0.to_s -> 2.0に
* eval.c (thread_save_context): $_, $~をthread毎に保存
* eval.c (thread_kill): main threadではexit(0)
* string.c (str_split_method): 間違った結果を返していた
Thu Dec 12 15:32:48 1996 WATANABE Hirofumi <[email protected]>
* dir.c: CYGWIN32対応
* ext/socket/socket.c: CYGWIN32対応
* io.c: CYGWIN32対応
Thu Dec 12 14:43:51 1996 Jun Kuroda <[email protected]>
* lib/tk.rb: wish4.2も探索候補に含める
* config.guess: JCC対応
Thu Dec 12 00:41:17 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.4-961212
* parse.y (parse_string): """..."""はやはり無くすことにした
* parse.y (parse_regx): %r|...|でterminatorを \ でエスケープできる
ように
* signal.c (posix_signal): sigactionを使うsignal
* configure.in: posix signal/bsd signalの検出
Wed Dec 11 17:47:35 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_schedule): critical sectionではコンテキストスイッ
チが起きないように
* lib/thread.rb: SharedMutexクラス
* lib/jcode.rb: String#scanを使うように
Tue Dec 10 12:21:28 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961210
* string.c (str_split_method): 正規表現に()を含む時にバグ
* lib/jcode.rb: ちょっとましになった
* string.c (tr_setup_table): 置換文字が短すぎる(2文字)のときのバグ
Mon Dec 9 11:38:04 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_scan): 文字列のマッチを行う.イテレータとしても動
作する
* regex.c (re_copy_registers): allocatedが初期化されていなかった
* re.c (match_to_s): $~の文字列化
* re.c (match_to_a): $~を配列化できるように
* re.c (match_getter): レジスタが初期化されていなかった
Thu Dec 5 11:06:10 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_split_method): マッチしなかった括弧は空文字列を
pushするべきではない
* string.c (str_succ): アルファベットを含まない文字に対応
Wed Dec 4 10:48:09 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961204
* io.c (io_binmode): DJGPPでのbinmode対応
* sprintf.c (f_sprintf): intの範囲の数値は直接sprintfで変換する
* sprintf.c (f_sprintf): "%02s"に頼らない
* re.c (reg_search): indexでSEGV
Tue Dec 3 10:09:36 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961203
* ext/extmk.rb.in (install): INSTALL_DATAからINSTALLに変更
* dln.c: hpux対応
* string.c (str_aset_method): 負の値を含む範囲でも例外を起こさない
* array.c (ary_replace): 負の値を含む範囲でも例外を起こさない
* array.c (beg_len): beg==endの時,長さ0に
Mon Dec 2 14:07:12 1996 Yukihiro Matsumoto <[email protected]>
* configure.in: HP shl対応
* string.c (str_upto): beg > endの時無限ループに落ちるのを止めた
* range.c (range_each): String#uptoが再定義された場合に対応
* string.c (str_split_method): "ABC".split(/(B)/)が誤動作
Sat Nov 30 01:43:52 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): undefでSEGV
Fri Nov 29 12:17:59 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-parse-region): %Q#..#などに対応.しか
し,区切り文字が演算子で行末にある場合には対応できなかった.
* re.c (reg_raise): 例外でもスラッシュをエスケープ
* re.c (reg_inspect): スラッシュをエスケープ
* parse.y (parse_string): `%[QqXxRr](.)..\1'なる文字列形式(テスト
採用)
* parse.y (parse_qstring): '''...'''の形式
* ext/dbm/dbm.c (Init_dbm): 述語key?,value?の追加
* ext/dbm/dbm.c (Init_dbm): includes->include?
* hash.c (Init_Hash): 述語key?,value?,include?の追加
* eval.c (rb_eval): else節が実行されない(うーん)
* string.c (str_sub_iter_s): イテレータブロック内でマッチが行われ
ると位置がずれる(時に無限ループに落ちる)
* string.c (str_resize): lenが0の時sizeの調整が行われなかった
Thu Nov 28 00:59:54 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961128
* parse.y (parse_string): 3-quote styleの文字列(例:"""abc"d"e""")
* configure.in (EXTSTATIC): extを静的にリンクする時にはrubyはdllを
使うように
* io.c (Init_IO): getsの引数が間違っていた
* string.c (str_each_line): RSを明示的に指定できるように
Wed Nov 27 12:37:46 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961127
* eval.c (rb_eval): iver defined? でselfを指定するのを忘れた
* io.c: gets等でRSを明示的に指定できるように
* ext/extmk.rb.in (install): static linkに失敗
Tue Nov 26 10:33:04 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961126
* string.c (str_sub_s): 置換後の文字列長さが間違っていた
Mon Nov 25 09:11:22 1996 Yukihiro Matsumoto <[email protected]>
* numeric.c (fix_rshift): 32以上の右シフトで0を返すように(Cの
rshiftは(x>>(y%32))を返していた).
* string.c (str_gsub): 置換が行われない場合があった
* string.c (str_resize): 本当に必要な時だけrealloc
Thu Nov 21 04:13:21 1996 Yukihiro Matsumoto <[email protected]>
* configure.in (EXTSTATIC): --with-static-linked-extで全てのモジュー
ルを静的リンクするように
* pack.c (pack_unpack): 行末の改行がない時にもチェックサムをスキッ
プするように
Wed Nov 20 96 21:42:51 1996 Yasuo OHBA <[email protected]>
* configure.in: freebsd対応
Wed Nov 20 10:24:24 1996 Yukihiro Matsumoto <[email protected]>
* ext/extmk.rb.in (install): 通常リンク用のLDFLAGSとダイナミックリ
ンク用のDLDFALGSを分離
* ext/extmk.rb.in (install): コンパイルの成功したものを静的リンク
のリストに追加する
* eval.c (f_missing): オブジェクトの文字列表現が長すぎる時バッファ
を書き潰していた
* process.c (proc_exec_v): forkした後例外を発生させてはいけない
Tue Nov 19 13:28:15 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961119
* eval.c (mod_method_defined): Module#method_defined? の追加
* parse.y (call_args): 引数が唯一のコマンドコールである時のバグ(戻
り値が展開されてしまう)
Mon Nov 18 13:28:18 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_sub): 失敗した時にnilを返していた
* string.c (str_split_method): 検索開始位置が移動してなかった
* ext/socket/socket.c (sock_s_getservbyaname): まだ間違っていた
* version 0.99.3-961118
* string.c (str_sub_s): 元の文字列を置換するのを止めた
* pack.c (encodes): 領域外をアクセスしていた
Fri Nov 15 17:10:35 1996 Yukihiro Matsumoto <[email protected]>
* bignum.c (big_divmod): Bignumが引数の場合の対応忘れ
* sample/ruby-mode.el (ruby-expr-beg): word?形式への対応が不完全
Wed Nov 13 15:42:40 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_tr_s_bang): tr_sでtrが行われていなかった
* eval.c (rb_eval): autoloadクラスのチェック
* string.c (f_sub): subがsub!と同じ動作になっていた
* eval.c (thread_sleep): stopとsleepの分離
Mon Nov 11 13:53:19 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961111
* numeric.c (fix_step): to, stepが整数以外の場合に対応
* eval.c (rb_call): dynamic varがdynamic scopingになっていた(これ
はまずい)
* string.c (str_chop_bang): 長さ0の文字列のchopで,領域外のアクセ
スが発生していた.
* parse.y (yyerror): 割り当てた領域外をアクセスしていた
Fri Nov 8 11:54:46 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_yield): scopeをheapにコピー
Thu Nov 7 09:56:53 1996 Yukihiro Matsumoto <[email protected]>
* numeric.c (num_coerce): とりあえず両辺をFloatに変換することに
Wed Nov 6 10:45:13 1996 Yasuo OHBA <[email protected]>
* lib/parsearg.rb: 第2引数を変更.
Tue Nov 5 14:21:09 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961105
Sat Nov 2 01:11:40 1996 Yukihiro Matsumoto <[email protected]>
* bignum.c (big_pow): typo (dy -> dx)
* bignum.c (big_divmod): 知らない型はfloatに変換してみる
* numeric.c (fix_lshift): 境界条件のバグ(負になっていた)
* bignum.c (big_pow): 無駄なfloatへの変換をなくした
* math.c (math_atan2): typo(x -> y)
Fri Nov 1 15:30:59 1996 Yukihiro Matsumoto <[email protected]>
* ext/socket/socket.c (sock_gethostname): gethostnameがない時には
unameを使ってホスト名を得る
* ext/etc/etc.c (etc_getlogin): getloginがNULLを返しても環境変数を
調べるように
* object.c (krn_clone): オブジェクトのフラグもコピー
* hash.c (rb_cmp): ハッシュの比較を`=='でなく`eql?'に変更
* math.c (Need_Float): Float()を使って変換する
* compar.c (cmp_gt): 以前の右辺を返す仕様の名残が残っていた
Thu Oct 31 12:55:51 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961031
* numeric.c (Init_Numeric): typo
* eval.c (error_print): 長すぎるtrace backを途中省略する
* regex.c (re_compile_pattern): 全角のrangeに対応
Wed Oct 30 03:03:18 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.3-961030
* io.c (f_ungetc): 関数を追加
* eval.c (dyna_var_asgn): return値忘れ
Tue Oct 29 10:05:28 1996 Yukihiro Matsumoto <[email protected]>
* string.c (f_split): 関数splitを追加
* eval.c (rb_call): ネストした外側のクラス/モジュールの定数を参照
できるように
Mon Oct 28 09:51:03 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_sub): offsetが文字の末尾にある時のチェック
* regex.c (re_match): 割り当てるレジスタの数が1多かった
* io.c (io_gets): $/ = ""の動作をperlに合わせる(awkとはちょっと違
うらしい)
* io.c (io_gets): $/ = nilの時少し高速化
* string.c (str_split_method): 括弧がnullにマッチした時にも無視し
ないように
* string.c (str_split_method): 括弧にマッチした分はlimitの数に含め
ないように.
* numeric.c (num_coerce_bin): coerceの定義を変更,2要素の配列
[x,y]を返すように
* sample/ruby-mode.el (ruby-calculate-indent): "do |aa|"の対応を改
善した.
Sat Oct 26 01:43:51 1996 Yukihiro Matsumoto <[email protected]>
* ext/marshal/marshal.c (w_object): ビルトインクラスのサブクラスを
正しく復旧できるように
* ext/marshal/marshal.c (w_object): ユーザ定義dumpの優先
* numeric.c (flo_coerce): Float()を使って定義
* numeric.c (Init_Numeric): Numericのnewのundefはまずい
* ext/marshal/marshal.c (w_symbol): シンボルの内容(文字列)は一度し
かファイルに書き出さない.
* sample/ruby-mode.el (ruby-parse-region): if/while修飾子に対応し
なくなっていた
* bignum.c (Init_Bignum): Bignum.newを除く
* eval.c (rb_eval): 引数評価後にファイル名と行番号を再設定
* numeric.c (flo_div): typo
* sample/ruby-mode.el (ruby-parse-region): def /, def `に対応
Fri Oct 25 09:26:29 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-calculate-indent): "do |aa|"に対応
* array.c (ary_aset): indexがfixnumの場合ちょっと高速化
* eval.c (thread_fd_writable): 書き込み前のselectチェック
* array.c (ary_assoc): 無限ループに落ちた
* eval.c (thread_wait_for): selectがエラー終了した時,linux以外で
の動作が正しくなかった.
Thu Oct 24 08:26:48 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (backtrace): `$@'を文字列から配列に変更した.
* eval.c (eval): eval中の例外発生位置を保存する
* bignum.c (bigsub): オペランドの大小比較の失敗
* re.c (reg_search): 直接参照がない時にも`$~'がセットされるように
Wed Oct 23 10:40:10 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-961023
* ext/marshal/marshal.c (r_bytes): mallocをやめ,allocaを使う
* sample/ruby-mode.el (ruby-calculate-indent): 括弧の対応を変更.
()内ではインデントをレベルを合わせるように
Tue Oct 22 12:59:11 1996 Yukihiro Matsumoto <[email protected]>
* hash.c (hash_s_new): sizeを指定できるように
* ext/marshal/marshal.c (w_object): dumpする深さ制限を指定できるよ
うに
* array.c (ary_s_new): sizeを指定した時の初期化忘れ
* object.c (f_float): big2dblの宣言忘れ.
* bignum.c (bigsub): 大きさの近いBignum同士の演算で結果が負になる
場合に間違いがあった.
* array.c (ary_aset): 置換先と置換元が同じ長さの時内容を
shift(memmove)しないように.
* ext/marshal/marshal.c (marshal_dump): ファイルフォーマットにバー
ジョンを埋め込むように
* ext/marshal/marshal.c (tmpnam): linux-aout-dln用に定義
Mon Oct 21 08:40:20 1996 Yukihiro Matsumoto <[email protected]>
* ext/socket/socket.c (sock_s_gethostbyname): hostent構造体の情報
を返す
(sock_s_gethostbyaddr): IPアドレスからhostent構造体を得る
(sock_s_getservbyaname): getservbyname(3)
Fri Oct 18 10:37:36 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-indent-to): 移動先カラムが負になるバグ
* eval.c (compile): evalで元ソースの行番号でエラーを表示する
Thu Oct 17 09:52:28 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (eval): evalで文法エラーがあった時にSEGV
* lib/safe.rb: Restricted.evalの中だけ制限を加える.
* eval.c (error_print): バックトレースの出力.callerで例外発生位置
を調整した時に問題が出る(そんなことをしなければ良いのだが…)
* eval.c (make_backtrace): バックトレースの生成
Wed Oct 16 12:56:22 1996 Yukihiro Matsumoto <[email protected]>
* ruby-man-0.99.2-jp/index.html: 日本語版ドキュメントの完成(長かった…)
* re.c (reg_regcomp): $=がnilの時の処理
* string.c (f_chop): $_に対するchop
Tue Oct 15 11:04:23 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-961015
Mon Oct 14 18:22:38 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_schedule): BOW対応.selectが-1を返した時にバグ(実
はdo .. whileがcontinueで先頭にジャンプすると思い込んでいた.条
件の直前だったのね ^^);;;;;
* sample/ruby-mode.el (ruby-mode-syntax-table): ?のsyntaxが"/"では
まずいらしい
* hash.c (rb_hash): name conflict
Fri Oct 11 00:23:05 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-961011
* ext/marshal/marshal.c (w_object): 結局動いていなかった循環オブジェ
クト対応を外した.
* hash.c (rb_hash): Fixnumと文字列の高速化
* ext/marshal/marshal.c (w_object): 無駄なデータの削除(フォーマッ
トの非互換性)
* io.c (io_readline): 戻り値の不備
* ext/marshal/marshal.c (marshal_dumps): MSDOS対応
* ruby.c (load_file): MSDOS対応
Wed Oct 9 17:46:27 1996 Yukihiro Matsumoto <[email protected]>
* ext/extmk.rb.in (install): 無駄なコピーを避ける
* string.c (str_sub_method): マッチがなかった時のString#subの値が
違っていた.
* eval.c (obj_extend): extendした時にobject_extendedを呼ぶように
Tue Oct 8 00:55:38 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_alloc): 割当の平均化
* eval.c (thread_schedule): joinのバグを修正
* eval.c (thread_wait_for): selectへの割込みなどに対応
* eval.c (thread_select): linuxのselectの挙動に対応(timeoutが変化
する)
Mon Oct 7 09:47:19 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-961007
* eval.c (PUSH_BLOCK): the_classの保存を忘れていた.
* ext/dbm/dbm.c (fdbm_store): sizeの保存する場所が間違っていた
* ext/socket/socket.c (s_accept): thread対応していなかった
Sat Oct 5 01:32:27 1996 Yukihiro Matsumoto <[email protected]>
* io.c (io_readchar): EOFで例外を発生させる
Fri Oct 4 11:59:54 1996 Yukihiro Matsumoto <[email protected]>
* ext/marshal/marshal.c (w_object): HashとObjectの復旧に必要なハッ
シュテーブルが渡されていなかった.
* variable.c (rb_path2class): ユーザ定義クラスの復旧に失敗していた
* variable.c (rb_path2class): クラスが存在しない時のエラーをFatal
からNameErrorへ.
* range.c (range_s_new): first,lastが両方Numericの時エラーになって
いた.
* range.c: start->first, end->last
Wed Oct 2 02:02:46 1996 Yukihiro Matsumoto <[email protected]>
* file.c: DJGPPでchmod,chownを使えるように(ってDOSにchownがあるのか?)
* class.c (rb_singleton_class): ビルトインクラスもextendしたり特異
メソッドを追加したりできるように
* variable.c (rb_set_class_path): ユーザ定義のトップレベルクラスに
pathを設定しない
* eval.c (eval): 例外がRuntimeErrorに化けていた
* eval.c (eval): eval中の例外の表現の改善
* eval.c (eval): eval_with_bindingとの一本化
* eval.c (rb_eval): クラス/モジュール定義の中から定義中のクラス/モ
ジュールが参照できるように
Tue Oct 1 01:40:09 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-961001
* parse.y: cur_crefが2度宣言されていた
* signal.c (trap): SIGSEGV,SIGBUSのない機種に対応
* io.c (Init_IO): 引数タイプの指定間違い
Mon Sep 30 15:28:00 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-960930
* config.guess,config.sub: $host_osが正しく設定されない
* eval.c (rb_eval): yieldで正しくないselfが設定されていた
* eval.c (ruby_run): toplevelの例外処理のバグ
Mon Sep 30 09:13:26 1996 WATANABE Hirofumi <[email protected]>
* djgpp対応
Sat Sep 28 02:45:10 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-960928
* sample/ruby-mode.el (ruby-beginning-of-block): ブロックの先頭に
移動(正しくインデントしていないと動作しない)
(ruby-end-of-block): 同上
* eval.c (class_s_new): Class#newがイテレータとして呼ばれた時は
initializeもイテレータとして呼ばれるように
* signal.c (sigsegv): SEGVでbacktraceを表示するように
Fri Sep 27 09:51:07 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-960927
* eval.c (error_print): 引数のないraiseでメッセージが正しく表示さ
れるように.
* eval.c (rb_longjmp): mesgがnilの時RuntimeErrorを生成する.
* eval.c (f_raise): 引数がない時に対応
* eval.c (thread_mark): stack上にないデータのアドレス変換を行って
いた.
* eval.c (Init_Thread): 割込みの間隔が1秒と長すぎた.
Thu Sep 26 16:02:45 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_schedule): 一度ペンディングになるとフラグがクリア
されていなかった.
* process.c (rb_proc_exec): system/execの引数が空文字列であった場
合,例外を発生すべきだった.
* config.sub/config.guess: 新しいものに置き換え
Thu Sep 26 15:41:35 1996 WATANABE Hirofumi <[email protected]>
* io.c (next_argv): -i.bakをBOWとDOSに対応.
Thu Sep 26 01:31:43 1996 Yukihiro Matsumoto <[email protected]>
* io.c (io_sysread): EOFで例外
* io.c (f_readline): EOFで例外を発生するように.getsは互換性のため
nilを返すままにする
* eval.c (proc_call): lambdaからのreturnでIN_BLOCKフラグが立ったま
まだった
* eval.c (PUSH_BLOCK2): threadに対応するためBlockを一度stackにコピー
Wed Sep 25 11:54:11 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (method_call): Const::method()形式を使えるようにしてみた.
引数括弧は省略できない.
* sample/test.rb: Process.killの存在を確かめてからテストを行う
* eval.c (eval_with_binding): 第2引数としてbinding(またはlambda)を
与えるとその環境でevalを実行するようにした
* eval.c (f_binding): 現在のbindingを返す関数
* eval.c: block構造体にthe_classを保存するメンバを追加
* process.c (Init_process): kill,wait,waitpidをProcessに移動
Tue Sep 24 02:44:43 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el: いろいろ問題が多いので以前の高速化は破棄.
別のアプローチを使った.
* lib/tk.rb (Tk.pack): 複数のウィンドウを受け付けるpack
Sat Sep 21 11:08:09 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (exprs): 空文も受け付けるように文法を変更.今までは改行
の連続だけが許されていた.
Fri Sep 20 11:39:18 1996 Yukihiro Matsumoto <[email protected]>
* Failの大半を名前つき例外に変更.
* re.c (Init_Regexp): 名前つき例外を導入.
* eval.c (f_missing): Objectはinspectしない.
* object.c (inspect_i): Object#inspectでloopに対応.
* regex.c (re_search): /^$/が""にマッチしなかった.
Thu Sep 19 19:25:12 1996 Yukihiro Matsumoto <[email protected]>
* regex.c (re_search): /^$/が非空行にマッチしていた.
Tue Sep 17 10:28:11 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-960917
Mon Sep 16 10:47:56 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-calculate-indent): 演算子継続の場合の
文字列の判定のバグ
* sample/ruby-mode.el (ruby-calculate-indent): elseなどの次の行の
インデント計算を正しく.
Sat Sep 14 08:37:19 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.2-960914
Fri Sep 13 08:06:03 1996 Yukihiro Matsumoto <[email protected]>
* ext/socket/socket.c (tcpaddr): port番号にntohsをつけ忘れ
* dln.c (link_undef): テーブルの種類が間違っていた.
* bignum.c (bigadd): 引き算が発生する時に計算違いが起きていた.
* parse.y (iter_do_block): do..endでもdynamic variableを.
* bignum.c (big_pow): より正確な計算を(整数同士ではfloatに変換しな
い).
Thu Sep 12 13:11:55 1996 Yukihiro Matsumoto <[email protected]>
* variable.c (rb_set_class_path): Stringクラスが初期化される前に
Stringを作っていた.組込みクラスにはpathはいらない
* parse.y (yylex): 0.1が0になっていた
* parse.y (yylex): 行番号の不整合
* gc.c (oblist_live_obj): 今「生きている」全部のオブジェクトを返す
イテレータ.そのクラス(またはサブクラス)の全部のインスタンスを返
すeach_object_ofも定義した.
* class.c (rb_define_class_id): 無駄なクラスを割り当てていた.結果
として未初期化のクラスオブジェクトが存在していた.
Wed Sep 11 00:56:23 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (yylex): octalの定数の検出をより正確に(090はエラーとか).
* bignum.c (big_minus): yがxより大きい場合にエラー.
* parse.y (yylex): エラー行番号の表示をより正確に
* sample/ruby-mode.el (ruby-expr-beg): 変数名が1文字の時誤動作して
いた.
* sample/ruby-mode.el (ruby-calculate-indent): ?/でループに落ちい
たバグを修正.
* enum.c (enum_min,enum_max): sortのようにイテレータとしても動作す
るように.
* enum.c (enum_find_all): typo
Tue Sep 10 12:07:12 1996 Yukihiro Matsumoto <[email protected]>
* node.h (nd_line): NODEのlineをflagsに押し込めてオブジェクトサイ
ズを小さくした.制限:32bit intのマシンの場合,ファイルの行数が
32767を越えると正常に表示されない.
* st.c: hashとcompareの関数メンバを構造体にパック,クラス的な使い
方を行う.1 tableあたり4 byteの節約.
Mon Sep 9 16:35:54 1996 Yukihiro Matsumoto <[email protected]>
* file.c (file_truncate): 提供されない時には特別な例外を発生するよ
うに.
* eval.c (Init_Proc): 不適切な位置のlocal-jumpを例外に.
Sat Sep 7 17:06:15 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (proc_call): まだスコープがスタック上にある時には局所脱出
を有効にする.これで,procを生成してcallすることは,スコープを脱
出しない限り,yieldと同じ意味を持つことになる.
Fri Sep 6 13:30:59 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-indent-to): インデントが変わらない時に
はバッファを変更しない.
(ruby-calculate-indent): まず文字列の内部か判断してから,前の行
からパーズを行う.defunが大きくなった時の高速化.
(ruby-in-string-p): 文字列の内部かどうかを判断する関数(以前の
parseから分離)
(ruby-parse-region): 文字列に対する処理をはずす.
(ruby-beginning-of-block): ブロックの先頭に
(ruby-end-of-block): ブロックの末尾に(遅い…)
Thu Sep 5 14:23:07 1996 Yukihiro Matsumoto <[email protected]>
* file.c (file_s_split): [dirname,basename]にsplitする.
* eval.c (rb_eval): evalの中でも定数の値が正しくなるように.これで
定数に関しては静的なスコープが保証されるようになった.
* st.c (rehash): ハッシュ拡大の系数を2から1.79に.割算がより良い値
を返すように.
Thu Sep 5 00:32:07 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (class_superclass) クラスのスーパークラスを返すメソッド.
Wed Sep 4 16:54:56 1996 Yukihiro Matsumoto <[email protected]>
* random.c (f_rand): Bignumやlongの範囲を越えるFloatに対する乱数も
発生できるように.
* struct.c (struct_alloc): Fatalではなく例外を発生させるように(通
常の使用で発生しうる).
* struct.c (struct_s_members): Structの特異メソッドではなく,生成
されたStructクラスの特異メソッドにした.
* st.c (st_init_table): ruby専用にパラメタを固定にした(サイ
ズが減った)
Mon Sep 2 11:37:59 1996 Yukihiro Matsumoto <[email protected]>
* array.c (ary_shift): capaがあまりにも大きい時には領域をREALLOC
(ary_pop): 同上
* string.c (str_inspect): multibyte character 対応にミス.
(str_inspect): unsigned charにしないと符号展開されてしまう
* parse.y (primary): `::'をprimaryに移動 Foo::Bar.Bazがエラーにな
らないように.
* parse.y (primary): オペレータ形式の特異メソッドが定義できない
* random.c (f_rand): maxが0の時に対応
* io.c (io_printf): 関数を定義していたがインタプリタに登録していな
かった.
* file.c (file_s_basename): 第2引数が無い時にエラー.
Thu Aug 29 10:49:40 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (expr): イテレータの新形式に「method do .. end」形式を採
用した.もちろん昔の形式も有効.
* sample/ruby-mode.el (ruby-calculate-indent): endの数の方が多い場
合にもエラーを起こさないように.
Wed Aug 28 09:41:36 1996 Yukihiro Matsumoto <[email protected]>
* numeric.c (upto,downto,step,times): 対象がfixnumの範囲を越えても
動作するように.
Mon Aug 26 10:04:37 1996 Yukihiro Matsumoto <[email protected]>
* missing/setenv.c (envix): typo(missing `== 0' for memcmp)
* dir.c (dir_foreach): foreach(dir open -> read loop -> closeまで)
* io.c (io_foreach): foreach(file open -> read loop -> closeまで)
* Fatalのうち捕捉可能ないくつかを例外に.
Sat Aug 24 23:56:37 1996 Yukihiro Matsumoto <[email protected]>
* bignum.c (bigdivmod): FIX2INT -> INT2FIX 大間違い
Fri Aug 23 18:13:03 1996 Yukihiro Matsumoto <[email protected]>
* regex.c (re_free_registers): allocateしていない時には当然 free
してはいけない.
Thu Aug 22 01:20:35 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_create): 外側から強制終了させられたthreadは
cleanupする必要が無い.
Wed Aug 21 09:57:28 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_create): threadを終了させた大域脱出の情報を
main_threadに渡すように.
* parse.y (call_args): 最終引数に括弧を省略したメソッド呼出しを置
けるように(例: print foo bar, baz == print(foo(bar,baz)))
Tue Aug 20 13:37:16 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (masign): 多重代入とrest引数の動作を合わせて空の配列を代
入するように.
* parse.y (arg): defined?の強度をもうちょっと強く
* eval.c (error_print): -wで例外名も表示するように
* eval.c (rb_eval): 新構文に対応
(handle_rescue): 捕捉する例外を kind_of? で同定
* parse.y (primary): rescueの構文を変更(同定引数の追加,複数rescue)
* Fail()のかなりを適当な例外を使うように
* eval.c (thread_interrupt): Interrupt(今はnon-local jump)は
main-threadに送られるように.
* eval.c (rb_longjmp): $! の内容を文字列から例外クラスに変更
(rb_raise): rb_fail から名称変更
(rb_interrupt): 例外化
(rb_exit): 例外化
* error.c (Init_Exception): 例外クラスの新設(文字列のサブクラス)
Mon Aug 19 19:40:52 1996 Yukihiro Matsumoto <[email protected]>
* signal.c (trap): 古いハンドラを返すように.
Wed Aug 14 00:07:18 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_trap_eval): ハンドラのためにthreadをforkすることを止
めた.
* eval.c (thread_mark): thread毎の $!, $@ をマークし忘れ
* ext/dbm/dbm.c (fdbm_delete): イテレータとして呼ばれた場合,要素
が無ければブロックを評価する.
* hash.c (hash_delete): イテレータとして呼ばれた場合,要素が無けれ
ばブロックを評価する.
* array.c (ary_delete): イテレータとして呼ばれた場合,要素が無けれ
ばブロックを評価する.
* eval.c (rb_interrupt): SIGINTのデフォルトをexitから特別な大域脱
出に.やはり割り込まれた位置の表示が無いのは寂しいので.
Tue Aug 13 01:34:00 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_exit): sub-thread内でのexitもstatusを保存するように
(thread_create): 自thread内のexitに対応
* signal.c (sighandle): SIGINTのデフォルトハンドラはexitするように
(以前は例外を発生していた).
* 例外の一部をFatalに.
* string.c (str_aset): 文字列の置換の対象が部分文字列でなかった時,
例外を発生させないように
* eval.c (proc_call): Procの中からbreak/nextは通し,他のものは通さ
ないように
Mon Aug 12 14:15:09 1996 Yukihiro Matsumoto <[email protected]>
* object.c (krn_type): 文字列を返す
* eval.c (thread_create): sub-thread内でのexitに対応
* numeric.c (fix_type): 文字列を返す
* io.c (f_p): デバッグ用データ表示メソッド
* eval.c (f_missing): nil/TRUE/FALSEを特別扱い
* string.c (str_inspect): 長い文字列を短縮表示.inspectの働きを
human readable stringの生成に統一(re-generatable string は正式に
無くなった).
Sat Aug 10 16:54:21 1996 Yukihiro Matsumoto <[email protected]>
* object.c (Init_Object): kernel/nil/false/trueのクラス名を変更(小
文字に),rubyスクリプトからアクセスできないように.
* eval.c (rb_eval): CONSTANTのアクセス先を単純化.crefを使わない.
* eval.c (f_eval): 特異メソッド内でも定数の値が正しくなるように
Fri Aug 9 12:23:17 1996 Yukihiro Matsumoto <[email protected]>
* array.c (ary_concat): append -> concat Stringに合わせた
* parse.y (yylex): `$;'が使えなかった.
* array.c (ary_push_method): 複数引数を受け付けるように.
(ary_unshift): 複数引数を受け付けるように.
* io.c (io_popen): IO.popenでcommand pipeが開けるように.
* object.c (Init_Object): KernelとNilをruby scriptからアクセスでき
ないように.
Thu Aug 8 01:21:47 1996 Yukihiro Matsumoto <[email protected]>
* object.c (f_integer): 整数への変換関数
(f_float): 実数への変換関数
(f_string): 文字列への変換関数
(f_array): 配列への変換関数
* bignum.c (big_to_i): FIXNUMの範囲でない時はBignumのまま返すよう
に変更.
Wed Aug 7 09:28:38 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99.1-960807
* parse.y (mlhs): 「*foo = 1,2,3」タイプの多重代入も可能に.
* object.c (Init_Object): クラスTrue/Falseをruby scriptからアクセ
スできないように.
* object.c (nil_inspect): inspect表現は"nil"に
* io.c (io_print): nilのprintをnilに.
* object.c (nil_to_s): nilの文字列表現を""に.
Tue Aug 6 01:12:32 1996 Yukihiro Matsumoto <[email protected]>
* dir.c (dir_s_open): file descripterが足りない時にはgcしてからも
う一度openしてみる.
* io.c (rb_fopen): すべてのfopen()についてfile descripterが足りな
い時にはgcしてからもう一度openしてみる.
* ext/socket/socket.c (Init_socket): 定数の追加.
* sample/ruby-mode.el (ruby-indent-to): インデント後のカーソル位置
の調整を正しく.
* gc.c (gc): 割込みチェックを行わない(Cコードの中で安心して
malloc()が使えなくなるので).
* st.c (call_hash_func): signalとthreadによる割込みに対応.
* sig.h (DEFER_INTS): 割込み禁止区間の指定
* eval.c (f_require): threadによるrequireの競合に対応(最初の
requireが終了するまで他のthreadは待つ).
* bignum.c (str2inum): 0x80000000の値が負になっていた
* sprintf.c (f_sprintf): 文字列末尾,行末の単独の`%'に対応
* bignum.c (big_cmp): 比較の結果が逆になる時があった.
Mon Aug 5 10:58:13 1996 Yukihiro Matsumoto <[email protected]>
* process.c (proc_exec_v): 例外のメッセージを分かりやすく.
* ext/dbm/dbm.c (fdbm_store): nilを格納すると要素の削除になる
* ext/dbm/dbm.c: サイズをキャッシュ.
Sat Aug 3 01:52:52 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_fail): `fail'が引数無しで呼ばれた時だけ以前の`$@'を保
存するように.
* eval.c (f_fail): frameの調整
Fri Aug 2 11:26:21 1996 Yukihiro Matsumoto <[email protected]>
* ext/socket/socket.c (bsock_setopt): valとしてTRUE/FALSE/Fixnumも
受け付けるように.
* ext/socket/socket.c (Init_socket): SO_REUSEADDR等の定数の追加
* ext/md5/md5init.c: md5モジュール(初の複数ファイルからなるモジュー
ルでもある)
* ruby.h (Make_Data_Struct): Data: objectのinstance変数に格納 ->
Data型のObjectに(Dir,Time,Proc,Thread,DBM)
Thu Aug 1 11:38:44 1996 Yukihiro Matsumoto <[email protected]>
* ext/dbm/dbm.c (fdbm_store): valueが文字で無い時に対応
Wed Jul 31 10:53:42 1996 Yukihiro Matsumoto <[email protected]>
* ext/socket/socket.c (open_inet): htonsが必要であった
(tcpaddr): ntohlで変換した
* process.c (rb_proc_exec): execvp -> execv
Tue Jul 30 17:48:33 1996 Yukihiro Matsumoto <[email protected]>
* eval.c: `$?'をthread localに
* Makefile.in (install): install時にstripを行う
* configure.in: install時のstripの検出
* configure.in: NEXTSTEP対応
* version 0.99.1-960730
Tue Jul 30 16:40:35 1996 SHIROYAMA Takayuki <[email protected]>
* dln.c (dln_load): NeXT dln(mach-o)対応.configureは未対応
Tue Jul 30 09:46:51 1996 Yukihiro Matsumoto <[email protected]>
* process.c (f_system): 複数引数もとれるように
* process.c (f_exec): 複数引数もとれるように
* array.c (ary_append): 配列(またはEnum)の要素を破壊的に追加
* array.c (ary_plus): Enumはその要素を追加
* file.c (file_s_open): File.openを追加
* struct.c (struct_new): FIX2INTを忘れていた
* file.c (Init_File): exists? -> exist?
* object.c (obj_is_kind_of): is_kind_of? -> kind_of?, is_a?
* object.c (obj_is_instance_of): is_instance_of? -> instance_of?
Mon Jul 29 16:40:02 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (parse_regx): 式展開を行った場合,casefoldの設定ができて
いなかった.
* object.c (true_type): TRUE/FALSEにtypeを実装.
* parse.y (read_escape): 3文字以内のoctalに対応(\0とか)
Fri Jul 26 00:31:45 1996 Yukihiro Matsumoto <[email protected]>
* array.c (ary_reverse_bang): in-placeで配列を反転させる
(ary_sort_bang): in-placeでsortする
(ary_sort): sortした配列を返すように
(ary_delete_at): 指定した位置の要素を削除する
* eval.c (rb_call): stack深さチェックを毎回は行わないように
* error.c (Warning): 実行中のwarningが表示されていなかった
* eval.c (compile): 例外発生を分離.
* eval.c (f_eval): 変数rb_in_evalを正しく管理するように
* ext/dbm/dbm.c (fdbm_store): 格納するkeyを文字列に変換
* eval.c (rb_call): 無限再帰のチェックを大域脱出を行うC methodにも
対応させた.threadのstack深さチェックルーチンを流用.
* parse.y (yylex): 第1引数のunary -/+の判定が間違っていた.
* parse.y (yylex): unary +で数字を余計に読んでいた(ex. +5 -> 55)
Thu Jul 25 12:15:04 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (yylex): 曖昧でない引数に対して警告を出していた.
* eval.c (iterator_p): 引数で呼んでも正しい結果を返すように.
* parse.y: break/next/redo/retryのメソッド化.
* sample/ruby-mode.el (ruby-calculate-indent): nestのチェックミス
* sample/ruby-mode.el (ruby-parse-region): 予約語のチェックを強化
* parse.y (primary): unless/untilの復活
Tue Jul 23 18:50:10 1996 Yukihiro Matsumoto <[email protected]>
* array.c (Array#empty?), Hash.c (Hash#empty?), ext/dbm/dbm.c (DBM#empty?):
空の判定述語
* eval.c (f_unless): ifの逆をするイテレータ
* eval.c (f_until): whileの逆をするイテレータ
* parse.y: notの優先順位をand/orより高く
* parse.y (expr): `!'を引数括弧を省略したcallでも有効に
Mon Jul 22 10:15:38 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960722
* array.c (ary_print_on): OFSのNILチェックが不完全
* ruby.c (load_file): 標準入力からのスクリプトが空の時に対応.
* ruby.c (proc_options): -wでは引数無しの時には標準入力からスクリ
プトをとる(-vではたんに終了する).
* array.c (ary_compact): nilの要素を取り除くメソッド
* array.c (ary_nitems): nilでない要素を数えるメソッド
Sun Jul 20 00:51:53 1996 Yukihiro Matsumoto <[email protected]>
* ruby.c (proc_options): -w optionを追加
* parse.y: {}が閉じていない時には展開しない文字列を
Fri Jul 19 16:16:05 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960719
* lib/find.rb: 石塚版(pruneの拡張付き)
* file.c (test_l): lstatで調べないとね.
* eval.c (f_throw): 第2引数を省略可能に.
* parse.y (str_extend): {}のネストに対応
Thu Jul 18 18:25:46 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960718
* parse.y (str_extend): 文字列中の式展開に \" ' ` / を含む事ができ
るように.
Tue Jul 16 15:55:31 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-parse-region): 正規表現内のエスケープ
に対応
* version 0.99-960716
Fri Jul 12 10:06:19 1996 Yukihiro Matsumoto <[email protected]>
* io.c (f_select): 引数のclose check.
* ruby.c (load_file): #!行の引数チェックを第1引数に限定(実をいうと
DOS改行対策)
Wed Jul 10 17:18:35 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960710
* time.c (time_s_timegm/time_s_timelocal): 時間を生成するメソッド
Mon Jun 17 15:59:20 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960617
* parse.y (yyerror): エラー表示の簡略化.
Wed Jun 12 14:11:01 1996 Yukihiro Matsumoto <[email protected]>
* signal.c (rb_trap_exit): trap 0はthreadを生成せずに処理する.
Fri Jun 7 10:17:01 1996 Yukihiro Matsumoto <[email protected]>
* array.c/hash.c (indexes): 配列1引数のパターンを無くした.配列の
場合は`*ary'を使ってもらおう.
* eval.c (thread_wait_threads): main_threadが終了する前に他の
threadを待つ(強制的には終了させない).
(ruby_run): 他のthreadを待っている間にシグナルが来たら,全thread
を強制終了させる.
* eval.c (rb_fail): メソッド名を`$!'に埋め込む.
* eval.c (thread_create): main_threadのコンテクストがセーブされな
い場合があった.
* process.c (f_sleep): 時間を指定せず,threadがひとつしかない状況
にも対応.
* eval.c (thread_create): create後,fnを呼び出す前にcontext switch
が起きると違うcontextでfnが実行されてしまうバグ.
Mon Jun 3 08:03:17 1996 Yukihiro Matsumoto <[email protected]>
* struct.c (struct_s_def): メンバの指定を文字列,シンボル(FIXNUM)
双方で可能にした.
* ext/etc/etc.c (Init_etc): 構造体オブジェクトをGCから保護した.
* error.c (rb_sys_fail): nil/FALSEを引数として受け付けるように.
Thu May 30 16:19:08 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_select): EINTRに対応.
Wed May 29 11:04:51 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (f_catch): catch/throwを実装した.
Tue May 28 13:30:52 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960528
* eval.c (thread_cleanup): main threadが終了すると他のthreadも終了
することの明確化.
* signal.c (trap): SIGINTのデフォルトの設定ミス(本当にSIG_DFLでは
まずかった).rubyではちゃんとハンドルしないと.
* eval.c (thread_interrupt): SIGINTはmain_threadに例外を発生させる
ように.
Mon May 27 15:13:31 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_status): threadの状態を返すメソッド.threadの終了
を待たない.
* eval.c (thread_value): 一種のpromiseを実装するためのメソッド.
* eval.c (thread_join): 待っているthreadが例外を起こした時には,
joinがその例外を発生するように.
* eval.c (thread_create): threadでの例外をpropagateしないように.
Fri May 24 10:47:53 1996 Yukihiro Matsumoto <[email protected]>
* enum.c (Init_Enumerable): `size' as alias to the `length'
* eval.c (thread_save_context): `$@', `$!'をスレッド毎にセーブ.
* eval.c (superclass): エラー表示をより親切に.
Thu May 23 10:38:41 1996 Yukihiro Matsumoto <[email protected]>
* version 0.99-960523
* eval.c (superclass): エラー時にスーパークラス名を(分かれば)表示
するように.
Wed May 22 19:48:42 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (superclass): スーパークラスの指定子を`:'から`<'に変更.
Tue May 21 09:27:59 1996 Yukihiro Matsumoto <[email protected]>
* lib/thread.rb: threadをサポートするクラス(Mutex, Queue).
Mon May 20 09:39:49 1996 Yukihiro Matsumoto <[email protected]>
* time.c (time_cmp): 浮動小数点数も扱えるように.
(time_minus): Time - Timeが浮動小数点数を返すように.
Fri May 17 15:40:10 1996 Yukihiro Matsumoto <[email protected]>
* process.c (rb_proc_exec): Thread対応時にexecの直前に
ITIMER_VIRTUALをリセットする.
Tue May 14 02:12:44 1996 Yukihiro Matsumoto <[email protected]>
* signal.c (sighandle): SIGINTに対してデフォルトで例外を発生させる
のをやめ,status 130でexitするようにした.
* eval.c (thread_schedule): Threadのバグはほとんどとれたようだ.
Fri May 10 11:21:08 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (thread_schedule): ユーザレベルThread機能.効率はともかく
移植性はある.今後,thread間の通信機能を実装する予定.
Thu May 2 21:22:31 1996 Yukihiro Matsumoto <[email protected]>
* time.c (time_timeval): struct timevalを直接返すように(static変数
を使わない).
Wed May 1 17:27:32 1996 Yukihiro Matsumoto <[email protected]>
* process.c (f_sleep): 整数以外のtimeを指定できるように.
Thu Apr 25 08:19:15 1996 Yukihiro Matsumoto <[email protected]>
* file.c (file_s_dirname): ファイル名が"/"を含まない時,"."を返す
ように(GNU dirnameの仕様).
* file.c (file_s_basename): まだnilと0を混同しているソースが残って
いた.
* parse.y (exprs): エラーリカバリを追加.
Wed Apr 24 15:51:05 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_chop_bang): CRLFの場合2 bytesをchop!するように.
* ext/socket/socket.c (tcp_svr_s_open): まだnilと0を混同しているソー
スが残っていた.
Tue Apr 23 18:14:25 1996 Yukihiro Matsumoto <[email protected]>
* pack.c (pack_pack): "A/a"のバグ.余計なpaddingが入っていた.
Thu Apr 18 13:02:11 1996 Yukihiro Matsumoto <[email protected]>
* configure.in: アーキテクチャ依存部を別ディレクトリにインストール
するように.
* parse.y (yyerror): エラー発生時にエラー行とその位置を表示するよ
うに.
Wed Apr 17 14:22:42 1996 Yukihiro Matsumoto <[email protected]>
* defines.h: SAFE_SIGHANDLEを無くし,危険な選択はできないように.
* io.c (io_ungetc): 新機能.
* ruby.c (load_file): ファイルからの読み込み方式が変わったのに対応.
* parse.y (compile_file): ファイルからの入力を一度全部読み込むのを
止めて,getsを使うことにした.
Wed Apr 10 17:40:11 1996 Yukihiro Matsumoto <[email protected]>
* version 0.98
Tue Apr 9 09:54:30 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (iter_block): イテレータブロックの指定をメソッド呼び出し
に限定.文法の明確化.
* eval.c (rb_eval): 条件式の正規表現の比較をinline化.
* eval.c (rb_eval): defined? の 定義情報(種別)を文字列で返す.
* node.h: NODE_BEGIN -> NODE_RESCUE, NODE_ENSUREに分離.
* eval.c (rb_eval): option -n/-pのトップレベルループのinline展開.
* parse.y (cond0): 条件式中の文字列は比較の対象としない
Wed Mar 27 12:33:54 1996 Tairo Nomura <[email protected]>
* defines.h: NeXT対応
Wed Mar 27 10:02:44 1996 Yukihiro Matsumoto <[email protected]>
* parse.y: 予約語の変更 continue -> next
Mon Mar 25 07:34:37 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (parse_regx): o(once)オプションを追加.
Fri Mar 22 14:25:35 1996 Yukihiro Matsumoto <[email protected]>
* version 0.97d
* eval.c (dyna_var_defined): 動的ローカル変数の定義チェック用ルー
チン.
* parse.y (gettable): eval()の中での動的ローカル変数(既に値を持っ
ているもの)の検出に失敗していた.
Tue Mar 19 10:46:47 1996 Yukihiro Matsumoto <[email protected]>
* version 0.97c
* re.c (reg_s_new): compile時にsegmentation fault.
* parse.y (str_extend): いつもevalするように.
Wed Mar 13 11:00:42 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (str_extend): 文字列中の式展開の不備を無くした.
* parse.y: 下手なエラーリカバリを外した.
Tue Mar 12 12:30:20 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rescue): 間違ってensureでも例外を捕捉していた.
Wed Mar 6 12:11:03 1996 Yukihiro Matsumoto <[email protected]>
* parse.y (var_extend): 変数展開"#{}"で,任意の式を書けるようにし
た,これで「変数」展開では無くなっちゃったなあ.
* regex.c (init_syntax_once): `_'をwordに追加.
* regex.c (re_compile_pattern): `\w',`\W'の判定をsyntax tableを使
うように.
Tue Feb 27 10:15:32 1996 Yukihiro Matsumoto <[email protected]>
* object.c (obj_inspect): 表示するインスタンス変数が無い時には,
to_sを使う.
* configure.in: dlnの検出を自動的に.
Mon Feb 26 19:55:33 1996 Yukihiro Matsumoto <[email protected]>
* ruby.c (readin): read(2)で一度にファイルが読み込めない場合に対応.
Sat Feb 24 14:47:18 1996 Yukihiro Matsumoto <[email protected]>
* version 0.97b
Fri Feb 23 11:26:02 1996 Yukihiro Matsumoto <[email protected]>
* class.c (rb_define_module): C言語で定義されたモジュールのPATHの
設定忘れ.文字列化でcore dump.
* eval.c (mod_include): 戻り値をnilに.
* version 0.97a
Thu Feb 22 21:03:42 1996 Yukihiro Matsumoto <[email protected]>
* array.c (ary_times): 「配列*文字列」がjoinと同じ働きをするように.
Wed Feb 21 11:18:09 1996 Yukihiro Matsumoto <[email protected]>
* configure.in : fileCountをcache.
* configure.in : LinuxでELF環境を自動的に検出できるよう.
Tue Feb 20 11:18:09 1996 Mitsuhide Satou <[email protected]>
* FreeBSD dynamic link対応.
Fri Feb 16 08:50:01 1996 Yukihiro Matsumoto <[email protected]>
* object.c (obj_inspect): インスタンス変数を持たないオブジェクトも
正しく表示されるように.
Wed Feb 14 16:56:44 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): 条件式の`2..2'など左辺成立直後に右辺が成立する
パターンにバグ.
Tue Feb 13 18:22:22 1996 Yukihiro Matsumoto <[email protected]>
* version 0.97
Fri Feb 9 21:32:55 1996 Yukihiro Matsumoto <[email protected]>
* lib/tkscrollbox.rb: スクロールでtclの設定を行い,ruby<->wishの不
要な通信を無くした.
Wed Feb 7 10:26:52 1996 Yukihiro Matsumoto <[email protected]>
* string.c (str_aref): indexをunsigned intでとっていた.
* string.c (str_aref): 範囲外のindexに対してnilを返す.
* parse.y (special_local_set): `$_'が宣言無しに使われた場合に対応.
関数をvariable.cから移動.
* string.c (str_sub): 置換開始位置が間違っていた.
Tue Feb 6 16:17:31 1996 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-parse-region): コメントの読み飛ばしの
バグ.
Fri Feb 2 18:35:28 1996 Yukihiro Matsumoto <[email protected]>
* variable.c (lastline_get): `$_'を`$~'と同じようにSCOPEローカルな
変数にした.
Thu Feb 1 14:14:07 1996 Yukihiro Matsumoto <[email protected]>
* file.c: statのcacheをやめた.
Wed Jan 31 07:13:08 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (proc_s_new): procの中でyieldを呼ばれた時にcore dumpして
いた.とりあえず例外を発生させる.
* variable.c (rb_class2path): singleton classに対応.
* ext/etc/etc.c (Init_etc): struct_defineのターミネータがnilだった
(0でなければならない).
* ext/marshal/marshal.c: TRUE/FALSEを吐き出せるように.
* eval.c (rb_get_method_body): キャッシュのalias対応,いままでは
aliasはキャッシュに入っていなかった.
Tue Jan 30 09:55:13 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): NODE_BLOCK - tail recursive(というほどでもない
が).
* io.c (io_pipe): pipe(2)を実装した.
* eval.c (rb_eval): Qselfをなくした.thread対応への第一歩.先は遠
いが….
* eval.c (proc_call): procの中でのreturnはprocの終了を意味するよう
に.ただし,procからのyieldの中でのreturnは例外を発生する.
Wed Jan 24 11:33:48 1996 Yukihiro Matsumoto <[email protected]>
* version 0.96a
* dir.c (dir_each): `$_'の値を変更するのをやめた.
* io.c (f_readlines): nilとFALSEの分離のあおりで無限ループに落ちて
いた.
* ruby.c (ruby_options): $0の設定ミス.
Tue Jan 23 15:28:21 1996 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): ``は文字列を引数とするメソッド(`)呼び出しのシ
ンタックスシュガーであるとした.
* ruby.c (addpath): `-I'オプションでディレクトリが「前に」追加され
るように変更.
Fri Jan 19 11:23:12 1996 Yukihiro Matsumoto <[email protected]>
* dln.c (load_1): N_INDR対応(出来たような気がする).
Thu Jan 18 18:14:20 1996 Yukihiro Matsumoto <[email protected]>
* ruby.texi: FALSEとnilの分離を反映した.
Tue Jan 16 17:39:23 1996 Yukihiro Matsumoto <[email protected]>
* version 0.96 - とりあえずnilとFALSEを区別する版
Wed Jan 10 15:31:48 1996 Yukihiro Matsumoto <[email protected]>
* re.c (reg_match): マッチしなかった時の戻り値はFALSE.
* object.c (rb_equal): `0 == nil'がTRUEになるバグ.
Tue Jan 9 00:44:58 1996 Yukihiro Matsumoto <[email protected]>
* nilとFALSEが分離可能に変更.
* nilとFALSEと0の区別を厳密に.
* struct.c (struct_new): 引数を0で終る必要が無くなった.
* object.c (inspect_i): オブジェクトのチェックのバグ(Fixnumでcore
dumpしていた).
* range.c (range_to_s): Rangeの表示を改善.
* object.c (true_inspect): TRUEの表示を`TRUE'に.
Mon Jan 8 15:02:33 1996 Yukihiro Matsumoto <[email protected]>
* numeric.c (fix_mul): divide by zero errorが発生した(オーバーフロー
検出のバグ)
* texinfo.texをパッケージに含めた.
Sun Dec 31 00:08:49 1995 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): `::'では,そのクラスで定義された定数を参照する
ように変更.
* string.c (Init_String): eachをeach_lineに戻した.
Thu Dec 28 12:31:55 1995 Yukihiro Matsumoto <[email protected]>
* eval.c (rb_eval): caseの演算子を`=~'から`==='に.
* variable.c (rb_const_set): クラス定数の再定義を許す(同じクラスで
は不可).警告は出す.
Wed Dec 27 13:27:52 1995 Yukihiro Matsumoto <[email protected]>
* version 0.95c
* ext/tkutil/tkutil.c: wishがあってもなくても一応コンパイルだけは
するように.
* lib/tk.rb: 環境変数PATHから{wish|wish4.0}を探すように.
Tue Dec 26 01:03:42 1995 Yukihiro Matsumoto <[email protected]>
* sample/ruby-mode.el (ruby-parse-region): 正規表現の検出強化.
* numeric.c (fix_mul): 乗算のオーバーフロー検出アルゴリズムのバグ.
* ext/extmk.rb.in: ./install-shを使う場合のPATHを調整.
* Makefile.in (install): lib/*.rbを一つずつインストール.
* io.c (io_each_line): イテレータの戻り値をnilで統一.
Fri Dec 22 10:34:32 1995 Yukihiro Matsumoto <[email protected]>
* version 0.95b
* variable.c (f_untrace_var): 第2引数を指定すると特定のtraceを削除
できるように.
* variable.c (f_trace_var): 第2引数がnilの時,traceを削除する.
* lib/tk.rb (file_readable/file_writable): 第2引数をnilにすること
によるevent handlerの削除.
* parse.y (variable): ドキュメントに`__FILE__'と`__LINE__'が残って
いた.`caller(0)'で代用したはずだったのに.
* eval.c (f_eval): $!のリセット.
* error.c (err_sprintf): 勝手に"\n"を付加するのを止めた.
* parse.y (f_arglist): 引数リスト直後のif/whileの読み間違い.
lex_stateの値が設定されていなかった.
Co-authored-by: Jun Kuroda <[email protected]>
Co-authored-by: Mitsuhide Satou <[email protected]>
Co-authored-by: SHIROYAMA Takayuki <[email protected]>
Co-authored-by: Tairo Nomura <[email protected]>
Co-authored-by: WATANABE Hirofumi <[email protected]>
Co-authored-by: Yasuo OHBA <[email protected]>
Diffstat (limited to 'sample')
-rw-r--r-- | sample/clnt.rb | 6 | ||||
-rw-r--r-- | sample/dir.rb | 4 | ||||
-rw-r--r-- | sample/eval.rb | 41 | ||||
-rw-r--r-- | sample/evaldef.rb | 26 | ||||
-rw-r--r-- | sample/export.rb | 2 | ||||
-rw-r--r-- | sample/fact.rb | 8 | ||||
-rwxr-xr-x | sample/from.rb | 14 | ||||
-rw-r--r-- | sample/fullpath.pl | 22 | ||||
-rw-r--r-- | sample/fullpath.rb | 6 | ||||
-rwxr-xr-x | sample/getopts.test | 25 | ||||
-rw-r--r-- | sample/io.rb | 4 | ||||
-rwxr-xr-x | sample/less.rb | 4 | ||||
-rw-r--r-- | sample/list.rb | 14 | ||||
-rwxr-xr-x | sample/mpart.rb | 6 | ||||
-rw-r--r-- | sample/observ.rb | 31 | ||||
-rw-r--r-- | sample/philos.rb | 54 | ||||
-rw-r--r-- | sample/pi.rb | 18 | ||||
-rw-r--r-- | sample/rcs.rb | 2 | ||||
-rw-r--r-- | sample/regx.rb | 23 | ||||
-rw-r--r-- | sample/ruby-mode.el | 575 | ||||
-rw-r--r-- | sample/sieve.rb | 2 | ||||
-rw-r--r-- | sample/svr.rb | 2 | ||||
-rw-r--r-- | sample/test.rb | 981 | ||||
-rwxr-xr-x | sample/time.rb | 2 | ||||
-rw-r--r-- | sample/tkbiff.rb | 46 | ||||
-rw-r--r-- | sample/tkbrowse.rb | 8 | ||||
-rw-r--r-- | sample/tkfrom.rb | 13 | ||||
-rw-r--r-- | sample/tkline.rb | 25 | ||||
-rw-r--r-- | sample/trojan.pl | 12 | ||||
-rw-r--r-- | sample/tsvr.rb | 23 | ||||
-rwxr-xr-x | sample/uumerge.rb | 8 |
31 files changed, 1072 insertions, 935 deletions
diff --git a/sample/clnt.rb b/sample/clnt.rb index c8c4b2db9f..7998379aa2 100644 --- a/sample/clnt.rb +++ b/sample/clnt.rb @@ -3,15 +3,15 @@ require "socket" -host=(if $ARGV.length == 2; $ARGV.shift; else "localhost"; end) +host=(if ARGV.length == 2; ARGV.shift; else "localhost"; end) print("Trying ", host, " ...") STDOUT.flush -s = TCPsocket.open(host, $ARGV.shift) +s = TCPsocket.open(host, ARGV.shift) print(" done\n") print("addr: ", s.addr.join(":"), "\n") print("peer: ", s.peeraddr.join(":"), "\n") while gets() s.write($_) - print(s.gets) + print(s.readline) end s.close diff --git a/sample/dir.rb b/sample/dir.rb index 3349dc7b6d..1fc0bb2aa8 100644 --- a/sample/dir.rb +++ b/sample/dir.rb @@ -1,9 +1,9 @@ # directory access # list all files but .*/*~/*.o dirp = Dir.open(".") -dirp.rewind for f in dirp - if !(~/^\./ || ~/~$/ || ~/\.o/) + $_ = f + if (~/^\./ || ~/~$/ || ~/\.o/) print f, "\n" end end diff --git a/sample/eval.rb b/sample/eval.rb new file mode 100644 index 0000000000..da31b77153 --- /dev/null +++ b/sample/eval.rb @@ -0,0 +1,41 @@ +line = '' +indent=0 +print "ruby> " +while TRUE + l = gets + if not l + break if line == '' + else + line = line + l + if l =~ /,\s*$/ + print "ruby| " + next + end + if l =~ /^\s*(class|module|def|if|case|while|for|begin)\b[^_]/ + indent += 1 + end + if l =~ /^\s*end\b[^_]/ + indent -= 1 + end + if l =~ /{\s*(\|.*\|)?\s*$/ + indent += 1 + end + if l =~ /^\s*\}/ + indent -= 1 + end + if indent > 0 + print "ruby| " + next + end + end + begin + print eval(line).inspect, "\n" + rescue + $! = 'exception raised' if not $! + print "ERR: ", $!, "\n" + end + break if not l + line = '' + print "ruby> " +end +print "\n" diff --git a/sample/evaldef.rb b/sample/evaldef.rb deleted file mode 100644 index 2cedd54999..0000000000 --- a/sample/evaldef.rb +++ /dev/null @@ -1,26 +0,0 @@ -# method definition by eval() -# output: -# bar -# (eval):26: method `baz' not available for "#<foo: 0xbfc5c>"(foo) - -class Foo - def foo - eval(" -def baz - print(\"bar\n\") -end") - end -end - -class Bar : Foo - def bar - baz() - end -end - -f = Foo.new -b = Bar.new - -b.foo -b.bar -f.baz diff --git a/sample/export.rb b/sample/export.rb index 2d05d8afd7..750b5c1948 100644 --- a/sample/export.rb +++ b/sample/export.rb @@ -28,7 +28,7 @@ f.printf "%s\n", Foo f.quux -class Bar : Foo +class Bar<Foo def quux super baz() diff --git a/sample/fact.rb b/sample/fact.rb new file mode 100644 index 0000000000..49678bc9d0 --- /dev/null +++ b/sample/fact.rb @@ -0,0 +1,8 @@ +def fact(n) + if n == 0 + 1 + else + n * fact(n-1) + end +end +print fact(ARGV[0].to_i), "\n" diff --git a/sample/from.rb b/sample/from.rb index 2f5fcebe12..2ef000face 100755 --- a/sample/from.rb +++ b/sample/from.rb @@ -5,15 +5,15 @@ require "base64" include ParseDate -if $ARGV[0] == '-w' +if ARGV[0] == '-w' wait = TRUE - $ARGV.shift + ARGV.shift end class Mail def Mail.new(f) - if !f.is_kind_of?(IO) + if !f.kind_of?(IO) f = open(f, "r") me = super f.close @@ -28,7 +28,7 @@ class Mail @body = [] while f.gets() $_.chop! - continue if /^From / # skip From-line + next if /^From / # skip From-line break if /^$/ # end of header if /^(\S+):\s*(.*)/ @header[attr = $1.capitalize] = $2 @@ -56,7 +56,7 @@ class Mail end -$ARGV[0] = '/usr/spool/mail/' + ENV['USER'] if $ARGV.length == 0 +ARGV[0] = '/usr/spool/mail/' + ENV['USER'] if ARGV.length == 0 $outcount = 0; def fromout(date, from, subj) @@ -72,8 +72,8 @@ def fromout(date, from, subj) $outcount += 1 end -for file in $ARGV - continue if !File.exists?(file) +for file in ARGV + next if !File.exist?(file) f = open(file, "r") while !f.eof mail = Mail.new(f) diff --git a/sample/fullpath.pl b/sample/fullpath.pl deleted file mode 100644 index a07b90edd4..0000000000 --- a/sample/fullpath.pl +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/local/bin/perl -# convert ls-lR filename into fullpath. - -$path = shift; -if (!defined $path) { - $path = ""; -} -elsif ($path !~ /\/$/) { - $path .= "/" -} - -while (<>) { - if (/:$/) { - chop; chop; - $path = $_ . "/"; - } elsif (/^total/ || /^d/) { - next; - } elsif (/^(.*\d )(.+)$/) { - print $1, $path, $2, "\n"; - } -} - diff --git a/sample/fullpath.rb b/sample/fullpath.rb index 6c528f6f96..ce268e20b9 100644 --- a/sample/fullpath.rb +++ b/sample/fullpath.rb @@ -1,9 +1,9 @@ #! /usr/local/bin/ruby # convert ls-lR filename into fullpath. -if $ARGV[0] =~ /-p/ - $ARGV.shift - path = $ARGV.shift +if ARGV[0] =~ /-p/ + ARGV.shift + path = ARGV.shift end if path == nil diff --git a/sample/getopts.test b/sample/getopts.test index adef7628db..2866bccea8 100755 --- a/sample/getopts.test +++ b/sample/getopts.test @@ -3,13 +3,16 @@ load("parsearg.rb") def usage() - printf("Usage:\n") - printf("This is Getopt test program \n") + printf "Usage:\n" + printf "%s -d [-x x] [-y y] [--geometry geom] [--version] [string ...]\n", $0 end $USAGE = 'usage' -parseArgs(0, !nil, "d", "x:", "y:", "version", "geometry:") +parseArgs(0, "d&(x|y)", "dfg", "x:", "y:", "geometry:800x600", "version") if ($OPT_d) + if $OPT_version + printf "version 1.0\n" + end if ($OPT_x) printf("x = %d\n", $OPT_x.to_i) end @@ -19,13 +22,15 @@ if ($OPT_d) if ($OPT_geometry) printf("geometry = %s\n", $OPT_geometry) end + if $OPT_f + printf "f = TRUE\n" + end + if $OPT_g + printf "g = TRUE\n" + end end -if ($OPT_version) - printf("version 1.00\n") -end - -while ($ARGV.length != 0) - print ("other = ", $ARGV[0], "\n") - $ARGV.shift +while (ARGV.length != 0) + print "other = ", ARGV[0], "\n" + ARGV.shift end diff --git a/sample/io.rb b/sample/io.rb index c12e4f4498..0b38d2112d 100644 --- a/sample/io.rb +++ b/sample/io.rb @@ -15,8 +15,8 @@ for i in "abc\n\ndef\nghi\n" print("tt: ", i) end -printf("%s:(%d)%s\n", $0, $ARGV.length, $ARGV[0]) -passwd = open($ARGV[0], "r") +printf("%s:(%d)%s\n", $0, ARGV.length, ARGV[0]) +passwd = open(ARGV[0], "r") #printf("%s", passwd.find{i|i =~ /\*/}) n = 1 diff --git a/sample/less.rb b/sample/less.rb index b0906d5d22..8be359108f 100755 --- a/sample/less.rb +++ b/sample/less.rb @@ -3,8 +3,8 @@ ZCAT = "/usr/local/bin/zcat" LESS = "/usr/local/bin/less" -FILE = $ARGV.pop -OPTION = (if $ARGV.length == 0; "" else $ARGV.join(" "); end) +FILE = ARGV.pop +OPTION = (if ARGV.length == 0; "" else ARGV.join(" "); end) if FILE =~ /\.(Z|gz)$/ exec(format("%s %s | %s %s", ZCAT, FILE, LESS, OPTION)) diff --git a/sample/list.rb b/sample/list.rb index 93e3182f84..76035e67d6 100644 --- a/sample/list.rb +++ b/sample/list.rb @@ -4,20 +4,20 @@ class MyElem def initialize(item) # @�ѿ��ϥ������ѿ�(������פ�ʤ�) @data = item - @next = nil + @succ = nil end def data @data end - def next - @next + def succ + @succ end # ��obj.data = val�פȤ����Ȥ��˰��ۤ˸ƤФ���å� - def next=(new) - @next = new + def succ=(new) + @succ = new end end @@ -25,7 +25,7 @@ class MyList def add_to_list(obj) elt = MyElem.new(obj) if @head - @tail.next = elt + @tail.succ = elt else @head = elt end @@ -36,7 +36,7 @@ class MyList elt = @head while elt yield elt - elt = elt.next + elt = elt.succ end end diff --git a/sample/mpart.rb b/sample/mpart.rb index 2374ae0938..6c40d50e18 100755 --- a/sample/mpart.rb +++ b/sample/mpart.rb @@ -4,12 +4,12 @@ lines = 1000 -if ($ARGV[0] =~ /^-(\d+)$/ ) +if (ARGV[0] =~ /^-(\d+)$/ ) lines = $1.to_i; - $ARGV.shift; + ARGV.shift; end -basename = $ARGV[0] +basename = ARGV[0] extname = "part" part = 1 diff --git a/sample/observ.rb b/sample/observ.rb new file mode 100644 index 0000000000..f7b1e73137 --- /dev/null +++ b/sample/observ.rb @@ -0,0 +1,31 @@ +#! /usr/local/bin/ruby + +require "thread" +require "observer" + +class Tick + include Observable + def initialize + Thread.start do + while TRUE + sleep 0.999 + changed + notify_observers(Time.now.strftime("%H:%M:%S")) + end + end + end +end + +class Clock + def initialize + @tick = Tick.new + @tick.add_observer(self) + end + def update(time) + print "\e[8D", time + STDOUT.flush + end +end + +clock = Clock.new +sleep diff --git a/sample/philos.rb b/sample/philos.rb new file mode 100644 index 0000000000..ee0a8cd5fc --- /dev/null +++ b/sample/philos.rb @@ -0,0 +1,54 @@ +# +# The Dining Philosophers - thread example +# +require "thread" + +srand +#srand +N=9 # number of philosophers +$forks = [] +for i in 0..N-1 + $forks[i] = Mutex.new +end +$state = "-o"*N + +def wait + sleep rand(20)/10.0 +end + +def think(n) + wait +end + +def eat(n) + wait +end + +def philosopher(n) + while TRUE + think n + $forks[n].lock + if not $forks[(n+1)%N].try_lock + $forks[n].unlock # avoid deadlock + continue + end + $state[n*2] = ?|; + $state[(n+1)%N*2] = ?|; + $state[n*2+1] = ?*; + print $state, "\n" + eat(n) + $state[n*2] = ?-; + $state[(n+1)%N*2] = ?-; + $state[n*2+1] = ?o; + print $state, "\n" + $forks[n].unlock + $forks[(n+1)%N].unlock + end +end + +for i in 0..N-1 + Thread.start{philosopher(i)} + sleep 0.1 +end + +sleep diff --git a/sample/pi.rb b/sample/pi.rb new file mode 100644 index 0000000000..49067cc347 --- /dev/null +++ b/sample/pi.rb @@ -0,0 +1,18 @@ +#!/usr/local/bin/ruby + +k, a, b, a1, b1 = 2, 4, 1, 12, 4 + +while TRUE + # Next approximation + p, q, k = k*k, 2*k+1, k+1 + a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 + # Print common digits + d = a / b + d1 = a1 / b1 + while d == d1 + print d + $stdout.flush + a, a1 = 10*(a%b), 10*(a1%b1) + d, d1 = a/b, a1/b1 + end +end diff --git a/sample/rcs.rb b/sample/rcs.rb index 13476267b2..3f74da9ef2 100644 --- a/sample/rcs.rb +++ b/sample/rcs.rb @@ -7,7 +7,7 @@ hdw = dw / 2.0 w = 20.0 # ����̕� h =1.0 # ��ʂƊ�ʂ̋��� d = 0.2 # �P�ʓ�����̕����オ��� -ss="abcdefghijklmnopqrstuvwxyz0123456789!#$%^&*()-=\\[];'`,./" +ss="abcdefghijklmnopqrstuvwxyz0123456789#!$%^&*()-=\\[];'`,./" rnd = srand() while gets() diff --git a/sample/regx.rb b/sample/regx.rb new file mode 100644 index 0000000000..b9d8ca6e14 --- /dev/null +++ b/sample/regx.rb @@ -0,0 +1,23 @@ +st = "\033[7m" +en = "\033[m" +#st = "<<" +#en = ">>" + +while TRUE + print "str> " + STDOUT.flush + input = gets + break if not input + if input != "" + str = input + str.chop! + end + print "pat> " + STDOUT.flush + re = gets + break if not re + re.chop! + str.gsub! re, "#{st}&#{en}" + print str, "\n" +end +print "\n" diff --git a/sample/ruby-mode.el b/sample/ruby-mode.el index b555994fea..9dfde8588c 100644 --- a/sample/ruby-mode.el +++ b/sample/ruby-mode.el @@ -7,8 +7,18 @@ ;;; created at: Fri Feb 4 14:49:13 JST 1994 ;;; +(defconst ruby-mode-version "1.0.2") + (defconst ruby-block-beg-re - "class\\|module\\|def\\|if\\|case\\|while\\|for\\|begin" + "class\\|module\\|def\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin\\|do" + ) + +(defconst ruby-indent-beg-re + "\\(\\s *\\(class\\|module\\|def\\)\\)\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin" + ) + +(defconst ruby-modifier-re + "if\\|unless\\|while\\|until" ) (defconst ruby-block-mid-re @@ -18,13 +28,13 @@ (defconst ruby-block-end-re "end") (defconst ruby-delimiter - (concat "[?$/(){}#\"'`]\\|\\[\\|\\]\\|\\<\\(" - ruby-block-beg-re "\\|" ruby-block-end-re "\\)\\>") + (concat "[?$/%(){}#\"'`]\\|\\[\\|\\]\\|\\<\\(" + ruby-block-beg-re "\\|" ruby-block-end-re "\\)\\>") ) (defconst ruby-negative - (concat "^[ \t]*\\(\\b\\(" ruby-block-mid-re "\\)\\|\\(" - ruby-block-end-re "\\)\\>\\|\\}\\|\\]\\)") + (concat "^[ \t]*\\(\\(" ruby-block-mid-re "\\)\\|\\(" + ruby-block-end-re "\\)\\>\\|\\}\\|\\]\\)") ) (defconst ruby-operator-chars "[,.+*/%-&|^~=<>:]") @@ -44,6 +54,10 @@ (define-key ruby-mode-map "}" 'ruby-electric-brace) (define-key ruby-mode-map "\e\C-a" 'ruby-beginning-of-defun) (define-key ruby-mode-map "\e\C-e" 'ruby-end-of-defun) + (define-key ruby-mode-map "\e\C-b" 'ruby-beginning-of-block) + (define-key ruby-mode-map "\e\C-f" 'ruby-end-of-block) + (define-key ruby-mode-map "\e\C-p" 'ruby-beginning-of-block) + (define-key ruby-mode-map "\e\C-n" 'ruby-end-of-block) (define-key ruby-mode-map "\t" 'ruby-indent-command) (define-key ruby-mode-map "\C-m" 'ruby-reindent-then-newline-and-indent) (define-key ruby-mode-map "\C-j" 'newline)) @@ -60,7 +74,7 @@ (modify-syntax-entry ?\n ">" ruby-mode-syntax-table) (modify-syntax-entry ?\\ "'" ruby-mode-syntax-table) (modify-syntax-entry ?$ "/" ruby-mode-syntax-table) - (modify-syntax-entry ?? "/" ruby-mode-syntax-table) + (modify-syntax-entry ?? "_" ruby-mode-syntax-table) (modify-syntax-entry ?_ "_" ruby-mode-syntax-table) (modify-syntax-entry ?< "." ruby-mode-syntax-table) (modify-syntax-entry ?> "." ruby-mode-syntax-table) @@ -121,17 +135,6 @@ The variable ruby-indent-level controls the amount of indentation. (back-to-indentation) (current-column))) -(defun ruby-delete-indentation () - (let - ((b nil) - (m nil)) - (save-excursion - (beginning-of-line) - (setq b (point)) - (back-to-indentation) - (setq m (point))) - (delete-region b m))) - (defun ruby-indent-line (&optional flag) "Correct indentation of the current ruby line." (ruby-indent-to (ruby-calculate-indent))) @@ -141,222 +144,294 @@ The variable ruby-indent-level controls the amount of indentation. (ruby-indent-line t)) (defun ruby-indent-to (x) - (let ((p nil) beg end) - (if (null x) - nil - (setq p (- (current-column) (ruby-current-indentation))) - (ruby-delete-indentation) - (beginning-of-line) - (save-excursion + (if x + (let (shift top beg) + (and (< x 0) + (error "invalid nest")) + (setq shift (current-column)) + (beginning-of-line) (setq beg (point)) - (forward-line 1) - (setq end (point))) - (indent-to x) - (if (> p 0) (forward-char p))))) + (back-to-indentation) + (setq top (current-column)) + (skip-chars-backward " \t") + (cond + ((>= x shift) + (setq shift 0)) + ((>= shift top) + (setq shift (- shift top))) + (t (setq shift 0))) + (if (and (bolp) + (= x top)) + (move-to-column (+ x shift)) + (move-to-column top) + (delete-region beg (point)) + (beginning-of-line) + (indent-to x) + (move-to-column (+ x shift)))))) (defun ruby-expr-beg () (save-excursion - (skip-chars-backward " \t") - (or (bolp) (forward-char -1)) - (or (looking-at ruby-operator-chars) - (looking-at "[\\[({]") - (bolp) - (and (looking-at ruby-symbol-chars) - (forward-word -1) - (or - (looking-at ruby-block-beg-re) - (looking-at ruby-block-mid-re)))))) + (if (looking-at "\\?") + (progn + (or (bolp) (forward-char -1)) + (not (looking-at "\\sw"))) + (skip-chars-backward " \t") + (or (bolp) (forward-char -1)) + (or (looking-at ruby-operator-chars) + (looking-at "[\\[({]") + (bolp) + (and (looking-at ruby-symbol-chars) + (forward-word -1) + (or + (looking-at ruby-block-beg-re) + (looking-at ruby-block-mid-re))))))) (defun ruby-parse-region (start end) (let ((indent-point end) - (indent 0) - (in-string nil) - (in-paren nil) - (depth 0) - (nest nil)) + (indent 0) + (in-string nil) + (in-paren nil) + (depth 0) + (nest nil) + (pcol nil)) (save-excursion - (if start - (goto-char start) - (ruby-beginning-of-defun)) - (save-restriction - (narrow-to-region (point) end) - (while (and (> indent-point (point)) - (re-search-forward ruby-delimiter indent-point t)) - (let ((pnt (point)) w) - (goto-char (match-beginning 0)) - (cond - - ((or (looking-at "\"") ;skip string - (looking-at "'") - (looking-at "`")) - (setq w (char-after (point))) - (cond - ((and (not (eobp)) - (equal w (char-after (point))) - (re-search-forward (format "[^\\]%c" w) indent-point t)) - nil) - (t - (goto-char indent-point) - (setq in-string t)))) - ((looking-at "/") - (if (and (ruby-expr-beg) - (goto-char pnt) - (looking-at "\\([^/\n]\\|\\\\/\\)*") - (eq ?/ (char-after (match-end 0)))) - (goto-char (1+ (match-end 0))) - (goto-char indent-point) - (setq in-string t))) - ((looking-at "\\?") ;skip ?char + (if start + (goto-char start) + (ruby-beginning-of-indent)) + (save-restriction + (narrow-to-region (point) end) + (while (and (> indent-point (point)) + (re-search-forward ruby-delimiter indent-point t)) + (let ((pnt (point)) w) + (goto-char (match-beginning 0)) (cond - ((ruby-expr-beg) - (looking-at "?\\(\\\\C-\\|\\\\M-\\)*.") - (goto-char (match-end 0))) - (t - (goto-char pnt)))) - ((looking-at "\\$") ;skip $char - (goto-char pnt) - (forward-char 1)) - ((looking-at "#") ;skip comment - (forward-line 1) - (goto-char pnt)) - ((looking-at "[\\[({]") - (setq nest (cons (cons (char-after (point)) pnt) nest)) - (setq depth (1+ depth)) - (goto-char pnt)) - ((looking-at "[])}]") - (setq nest (cdr nest)) - (setq depth (1- depth)) - (goto-char pnt)) - ((looking-at ruby-block-end-re) - (if (and (not (bolp)) - (progn - (forward-char -1) - (eq ?_ (char-after (point)))) - (progn - (goto-char pnt) - (eq ?_ (char-after (point))))) - nil + ((or (looking-at "\"") ;skip string + (looking-at "'") + (looking-at "`")) + (setq w (char-after (point))) + (cond + ((and (not (eobp)) + (re-search-forward (format "[^\\]%c" w) indent-point t)) + nil) + (t + (setq in-string (point)) + (goto-char indent-point)))) + ((looking-at "/") + (cond + ((and (not (eobp)) (ruby-expr-beg)) + (if (re-search-forward "[^\\]/" indent-point t) + nil + (setq in-string (point)) + (goto-char indent-point))) + (t + (goto-char pnt)))) + ((looking-at "%") + (cond + ((and (not (eobp)) (ruby-expr-beg) + (looking-at "%[Qq\"'Rr/Xx`]\\(.\\)")) + (setq w (buffer-substring (match-beginning 1) + (match-end 1))) + (cond + ((string= w "[") (setq w "]")) + ((string= w "{") (setq w "}")) + ((string= w "(") (setq w ")")) + ((string= w "<") (setq w ">"))) + (goto-char (match-end 0)) + (if (search-forward w indent-point t) + nil + (setq in-string (point)) + (goto-char indent-point))) + (t + (goto-char pnt)))) + ((looking-at "\\?") ;skip ?char + (cond + ((ruby-expr-beg) + (looking-at "?\\(\\\\C-\\|\\\\M-\\)*.") + (goto-char (match-end 0))) + (t + (goto-char pnt)))) + ((looking-at "\\$") ;skip $char + (goto-char pnt) + (forward-char 1)) + ((looking-at "#") ;skip comment + (forward-line 1) + (goto-char (point)) + ) + ((looking-at "(") + (setq nest (cons (cons (char-after (point)) pnt) nest)) + (setq pcol (cons (cons pnt depth) pcol)) + (setq depth 0) + (goto-char pnt) + ) + ((looking-at "[\\[{]") + (setq nest (cons (cons (char-after (point)) pnt) nest)) + (setq depth (1+ depth)) + (goto-char pnt) + ) + ((looking-at ")") (setq nest (cdr nest)) - (setq depth (1- depth))) - (goto-char pnt)) - ((looking-at ruby-block-beg-re) - (and - (or (bolp) - (progn - (forward-char -1) - (not (eq ?_ (char-after (point)))))) - (save-excursion - (goto-char pnt) - (not (eq ?_ (char-after (point))))) - (skip-chars-backward " \t") - (or (bolp) - (save-excursion - (forward-char -1) - (looking-at ruby-operator-chars))) - (progn - (setq nest (cons (cons nil pnt) nest)) - (setq depth (1+ depth)))) - (goto-char pnt)) - (t - (error (format "bad string %s" - (buffer-substring (point) pnt) - ))))))) - (list in-string (car nest) depth)))) + (setq depth (cdr (car pcol))) + (setq pcol (cdr pcol)) + (goto-char pnt)) + ((looking-at "[])}]") + (setq nest (cdr nest)) + (setq depth (1- depth)) + (goto-char pnt)) + ((looking-at ruby-block-end-re) + (if (and (not (bolp)) + (progn + (forward-char -1) + (eq ?_ (char-after (point)))) + (progn + (goto-char pnt) + (eq ?_ (char-after (point))))) + nil + (setq nest (cdr nest)) + (setq depth (1- depth))) + (goto-char pnt)) + ((looking-at ruby-block-beg-re) + (and + (or (bolp) + (progn + (forward-char -1) + (not (eq ?_ (char-after (point)))))) + (save-excursion + (goto-char pnt) + (setq w (char-after (point))) + (and (not (eq ?_ w)) + (not (eq ?! w)) + (not (eq ?? w)))) + (progn + (goto-char (match-beginning 0)) + (if (looking-at ruby-modifier-re) + (ruby-expr-beg) + t)) + (progn + (setq nest (cons (cons nil pnt) nest)) + (setq depth (1+ depth)))) + (if (looking-at "def\\s *[/`]") + (goto-char (match-end 0)) + (goto-char pnt))) + (t + (error (format "bad string %s" + (buffer-substring (point) pnt) + ))))))) + (list in-string (car nest) depth (car (car pcol)))))) (defun ruby-calculate-indent (&optional parse-start) (save-excursion (beginning-of-line) (let ((indent-point (point)) - (case-fold-search nil) - state bol eol - (indent 0)) - (if parse-start - (goto-char parse-start) - (ruby-beginning-of-defun) - (setq parse-start (point))) - (setq state (ruby-parse-region parse-start indent-point)) - (cond - ((nth 0 state) ; within string - (setq indent nil)) ; do nothing - - ((nth 1 state) ; in paren - (goto-char (cdr (nth 1 state))) - (setq indent - (if (and (eq (car (nth 1 state)) ?\( ) - (not (looking-at "(\\s *$"))) - (current-column) - (+ (current-indentation) ruby-indent-level)))) - - ((> (nth 2 state) 0) ; in nest - (goto-char (cdr (nth 1 state))) - (forward-word -1) ; skip back a keyword - (setq indent (+ (current-column) ruby-indent-level))) - - (t ; toplevel - (setq indent 0))) - - (cond - (indent - (goto-char indent-point) - (end-of-line) - (setq eol (point)) - (beginning-of-line) - (cond - ((re-search-forward ruby-negative eol t) - (setq indent (- indent ruby-indent-level))) - ;;operator terminated lines - ((and - (save-excursion - (beginning-of-line) - (not (bobp))) - (or (null (car (nth 1 state))) ;not in parens - (and (eq (car (nth 1 state)) ?\{) - (save-excursion ;except non-block braces - (goto-char (cdr (nth 1 state))) - (or (bobp) (forward-char -1)) - (not (ruby-expr-beg)))))) - (beginning-of-line) - (skip-chars-backward " \t\n") - (beginning-of-line) ; goto beginning of non-empty line - (setq bol (point)) + (case-fold-search nil) + state bol eol + (indent 0)) + (if parse-start + (goto-char parse-start) + (ruby-beginning-of-indent) + (setq parse-start (point))) + (back-to-indentation) + (setq indent (current-column)) + (setq state (ruby-parse-region parse-start indent-point)) + (cond + ((nth 0 state) ; within string + (setq indent nil)) ; do nothing + + ((car (nth 1 state)) ; in paren + (goto-char (cdr (nth 1 state))) + (if (eq (car (nth 1 state)) ?\( ) + (let ((column (current-column)) + (s (ruby-parse-region (point) indent-point))) + (cond + ((> (nth 2 s) 0) + (goto-char (cdr (nth 1 s))) + (forward-word -1) + (setq indent (+ (current-column) ruby-indent-level))) + (t + (setq indent (current-column))))) + (cond + ((nth 3 state) + (goto-char (nth 3 state)) + (setq indent (+ (current-column) ruby-indent-level))) + (t + (goto-char parse-start) + (back-to-indentation) + (setq indent (+ (current-column) (* (nth 2 state) ruby-indent-level))))) + )) + + ((> (nth 2 state) 0) ; in nest + (goto-char (cdr (nth 1 state))) + (forward-word -1) ; skip back a keyword + (cond + ((looking-at "do") ; iter block is a special case + (cond + ((nth 3 state) + (goto-char (nth 3 state)) + (setq indent (+ (current-column) ruby-indent-level))) + (t + (goto-char parse-start) + (back-to-indentation) + (setq indent (+ (current-column) (* (nth 2 state) ruby-indent-level)))))) + (t + (setq indent (+ (current-column) ruby-indent-level))))) + + ((< (nth 2 state) 0) ; in negative nest + (setq indent (+ (current-column) (* (nth 2 state) ruby-indent-level))))) + + (cond + (indent + (goto-char indent-point) (end-of-line) (setq eol (point)) - (and (search-backward "#" bol t) ; check for comment line - (not (eq ?? (char-after (1- (point))))) - (not (nth 0 (ruby-parse-region parse-start (point)))) - (setq eol (point))) - (goto-char eol) - (skip-chars-backward " \t") - (or (bobp) (forward-char -1)) - (and (looking-at ruby-operator-chars) -;; (or (not (eq ?/ (char-after (point)))) -;; (progn -;; (not (nth 0 (ruby-parse-region parse-start (point)))))) - (or (not (eq ?/ (char-after (point)))) - (null (nth 0 (ruby-parse-region parse-start (point))))) - (save-excursion - (goto-char parse-start) - (sit-for 1)) - (not (eq (char-after (1- (point))) ?$)) - (or (not (eq ?| (char-after (point)))) - (save-excursion - (or (eolp) (forward-char -1)) - (and (search-backward "|" bol t) - (skip-chars-backward " \t\n") - (and (not (eolp)) - (progn - (forward-char -1) - (not (looking-at "\\{"))))))) - (setq indent (+ indent ruby-indent-level))))))) - indent))) - + (beginning-of-line) + (cond + ((re-search-forward ruby-negative eol t) + (setq indent (- indent ruby-indent-level))) + ;;operator terminated lines + ((and + (save-excursion + (beginning-of-line) + (not (bobp))) + (or (null (car (nth 1 state))) ;not in parens + (and (eq (car (nth 1 state)) ?\{) + (save-excursion ;except non-block braces + (goto-char (cdr (nth 1 state))) + (or (bobp) (forward-char -1)) + (not (ruby-expr-beg)))))) + (beginning-of-line) + (skip-chars-backward " \t\n") + (beginning-of-line) ; goto beginning of non-empty line + (setq bol (point)) + (end-of-line) + (skip-chars-backward " \t") + (or (bobp) (forward-char -1)) + (and (looking-at ruby-operator-chars) + (or (not (or (eq ?/ (char-after (point))))) + (null (nth 0 (ruby-parse-region parse-start (point))))) + (save-excursion + (goto-char parse-start)) + (not (eq (char-after (1- (point))) ?$)) + (or (not (eq ?| (char-after (point)))) + (save-excursion + (or (eolp) (forward-char -1)) + (and (search-backward "|") + (skip-chars-backward " \t\n") + (and (not (eolp)) + (progn + (forward-char -1) + (not (looking-at "\\{"))) + (progn + (forward-word -1) + (not (looking-at "do\\>[^_]"))))))) + (setq indent (+ indent ruby-indent-level))))))) + indent))) + (defun ruby-electric-brace (arg) (interactive "P") (self-insert-command (prefix-numeric-value arg)) (ruby-indent-line t)) (defun ruby-beginning-of-defun (&optional arg) - "Move backward to next beginning-of-defun. + "Move backward to next beginning-of-defun. With argument, do this that many times. Returns t unless search stops due to end of buffer." (interactive "p") @@ -364,6 +439,13 @@ Returns t unless search stops due to end of buffer." nil 'move (or arg 1)) (progn (beginning-of-line) t))) +(defun ruby-beginning-of-indent () + (and (re-search-backward (concat "^\\(" ruby-indent-beg-re "\\)\\b") + nil 'move) + (progn + (beginning-of-line) + t))) + (defun ruby-end-of-defun (&optional arg) "Move forward to next end of defun. An end of a defun is found by moving forward from the beginning of one." @@ -373,6 +455,42 @@ An end of a defun is found by moving forward from the beginning of one." (progn (beginning-of-line) t)) (forward-line 1)) +(defun ruby-move-to-block (n) + (let (start pos done down) + (setq start (ruby-calculate-indent)) + (if (eobp) + nil + (while (and (not (bobp)) (not done)) + (forward-line n) + (cond + ((looking-at "^$")) + ((looking-at "^\\s *#")) + (t + (setq pos (current-indentation)) + (cond + ((< start pos) + (setq down t)) + ((and down (= pos start)) + (setq done t)) + ((> start pos) + (setq done t))))) + (if done + (progn + (back-to-indentation) + (if (looking-at ruby-block-mid-re) + (setq done nil))))))) + (back-to-indentation)) + +(defun ruby-beginning-of-block () + "Move backward to next beginning-of-block" + (interactive) + (ruby-move-to-block -1)) + +(defun ruby-end-of-block () + "Move forward to next beginning-of-block" + (interactive) + (ruby-move-to-block 1)) + (defun ruby-reindent-then-newline-and-indent () (interactive "*") (save-excursion @@ -383,39 +501,32 @@ An end of a defun is found by moving forward from the beginning of one." (indent-according-to-mode)) (indent-according-to-mode)) -(defun ruby-encomment-region (beg end) - (interactive "r") - (save-excursion - (goto-char beg) - (while (re-search-forward "^" end t) - (replace-match "#" nil nil)))) +(fset 'ruby-encomment-region (symbol-function 'comment-region)) (defun ruby-decomment-region (beg end) (interactive "r") (save-excursion (goto-char beg) (while (re-search-forward "^\\([ \t]*\\)#" end t) - (replace-match "\\1" nil nil)))) + (replace-match "\\1" nil nil) + (save-excursion + (ruby-indent-line))))) (if (featurep 'hilit19) (hilit-set-mode-patterns 'ruby-mode - '(("\\s #.*$" nil comment) - ("^#.*$" nil comment) - ("\\$\\(.\\|\\sw+\\)" nil type) - ("[^$\\?]\\(\"[^\\\"]*\\(\\\\\\(.\\|\n\\)[^\\\"]*\\)*\"\\)" 1 string) + '(("[^$\\?]\\(\"[^\\\"]*\\(\\\\\\(.\\|\n\\)[^\\\"]*\\)*\"\\)" 1 string) ("[^$\\?]\\('[^\\']*\\(\\\\\\(.\\|\n\\)[^\\']*\\)*'\\)" 1 string) - ("^/\\([^/\n]\\|\\\\/\\)*/" nil string) - ("[^a-zA-Z_]\\s *\\(/\\([^/\n]\\|\\\\/\\)*/\\)" 1 string) - ("\\(begin\\|case\\|else\\|elsif\\|end\\|ensure\\|for\\|if\\|rescue\\|then\\|when\\|while\\)\\s *\\(/\\([^/\n]\\|\\\\/\\)*/\\)" 2 string) - ("^\\s *require.*$" nil include) - ("^\\s *load.*$" nil include) + ("[^$\\?]\\(`[^\\`]*\\(\\\\\\(.\\|\n\\)[^\\`]*\\)*`\\)" 1 string) + ("^\\s *#.*$" nil comment) + ("[^$@?\\]\\(#[^$@{].*$\\)" 1 comment) + ("[^a-zA-Z_]\\(\\?\\(\\\\[CM]-\\)*.\\)" 1 string) + ("^\\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\\|rescue\\|then\\|when\\|while\\)\\>[^_]" 1 defun) - ("[^_]\\<\\(and\\|break\\|continue\\|fail\\|in\\|not\\|or\\|redo\\|retry\\|return\\|super\\|yield\\)\\>[^_]" 1 keyword) - ("[^_]\\<\\(self\\|nil\\|TRUE\\|FALSE\\|__LINE__\\|__FILE__\\)\\>[^_]" 1 define) - ("$.[a-zA-Z_0-9]*" nil struct) - ("@[a-zA-Z_0-9]+" nil struct) - ("[^_]\\<[A-Z].[a-zA-Z_0-9]*" nil define) + ("[^_]\\<\\(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\\)\\>[^_]" 1 keyword) + ("[^_]\\<\\(self\\|nil\\|[A-Z][a-zA-Z_0-9]*\\)\\>[^_]" 1 define) + ("\\$\\(.\\|\\sw+\\)" nil type) + ("[$@].[a-zA-Z_0-9]*" nil struct) ("^__END__" nil label)))) diff --git a/sample/sieve.rb b/sample/sieve.rb index a953784284..03ff8a67f4 100644 --- a/sample/sieve.rb +++ b/sample/sieve.rb @@ -1,6 +1,6 @@ # sieve of Eratosthenes sieve = [] -if ! max = $ARGV.shift; max = 100; end +if ! max = ARGV.shift; max = 100; end max = max.to_i print "1" diff --git a/sample/svr.rb b/sample/svr.rb index 460c16bedf..14aded8c3f 100644 --- a/sample/svr.rb +++ b/sample/svr.rb @@ -11,7 +11,7 @@ socks = [gs] while TRUE nsock = select(socks); - if nsock == nil; continue end + next if nsock == nil for s in nsock[0] if s == gs ns = s.accept diff --git a/sample/test.rb b/sample/test.rb index 7f26433181..aacddbc56a 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -1,6 +1,8 @@ #! /usr/local/bin/ruby $testnum=0 +$ntest=0 +$failed = 0 def check(what) printf "%s\n", what @@ -8,15 +10,16 @@ def check(what) $testnum = 0 end -def ok +def ok(cond) $testnum+=1 - printf "ok %d\n", $testnum -end - -def notok - $testnum+=1 - printf "not ok %s %d\n", $what, $testnum - $failed = TRUE + $ntest+=1 + if cond + printf "ok %d\n", $testnum + else + where = caller[0] + printf "not ok %s %d -- %s\n", $what, $testnum, where + $failed+=1 + end end # make sure conditional operators work @@ -25,50 +28,62 @@ check "condition" $x = '0'; -$x == $x && ok -$x != $x && notok -$x == $x || notok -$x != $x || ok +$x == $x && ok(TRUE) +$x != $x && ok(FALSE) +$x == $x || ok(FALSE) +$x != $x || ok(TRUE) # first test to see if we can run the tests. -check "if"; +check "if/unless"; $x = 'test'; -if $x == $x then ok else notok end -if $x != $x then notok else ok end +ok(if $x == $x then TRUE else FALSE end) +$bad = FALSE +unless $x == $x + $bad = TRUE +end +ok(!$bad) +ok(unless $x != $x then TRUE else FALSE end) check "case" case 5 when 1, 2, 3, 4, 6, 7, 8 - notok + ok(FALSE) when 5 - ok + ok(TRUE) end case 5 when 5 - ok + ok(TRUE) when 1..10 - notok + ok(FALSE) +end + +case 5 +when 1..10 + ok(TRUE) +else + ok(FALSE) end case 5 when 5 - ok + ok(TRUE) else - notok + ok(FALSE) end case "foobar" when /^f.*r$/ - ok + ok(TRUE) else - notok + ok(FALSE) end -check "while"; +check "while/until"; tmp = open("while_tmp", "w") tmp.print "tvi925\n"; @@ -81,30 +96,23 @@ tmp.close # test break tmp = open("while_tmp", "r") +ok(tmp.type == "File") while tmp.gets() break if /vt100/ end -if !tmp.eof && /vt100/ then - ok -else - notok -end +ok(!tmp.eof && /vt100/) tmp.close -# test continue +# test next $bad = FALSE tmp = open("while_tmp", "r") while tmp.gets() - continue if /vt100/; + next if /vt100/; $bad = 1 if /vt100/; end -if !tmp.eof || /vt100/ || $bad - notok -else - ok -end +ok(!(!tmp.eof || /vt100/ || $bad)) tmp.close # test redo @@ -118,37 +126,39 @@ while tmp.gets() $bad = 1 if /vt100/; $bad = 1 if /VT100/; end -if !tmp.eof || $bad - notok -else - ok -end +ok(tmp.eof && !$bad) tmp.close # test interval $bad = FALSE tmp = open("while_tmp", "r") while tmp.gets() - break if not 1..2 + break unless 1..2 if /vt100/ || /Amiga/ || /paper/ $bad = TRUE - notok break end end -ok if not $bad +ok(!$bad) tmp.close File.unlink "while_tmp" or `/bin/rm -f "while_tmp"` +ok(!File.exist?("while_tmp")) + +i = 0 +until i>4 + i+=1 +end +ok(i>4) # exception handling check "exception"; begin fail "this must be handled" - notok + ok(FALSE) rescue - ok + ok(TRUE) end $bad = TRUE @@ -158,10 +168,10 @@ rescue if $bad $bad = FALSE retry - notok + ok(FALSE) end end -ok +ok(TRUE) $bad = TRUE $string = "this must be handled no.3" @@ -170,9 +180,9 @@ begin rescue ensure $bad = FALSE - ok + ok(TRUE) end -notok if $bad || $! != $string +ok(FALSE) if $bad || $! != $string # exception in rescue clause begin @@ -181,164 +191,163 @@ begin rescue fail "exception in rescue clause" end - notok + ok(FALSE) rescue - ok + ok(TRUE) end -check "array" -$x = [0, 1, 2, 3, 4, 5] -if $x[2] == 2 - ok -else - notok +# exception in ensure clause +begin + begin + fail "this must be handled no.5" + ensure + fail "exception in ensure clause" + end + ok(FALSE) +rescue + ok(TRUE) end -if $x[1..3] == [1, 2, 3] - ok -else - notok +$bad = TRUE +begin + begin + fail "this must be handled no.5" + ensure + $bad = FALSE + end +rescue end +ok(!$bad) -if $x[1,3] == [1, 2, 3] - ok -else - notok +$bad = TRUE +begin + begin + fail "this must be handled no.5" + ensure + $bad = FALSE + end +rescue end +ok(!$bad) -if [1, 2] + [3, 4] == [1, 2, 3, 4] - ok -else - notok +$bad = TRUE +while TRUE + begin + break + ensure + $bad = FALSE + end end +ok(!$bad) + +check "array" +ok([1, 2] + [3, 4] == [1, 2, 3, 4]) +ok([1, 2] * 2 == [1, 2, 1, 2]) +ok([1, 2] * ":" == "1:2") + +ok([1, 2].hash == [1, 2].hash) + +ok([1,2,3] & [2,3,4] == [2,3]) +ok([1,2,3] | [2,3,4] == [1,2,3,4]) +ok([1,2,3] - [2,3] == [1]) + +$x = [0, 1, 2, 3, 4, 5] +ok($x[2] == 2) +ok($x[1..3] == [1, 2, 3]) +ok($x[1,3] == [1, 2, 3]) $x[0, 2] = 10 -if $x[0] == 10 && $x[1] == 2 - ok -else - notok -end +ok($x[0] == 10 && $x[1] == 2) $x[0, 0] = -1 -if $x[0] == -1 && $x[1] == 10 - ok -else - notok -end +ok($x[0] == -1 && $x[1] == 10) $x[-1, 1] = 20 -if $x[-1] == 20 && $x.pop == 20 - ok -else - notok -end +ok($x[-1] == 20 && $x.pop == 20) +# compact +$x = [nil, 1, nil, nil, 5, nil, nil] +$x.compact! +ok($x == [1, 5]) + +# empty? +ok(!$x.empty?) +$x = [] +ok($x.empty?) + +# sort $x = ["it", "came", "to", "pass", "that", "..."] $x = $x.sort.join(" ") -if $x == "... came it pass that to" - ok -else - notok -end +ok($x == "... came it pass that to") +$x = [2,5,3,1,7] +$x.sort!{|a,b| a<=>b} # sort with condition +ok($x == [1,2,3,5,7]) +$x.sort!{|a,b| b-a} # reverse sort +ok($x == [7,5,3,2,1]) # split test -if "1 byte string".split(//).reverse.join(":") == "g:n:i:r:t:s: :e:t:y:b: :1" - ok -else - notok -end +$x = "The Book of Mormon" +ok($x.split(//).reverse!.join == "nomroM fo kooB ehT") +ok("1 byte string".split(//).reverse.join(":") == "g:n:i:r:t:s: :e:t:y:b: :1") +$x = "a b c d" +ok($x.split == ['a', 'b', 'c', 'd']) +ok($x.split(' ') == ['a', 'b', 'c', 'd']) $x = [1] -if ($x * 5).join(":") == '1:1:1:1:1' then ok else notok end -if ($x * 1).join(":") == '1' then ok else notok end -if ($x * 0).join(":") == '' then ok else notok end +ok(($x * 5).join(":") == '1:1:1:1:1') +ok(($x * 1).join(":") == '1') +ok(($x * 0).join(":") == '') + +*$x = 1..7 +ok($x.size == 7) +ok($x == [1, 2, 3, 4, 5, 6, 7]) check "hash" $x = {1=>2, 2=>4, 3=>6} $y = {1, 2, 2, 4, 3, 6} -if $x[1] == 2 - ok -else - notok -end +ok($x[1] == 2) -begin - for k,v in $y - fail if k*2 != v - end - ok -rescue - notok -end - -if $x.length == 3 - ok -else - notok -end - -if $x.has_key?(1) - ok -else - notok -end - -if $x.has_value?(4) - ok -else - notok -end +ok(begin + for k,v in $y + fail if k*2 != v + end + TRUE + rescue + FALSE + end) -if $x.indexes(2,3) == [4,6] - ok -else - notok -end +ok($x.length == 3) +ok($x.has_key?(1)) +ok($x.has_value?(4)) +ok($x.indexes(2,3) == [4,6]) +ok($x == (1=>2, 2=>4, 3=>6)) $z = $y.keys.join(":") -if $z == "1:2:3" - ok -else - notok -end +ok($z == "1:2:3") $z = $y.values.join(":") -if $z == "2:4:6" - ok -else - notok -end - -if $x == $y - ok -else - notok -end +ok($z == "2:4:6") +ok($x == $y) $y.shift -if $y.length == 2 - ok -else - notok -end +ok($y.length == 2) + +$z = [1,2] +$y[$z] = 256 +ok($y[$z] == 256) check "iterator" -if iterator? then notok else ok end +ok(!iterator?) def ttt - if iterator? then ok else notok end + ok(iterator?) end ttt{} # yield at top level -begin - yield - notok -rescue - ok -end +ok(!defined?(yield)) $x = [1, 2, 3, 4] $y = [] @@ -347,11 +356,7 @@ $y = [] for i in $x $y.push i end -if $x == $y - ok -else - notok -end +ok($x == $y) # nested iterator def tt @@ -361,59 +366,54 @@ def tt end tt{|i| break if i == 5} -if i == 5 - ok +ok(i == 5) + +# iterator break/redo/next/retry +unless defined? loop + def loop + while TRUE + yield + end + end + ok(FALSE) else - notok + ok(TRUE) end -# iterator break/redo/continue/retry done = TRUE loop{ break done = FALSE - notok } -ok if done +ok(done) -done = TRUE +done = FALSE $bad = FALSE loop { - break if not done - done = FALSE - continue + break if done + done = TRUE + next $bad = TRUE } -if $bad - notok -else - ok -end +ok(!$bad) -done = TRUE +done = FALSE $bad = FALSE loop { - break if not done - done = FALSE + break if done + done = TRUE redo $bad = TRUE } -if $bad - notok -else - ok -end +ok(!$bad) $x = [] for i in 1 .. 7 - $x.push(i) -end -if $x.size == 7 - ok -else - notok + $x.push i end -# $x == [1, 2, 3, 4, 5, 6, 7] +ok($x.size == 7) +ok($x == [1, 2, 3, 4, 5, 6, 7]) + $done = FALSE $x = [] for i in 1 .. 7 # see how retry works in iterator loop @@ -423,102 +423,56 @@ for i in 1 .. 7 # see how retry works in iterator loop end $x.push(i) end -# $x == [1, 2, 3, 1, 2, 3, 4, 5, 6, 7] -if $x.size == 10 - ok -else - notok -end +ok($x.size == 10) +ok($x == [1, 2, 3, 1, 2, 3, 4, 5, 6, 7]) check "bignum" def fact(n) return 1 if n == 0 return n*fact(n-1) end -if fact(40) == 815915283247897734345611269596115894272000000000 - ok -else - notok -end -if fact(40) == 815915283247897734345611269596115894272000000001 - notok -else - ok -end +$x = fact(40) +ok($x == $x) +ok($x == fact(40)) +ok($x < $x+2) +ok($x > $x-2) +ok($x == 815915283247897734345611269596115894272000000000) +ok($x != 815915283247897734345611269596115894272000000001) +ok($x+1 == 815915283247897734345611269596115894272000000001) +ok($x/fact(20) == 335367096786357081410764800000) +$x = -$x +ok($x == -815915283247897734345611269596115894272000000000) +ok(2-(2**32) == -(2**32-2)) +ok(2**32 - 5 == (2**32-3)-2) check "string & char" -if "abcd" == "abcd" - ok -else - notok -end - -if "abcd" =~ "abcd" - ok -else - notok -end +ok("abcd" == "abcd") +ok("abcd" =~ "abcd") +ok("abcd" === "abcd") $foo = "abc" -if "#$foo = abc" == "abc = abc" - ok -else - notok -end - -if "#{$foo} = abc" == "abc = abc" - ok -else - notok -end +ok("#$foo = abc" == "abc = abc") +ok("#{$foo} = abc" == "abc = abc") foo = "abc" -if "#{foo} = abc" == "abc = abc" - ok -else - notok -end +ok("#{foo} = abc" == "abc = abc") -if '-' * 5 == '-----' then ok else notok end -if '-' * 1 == '-' then ok else notok end -if '-' * 0 == '' then ok else notok end +ok('-' * 5 == '-----') +ok('-' * 1 == '-') +ok('-' * 0 == '') foo = '-' -if foo * 5 == '-----' then ok else notok end -if foo * 1 == '-' then ok else notok end -if foo * 0 == '' then ok else notok end +ok(foo * 5 == '-----') +ok(foo * 1 == '-') +ok(foo * 0 == '') # character constants(assumes ASCII) -if "a"[0] == ?a - ok -else - notok -end - -if ?a == ?a - ok -else - notok -end - -if ?\C-a == 1 - ok -else - notok -end - -if ?\M-a == 225 - ok -else - notok -end - -if ?\M-\C-a == 129 - ok -else - notok -end +ok("a"[0] == ?a) +ok(?a == ?a) +ok(?\C-a == 1) +ok(?\M-a == 225) +ok(?\M-\C-a == 129) $x = "abcdef" $y = [ ?a, ?b, ?c, ?d, ?e, ?f ] @@ -529,33 +483,28 @@ $x.each_byte {|i| break end } -if not $bad - ok -else - notok -end +ok(!$bad) check "asignment" a = nil -if a == nil - ok -else - notok -end +ok(defined?(a)) +ok(a == nil) +# multiple asignment a, b = 1, 2 -if a == 1 and b == 2 then - ok -else - notok -end +ok(a == 1 && b == 2) + +a, b = b, a +ok(a == 2 && b == 1) + +a, = 1,2 +ok(a == 1) a, *b = 1, 2, 3 -if a == 1 and b == [2, 3] then - ok -else - notok -end +ok(a == 1 && b == [2, 3]) + +*a = 1, 2, 3 +ok(a == [1, 2, 3]) check "call" def aaa(a, b=100, *rest) @@ -564,191 +513,167 @@ def aaa(a, b=100, *rest) return res end +# not enough argument begin - aaa() - notok + aaa() # need at least 1 arg + ok(FALSE) rescue - ok + ok(TRUE) end begin - aaa - notok + aaa # no arg given (exception raised) + ok(FALSE) rescue - ok + ok(TRUE) end begin if aaa(1) == [1, 100] - ok + ok(TRUE) else fail end rescue - notok + ok(FALSE) end begin if aaa(1, 2) == [1, 2] - ok + ok(TRUE) else fail end rescue - notok + ok(FALSE) end -begin - if aaa(1, 2, 3, 4) == [1, 2, 3, 4] - ok - else - fail - end -rescue - notok -end - -begin - if aaa(1, *[2, 3, 4]) == [1, 2, 3, 4] - ok - else - fail - end -rescue - notok -end +ok(aaa(1, 2, 3, 4) == [1, 2, 3, 4]) +ok(aaa(1, *[2, 3, 4]) == [1, 2, 3, 4]) check "proc" $proc = proc{|i| i} -if $proc.call(2) == 2 - ok -else - notok -end +ok($proc.call(2) == 2) +ok($proc.call(3) == 3) $proc = proc{|i| i*2} -if $proc.call(2) == 4 - ok -else - notok -end +ok($proc.call(2) == 4) +ok($proc.call(3) == 6) proc{ iii=5 # dynamic local variable - $proc = proc{ |i| + $proc = proc{|i| iii = i } $proc2 = proc { $x = iii # dynamic variables shared by procs } - if defined?(iii) # dynamic variables' scope - ok - else - notok - end + # scope of dynamic variables + ok(defined?(iii)) }.call -if defined?(iii) # out of scope - notok -else - ok -end +ok(!defined?(iii)) # out of scope + $x=0 $proc.call(5) $proc2.call -if $x == 5 - ok -else - notok -end +ok($x == 5) -check "signal" -begin - kill "SIGINT", $$ - sleep 1 - notok -rescue - ok -end +if defined? Process.kill + check "signal" -$x = 0 -trap "SIGINT", proc{|sig| $x = sig;fail} -begin - kill "SIGINT", $$ - sleep 1 - notok -rescue - if $x == 2 - ok - else - notok - end -end + $x = 0 + trap "SIGINT", proc{|sig| $x = sig} + Process.kill "SIGINT", $$ + sleep 0.1 + ok($x == 2) -$x = FALSE -trap "SIGINT", "$x = TRUE;fail" -begin - kill "SIGINT", $$ - sleep 1 - notok -rescue - if $x - ok - else - notok + trap "SIGINT", proc{fail "Interrupt"} + + x = FALSE + begin + Process.kill "SIGINT", $$ + sleep 0.1 + rescue + x = $! end + ok(x =~ /Interrupt/) +else + ok(FALSE) end check "eval" $bad=FALSE -eval 'while FALSE; $bad = TRUE; print "foo\n" end -if not $bad then ok else notok end' +eval 'while FALSE; $bad = TRUE; print "foo\n" end' +ok(!$bad) -$foo = 'ok' +ok(eval('TRUE')) + +$foo = 'ok(TRUE)' begin eval $foo rescue - notok + ok(FALSE) end -check "system" -if `echo foobar` == "foobar\n" - ok -else - notok +ok(eval("$foo") == 'ok(TRUE)') +ok(eval("TRUE") == TRUE) +i = 5 +ok(eval("i == 5")) +ok(eval("i") == 5) +ok(eval("defined? i")) + +# eval with binding +def test_ev + local1 = "local1" + lambda { + local2 = "local2" + return binding + }.call end -if `./ruby -e 'print "foobar"'` == 'foobar' - ok -else - notok +$x = test_ev +ok(eval("local1", $x) == "local1") # static local var +ok(eval("local2", $x) == "local2") # dynamic local var +$bad = TRUE +begin + p eval("local1") +rescue NameError # must raise error + $bad = FALSE end +ok(!$bad) + +module EvTest + EVTEST1 = 25 + evtest2 = 125 + $x = binding +end +ok(eval("EVTEST1", $x) == 25) # constant in module +ok(eval("evtest2", $x) == 125) # local var in module +$bad = TRUE +begin + eval("EVTEST1") +rescue NameError # must raise error + $bad = FALSE +end +ok(!$bad) + +check "system" +ok(`echo foobar` == "foobar\n") +ok(`./ruby -e 'print "foobar"'` == 'foobar') tmp = open("script_tmp", "w") tmp.print "print $zzz\n"; tmp.close -if `./ruby -s script_tmp -zzz` == 't' - ok -else - notok -end - -if `./ruby -s script_tmp -zzz=555` == '555' - ok -else - notok -end +ok(`./ruby -s script_tmp -zzz` == 'TRUE') +ok(`./ruby -s script_tmp -zzz=555` == '555') tmp = open("script_tmp", "w") tmp.print "#! /usr/local/bin/ruby -s\n"; tmp.print "print $zzz\n"; tmp.close -if `./ruby script_tmp -zzz=678` == '678' - ok -else - notok -end +ok(`./ruby script_tmp -zzz=678` == '678') tmp = open("script_tmp", "w") tmp.print "this is a leading junk\n"; @@ -758,17 +683,8 @@ tmp.print "__END__\n"; tmp.print "this is a trailing junk\n"; tmp.close -if `./ruby -x script_tmp` == 'nil' - ok -else - notok -end - -if `./ruby -x script_tmp -zzz=555` == '555' - ok -else - notok -end +ok(`./ruby -x script_tmp` == 'nil') +ok(`./ruby -x script_tmp -zzz=555` == '555') tmp = open("script_tmp", "w") for i in 1..5 @@ -780,13 +696,14 @@ tmp.close done = TRUE tmp = open("script_tmp", "r") while tmp.gets + print "c: ", $_ if $_.to_i % 5 != 0 done = FALSE - notok break end end -ok if done +tmp.close +ok(done) File.unlink "script_tmp" or `/bin/rm -f "script_tmp"` File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"` @@ -807,19 +724,11 @@ end include Const -if [TEST1,TEST2,TEST3,TEST4] == [1,2,3,4] - ok -else - notok -end +ok([TEST1,TEST2,TEST3,TEST4] == [1,2,3,4]) include Const2 - -if [TEST1,TEST2,TEST3,TEST4] == [1,2,6,8] - ok -else - notok -end +STDERR.print "intentionally redefines TEST3, TEST4\n" if $VERBOSE +ok([TEST1,TEST2,TEST3,TEST4] == [1,2,6,8]) check "clone" foo = Object.new @@ -831,200 +740,124 @@ def bar.test2 "test2" end -if bar.test2 == "test2" - ok -else - notok -end - -if bar.test == "test" - ok -else - notok -end - -if foo.test == "test" - ok -else - notok -end +ok(bar.test2 == "test2") +ok(bar.test == "test") +ok(foo.test == "test") begin foo.test2 - notok + ok FALSE rescue - ok + ok TRUE end check "pack" $format = "c2x5CCxsdila6"; # Need the expression in here to force ary[5] to be numeric. This avoids -# test2 failing because ary2 goes str->numeric->str and ary doesn't. +# test2 failing because ary2 goes str->numeric->str and ary does not. ary = [1,-100,127,128,32767,987.654321098 / 100.0,12345,123456,"abcdef"] $x = ary.pack($format) ary2 = $x.unpack($format) -if ary.length == ary2.length then ok else notok end - -if ary.join(':') == ary2.join(':') then ok else notok end - -if $x =~ /def/ then ok else notok end +ok(ary.length == ary2.length) +ok(ary.join(':') == ary2.join(':')) +ok($x =~ /def/) check "math" -if Math.sqrt(4) == 2 - ok -else - notok -end +ok(Math.sqrt(4) == 2) include Math -if sqrt(4) == 2 - ok -else - notok -end +ok(sqrt(4) == 2) check "struct" struct_test = Struct.new("Test", :foo, :bar) -if struct_test == Struct::Test - ok -else - notok -end +ok(struct_test == Struct::Test) + test = struct_test.new(1, 2) -if test.foo == 1 && test.bar == 2 - ok -else - notok -end -if test[0] == 1 && test[1] == 2 - ok -else - notok -end +ok(test.foo == 1 && test.bar == 2) +ok(test[0] == 1 && test[1] == 2) + a, b = test -if a == 1 && b == 2 - ok -else - notok -end +ok(a == 1 && b == 2) + test[0] = 22 -if test.foo == 22 - ok -else - notok -end +ok(test.foo == 22) + test.bar = 47 -if test.bar == 47 - ok -else - notok -end +ok(test.bar == 47) check "variable" -if $$.is_instance_of? Fixnum - ok -else - notok -end +ok($$.instance_of?(Fixnum)) +# read-only variable begin $$ = 5 - notok + ok FALSE rescue - ok + ok TRUE end foobar = "foobar" $_ = foobar -if $_ == foobar - ok -else - notok -end +ok($_ == foobar) check "trace" $x = 1234 $y = 0 trace_var :$x, proc{$y = $x} $x = 40414 -if $y == $x - ok -else - notok -end +ok($y == $x) untrace_var :$x $x = 19660208 -if $y != $x - ok -else - notok -end +ok($y != $x) trace_var :$x, proc{$x *= 2} $x = 5 -if $x == 10 - ok -else - notok -end +ok($x == 10) + untrace_var :$x check "defined?" -if defined? $x - ok -else - notok -end + +ok(defined?($x)) # global variable +ok(defined?($x) == 'global-variable')# returns description foo=5 -if defined? foo - ok -else - notok -end +ok(defined?(foo)) # local variable -if defined? Array - ok -else - notok -end +ok(defined?(Array)) # constant +ok(defined?(Object.new)) # method +ok(!defined?(Object.print)) # private method +ok(defined?(1 == 2)) # operator expression -if defined? Object.new - ok -else - notok +def defined_test + return !defined?(yield) end -if defined? 1 == 2 - ok -else - notok -end +ok(defined_test) # not iterator +ok(!defined_test{}) # called as iterator -if defined? fail - ok -else - notok +check "alias" +class Alias0 + def foo; "foo" end end - -def defined_test - return defined?(yield) +class Alias1<Alias0 + alias bar foo + def foo; "foo+" + super end end - -if defined_test - notok -else - ok +class Alias2<Alias1 + alias baz foo + undef foo end -if defined_test{} - ok -else - notok -end +x = Alias2.new +ok(x.bar == "foo") +ok(x.baz == "foo+foo") + +# check for cache +ok(x.baz == "foo+foo") check "gc" begin @@ -1032,9 +865,13 @@ begin tmp = [0,1,2,3,4,5,6,7,8,9] } tmp = nil - ok + ok TRUE rescue - notok + ok FALSE end -print "end of test\n" if not $failed +if $failed > 0 + printf "test: %d failed %d\n", $ntest, $failed +else + printf "end of test(test: %d)\n", $ntest +end diff --git a/sample/time.rb b/sample/time.rb index 715d98ac9e..f4f4ec4883 100755 --- a/sample/time.rb +++ b/sample/time.rb @@ -1,5 +1,5 @@ #! /usr/local/bin/ruby -cmd = $ARGV.join(" ") +cmd = ARGV.join(" ") b = Time.now system(cmd) e = Time.now diff --git a/sample/tkbiff.rb b/sample/tkbiff.rb index 9b406010cb..24860c11a6 100644 --- a/sample/tkbiff.rb +++ b/sample/tkbiff.rb @@ -1,17 +1,23 @@ #! /usr/local/bin/ruby -if $ARGV.length == 0 +if ARGV[0] != '-d' + unless $DEBUG + exit if fork + end +else + ARGV.shift +end + +if ARGV.length == 0 if ENV['MAIL'] $spool = ENV['MAIL'] else $spool = '/usr/spool/mail/' + ENV['USER'] end else - $spool = $ARGV[0] + $spool = ARGV[0] end -exit if fork - require "parsedate" require "base64" @@ -19,7 +25,7 @@ include ParseDate class Mail def Mail.new(f) - if !f.is_kind_of?(IO) + if !f.kind_of?(IO) f = open(f, "r") me = super f.close @@ -34,7 +40,7 @@ class Mail @body = [] while f.gets() $_.chop! - continue if /^From / # skip From-line + next if /^From / # skip From-line break if /^$/ # end of header if /^(\S+):\s*(.*)/ @header[attr = $1.capitalize] = $2 @@ -83,23 +89,37 @@ $top.bind "Control-q", proc{exit} $top.bind "space", proc{exit} $spool_size = 0 +$check_time = Time.now + def check + $check_time = Time.now size = File.size($spool) if size and size != $spool_size + $spool_size = size pop_up if size > 0 end Tk.after 5000, proc{check} end +if defined? Thread + Thread.start do + loop do + sleep 600 + if Time.now - $check_time > 200 + Tk.after 5000, proc{check} + end + end + end +end + def pop_up outcount = 0; - $spool_size = File.size($spool) $list.delete 0, 'end' f = open($spool, "r") while !f.eof mail = Mail.new(f) date, from, subj = mail.header['Date'], mail.header['From'], mail.header['Subject'] - continue if !date + next if !date y = m = d = 0 y, m, d = parsedate(date) if date from = "sombody@somewhere" if ! from @@ -112,10 +132,18 @@ def pop_up f.close if outcount == 0 $list.insert 'end', "You have no mail." + else + $list.see 'end' end $top.deiconify Tk.after 2000, proc{$top.withdraw} end +$list.insert 'end', "You have no mail." check -Tk.mainloop +Tk.after 2000, proc{$top.withdraw} +begin + Tk.mainloop +rescue + `echo #$! > /tmp/tkbiff` +end diff --git a/sample/tkbrowse.rb b/sample/tkbrowse.rb index dbaa132d1f..d127996173 100644 --- a/sample/tkbrowse.rb +++ b/sample/tkbrowse.rb @@ -25,10 +25,10 @@ list = TkScrollbox.new { def browse (dir, file) if dir != "." file="#{dir}/#{file}" - if File.isdirectory? file + if File.directory? file system "browse #{file} &" else - if File.isfile? file + if File.file? file if ENV['EDITOR'] system format("%s %s&", ENV['EDITOR'], file) else @@ -44,8 +44,8 @@ end # Fill the listbox with a list of all the files in the directory (run # the "ls" command to get that information). -if $ARGV.length>0 - dir = $ARGV[0] +if ARGV.length>0 + dir = ARGV[0] else dir="." end diff --git a/sample/tkfrom.rb b/sample/tkfrom.rb index 4a0d8c2b5d..9a53ea2d72 100644 --- a/sample/tkfrom.rb +++ b/sample/tkfrom.rb @@ -7,7 +7,7 @@ include ParseDate class Mail def Mail.new(f) - if !f.is_kind_of?(IO) + if !f.kind_of?(IO) f = open(f, "r") me = super f.close @@ -22,7 +22,7 @@ class Mail @body = [] while f.gets() $_.chop! - continue if /^From / # skip From-line + next if /^From / # skip From-line break if /^$/ # end of header if /^(\S+):\s*(.*)/ @header[attr = $1.capitalize] = $2 @@ -50,7 +50,7 @@ class Mail end -$ARGV[0] = '/usr/spool/mail/' + ENV['USER'] if $ARGV.length == 0 +ARGV[0] = '/usr/spool/mail/' + ENV['USER'] if ARGV.length == 0 require "tk" list = scroll = nil @@ -85,13 +85,13 @@ root.bind "Control-q", proc{exit} root.bind "space", proc{exit} $outcount = 0; -for file in $ARGV - continue if !File.exists?(file) +for file in ARGV + next if !File.exist?(file) f = open(file, "r") while !f.eof mail = Mail.new(f) date, from, subj = mail.header['Date'], mail.header['From'], mail.header['Subject'] - continue if !date + next if !date y = m = d = 0 y, m, d = parsedate(date) if date from = "sombody@somewhere" if ! from @@ -102,6 +102,7 @@ for file in $ARGV $outcount += 1 end f.close + list.see 'end' end limit = 10000 diff --git a/sample/tkline.rb b/sample/tkline.rb index 843893b5d9..63d763a680 100644 --- a/sample/tkline.rb +++ b/sample/tkline.rb @@ -1,5 +1,21 @@ + +$tk_thread_safe = TRUE require "tkclass" +$tkline_init = FALSE +def start_random + return if $tkline_init + $tkline_init = TRUE + if defined? Thread + Thread.start do + loop do + sleep 2 + Line.new($c, rand(400), rand(200), rand(400), rand(200)) + end + end + end +end + $c = Canvas.new $c.pack $start_x = start_y = 0 @@ -7,7 +23,8 @@ $start_x = start_y = 0 def do_press(x, y) $start_x = x $start_y = y - $current_line = Line.new($c, x, y, x, y, 'fill' => 'gray') + $current_line = Line.new($c, x, y, x, y) + start_random end def do_motion(x, y) if $current_line @@ -23,7 +40,7 @@ def do_release(x, y) end end -$c.bind("1", proc{|e| do_press e.x,e.y}) -$c.bind("B1-Motion", proc{|e| do_motion e.x,e.y}) -$c.bind("ButtonRelease-1", proc{|e| do_release e.x,e.y}) +$c.bind("1", proc{|e| do_press e.x, e.y}) +$c.bind("B1-Motion", proc{|x, y| do_motion x, y}, "%x %y") +$c.bind("ButtonRelease-1", proc{|x, y| do_release x, y}, "%x %y") Tk.mainloop diff --git a/sample/trojan.pl b/sample/trojan.pl deleted file mode 100644 index fe80786fa5..0000000000 --- a/sample/trojan.pl +++ /dev/null @@ -1,12 +0,0 @@ -#! /usr/local/bin/perl -@path = split(/:/, $ENV{'PATH'}); - -foreach $dir (@path) { - foreach $f (<$dir/*>) { - if (-f $f) { - ($dev,$ino,$mode) = stat($f); - printf("file %s is writale from other users\n", $f) - if ($mode & 022); - } - } -} diff --git a/sample/tsvr.rb b/sample/tsvr.rb new file mode 100644 index 0000000000..fbc6545bb5 --- /dev/null +++ b/sample/tsvr.rb @@ -0,0 +1,23 @@ +# socket example - server side using thread +# usage: ruby tsvr.rb + +require "socket" +require "thread" + +gs = TCPserver.open(0) +addr = gs.addr +addr.shift +printf("server is on %d\n", addr.join(":")) + +while TRUE + ns = gs.accept + print(ns, " is accepted\n") + Thread.start do + s = ns # save to dynamic variable + while s.gets + s.write($_) + end + print(s, " is gone\n") + s.close + end +end diff --git a/sample/uumerge.rb b/sample/uumerge.rb index ac6e1c6849..297b08f26a 100755 --- a/sample/uumerge.rb +++ b/sample/uumerge.rb @@ -1,8 +1,8 @@ #!/usr/local/bin/ruby -if $ARGV[0] == "-c" +if ARGV[0] == "-c" out_stdout = 1; - $ARGV.shift + ARGV.shift end while gets() @@ -27,8 +27,8 @@ while gets() break end sub(/[a-z]+$/, ""); # handle stupid trailing lowercase letters - continue if /[a-z]/ - continue if !(((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4) + next if /[a-z]/ + next if !(((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4) out << $_.unpack("u"); end |