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

2000-05-01

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-05-01 09:42:38 +00:00
parent acbb1c9434
commit fedf48986d
69 changed files with 1841 additions and 1455 deletions

161
ChangeLog
View file

@ -1,3 +1,58 @@
Sat Apr 29 04:58:12 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* array.c (rb_ary_unshift_m): performance improvement.
Fri Apr 28 00:19:22 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* array.c (rb_ary_unshift_m): takes items to push.
Wed Apr 26 15:23:02 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (rb_str_succ): insert carrying character just before
the leftmost alpha numeric character.
* string.c (rb_str_succ): proper behavior for "".succ and "\377".succ.
* string.c (rb_str_succ): use realloc and memmove.
Tue Apr 25 14:30:13 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* io.c (rb_io_gets_internal): shortcut when rs == rb_default_rs.
Sat Apr 22 23:14:41 2000 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
* configure.in: MacOS X support.
Fri Apr 21 21:44:34 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* io.c (rb_io_s_pipe): should set FMODE_SYNC.
Thu Apr 20 16:59:22 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* eval.c (massign): `*lvalue = false' should assign `[false]' to
lvalue.
Wed Apr 19 08:35:08 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* class.c (rb_singleton_class): generate singleton class for
special constants: nil, true, false.
Wed Apr 19 02:09:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* class.c (rb_singleton_class): singleton method for nil, true,
false is possible now.
* eval.c (rb_eval): ditto.
Mon Apr 17 15:16:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* io.c (rb_io_close): to detect some exceptional status, writable
IO should be flushed before close;
Sat Apr 15 18:29:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* array.c (rb_ary_collect_bang): Array#filter renamed.
Tue Apr 11 21:14:42 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* config_s.dj: add @sitedir@.
@ -115,7 +170,7 @@ Tue Mar 21 12:57:50 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
Sat Mar 18 12:36:09 2000 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (rb_backtrace, make_backtrace): removed unsed variable
* eval.c (rb_backtrace, make_backtrace): removed unused variable
`lev'.
* eval.c (rb_attr): calls `method_added' at attribute definition.
@ -548,7 +603,7 @@ Mon Jan 24 02:56:44 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_eval): when defining class is already there, and
superclass differ, throw away the old class.
* variable.c (rb_const_set): gives warining again on constant
* variable.c (rb_const_set): gives warning again on constant
redefinition.
* error.c (Init_Exception): SyntaxError, NameError, LoadError and
@ -704,7 +759,7 @@ Mon Dec 27 12:35:47 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
Sun Dec 26 23:15:13 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* win32/win32.c (mypopen): raise catchable error instead of rb_fatal.
* win32/win32.c (mypclose): fix process handle laek.
* win32/win32.c (mypclose): fix process handle leak.
Sun Dec 26 16:17:11 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
@ -735,7 +790,7 @@ Tue Dec 21 17:21:28 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
Mon Dec 20 19:08:12 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* file.c (rb_file_s_expand_path): handle dir separetor correctly.
* file.c (rb_file_s_expand_path): handle dir separator correctly.
Sun Dec 19 22:56:31 1999 KANEKO Naoshi <wbs01621@mail.wbs.ne.jp>
@ -768,7 +823,7 @@ Wed Dec 15 01:35:29 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Mon Dec 13 15:15:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_adjust_startpos): separate startpos adjustment
because of major performace drawback.
because of major performance drawback.
* class.c (rb_singleton_class): tainted status of the singleton
class must be synchronized with the object.
@ -931,7 +986,7 @@ Sat Nov 20 10:10:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Fri Nov 19 18:06:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* dir.c (glob): recurseve wildcard match by `**' ala zsh.
* dir.c (glob): recursive wildcard match by `**' ala zsh.
Fri Nov 19 11:44:26 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
@ -981,7 +1036,7 @@ Sat Nov 13 07:34:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
assign shared variables within methods.
* eval.c (rb_eval): remove warnings from constants modification,
becase they are no longer constants.
because they are no longer constants.
* parse.y (node_assign): modified for shared variables.
@ -1364,7 +1419,7 @@ Wed Sep 1 00:28:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Fri Aug 28 17:32:55 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
* eval.c (rb_eval): should set return value (nil) explicitly if a
value is ommited for return statement.
value is omitted for return statement.
Thu Aug 26 15:06:11 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
@ -1389,7 +1444,7 @@ Fri Aug 20 20:50:58 1999 Kenji Nagasawa <kenn@hma.att.ne.jp>
Thu Aug 19 10:50:43 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
* gc.c (rb_gc): add volatile to avoid GCC optimaize bug(?).
* gc.c (rb_gc): add volatile to avoid GCC optimize bug(?).
Wed Aug 18 23:48:10 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -1404,7 +1459,7 @@ Fri Aug 13 15:41:39 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Fri Aug 13 03:16:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* io.c (argf_forward): since $stdout may be non-IO, ARGF.file is
not granteed to be IO. check and forwarding added to every ARGF
not guaranteed to be IO. check and forwarding added to every ARGF
method.
* io.c (set_outfile): $stdout/$stderr may not be IO now.
@ -1544,7 +1599,7 @@ Fri Jul 30 02:11:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* io.c (rb_io_fptr_close): do not call rb_sys_wait() on finalize.
* eval.c (yield_under_i): cbase context should be maintaind for
* eval.c (yield_under_i): cbase context should be maintained for
Module#module_eval(). suggested by <inaba@st.rim.or.jp>.
Wed Jul 28 01:18:28 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
@ -1583,7 +1638,7 @@ Fri Jul 23 02:49:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Thu Jul 22 19:37:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_thread_join): get_backtrace() may retrun Qnil.
* eval.c (rb_thread_join): get_backtrace() may return Qnil.
typecheck added.
Tue Jul 20 14:36:43 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
@ -1634,7 +1689,7 @@ Fri Jul 16 10:58:22 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
Fri Jul 16 09:58:15 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* many files: clean up unsed variables found by gcc -Wall.
* many files: clean up unused variables found by gcc -Wall.
* lib/mkmf.rb: better cygwin support etc.
@ -1966,7 +2021,7 @@ Fri Jun 11 23:27:00 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
Fri Jun 11 15:21:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* gc.c (rb_gc_mark_locations): add safty margin 1.
* gc.c (rb_gc_mark_locations): add safety margin 1.
* eval.c (ruby_run): should protect toplevel node tree.
@ -1975,7 +2030,7 @@ Fri Jun 11 15:21:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Fri Jun 11 01:50:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (ruby_run): Init_stack() was called too late; local
variables happend to be higher (or lower) than stack_start.
variables happened to be higher (or lower) than stack_start.
Thu Jun 10 16:41:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -2080,7 +2135,7 @@ Tue Jun 1 15:29:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (module_setup): need to add PUSH_VAR/POP_VAR to clear
dyna vars link list.
* version.h (RUBY_RELEASE_CODE): integer macro contant for source
* version.h (RUBY_RELEASE_CODE): integer macro constant for source
version detection.
Sun May 30 22:19:12 1999 Kenji Nagasawa <kenn@tcp-ip.or.jp>
@ -2133,7 +2188,7 @@ Fri May 28 17:16:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* ext/socket/socket.c (setipaddr): re-wrote using ip_addrsetup().
* ext/sockt/socket.c (ip_addrsetup): decode symbolic address
* ext/socket/socket.c (ip_addrsetup): decode symbolic address
<broadcast>.
Thu May 27 12:27:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -2331,7 +2386,7 @@ Thu May 6 13:21:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Thu May 4 12:34:18 1999 Koji Arai <JCA02266@nifty.ne.jp>
* parse.y (parse_string): there shuould be newline escape by
* parse.y (parse_string): there should be newline escape by
backslashes in strings.
* parse.y (parse_qstring): ditto.
@ -2696,7 +2751,7 @@ Fri Mar 12 02:12:50 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Thu Mar 11 18:23:50 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
* ext/socket/socket.c (Init_socket): UDPsocket was ommited.
* ext/socket/socket.c (Init_socket): UDPsocket was omitted.
Thu Mar 11 16:43:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -2775,8 +2830,8 @@ Tue Mar 2 17:04:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Mon Mar 1 14:05:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_call0): adjust argv for optional arguments. super
without arguments emit superclasse method with the value from
optinal arguments. enabled as experiment.
without arguments emit superclass method with the value from
optional arguments. enabled as experiment.
Sun Feb 28 14:04:07 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
@ -2864,9 +2919,9 @@ Tue Feb 23 14:21:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Tue Feb 23 12:32:41 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
* eval.c (rb_load): tilde expandion moved to find_file.
* eval.c (rb_load): tilde expansion moved to find_file.
* eval.c (find_file): tilde expandion added.
* eval.c (find_file): tilde expansion added.
Tue Feb 23 10:50:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -2913,18 +2968,18 @@ Fri Feb 19 00:25:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* time.c (time_plus): Time#+ should not receive Time object
operand.
* string.c (rb_str_substr): nagative length raises exception now.
* string.c (rb_str_substr): negative length raises exception now.
* array.c (beg_len): if end == -1, it points end of the array.
* array.c (rb_ary_subseq): nagative length raises exception now.
* array.c (rb_ary_subseq): negative length raises exception now.
Thu Feb 18 20:57:04 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
* time.c (rb_strftime): strftime() may return 0 on success too.
* time.c (time_strftime): `\0' within format string shoule not be
ommited in the result.
* time.c (time_strftime): `\0' within format string should not be
omitted in the result.
* time.c (rb_strftime): zero length format.
@ -2992,7 +3047,7 @@ Mon Feb 15 11:43:22 1999 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
Sun Feb 14 22:36:40 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* sprintf.c (rb_f_sprintf): `%G' was ommited.
* sprintf.c (rb_f_sprintf): `%G' was omitted.
Sun Feb 14 12:47:48 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
@ -3001,7 +3056,7 @@ Sun Feb 14 12:47:48 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* numeric.c (Init_Numeric): FloatDomainError added.
* configure.in (AC_REPLACE_FUNCS): add checks for functions
insinf, isnan, and finite.
isinf, isnan, and finite.
Sat Feb 13 01:24:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -3075,7 +3130,7 @@ Sat Feb 6 22:56:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Sat Feb 6 03:06:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* re.c (match_getter): accessng $~ without matching caused SEGV.
* re.c (match_getter): accessing $~ without matching caused SEGV.
Fri Feb 5 22:11:08 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
@ -3107,7 +3162,7 @@ Thu Feb 4 11:56:24 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* configure.in (strtod): add strtod compatible check.
* numeric.c (rb_num2long): missing/vsnprintf.c does not supprt
* numeric.c (rb_num2long): missing/vsnprintf.c does not support
floating points.
* numeric.c (flo_to_s): ditto.
@ -3147,7 +3202,7 @@ Wed Feb 3 15:03:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
Tue Feb 2 17:11:26 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
* string.c (rb_str_gsub_bang): too small realoc condition.
* string.c (rb_str_gsub_bang): too small realloc condition.
Mon Feb 1 10:01:17 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
@ -3164,7 +3219,7 @@ Sat Jan 30 08:45:16 1999 IKARASHI Akira <ikarashi@itlb.te.noda.sut.ac.jp>
Sat Jan 30 13:38:24 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_compile_pattern): mbchars should match with \w
within character classs. Was matching with \W.
within character class. Was matching with \W.
* regex.c (re_match): \w should match with multi byte characters,
not its first byte.
@ -3461,7 +3516,7 @@ Mon Dec 7 22:08:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
Mon Dec 7 18:24:50 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
* ruby.c (set_arg0): $0 supprt for HP-UX.
* ruby.c (set_arg0): $0 support for HP-UX.
Mon Dec 7 01:30:28 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
@ -3624,7 +3679,7 @@ Wed Nov 11 10:54:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
Tue Nov 10 00:22:11 1998 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* configure.in: elf supprt for FreeBSD 3.x
* configure.in: elf support for FreeBSD 3.x
Tue Nov 10 00:05:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -3755,7 +3810,7 @@ Fri Oct 16 15:31:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
Thu Oct 15 13:54:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (arg): local variabls can be accessed within right side
* parse.y (arg): local variables can be accessed within right side
expression in assignment, notably in blocks.
Wed Oct 14 00:18:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -3869,7 +3924,7 @@ Mon Sep 14 14:42:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_match): beginning and end of the string, do not
automatically match `\b'.
* string.c (scan_once): comsume at leaset on character.
* string.c (scan_once): consume at least on character.
* regex.c (re_search): wrong behavior for negative range.
@ -4197,7 +4252,7 @@ Fri Jul 3 11:20:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* numeric.c (fix_mul): use FIX2LONG() instead of FIX2INT() for
64bit architectures.
* marshal.c (r_bytes): remove weird casting bwetween pointer and int.
* marshal.c (r_bytes): remove weird casting between pointer and int.
* process.c (proc_setsid): new method Process#setsid().
@ -4656,7 +4711,7 @@ Tue Apr 28 00:07:38 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
Mon Apr 27 16:59:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* ext/gtk/gtk.c (Init_gtk): use timeout, not idle to avoid
comsuming CPU too much.
consuming CPU too much.
* lib/tk.rb: use tcltklib#_invoke instead of `_eval'.
@ -4997,7 +5052,7 @@ Tue Mar 31 13:23:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
Mon Mar 30 11:12:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* file.c (f_test): raises exception for unkown command.
* file.c (f_test): raises exception for unknown command.
* eval.c (Init_eval): `class_eval': alias to the module_eval.
@ -5114,7 +5169,7 @@ Wed Mar 18 17:46:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* ruby.c (load_file): new file object constant DATA. Only
available for the script from the file.
* regex.c (re_match): forwading failure point popped too much.
* regex.c (re_match): forwarding failure point popped too much.
Tue Mar 17 18:23:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -5229,7 +5284,7 @@ Fri Mar 6 17:23:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
primitive classes (mostly perfect).
* ext/curses/curses.c (curses_finalize): restore original state at
interpreter temination.
interpreter termination.
* ext/curses/curses.c (curses_addstr): forgot to check argument
type (caused SEGV). now uses STR2CSTR() macro.
@ -5273,7 +5328,7 @@ Tue Mar 3 11:21:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
Tue Mar 3 08:04:56 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
* struct.c (struct_alloc): imcomplete struct initialization made
* struct.c (struct_alloc): incomplete struct initialization made
GC to access unallocated addresses.
Mon Mar 2 16:28:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -5644,7 +5699,7 @@ Tue Jan 6 00:27:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
Mon Jan 5 16:59:13 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
* file.c (file_s_basename): removes any extention by ".*".
* file.c (file_s_basename): removes any extension by ".*".
Sun Jan 4 19:36:22 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
@ -5782,7 +5837,7 @@ Fri Dec 12 00:50:25 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_eval): new visibility status `function'.
* parse.y (yycompile): do not clear eval_tree. thus enable multipe
* parse.y (yycompile): do not clear eval_tree. thus enable multiple
command line script by option `-e'.
* eval.c (rb_eval): END execute just once.
@ -5863,7 +5918,7 @@ Mon Dec 1 15:24:41 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
Wed Nov 26 18:18:05 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
* lib/mkmf.rb: generate Makefile for extention modules out of ruby
* lib/mkmf.rb: generate Makefile for extension modules out of ruby
source tree. use like `ruby -r mkmf extconf.rb'.
* numeric.c (fix2str): enlarge buffer to prevent overflow on some
@ -6061,7 +6116,7 @@ Fri Oct 3 10:51:10 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (ruby_options): f_require() called too early.
* eval.c (rb_provide): module extentions should always be `.o'.
* eval.c (rb_provide): module extensions should always be `.o'.
Thu Oct 2 11:38:31 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -6257,7 +6312,7 @@ Mon Sep 1 13:42:48 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
* class.c (rb_define_attr): always defines accessors.
* eval.c (rb_call): alias occured in the module body caused SEGV.
* eval.c (rb_call): alias occurred in the module body caused SEGV.
* parse.y: did not generate here document strings properly.
@ -6276,7 +6331,7 @@ Fri Aug 29 11:10:21 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
unnamed fundamental classes, such as Object, String, etc.
* variable.c (rb_name_class): can't name class before String class
is initilialized.
is initialized.
* inits.c (rb_call_inits): unrecognized dependency from GC to
Array.
@ -6310,7 +6365,7 @@ Wed Aug 27 11:32:42 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
* variable.c (fc_i): some classes/modules does not have iv_tbl.
* variable.c (find_class_path): avoid inifinite loop.
* variable.c (find_class_path): avoid infinite loop.
Tue Aug 26 13:43:47 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -6327,7 +6382,7 @@ Tue Aug 26 13:43:47 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
* object.c (Init_Object): superclass()'s method argument setting
was wrong again.
* class.c (mod_anscestors): list superclasses and included modules
* class.c (mod_ancestors): list superclasses and included modules
in priority order.
Mon Aug 25 11:53:11 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -6342,7 +6397,7 @@ Mon Aug 25 11:53:11 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
Sat Aug 23 21:39:05 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (asignable): remove unnecessary local variable
* parse.y (assignable): remove unnecessary local variable
initialize by nil.
Fri Aug 22 14:26:40 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
@ -6407,7 +6462,7 @@ Fri Aug 15 15:49:46 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (call_trace_func): block context switch in the trace
function.
* eval.c (rb_eval): clear method cache at class extention.
* eval.c (rb_eval): clear method cache at class extension.
* object.c (obj_type): returns object's class even if it defines
singleton methods.

View file

@ -130,6 +130,7 @@ lib/net/ftp.rb
lib/net/pop.rb
lib/net/protocol.rb
lib/net/smtp.rb
lib/net/telnet.rb
lib/observer.rb
lib/open3.rb
lib/ostruct.rb

2
README
View file

@ -129,7 +129,7 @@ You can redistribute it and/or modify it under either the terms of the GPL
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
* Ruby home-page

View file

@ -881,7 +881,7 @@ Returns the name of the class.
int rb_respond_to(VALUE object, ID id)
Returns true if the object reponds to the message specified by id.
Returns true if the object responds to the message specified by id.
** Instance Variables

View file

@ -172,7 +172,7 @@ Public License)
4. 他のプログラムへの引用はいかなる目的であれ自由です.た
だし,本プログラムに含まれる他の作者によるコードは,そ
れぞれの作者の意向による制限が加えらる場合があります.
れぞれの作者の意向による制限が加えらる場合があります.
具体的にはgc.c(一部)util.c(一部)st.[ch]regex.[ch]
および ./missingディレクトリ下のファイル群が該当します

87
array.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
array.c -
@ -7,8 +7,10 @@
created at: Fri Aug 6 09:46:12 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
**********************************************************************/
#include "ruby.h"
#include "util.h"
@ -276,8 +278,15 @@ rb_ary_push_m(argc, argv, ary)
VALUE *argv;
VALUE ary;
{
while (argc--) {
rb_ary_store(ary, RARRAY(ary)->len, *argv++);
if (argc > 0) {
long len = RARRAY(ary)->len;
--argc;
/* make rooms by copying the last item */
rb_ary_store(ary, len + argc, argv[argc]);
if (argc) /* if any rest */
MEMCPY(RARRAY(ary)->ptr + len, argv, VALUE, argc);
}
return ary;
}
@ -340,6 +349,26 @@ rb_ary_unshift(ary, item)
return ary;
}
static VALUE
rb_ary_unshift_m(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
if (argc > 0) {
long len = RARRAY(ary)->len;
/* make rooms by setting the last item */
rb_ary_store(ary, len + argc - 1, Qnil);
/* sliding items */
MEMMOVE(RARRAY(ary)->ptr + argc, RARRAY(ary)->ptr, VALUE, len);
MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc);
}
return ary;
}
VALUE
rb_ary_entry(ary, offset)
VALUE ary;
@ -980,6 +1009,27 @@ rb_ary_collect(ary)
return collect;
}
static VALUE
rb_ary_collect_bang(ary)
VALUE ary;
{
long i;
rb_ary_modify(ary);
for (i = 0; i < RARRAY(ary)->len; i++) {
RARRAY(ary)->ptr[i] = rb_yield(RARRAY(ary)->ptr[i]);
}
return ary;
}
static VALUE
rb_ary_filter(ary)
VALUE ary;
{
rb_warn("Array#filter is deprecated; use Array#collect!");
return rb_ary_collect_bang(ary);
}
VALUE
rb_ary_delete(ary, item)
VALUE ary;
@ -1091,19 +1141,6 @@ rb_ary_delete_if(ary)
return ary;
}
static VALUE
rb_ary_filter(ary)
VALUE ary;
{
long i;
rb_ary_modify(ary);
for (i = 0; i < RARRAY(ary)->len; i++) {
RARRAY(ary)->ptr[i] = rb_yield(RARRAY(ary)->ptr[i]);
}
return ary;
}
static VALUE
rb_ary_replace_m(ary, ary2)
VALUE ary, ary2;
@ -1195,17 +1232,9 @@ VALUE
rb_ary_concat(x, y)
VALUE x, y;
{
VALUE *p, *pend;
rb_ary_modify(x);
Check_Type(y, T_ARRAY);
p = RARRAY(y)->ptr;
pend = p + RARRAY(y)->len;
while (p < pend) {
rb_ary_store(x, RARRAY(x)->len, *p);
p++;
}
rb_ary_push_m(RARRAY(y)->len, RARRAY(y)->ptr, x);
return x;
}
@ -1575,7 +1604,7 @@ Init_Array()
rb_define_method(rb_cArray, "push", rb_ary_push_m, -1);
rb_define_method(rb_cArray, "pop", rb_ary_pop, 0);
rb_define_method(rb_cArray, "shift", rb_ary_shift, 0);
rb_define_method(rb_cArray, "unshift", rb_ary_unshift, 1);
rb_define_method(rb_cArray, "unshift", rb_ary_unshift_m, -1);
rb_define_method(rb_cArray, "each", rb_ary_each, 0);
rb_define_method(rb_cArray, "each_index", rb_ary_each_index, 0);
rb_define_method(rb_cArray, "reverse_each", rb_ary_reverse_each, 0);
@ -1594,11 +1623,13 @@ Init_Array()
rb_define_method(rb_cArray, "sort", rb_ary_sort, 0);
rb_define_method(rb_cArray, "sort!", rb_ary_sort_bang, 0);
rb_define_method(rb_cArray, "collect", rb_ary_collect, 0);
rb_define_method(rb_cArray, "collect!", rb_ary_collect_bang, 0);
rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0);
rb_define_method(rb_cArray, "filter", rb_ary_filter, 0);
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at_m, -1);
rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);
rb_define_method(rb_cArray, "reject!", rb_ary_delete_if, 0);
rb_define_method(rb_cArray, "filter", rb_ary_filter, 0);
rb_define_method(rb_cArray, "replace", rb_ary_replace_m, 1);
rb_define_method(rb_cArray, "clear", rb_ary_clear, 0);
rb_define_method(rb_cArray, "fill", rb_ary_fill, -1);

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
bignum.c -
@ -6,7 +6,9 @@
$Date$
created at: Fri Jun 10 00:48:55 JST 1994
************************************************/
Copyright (C) 1993-2000 Yukihiro Matsumoto
**********************************************************************/
#include "ruby.h"
#include <math.h>

21
class.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
class.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"
#include "node.h"
@ -502,15 +502,30 @@ rb_undef_method(klass, name)
rb_add_method(klass, rb_intern(name), 0, NOEX_UNDEF);
}
#define SPECIAL_SINGLETON(x,c) if (obj == (x)) {\
if (!FL_TEST(c, FL_SINGLETON)) {\
c = rb_singleton_class_new(c);\
rb_singleton_class_attached(c,obj);\
}\
return c;\
}
VALUE
rb_singleton_class(obj)
VALUE obj;
{
VALUE klass;
if (rb_special_const_p(obj)) {
if (FIXNUM_P(obj) || SYMBOL_P(obj)) {
rb_raise(rb_eTypeError, "can't define singleton");
}
if (rb_special_const_p(obj)) {
SPECIAL_SINGLETON(Qnil, rb_cNilClass);
SPECIAL_SINGLETON(Qfalse, rb_cFalseClass);
SPECIAL_SINGLETON(Qtrue, rb_cTrueClass);
rb_bug("unknown immediate %d", obj);
}
if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON)) {
klass = RBASIC(obj)->klass;
}

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
compar.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"

4
config.guess vendored
View file

@ -969,6 +969,10 @@ EOF
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
*:"Mac OS":*:*)
echo `uname -p`-apple-macos${UNAME_RELEASE}
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2

2
config.sub vendored
View file

@ -910,7 +910,7 @@ case $os in
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -rhapsody* | -openstep* | -oskit*)
| -interix* | -uwin* | -rhapsody* | -openstep* | -macos | -oskit*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \

512
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -44,6 +44,12 @@ AC_ARG_ENABLE(fat-binary,
TARGET_ARCHS="ppc i386"
fi
;;
macos*)
echo -n "MacOS X : "
if test "$TARGET_ARCHS" = "" ; then
TARGET_ARCHS="ppc i386"
fi
;;
nextstep*|openstep*)
echo -n "NeXTSTEP/OPENSTEP: "
if test "$TARGET_ARCHS" = "" ; then
@ -155,6 +161,7 @@ case "$target_os" in
nextstep*) ;;
openstep*) ;;
rhapsody*) ;;
macos*) ;;
human*) ac_cv_func_getpgrp_void=yes;;
beos*) ;;
cygwin*) ;;
@ -407,6 +414,7 @@ if test "$with_dln_a_out" != yes; then
nextstep*) ;;
openstep*) ;;
rhapsody*) ;;
macos*) ;;
human*) ;;
bsdi*) ;;
cygwin*) ;;
@ -485,6 +493,10 @@ if test "$with_dln_a_out" != yes; then
LDFLAGS=""
DLDFLAGS="$ARCH_FLAG"
rb_cv_dlopen=yes ;;
macos*) LDSHARED='cc -dynamic -bundle -undefined suppress'
LDFLAGS=""
DLDFLAGS="$ARCH_FLAG"
rb_cv_dlopen=yes ;;
aix*) LDSHARED='/usr/ccs/bin/ld'
XLDFLAGS='-Wl,-bE:ruby.imp'
DLDFLAGS='-eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 -lc'
@ -553,8 +565,8 @@ else
AC_DEFINE(DLEXT, ".bundle");;
rhapsody*) DLEXT=bundle
AC_DEFINE(DLEXT, ".bundle");;
cygwin*) DLEXT=dll
AC_DEFINE(DLEXT, ".dll");;
macos*) DLEXT=bundle
AC_DEFINE(DLEXT, ".bundle");;
os2_emx*) DLEXT=dll
AC_DEFINE(DLEXT, ".dll");;
*) DLEXT=so
@ -578,6 +590,8 @@ case "$target_os" in
STRIP='strip -A -n';;
rhapsody*)
STRIP='strip -A -n';;
macos*)
STRIP='strip -A -n';;
esac
EXTSTATIC=

6
dir.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
dir.c -
@ -7,8 +7,10 @@
created at: Wed Jan 5 09:51:01 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
**********************************************************************/
#include "ruby.h"

4
dln.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
dln.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "config.h"
#include "defines.h"

7
dln.h
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
dln.h -
@ -6,7 +6,10 @@
$Date$
created at: Wed Jan 19 16:53:09 JST 1994
************************************************/
Copyright (C) 1993-2000 Yukihiro Matsumoto
**********************************************************************/
#ifndef DLN_H
#define DLN_H

5
enum.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
enum.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"
#include "node.h"
@ -338,6 +338,7 @@ Init_Enumerable()
rb_define_method(rb_mEnumerable,"select", enum_find_all, 0);
rb_define_method(rb_mEnumerable,"reject", enum_reject, 0);
rb_define_method(rb_mEnumerable,"collect", enum_collect, 0);
rb_define_method(rb_mEnumerable,"map", enum_collect, 0);
rb_define_method(rb_mEnumerable,"min", enum_min, 0);
rb_define_method(rb_mEnumerable,"max", enum_max, 0);
rb_define_method(rb_mEnumerable,"member?", enum_member, 1);

7
env.h
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
env.h -
@ -6,7 +6,10 @@
$Date$
created at: Mon Jul 11 11:53:03 JST 1994
************************************************/
Copyright (C) 1993-2000 Yukihiro Matsumoto
**********************************************************************/
#ifndef ENV_H
#define ENV_H

12
error.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
error.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"
#include "env.h"
@ -404,6 +404,7 @@ typedef struct {
int n;
} syserr_index_entry;
static VALUE syserr_error;
static VALUE syserr_list_b_general[16+1];
static VALUE syserr_list_b_os0[2+1];
static VALUE syserr_list_b_os1[5+1];
@ -464,6 +465,11 @@ set_syserr(i, name)
VALUE error = rb_define_class_under(rb_mErrno, name, rb_eSystemCallError);
rb_define_const(error, "Errno", INT2FIX(i));
#ifdef __BEOS__
if (i == B_ERROR) {
syserr_error = error;
rb_global_variable(&syserr_error);
return error;
}
i -= B_GENERAL_ERROR_BASE;
ix = (i >> 12) & 0xf;
offset = (i >> 8) & 0xf;
@ -497,6 +503,7 @@ get_syserr(int i)
VALUE *list;
int ix, offset;
if (i == B_ERROR) return syserr_error;
i -= B_GENERAL_ERROR_BASE;
ix = (i >> 12) & 0xf;
offset = (i >> 8) & 0xf;
@ -690,6 +697,7 @@ init_syserr()
MEMZERO(syserr_list[ix + offset].list, VALUE, syserr_list[ix + offset].n);
}
}
set_syserr(B_ERROR, "ERROR");
#else
syserr_list = ALLOC_N(VALUE, sys_nerr+1);
MEMZERO(syserr_list, VALUE, sys_nerr+1);

96
eval.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
eval.c -
@ -7,8 +7,10 @@
created at: Thu Jun 10 14:22:17 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
**********************************************************************/
#include "ruby.h"
#include "node.h"
@ -1837,10 +1839,11 @@ static void return_check _((void));
#define return_value(v) prot_tag->retval = (v)
static VALUE
rb_eval(self, node)
rb_eval(self, n)
VALUE self;
NODE * volatile node;
NODE *n;
{
NODE * volatile node = n;
int state;
volatile VALUE result = Qnil;
@ -2745,6 +2748,10 @@ rb_eval(self, node)
rb_warning("discarding old %s", rb_id2name(node->nd_mid));
}
rb_clear_cache_by_id(node->nd_mid);
if (node->nd_noex) { /* toplevel */
rb_warning("overriding global function `%s'",
rb_id2name(node->nd_mid));
}
}
if (SCOPE_TEST(SCOPE_PRIVATE) || node->nd_mid == init) {
@ -2754,7 +2761,7 @@ rb_eval(self, node)
noex = NOEX_PROTECTED;
}
else {
noex = NOEX_PUBLIC;
noex = node->nd_noex;
}
if (body && origin == ruby_class && body->nd_noex & NOEX_UNDEF) {
noex |= NOEX_UNDEF;
@ -2782,16 +2789,16 @@ rb_eval(self, node)
VALUE klass;
NODE *body = 0;
if (rb_special_const_p(recv)) {
if (rb_safe_level() >= 4 && !OBJ_TAINTED(recv)) {
rb_raise(rb_eSecurityError, "Insecure; can't define singleton method");
}
if (FIXNUM_P(recv) || SYMBOL_P(recv)) {
rb_raise(rb_eTypeError,
"can't define method \"%s\" for %s",
"can't define singleton method \"%s\" for %s",
rb_id2name(node->nd_mid),
rb_class2name(CLASS_OF(recv)));
}
if (rb_safe_level() >= 4 && !OBJ_TAINTED(recv)) {
rb_raise(rb_eSecurityError, "can't define singleton method");
}
if (OBJ_FROZEN(recv)) rb_error_frozen("object");
klass = rb_singleton_class(recv);
if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &body)) {
@ -2995,10 +3002,11 @@ rb_eval(self, node)
}
static VALUE
module_setup(module, node)
module_setup(module, n)
VALUE module;
NODE * volatile node;
NODE *n;
{
NODE * volatile node = n;
int state;
struct FRAME frame;
VALUE result; /* OK */
@ -3428,37 +3436,30 @@ massign(self, node, val, check)
list = node->nd_head;
if (val) {
if (TYPE(val) != T_ARRAY) {
if (NIL_P(val))
val = rb_ary_new2(0);
else
val = rb_ary_new3(1, val);
}
len = RARRAY(val)->len;
for (i=0; list && i<len; i++) {
assign(self, list->nd_head, RARRAY(val)->ptr[i], check);
list = list->nd_next;
}
if (check && list) goto arg_error;
if (node->nd_args) {
if (node->nd_args == (NODE*)-1) {
/* ignore rest args */
}
else if (!list && i<len) {
assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), check);
}
else {
assign(self, node->nd_args, rb_ary_new2(0), check);
}
}
else if (check && i<len) goto arg_error;
if (TYPE(val) != T_ARRAY) {
if (NIL_P(val))
val = rb_ary_new2(0);
else
val = rb_ary_new3(1, val);
}
else if (node->nd_args && node->nd_args != (NODE*)-1) {
assign(self, node->nd_args, Qnil, check);
len = RARRAY(val)->len;
for (i=0; list && i<len; i++) {
assign(self, list->nd_head, RARRAY(val)->ptr[i], check);
list = list->nd_next;
}
if (check && list) goto arg_error;
if (node->nd_args) {
if (node->nd_args == (NODE*)-1) {
/* ignore rest args */
}
else if (!list && i<len) {
assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), check);
}
else {
assign(self, node->nd_args, rb_ary_new2(0), check);
}
}
if (check && list) goto arg_error;
while (list) {
i++;
assign(self, list->nd_head, Qnil, check);
@ -6199,7 +6200,7 @@ enum thread_status {
THREAD_RUNNABLE,
THREAD_STOPPED,
THREAD_TO_KILL,
THREAD_KILLED,
THREAD_KILLED
};
#define WAIT_FD (1<<0)
@ -6261,7 +6262,9 @@ struct thread {
#define THREAD_RAISED 0x200
static thread_t main_thread;
static thread_t curr_thread = 0;
static int num_waiting_on_fd = 0;
static int num_waiting_on_timer = 0;
static int num_waiting_on_join = 0;
@ -6281,8 +6284,6 @@ timeofday()
return (double)tv.tv_sec + (double)tv.tv_usec * 1e-6;
}
static thread_t main_thread;
#define STACK(addr) (th->stk_pos<(VALUE*)(addr) && (VALUE*)(addr)<th->stk_pos+th->stk_len)
#define ADJ(addr) (void*)(STACK(addr)?(((VALUE*)(addr)-th->stk_pos)+th->stk_ptr):(VALUE*)(addr))
@ -6358,11 +6359,9 @@ thread_free(th)
if (th->stk_ptr) free(th->stk_ptr);
th->stk_ptr = 0;
if (th->locals) st_free_table(th->locals);
if (th->status != THREAD_KILLED) {
if (th->prev)
th->prev->next = th->next;
if (th->next)
th->next->prev = th->prev;
if (th->status != THREAD_KILLED && th->prev) {
th->prev->next = th->next;
th->next->prev = th->prev;
}
if (th != main_thread) free(th);
}
@ -7990,7 +7989,6 @@ rb_f_throw(argc, argv)
return_value(value);
rb_trap_restore_mask();
JUMP_TAG(TAG_THROW);
/* not reached */
}
void

View file

@ -501,7 +501,7 @@ def extmake(target)
$objs = nil
$local_flags = ""
case RUBY_PLATFORM
when /cygwin|beos|openstep|nextstep|rhapsody|i386-os2_emx/
when /cygwin|beos|openstep|nextstep|rhapsody|macos|i386-os2_emx/
$libs = ""
when /mswin32/
$LIBEXT = "lib"

View file

@ -6,6 +6,7 @@ case PLATFORM
when /mswin32/
test_func = "WSACleanup"
have_library("wsock32", "WSACleanup")
have_func("closesocket")
when /cygwin/
# $LDFLAGS << " -L/usr/lib" if File.directory?("/usr/lib")
# $CFLAGS << " -I/usr/include"
@ -14,6 +15,7 @@ when /cygwin/
when /beos/
test_func = "socket"
have_library("net", "socket")
have_func("closesocket")
when /i386-os2_emx/
test_func = "socket"
have_library("socket", "socket")

View file

@ -421,7 +421,11 @@ getaddrinfo(hostname, servname, hints, res)
s = socket(afd->a_af, SOCK_DGRAM, 0);
if (s < 0)
continue;
#if defined(HAVE_CLOSESOCKET)
closesocket(s);
#else
close(s);
#endif
if (pai->ai_flags & AI_PASSIVE) {
GET_AI(cur->ai_next, afd, afd->a_addrany, port);

View file

@ -181,7 +181,7 @@ bsock_close_read(sock)
rb_thread_fd_close(fileno(fptr->f));
fptr->mode &= ~FMODE_READABLE;
#ifdef NT
free(fptr->f);
myfdclose(fptr->f);
#else
fclose(fptr->f);
#endif
@ -207,7 +207,7 @@ bsock_close_write(sock)
shutdown(fileno(fptr->f2), 1);
fptr->mode &= ~FMODE_WRITABLE;
#ifdef NT
free(fptr->f2);
myfdclose(fptr->f2);
#else
fclose(fptr->f2);
#endif
@ -256,7 +256,8 @@ bsock_getsockopt(sock, lev, optname)
VALUE sock, lev, optname;
{
#if !defined(__BEOS__)
int level, option, len;
int level, option;
socklen_t len;
char *buf;
OpenFile *fptr;
@ -280,7 +281,7 @@ bsock_getsockname(sock)
VALUE sock;
{
char buf[1024];
int len = sizeof buf;
socklen_t len = sizeof buf;
OpenFile *fptr;
GetOpenFile(sock, fptr);
@ -294,7 +295,7 @@ bsock_getpeername(sock)
VALUE sock;
{
char buf[1024];
int len = sizeof buf;
socklen_t len = sizeof buf;
OpenFile *fptr;
GetOpenFile(sock, fptr);
@ -374,9 +375,9 @@ s_recv(sock, argc, argv, from)
OpenFile *fptr;
VALUE str;
char buf[1024];
int fd, alen = sizeof buf;
socklen_t alen = sizeof buf;
VALUE len, flg;
int flags;
int fd, flags;
rb_scan_args(argc, argv, "11", &len, &flg);
@ -763,7 +764,11 @@ open_inet(class, h, serv, type)
}
if (status < 0) {
#if defined(HAVE_CLOSESOCKET)
closesocket(fd);
#else
close(fd);
#endif
fd = -1;
continue;
} else
@ -771,7 +776,11 @@ open_inet(class, h, serv, type)
}
if (status < 0) {
if (fd >= 0)
#if defined(HAVE_CLOSESOCKET)
closesocket(fd);
#else
close(fd);
#endif
freeaddrinfo(res0);
rb_sys_fail(syscall);
}
@ -956,7 +965,7 @@ s_accept(class, fd, sockaddr, len)
VALUE class;
int fd;
struct sockaddr *sockaddr;
int *len;
socklen_t *len;
{
int fd2;
@ -989,7 +998,7 @@ tcp_accept(sock)
{
OpenFile *fptr;
struct sockaddr_storage from;
int fromlen;
socklen_t fromlen;
GetOpenFile(sock, fptr);
fromlen = sizeof(from);
@ -1037,7 +1046,11 @@ open_unix(class, path, server)
}
if (status < 0) {
#if defined(HAVE_CLOSESOCKET)
closesocket(fd);
#else
close(fd);
#endif
rb_sys_fail(sockaddr.sun_path);
}
@ -1057,7 +1070,7 @@ ip_addr(sock)
{
OpenFile *fptr;
struct sockaddr_storage addr;
int len = sizeof addr;
socklen_t len = sizeof addr;
GetOpenFile(sock, fptr);
@ -1072,7 +1085,7 @@ ip_peeraddr(sock)
{
OpenFile *fptr;
struct sockaddr_storage addr;
int len = sizeof addr;
socklen_t len = sizeof addr;
GetOpenFile(sock, fptr);
@ -1231,7 +1244,7 @@ unix_path(sock)
GetOpenFile(sock, fptr);
if (fptr->path == 0) {
struct sockaddr_un addr;
int len = sizeof(addr);
socklen_t len = sizeof(addr);
if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail(0);
fptr->path = strdup(addr.sun_path);
@ -1261,7 +1274,7 @@ unix_accept(sock)
{
OpenFile *fptr;
struct sockaddr_un from;
int fromlen;
socklen_t fromlen;
GetOpenFile(sock, fptr);
fromlen = sizeof(struct sockaddr_un);
@ -1282,7 +1295,7 @@ unix_addr(sock)
{
OpenFile *fptr;
struct sockaddr_un addr;
int len = sizeof addr;
socklen_t len = sizeof addr;
GetOpenFile(sock, fptr);
@ -1297,7 +1310,7 @@ unix_peeraddr(sock)
{
OpenFile *fptr;
struct sockaddr_un addr;
int len = sizeof addr;
socklen_t len = sizeof addr;
GetOpenFile(sock, fptr);
@ -1500,7 +1513,7 @@ sock_accept(sock)
OpenFile *fptr;
VALUE sock2;
char buf[1024];
int len = sizeof buf;
socklen_t len = sizeof buf;
GetOpenFile(sock, fptr);
sock2 = s_accept(rb_cSocket,fileno(fptr->f),(struct sockaddr*)buf,&len);

View file

@ -428,15 +428,9 @@ class TkText<TkTextWin
rsearch_with_length(pat,start,stop)[0]
end
def dump(type_info, *index)
args = type_info.collect{|inf|
if inf.kind_of? Array
inf[0] = '-' + inf[0]
inf
else
'-' + inf
end
}.flatten
def dump(type_info, *index, &block)
args = type_info.collect{|inf| '-' + inf}
args << '-command' << Proc.new(&block) if iterator?
str = tk_send('dump', *(args + index))
result = []
sel = nil
@ -546,26 +540,23 @@ class TkText<TkTextWin
end
private :_retrieve_backslashed_text
def dump_all(*index)
dump(['all'], *index)
def dump_all(*index, &block)
dump(['all'], *index, &block)
end
def dump_command(cmd, *index)
dump([['command', cmd]], *index)
def dump_mark(*index, &block)
dump(['mark'], *index, &block)
end
def dump_mark(*index)
dump(['mark'], *index)
def dump_tag(*index, &block)
dump(['tag'], *index, &block)
end
def dump_tag(*index)
dump(['tag'], *index)
def dump_text(*index, &block)
dump(['text'], *index, &block)
end
def dump_text(*index)
dump(['text'], *index)
def dump_window(*index, &block)
dump(['window'], *index, &block)
end
def dump_window(*index)
dump(['window'], *index)
end
def dump_image(*index)
dump(['image'], *index)
def dump_image(*index, &block)
dump(['image'], *index, &block)
end
end

6
file.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
file.c -
@ -7,8 +7,10 @@
created at: Mon Nov 15 12:24:34 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
**********************************************************************/
#ifdef NT
#include "missing/file.h"

6
gc.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
gc.c -
@ -7,8 +7,10 @@
created at: Tue Oct 5 09:44:46 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
**********************************************************************/
#include "ruby.h"
#include "rubysig.h"

6
hash.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
hash.c -
@ -7,8 +7,10 @@
created at: Mon Nov 22 18:51:18 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
**********************************************************************/
#include "ruby.h"
#include "st.h"

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
inits.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"

View file

@ -1,5 +1,20 @@
/* Functions and variables that are used by more than one source file of
* the kernel. Not available to extensions and applications.
/**********************************************************************
intern.h -
$Author$
$Date$
created at: Thu Jun 10 14:22:17 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
**********************************************************************/
/*
* Functions and variables that are used by more than one source file of
* the kernel.
*/
/* array.c */

65
io.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
io.c -
@ -7,8 +7,10 @@
created at: Fri Oct 15 18:08:59 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
**********************************************************************/
#include "ruby.h"
#include "rubyio.h"
@ -209,7 +211,7 @@ io_write(io, str)
}
#endif
if (fptr->mode & FMODE_SYNC) {
fflush(f);
if (fflush(f) == EOF) rb_sys_fail(fptr->path);
}
return INT2FIX(n);
@ -241,7 +243,7 @@ rb_io_flush(io)
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);
if (fflush(f) == EOF) rb_sys_fail(0);
if (fflush(f) == EOF) rb_sys_fail(fptr->path);
return io;
}
@ -531,6 +533,9 @@ rb_io_gets_internal(argc, argv, io)
rsptr = 0;
rslen = 0;
}
else if (rs == rb_default_rs) {
return rb_io_gets(io);
}
else {
rslen = RSTRING(rs)->len;
if (rslen == 0) {
@ -919,15 +924,13 @@ fptr_finalize(fptr)
}
}
static void
rb_io_fptr_close(fptr)
void
rb_io_fptr_finalize(fptr)
OpenFile *fptr;
{
int fd;
if (!fptr) return;
if (fptr->f == NULL && fptr->f2 == NULL) return;
fd = fileno(fptr->f);
if (fptr->finalize) {
(*fptr->finalize)(fptr);
}
@ -935,21 +938,27 @@ rb_io_fptr_close(fptr)
fptr_finalize(fptr);
}
fptr->f = fptr->f2 = NULL;
rb_thread_fd_close(fd);
}
void
rb_io_fptr_finalize(fptr)
OpenFile *fptr;
{
if (!fptr) return;
rb_io_fptr_close(fptr);
if (fptr->path) {
free(fptr->path);
fptr->path = NULL;
}
}
static void
rb_io_fptr_close(fptr)
OpenFile *fptr;
{
int fd;
if (!fptr) return;
if (fptr->f == NULL && fptr->f2 == NULL) return;
fd = fileno(fptr->f);
rb_io_fptr_finalize(fptr);
rb_thread_fd_close(fd);
}
VALUE
rb_io_close(io)
VALUE io;
@ -957,6 +966,9 @@ rb_io_close(io)
OpenFile *fptr;
fptr = RFILE(io)->fptr;
if (fptr->mode & FMODE_WRITABLE) {
rb_io_flush(io);
}
rb_io_fptr_close(fptr);
if (fptr->pid) {
rb_syswait(fptr->pid);
@ -1335,7 +1347,7 @@ rb_file_sysopen(fname, flags, mode)
{
NEWOBJ(io, struct RFile);
OBJSETUP(io, rb_cFile, T_FILE);
return rb_file_sysopen_internal((VALUE)io, fname, mode);
return rb_file_sysopen_internal((VALUE)io, fname, flags, mode);
}
#if defined (NT) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__)
@ -1736,10 +1748,10 @@ io_reopen(io, nfile)
if (fptr == orig) return io;
if (orig->f2) {
fflush(orig->f2);
if (fflush(orig->f2) == EOF) rb_sys_fail(orig->path);
}
else if (orig->mode & FMODE_WRITABLE) {
fflush(orig->f);
if (fflush(orig->f) == EOF) rb_sys_fail(orig->path);
}
rb_thread_fd_close(fileno(fptr->f));
@ -1852,10 +1864,10 @@ rb_io_clone(io)
MakeOpenFile(clone, fptr);
if (orig->f2) {
fflush(orig->f2);
if (fflush(orig->f2) == EOF) rb_sys_fail(orig->path);
}
else if (orig->mode & FMODE_WRITABLE) {
fflush(orig->f);
if (fflush(orig->f) == EOF) rb_sys_fail(orig->path);
}
/* copy OpenFile structure */
@ -1979,8 +1991,9 @@ rb_io_putc(io, ch)
if (fputc(c, f) == EOF)
rb_sys_fail(fptr->path);
if (fptr->mode & FMODE_SYNC)
fflush(f);
if (fptr->mode & FMODE_SYNC) {
if (fflush(f) == EOF) rb_sys_fail(fptr->path);
}
return ch;
}
@ -2250,7 +2263,7 @@ rb_io_initialize(argc, argv, io)
char *m = "r";
if (RFILE(io)->fptr) {
rb_io_fptr_finalize(RFILE(io)->fptr);
rb_io_close_m(io);
free(RFILE(io)->fptr);
RFILE(io)->fptr = 0;
}
@ -2883,7 +2896,7 @@ rb_io_s_pipe()
rb_sys_fail(0);
r = prep_stdio(rb_fdopen(pipes[0], "r"), FMODE_READABLE, rb_cIO);
w = prep_stdio(rb_fdopen(pipes[1], "w"), FMODE_WRITABLE, rb_cIO);
w = prep_stdio(rb_fdopen(pipes[1], "w"), FMODE_WRITABLE|FMODE_SYNC, rb_cIO);
ary = rb_ary_new2(2);
rb_ary_push(ary, r);

View file

@ -3,11 +3,12 @@ $Date$
== CGI SUPPORT LIBRARY
CGI.rb
cgi.rb
Version 1.10
Version 1.20
Copyright (C) 1999 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
Wakou Aoyama <wakou@fsinet.or.jp>
@ -182,7 +183,7 @@ class CGI
EOL = CR + LF
v = $-v
$-v = false
VERSION = "1.10"
VERSION = "1.20"
RELEASE_DATE = "$Date$"
$-v = v
@ -237,7 +238,8 @@ $-v = v
=end
def CGI::escape(string)
str = string.dup
str.gsub!(/[^a-zA-Z0-9_.-]/n){ sprintf("%%%02X", $&.unpack("C")[0]) }
str.gsub!(/ /n, '+')
str.gsub!(/([^a-zA-Z0-9_.-])/n){ sprintf("%%%02X", $1.unpack("C")[0]) }
str
end
@ -281,7 +283,16 @@ $-v = v
when /\Aquot\z/ni then '"'
when /\Agt\z/ni then '>'
when /\Alt\z/ni then '<'
when /\A#(\d+)\z/n then Integer($1).chr
when /\A#(\d+)\z/n then
if Integer($1) < 256
Integer($1).chr
else
if $KCODE[0] == ?u or $KCODE[0] == ?U
[Integer($1)].pack("U")
else
"#" + $1
end
end
when /\A#x([0-9a-f]+)\z/ni then $1.hex.chr
end
}
@ -594,7 +605,17 @@ convert string charset, and set language to "ja".
@name = options["name"]
@value = Array(options["value"])
@path = options["path"]
# simple support for IE
if options["path"]
@path = options["path"]
elsif ENV["REQUEST_URI"]
@path = ENV["REQUEST_URI"].sub(/\?.*/n,'')
if ENV["PATH_INFO"]
@path = @path[0...@path.rindex(ENV["PATH_INFO"])]
end
else
@path = ENV["SCRIPT_NAME"] or ""
end
@domain = options["domain"]
@expires = options["expires"]
@secure = options["secure"] == true ? true : false
@ -960,7 +981,7 @@ convert string charset, and set language to "ja".
def nn_element_def(element)
<<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
"<element.upcase" + attributes.collect{|name, value|
next if value == nil
next unless value
" " + CGI::escapeHTML(name) +
if true == value
""
@ -981,7 +1002,7 @@ convert string charset, and set language to "ja".
def nOE_element_def(element)
<<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
"<element.upcase" + attributes.collect{|name, value|
next if value == nil
next unless value
" " + CGI::escapeHTML(name) +
if true == value
""
@ -996,7 +1017,7 @@ convert string charset, and set language to "ja".
def nO_element_def(element)
<<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
"<element.upcase" + attributes.collect{|name, value|
next if value == nil
next unless value
" " + CGI::escapeHTML(name) +
if true == value
""
@ -1340,8 +1361,9 @@ convert string charset, and set language to "ja".
{ "TYPE" => "image", "SRC" => src, "NAME" => name,
"ALT" => alt }
else
name["TYPE"] = "image"
name
src["TYPE"] = "image"
src["SRC"] ||= ""
src
end
input(attributes)
end
@ -1881,7 +1903,20 @@ end
=begin
== HISTRY
== HISTORY
=== Version 1.20 - wakou
2000/04/03 18:31:42
- bug fix: CGI#image_button() can't get Hash option
thanks to Takashi Ikeda <ikeda@auc.co.jp>
- CGI::unescapeHTML()
simple support for "&#12345;"
- CGI::Cookie::new()
simple support for IE
- CGI::escape()
' ' replaced by '+'
=== Version 1.10 - wakou

View file

@ -1,3 +1,5 @@
# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
# Copyright (C) 2000 Information-technology Promotion Agancy, Japan
require 'cgi'
require 'final'

View file

@ -1,3 +1,6 @@
# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
# Copyright (C) 2000 Information-technology Promotion Agancy, Japan
if $SAFE > 0
STDERR.print "-r debug.rb is not available in safe mode\n"
exit 1
@ -190,159 +193,158 @@ class DEBUGGER__
def debug_command(file, line, id, binding)
MUTEX.lock
DEBUGGER__.set_last_thread(Thread.current)
frame_pos = 0
binding_file = file
binding_line = line
previous_line = nil
if (ENV['EMACS'] == 't')
stdout.printf "\032\032%s:%d:\n", binding_file, binding_line
else
stdout.printf "%s:%d:%s", binding_file, binding_line,
line_at(binding_file, binding_line)
end
@frames[0] = [binding, file, line, id]
display_expressions(binding)
while input = readline("(rdb:%d) "%thnum(), true)
catch (:debug_error) do
if input == ""
input = DEBUG_LAST_CMD[0]
stdout.print input, "\n"
DEBUGGER__.set_last_thread(Thread.current)
frame_pos = 0
binding_file = file
binding_line = line
previous_line = nil
if (ENV['EMACS'] == 't')
stdout.printf "\032\032%s:%d:\n", binding_file, binding_line
else
stdout.printf "%s:%d:%s", binding_file, binding_line,
line_at(binding_file, binding_line)
end
@frames[0] = [binding, file, line, id]
display_expressions(binding)
while input = readline("(rdb:%d) "%thnum(), true)
catch (:debug_error) do
if input == ""
input = DEBUG_LAST_CMD[0]
stdout.print input, "\n"
else
DEBUG_LAST_CMD[0] = input
end
case input
when /^\s*b(?:reak)?\s+((?:.*?+:)?.+)$/
pos = $1
if pos.index(":")
file, pos = pos.split(":")
end
file = File.basename(file)
if pos =~ /^\d+$/
pname = pos
pos = pos.to_i
else
DEBUG_LAST_CMD[0] = input
pname = pos = pos.intern.id2name
end
break_points.push [true, 0, file, pos]
stdout.printf "Set breakpoint %d at %s:%s\n", break_points.size, file, pname
when /^\s*wat(?:ch)?\s+(.+)$/
exp = $1
break_points.push [true, 1, exp]
stdout.printf "Set watchpoint %d\n", break_points.size, exp
when /^\s*b(?:reak)?$/
if break_points.find{|b| b[1] == 0}
n = 1
stdout.print "breakpoints:\n"
for b in break_points
if b[0] and b[1] == 0
stdout.printf " %d %s:%s\n", n, b[2], b[3]
end
n += 1
end
end
if break_points.find{|b| b[1] == 1}
n = 1
stdout.print "\n"
stdout.print "watchpoints:\n"
for b in break_points
if b[0] and b[1] == 1
stdout.printf " %d %s\n", n, b[2]
end
n += 1
end
end
if break_points.size == 0
stdout.print "no breakpoints\n"
else
stdout.print "\n"
end
case input
when /^\s*b(?:reak)?\s+((?:.*?+:)?.+)$/
pos = $1
if pos.index(":")
file, pos = pos.split(":")
end
file = File.basename(file)
if pos =~ /^\d+$/
pname = pos
pos = pos.to_i
else
pname = pos = pos.intern.id2name
end
break_points.push [true, 0, file, pos]
stdout.printf "Set breakpoint %d at %s:%s\n", break_points.size, file,
pname
when /^\s*wat(?:ch)?\s+(.+)$/
exp = $1
break_points.push [true, 1, exp]
stdout.printf "Set watchpoint %d\n", break_points.size, exp
when /^\s*b(?:reak)?$/
if break_points.find{|b| b[1] == 0}
n = 1
stdout.print "breakpoints:\n"
when /^\s*del(?:ete)?(?:\s+(\d+))?$/
pos = $1
unless pos
input = readline("clear all breakpoints? (y/n) ", false)
if input == "y"
for b in break_points
if b[0] and b[1] == 0
stdout.printf " %d %s:%s\n", n, b[2], b[3]
end
n += 1
b[0] = false
end
end
if break_points.find{|b| b[1] == 1}
n = 1
stdout.print "\n"
stdout.print "watchpoints:\n"
for b in break_points
if b[0] and b[1] == 1
stdout.printf " %d %s\n", n, b[2]
end
n += 1
else
pos = pos.to_i
if break_points[pos-1]
break_points[pos-1][0] = false
else
stdout.printf "Breakpoint %d is not defined\n", pos
end
end
when /^\s*disp(?:lay)?\s+(.+)$/
exp = $1
display.push.push [true, exp]
stdout.printf " %d: %s = %s\n", display.size, exp,
eval(exp, binding) rescue "--"
when /^\s*disp(?:lay)?$/
display_expressions(binding)
when /^\s*undisp(?:lay)?(?:\s+(\d+))?$/
pos = $1
unless pos
input = readline("clear all expressions? (y/n) ", false)
if input == "y"
for d in display
d[0] = false
end
end
if break_points.size == 0
stdout.print "no breakpoints\n"
else
pos = pos.to_i
if display[pos-1]
display[pos-1][0] = false
else
stdout.print "\n"
stdout.printf "display expression %d is not defined\n", pos
end
end
when /^\s*del(?:ete)?(?:\s+(\d+))?$/
pos = $1
unless pos
input = readline("clear all breakpoints? (y/n) ", false)
if input == "y"
for b in break_points
b[0] = false
end
end
else
pos = pos.to_i
if break_points[pos-1]
break_points[pos-1][0] = false
else
stdout.printf "Breakpoint %d is not defined\n", pos
end
end
when /^\s*c(?:ont)?$/
MUTEX.unlock
return
when /^\s*disp(?:lay)?\s+(.+)$/
exp = $1
display.push.push [true, exp]
stdout.printf " %d: %s = %s\n", display.size, exp,
eval(exp, binding) rescue "--"
when /^\s*s(?:tep)?(?:\s+(\d+))?$/
if $1
lev = $1.to_i
else
lev = 1
end
@stop_next = lev
return
when /^\s*disp(?:lay)?$/
display_expressions(binding)
when /^\s*n(?:ext)?(?:\s+(\d+))?$/
if $1
lev = $1.to_i
else
lev = 1
end
@stop_next = lev
@no_step = @frames.size - frame_pos
return
when /^\s*undisp(?:lay)?(?:\s+(\d+))?$/
pos = $1
unless pos
input = readline("clear all expressions? (y/n) ", false)
if input == "y"
for d in display
d[0] = false
end
end
else
pos = pos.to_i
if display[pos-1]
display[pos-1][0] = false
else
stdout.printf "display expression %d is not defined\n", pos
end
end
when /^\s*w(?:here)?$/, /^\s*f(?:rame)?$/
display_frames(frame_pos)
when /^\s*c(?:ont)?$/
MUTEX.unlock
return
when /^\s*s(?:tep)?(?:\s+(\d+))?$/
if $1
lev = $1.to_i
else
lev = 1
end
@stop_next = lev
return
when /^\s*n(?:ext)?(?:\s+(\d+))?$/
if $1
lev = $1.to_i
else
lev = 1
end
@stop_next = lev
@no_step = @frames.size - frame_pos
return
when /^\s*w(?:here)?$/, /^\s*f(?:rame)?$/
display_frames(frame_pos)
when /^\s*l(?:ist)?(?:\s+(.+))?$/
if not $1
b = previous_line ? previous_line + 10 : binding_line - 5
e = b + 9
elsif $1 == '-'
b = previous_line ? previous_line - 10 : binding_line - 5
e = b + 9
else
b, e = $1.split(/[-,]/)
if e
when /^\s*l(?:ist)?(?:\s+(.+))?$/
if not $1
b = previous_line ? previous_line + 10 : binding_line - 5
e = b + 9
elsif $1 == '-'
b = previous_line ? previous_line - 10 : binding_line - 5
e = b + 9
else
b, e = $1.split(/[-,]/)
if e
b = b.to_i
e = e.to_i
else
@ -412,6 +414,9 @@ class DEBUGGER__
when /^\s*p\s+/
p debug_eval($', binding)
when /^\s*h(?:elp)?/
debug_print_help()
else
v = debug_eval(input, binding)
p v unless (v == nil)
@ -420,6 +425,45 @@ class DEBUGGER__
end
end
def debug_print_help
print <<EOHELP
Debugger help v.-0.002b
Commands
b[reak] [file or method:]<line> set breakpoint to some position
wat[ch] <expression> set watchpoint to some expression
b[reak] list breakpoints
del[ele][ nnn] delete some or all breakpoints
disp[lay] <expression> add expression into display expression list
undisp[lay][ nnn] delete one particular or all display expressions
c[ont] run until program ends or hit breakpoint
s[tep][ nnn] step (into methods) one line or till line nnn
n[ext][ nnn] go over one line or till line nnn
w[here] display frames
f[rame] alias for where
l[ist][ (-|nn-mm)] list program, - lists backwards
nn-mm lists given lines
up[ nn] move to higher frame
down[ nn] move to lower frame
fin[ish] return to outer frame
q[uit] exit from debugger
v[ar] g[lobal] show global variables
v[ar] l[ocal] show local variables
v[ar] i[nstance] <object> show instance variables of object
v[ar] c[onst] <object> show constants of object
m[ethod] i[nstance] <obj> show methods of object
m[ethod] <class or module> show instance methods of class or module
th[read] l[ist] list all threads
th[read] c[ur[rent]] show current threads
th[read] <nnn> stop thread nnn
th[read] stop <nnn> alias for th[read] <nnn>
th[read] c[ur[rent]] <nnn> alias for th[read] <nnn>
th[read] resume <nnn> run thread nnn
p expression evaluate expression and print its value
h[elp] print this help
<everything else> evaluate
EOHELP
end
def display_expressions(binding)
n = 1
for d in display

749
lib/net/telnet.rb Normal file
View file

@ -0,0 +1,749 @@
=begin
$Date$
== SIMPLE TELNET CLIENT LIBRARY
net/telnet.rb
Version 1.30
Wakou Aoyama <wakou@fsinet.or.jp>
=== MAKE NEW TELNET OBJECT
host = Net::Telnet::new({
"Binmode" => false, # default: false
"Host" => "localhost", # default: "localhost"
"Output_log" => "output_log", # default: nil (no output)
"Dump_log" => "dump_log", # default: nil (no output)
"Port" => 23, # default: 23
"Prompt" => /[$%#>] \z/n, # default: /[$%#>] \z/n
"Telnetmode" => true, # default: true
"Timeout" => 10, # default: 10
# if ignore timeout then set "Timeout" to false.
"Waittime" => 0, # default: 0
"Proxy" => proxy # default: nil
# proxy is Telnet or TCPsocket object
})
Telnet object has socket class methods.
if set "Telnetmode" option to false. not telnet command interpretation.
"Waittime" is time to confirm "Prompt". There is a possibility that
the same character as "Prompt" is included in the data, and, when
the network or the host is very heavy, the value is enlarged.
=== STATUS OUTPUT
host = Net::Telnet::new({"Host" => "localhost"}){|c| print c }
connection status output.
example
Trying localhost...
Connected to localhost.
=== WAIT FOR MATCH
line = host.waitfor(/match/)
line = host.waitfor({"Match" => /match/,
"String" => "string",
"Timeout" => secs})
# if ignore timeout then set "Timeout" to false.
if set "String" option, then Match == Regexp.new(quote("string"))
==== REALTIME OUTPUT
host.waitfor(/match/){|c| print c }
host.waitfor({"Match" => /match/,
"String" => "string",
"Timeout" => secs}){|c| print c}
of cource, set sync=true or flush is necessary.
=== SEND STRING AND WAIT PROMPT
line = host.cmd("string")
line = host.cmd({"String" => "string",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10})
==== REALTIME OUTPUT
host.cmd("string"){|c| print c }
host.cmd({"String" => "string",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10}){|c| print c }
of cource, set sync=true or flush is necessary.
=== SEND STRING
host.print("string")
# == host.write("string\n")
=== TURN TELNET COMMAND INTERPRETATION
host.telnetmode # turn on/off
host.telnetmode(true) # on
host.telnetmode(false) # off
=== TOGGLE NEWLINE TRANSLATION
host.binmode # turn true/false
host.binmode(true) # no translate newline
host.binmode(false) # translate newline
=== LOGIN
host.login("username", "password")
host.login({"Name" => "username",
"Password" => "password",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10})
if no password prompt.
host.login("username")
host.login({"Name" => "username",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10})
==== REALTIME OUTPUT
host.login("username", "password"){|c| print c }
host.login({"Name" => "username",
"Password" => "password",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10}){|c| print c }
of cource, set sync=true or flush is necessary.
== EXAMPLE
=== LOGIN AND SEND COMMAND
localhost = Net::Telnet::new({"Host" => "localhost",
"Timeout" => 10,
"Prompt" => /[$%#>] \z/n})
localhost.login("username", "password"){|c| print c }
localhost.cmd("command"){|c| print c }
localhost.close
=== CHECKS A POP SERVER TO SEE IF YOU HAVE MAIL
pop = Net::Telnet::new({"Host" => "your_destination_host_here",
"Port" => 110,
"Telnetmode" => false,
"Prompt" => /^\+OK/n})
pop.cmd("user " + "your_username_here"){|c| print c}
pop.cmd("pass " + "your_password_here"){|c| print c}
pop.cmd("list"){|c| print c}
== HISTORY
=== Version 1.30
2000/04/03 18:27:02
- telnet.rb --> net/telnet.rb
=== Version 1.20
2000/01/24 17:02:57
- respond to "IAC WILL x" with "IAC DONT x"
- respond to "IAC WONT x" with "IAC DONT x"
- better dumplog format
thanks to WATANABE Hirofumi <Hirofumi.Watanabe@jp.sony.com>
=== Version 1.10
2000/01/18 17:47:31
- bug fix: write method
- respond to "IAC WILL BINARY" with "IAC DO BINARY"
=== Version 1.00
1999/10/04 22:51:26
- bug fix: waitfor(preprocess) method
thanks to Shin-ichiro Hara <sinara@blade.nagaokaut.ac.jp>
- add simple support for AO, DM, IP, NOP, SB, SE
- COUTION! TimeOut --> TimeoutError
=== Version 0.50
1999/09/21 21:24:07
- add write method
=== Version 0.40
1999/09/17 17:41:41
- bug fix: preprocess method
=== Version 0.30
1999/09/14 23:09:05
- change prompt check order.
not IO::select([@sock], nil, nil, waittime) and prompt === line
--> prompt === line and not IO::select([@sock], nil, nil, waittime)
=== Version 0.24
1999/09/13 22:28:33
- Telnet#login
if ommit password, then not require password prompt.
=== Version 0.232
1999/08/10 05:20:21
- STATUS OUTPUT sample code typo. thanks to Tadayoshi Funaba <tadf@kt.rim.or.jp>
host = Telnet.new({"Hosh" => "localhost"){|c| print c }
--> host = Telnet.new({"Host" => "localhost"){|c| print c }
=== Version 0.231
1999/07/16 13:39:42
- TRUE --> true, FALSE --> false
=== Version 0.23
1999/07/15 22:32:09
- waitfor: if end of file reached, then return nil.
=== Version 0.22
1999/06/29 09:08:51
- new, waitfor, cmd: {"Timeout" => false} # ignore timeout
=== Version 0.21
1999/06/28 18:18:55
- waitfor: not rescue (EOFError)
=== Version 0.20
1999/06/04 06:24:58
- waitfor: support for divided telnet command
=== Version 0.181
1999/05/22
- bug fix: print method
=== Version 0.18
1999/05/14
- respond to "IAC WON'T SGA" with "IAC DON'T SGA"
- DON'T SGA : end of line --> CR + LF
- bug fix: preprocess method
=== Version 0.17
1999/04/30
- bug fix: $! + "\n" --> $!.to_s + "\n"
=== Version 0.163
1999/04/11
- STDOUT.write(message) --> yield(message) if iterator?
=== Version 0.162
1999/03/17
- add "Proxy" option
- required timeout.rb
=== Version 0.161
1999/02/03
- select --> IO::select
=== Version 0.16
1998/10/09
- preprocess method change for the better
- add binmode method.
- change default Binmode. TRUE --> FALSE
=== Version 0.15
1998/10/04
- add telnetmode method.
=== Version 0.141
1998/09/22
- change default prompt. /[$%#>] $/ --> /[$%#>] \Z/
=== Version 0.14
1998/09/01
- IAC WILL SGA send EOL --> CR+NULL
- IAC WILL SGA IAC DO BIN send EOL --> CR
- NONE send EOL --> LF
- add Dump_log option.
=== Version 0.13
1998/08/25
- add print method.
=== Version 0.122
1998/08/05
- support for HP-UX 10.20 thanks to WATANABE Tetsuya <tetsu@jpn.hp.com>
- socket.<< --> socket.write
=== Version 0.121
1998/07/15
- string.+= --> string.concat
=== Version 0.12
1998/06/01
- add timeout, waittime.
=== Version 0.11
1998/04/21
- add realtime output.
=== Version 0.10
1998/04/13
- first release.
=end
require "socket"
require "delegate"
require "timeout"
module Net
class Telnet < SimpleDelegator
IAC = 255.chr # "\377" # "\xff" # interpret as command:
DONT = 254.chr # "\376" # "\xfe" # you are not to use option
DO = 253.chr # "\375" # "\xfd" # please, you use option
WONT = 252.chr # "\374" # "\xfc" # I won't use option
WILL = 251.chr # "\373" # "\xfb" # I will use option
SB = 250.chr # "\372" # "\xfa" # interpret as subnegotiation
GA = 249.chr # "\371" # "\xf9" # you may reverse the line
EL = 248.chr # "\370" # "\xf8" # erase the current line
EC = 247.chr # "\367" # "\xf7" # erase the current character
AYT = 246.chr # "\366" # "\xf6" # are you there
AO = 245.chr # "\365" # "\xf5" # abort output--but let prog finish
IP = 244.chr # "\364" # "\xf4" # interrupt process--permanently
BREAK = 243.chr # "\363" # "\xf3" # break
DM = 242.chr # "\362" # "\xf2" # data mark--for connect. cleaning
NOP = 241.chr # "\361" # "\xf1" # nop
SE = 240.chr # "\360" # "\xf0" # end sub negotiation
EOR = 239.chr # "\357" # "\xef" # end of record (transparent mode)
ABORT = 238.chr # "\356" # "\xee" # Abort process
SUSP = 237.chr # "\355" # "\xed" # Suspend process
EOF = 236.chr # "\354" # "\xec" # End of file
SYNCH = 242.chr # "\362" # "\xf2" # for telfunc calls
OPT_BINARY = 0.chr # "\000" # "\x00" # Binary Transmission
OPT_ECHO = 1.chr # "\001" # "\x01" # Echo
OPT_RCP = 2.chr # "\002" # "\x02" # Reconnection
OPT_SGA = 3.chr # "\003" # "\x03" # Suppress Go Ahead
OPT_NAMS = 4.chr # "\004" # "\x04" # Approx Message Size Negotiation
OPT_STATUS = 5.chr # "\005" # "\x05" # Status
OPT_TM = 6.chr # "\006" # "\x06" # Timing Mark
OPT_RCTE = 7.chr # "\a" # "\x07" # Remote Controlled Trans and Echo
OPT_NAOL = 8.chr # "\010" # "\x08" # Output Line Width
OPT_NAOP = 9.chr # "\t" # "\x09" # Output Page Size
OPT_NAOCRD = 10.chr # "\n" # "\x0a" # Output Carriage-Return Disposition
OPT_NAOHTS = 11.chr # "\v" # "\x0b" # Output Horizontal Tab Stops
OPT_NAOHTD = 12.chr # "\f" # "\x0c" # Output Horizontal Tab Disposition
OPT_NAOFFD = 13.chr # "\r" # "\x0d" # Output Formfeed Disposition
OPT_NAOVTS = 14.chr # "\016" # "\x0e" # Output Vertical Tabstops
OPT_NAOVTD = 15.chr # "\017" # "\x0f" # Output Vertical Tab Disposition
OPT_NAOLFD = 16.chr # "\020" # "\x10" # Output Linefeed Disposition
OPT_XASCII = 17.chr # "\021" # "\x11" # Extended ASCII
OPT_LOGOUT = 18.chr # "\022" # "\x12" # Logout
OPT_BM = 19.chr # "\023" # "\x13" # Byte Macro
OPT_DET = 20.chr # "\024" # "\x14" # Data Entry Terminal
OPT_SUPDUP = 21.chr # "\025" # "\x15" # SUPDUP
OPT_SUPDUPOUTPUT = 22.chr # "\026" # "\x16" # SUPDUP Output
OPT_SNDLOC = 23.chr # "\027" # "\x17" # Send Location
OPT_TTYPE = 24.chr # "\030" # "\x18" # Terminal Type
OPT_EOR = 25.chr # "\031" # "\x19" # End of Record
OPT_TUID = 26.chr # "\032" # "\x1a" # TACACS User Identification
OPT_OUTMRK = 27.chr # "\e" # "\x1b" # Output Marking
OPT_TTYLOC = 28.chr # "\034" # "\x1c" # Terminal Location Number
OPT_3270REGIME = 29.chr # "\035" # "\x1d" # Telnet 3270 Regime
OPT_X3PAD = 30.chr # "\036" # "\x1e" # X.3 PAD
OPT_NAWS = 31.chr # "\037" # "\x1f" # Negotiate About Window Size
OPT_TSPEED = 32.chr # " " # "\x20" # Terminal Speed
OPT_LFLOW = 33.chr # "!" # "\x21" # Remote Flow Control
OPT_LINEMODE = 34.chr # "\"" # "\x22" # Linemode
OPT_XDISPLOC = 35.chr # "#" # "\x23" # X Display Location
OPT_OLD_ENVIRON = 36.chr # "$" # "\x24" # Environment Option
OPT_AUTHENTICATION = 37.chr # "%" # "\x25" # Authentication Option
OPT_ENCRYPT = 38.chr # "&" # "\x26" # Encryption Option
OPT_NEW_ENVIRON = 39.chr # "'" # "\x27" # New Environment Option
OPT_EXOPL = 255.chr # "\377" # "\xff" # Extended-Options-List
NULL = "\000"
CR = "\015"
LF = "\012"
EOL = CR + LF
v = $-v
$-v = false
VERSION = "1.30"
RELEASE_DATE = "$Date$"
$-v = v
def initialize(options)
@options = options
@options["Binmode"] = false unless @options.has_key?("Binmode")
@options["Host"] = "localhost" unless @options.has_key?("Host")
@options["Port"] = 23 unless @options.has_key?("Port")
@options["Prompt"] = /[$%#>] \z/n unless @options.has_key?("Prompt")
@options["Telnetmode"] = true unless @options.has_key?("Telnetmode")
@options["Timeout"] = 10 unless @options.has_key?("Timeout")
@options["Waittime"] = 0 unless @options.has_key?("Waittime")
@telnet_option = { "SGA" => false, "BINARY" => false }
if @options.has_key?("Output_log")
@log = File.open(@options["Output_log"], 'a+')
@log.sync = true
@log.binmode
end
if @options.has_key?("Dump_log")
@dumplog = File.open(@options["Dump_log"], 'a+')
@dumplog.sync = true
@dumplog.binmode
def @dumplog.log_dump(dir, x)
len = x.length
addr = 0
offset = 0
while 0 < len
if len < 16
line = x[offset, len]
else
line = x[offset, 16]
end
hexvals = line.unpack('H*')[0]
hexvals.concat ' ' * (32 - hexvals.length)
hexvals = format "%s %s %s %s " * 4, *hexvals.unpack('a2' * 16)
line.gsub! /[\000-\037\177-\377]/n, '.'
printf "%s 0x%5.5x: %s%s\n", dir, addr, hexvals, line
addr += 16
offset += 16
len -= 16
end
print "\n"
end
end
if @options.has_key?("Proxy")
if @options["Proxy"].kind_of?(Telnet)
@sock = @options["Proxy"].sock
elsif @options["Proxy"].kind_of?(TCPsocket)
@sock = @options["Proxy"]
else
raise "Error; Proxy is Telnet or TCPSocket object."
end
else
message = "Trying " + @options["Host"] + "...\n"
yield(message) if iterator?
@log.write(message) if @options.has_key?("Output_log")
@dumplog.log_dump('#', message) if @options.has_key?("Dump_log")
begin
if @options["Timeout"] == false
@sock = TCPsocket.open(@options["Host"], @options["Port"])
else
timeout(@options["Timeout"]){
@sock = TCPsocket.open(@options["Host"], @options["Port"])
}
end
rescue TimeoutError
raise TimeoutError, "timed-out; opening of the host"
rescue
@log.write($!.to_s + "\n") if @options.has_key?("Output_log")
@dumplog.log_dump('#', $!.to_s + "\n") if @options.has_key?("Dump_log")
raise
end
@sock.sync = true
@sock.binmode
message = "Connected to " + @options["Host"] + ".\n"
yield(message) if iterator?
@log.write(message) if @options.has_key?("Output_log")
@dumplog.log_dump('#', message) if @options.has_key?("Dump_log")
end
super(@sock)
end # initialize
attr :sock
def telnetmode(mode = 'turn')
if 'turn' == mode
@options["Telnetmode"] = @options["Telnetmode"] ? false : true
else
@options["Telnetmode"] = mode ? true : false
end
end
def binmode(mode = 'turn')
if 'turn' == mode
@options["Binmode"] = @options["Binmode"] ? false : true
else
@options["Binmode"] = mode ? true : false
end
end
def preprocess(string)
str = string.dup
# combine CR+NULL into CR
str.gsub!(/#{CR}#{NULL}/no, CR) if @options["Telnetmode"]
# combine EOL into "\n"
str.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
str.gsub!(/#{IAC}(
[#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]|
[#{DO}#{DONT}#{WILL}#{WONT}]
[#{OPT_BINARY}-#{OPT_NEW_ENVIRON}#{OPT_EXOPL}]|
#{SB}[^#{IAC}]*#{IAC}#{SE}
)/xno){
if IAC == $1 # handle escaped IAC characters
IAC
elsif AYT == $1 # respond to "IAC AYT" (are you there)
self.write("nobody here but us pigeons" + EOL)
''
elsif DO[0] == $1[0] # respond to "IAC DO x"
if OPT_BINARY[0] == $1[1]
@telnet_option["BINARY"] = true
self.write(IAC + WILL + OPT_BINARY)
else
self.write(IAC + WONT + $1[1..1])
end
''
elsif DONT[0] == $1[0] # respond to "IAC DON'T x" with "IAC WON'T x"
self.write(IAC + WONT + $1[1..1])
''
elsif WILL[0] == $1[0] # respond to "IAC WILL x"
if OPT_BINARY[0] == $1[1]
self.write(IAC + DO + OPT_BINARY)
elsif OPT_ECHO[0] == $1[1]
self.write(IAC + DO + OPT_ECHO)
elsif OPT_SGA[0] == $1[1]
@telnet_option["SGA"] = true
self.write(IAC + DO + OPT_SGA)
else
self.write(IAC + DONT + $1[1..1])
end
''
elsif WONT[0] == $1[0] # respond to "IAC WON'T x"
if OPT_ECHO[0] == $1[1]
self.write(IAC + DONT + OPT_ECHO)
elsif OPT_SGA[0] == $1[1]
@telnet_option["SGA"] = false
self.write(IAC + DONT + OPT_SGA)
else
self.write(IAC + DONT + $1[1..1])
end
''
else
''
end
}
str
end # preprocess
def waitfor(options)
time_out = @options["Timeout"]
waittime = @options["Waittime"]
if options.kind_of?(Hash)
prompt = if options.has_key?("Match")
options["Match"]
elsif options.has_key?("Prompt")
options["Prompt"]
elsif options.has_key?("String")
Regexp.new( Regexp.quote(options["String"]) )
end
time_out = options["Timeout"] if options.has_key?("Timeout")
waittime = options["Waittime"] if options.has_key?("Waittime")
else
prompt = options
end
if time_out == false
time_out = nil
end
line = ''
buf = ''
rest = ''
until(prompt === line and not IO::select([@sock], nil, nil, waittime))
unless IO::select([@sock], nil, nil, time_out)
raise TimeoutError, "timed-out; wait for the next data"
end
begin
c = @sock.sysread(1024 * 1024)
@dumplog.log_dump('<', c) if @options.has_key?("Dump_log")
if @options["Telnetmode"]
if Integer(c.rindex(/#{IAC}#{SE}/no)) <
Integer(c.rindex(/#{IAC}#{SB}/no))
buf = preprocess(rest + c[0 ... c.rindex(/#{IAC}#{SB}/no)])
rest = c[c.rindex(/#{IAC}#{SB}/no) .. -1]
elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no)
buf = preprocess(rest + c[0 ... pt])
rest = c[pt .. -1]
else
buf = preprocess(c)
rest = ''
end
end
@log.print(buf) if @options.has_key?("Output_log")
line.concat(buf)
yield buf if iterator?
rescue EOFError # End of file reached
if line == ''
line = nil
yield nil if iterator?
end
break
end
end
line
end
def write(string)
length = string.length
while 0 < length
IO::select(nil, [@sock])
@dumplog.log_dump('>', string[-length..-1]) if @options.has_key?("Dump_log")
length -= @sock.syswrite(string[-length..-1])
end
end
def print(string)
str = string.dup + "\n"
str.gsub!(/#{IAC}/no, IAC + IAC) if @options["Telnetmode"]
unless @options["Binmode"]
if @telnet_option["BINARY"] and @telnet_option["SGA"]
# IAC WILL SGA IAC DO BIN send EOL --> CR
str.gsub!(/\n/n, CR)
elsif @telnet_option["SGA"]
# IAC WILL SGA send EOL --> CR+NULL
str.gsub!(/\n/n, CR + NULL)
else
# NONE send EOL --> CR+LF
str.gsub!(/\n/n, EOL)
end
end
self.write(str)
end
def cmd(options)
match = @options["Prompt"]
time_out = @options["Timeout"]
if options.kind_of?(Hash)
string = options["String"]
match = options["Match"] if options.has_key?("Match")
time_out = options["Timeout"] if options.has_key?("Timeout")
else
string = options
end
self.print(string)
if iterator?
waitfor({"Prompt" => match, "Timeout" => time_out}){|c| yield c }
else
waitfor({"Prompt" => match, "Timeout" => time_out})
end
end
def login(options, password = nil)
if options.kind_of?(Hash)
username = options["Name"]
password = options["Password"]
else
username = options
end
if iterator?
line = waitfor(/login[: ]*\z/n){|c| yield c }
if password
line.concat( cmd({"String" => username,
"Match" => /Password[: ]*\z/n}){|c| yield c } )
line.concat( cmd(password){|c| yield c } )
else
line.concat( cmd(username){|c| yield c } )
end
else
line = waitfor(/login[: ]*\z/n)
if password
line.concat( cmd({"String" => username,
"Match" => /Password[: ]*\z/n}) )
line.concat( cmd(password) )
else
line.concat( cmd(username) )
end
end
line
end
end
end

View file

@ -1,739 +1,9 @@
=begin
$Date: 2000/01/24 17:02:57 $
#
# telnet.rb
#
== SIMPLE TELNET CLIENT LIBRARY
$stderr.puts 'Warning: telnet.rb is obsolete: use net/telnet'
telnet.rb
require 'net/telnet'
Version 1.20
Wakou Aoyama <wakou@fsinet.or.jp>
=== MAKE NEW TELNET OBJECT
host = Telnet.new({"Binmode" => false, # default: false
"Host" => "localhost", # default: "localhost"
"Output_log" => "output_log", # default: not output
"Dump_log" => "dump_log", # default: not output
"Port" => 23, # default: 23
"Prompt" => /[$%#>] \z/n, # default: /[$%#>] \z/n
"Telnetmode" => true, # default: true
"Timeout" => 10, # default: 10
# if ignore timeout then set "Timeout" to false.
"Waittime" => 0, # default: 0
"Proxy" => proxy}) # default: nil
# proxy is Telnet or TCPsocket object
Telnet object has socket class methods.
if set "Telnetmode" option to false. not telnet command interpretation.
"Waittime" is time to confirm "Prompt". There is a possibility that
the same character as "Prompt" is included in the data, and, when
the network or the host is very heavy, the value is enlarged.
=== STATUS OUTPUT
host = Telnet.new({"Host" => "localhost"}){|c| print c }
connection status output.
example
Trying localhost...
Connected to localhost.
=== WAIT FOR MATCH
line = host.waitfor(/match/)
line = host.waitfor({"Match" => /match/,
"String" => "string",
"Timeout" => secs})
# if ignore timeout then set "Timeout" to false.
if set "String" option, then Match == Regexp.new(quote("string"))
==== REALTIME OUTPUT
host.waitfor(/match/){|c| print c }
host.waitfor({"Match" => /match/,
"String" => "string",
"Timeout" => secs}){|c| print c}
of cource, set sync=true or flush is necessary.
=== SEND STRING AND WAIT PROMPT
line = host.cmd("string")
line = host.cmd({"String" => "string",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10})
==== REALTIME OUTPUT
host.cmd("string"){|c| print c }
host.cmd({"String" => "string",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10}){|c| print c }
of cource, set sync=true or flush is necessary.
=== SEND STRING
host.print("string")
# == host.write("string\n")
=== TURN TELNET COMMAND INTERPRETATION
host.telnetmode # turn on/off
host.telnetmode(true) # on
host.telnetmode(false) # off
=== TOGGLE NEWLINE TRANSLATION
host.binmode # turn true/false
host.binmode(true) # no translate newline
host.binmode(false) # translate newline
=== LOGIN
host.login("username", "password")
host.login({"Name" => "username",
"Password" => "password",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10})
if no password prompt.
host.login("username")
host.login({"Name" => "username",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10})
==== REALTIME OUTPUT
host.login("username", "password"){|c| print c }
host.login({"Name" => "username",
"Password" => "password",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10}){|c| print c }
of cource, set sync=true or flush is necessary.
== EXAMPLE
=== LOGIN AND SEND COMMAND
localhost = Telnet.new({"Host" => "localhost",
"Timeout" => 10,
"Prompt" => /[$%#>] \z/n})
localhost.login("username", "password"){|c| print c }
localhost.cmd("command"){|c| print c }
localhost.close
=== CHECKS A POP SERVER TO SEE IF YOU HAVE MAIL
pop = Telnet.new({"Host" => "your_destination_host_here",
"Port" => 110,
"Telnetmode" => false,
"Prompt" => /^\+OK/n})
pop.cmd("user " + "your_username_here"){|c| print c}
pop.cmd("pass " + "your_password_here"){|c| print c}
pop.cmd("list"){|c| print c}
== HISTORY
=== Version 1.20
2000/01/24 17:02:57
- respond to "IAC WILL x" with "IAC DONT x"
- respond to "IAC WONT x" with "IAC DONT x"
- better dumplog format
thanks to WATANABE Hirofumi <Hirofumi.Watanabe@jp.sony.com>
=== Version 1.10
2000/01/18 17:47:31
- bug fix: write method
- respond to "IAC WILL BINARY" with "IAC DO BINARY"
=== Version 1.00
1999/10/04 22:51:26
- bug fix: waitfor(preprocess) method
thanks to Shin-ichiro Hara <sinara@blade.nagaokaut.ac.jp>
- add simple support for AO, DM, IP, NOP, SB, SE
- COUTION! TimeOut --> TimeoutError
=== Version 0.50
1999/09/21 21:24:07
- add write method
=== Version 0.40
1999/09/17 17:41:41
- bug fix: preprocess method
=== Version 0.30
1999/09/14 23:09:05
- change prompt check order.
not IO::select([@sock], nil, nil, waittime) and prompt === line
--> prompt === line and not IO::select([@sock], nil, nil, waittime)
=== Version 0.24
1999/09/13 22:28:33
- Telnet#login
if ommit password, then not require password prompt.
=== Version 0.232
1999/08/10 05:20:21
- STATUS OUTPUT sample code typo. thanks to Tadayoshi Funaba <tadf@kt.rim.or.jp>
host = Telnet.new({"Hosh" => "localhost"){|c| print c }
--> host = Telnet.new({"Host" => "localhost"){|c| print c }
=== Version 0.231
1999/07/16 13:39:42
- TRUE --> true, FALSE --> false
=== Version 0.23
1999/07/15 22:32:09
- waitfor: if end of file reached, then return nil.
=== Version 0.22
1999/06/29 09:08:51
- new, waitfor, cmd: {"Timeout" => false} # ignore timeout
=== Version 0.21
1999/06/28 18:18:55
- waitfor: not rescue (EOFError)
=== Version 0.20
1999/06/04 06:24:58
- waitfor: support for divided telnet command
=== Version 0.181
1999/05/22
- bug fix: print method
=== Version 0.18
1999/05/14
- respond to "IAC WON'T SGA" with "IAC DON'T SGA"
- DON'T SGA : end of line --> CR + LF
- bug fix: preprocess method
=== Version 0.17
1999/04/30
- bug fix: $! + "\n" --> $!.to_s + "\n"
=== Version 0.163
1999/04/11
- STDOUT.write(message) --> yield(message) if iterator?
=== Version 0.162
1999/03/17
- add "Proxy" option
- required timeout.rb
=== Version 0.161
1999/02/03
- select --> IO::select
=== Version 0.16
1998/10/09
- preprocess method change for the better
- add binmode method.
- change default Binmode. TRUE --> FALSE
=== Version 0.15
1998/10/04
- add telnetmode method.
=== Version 0.141
1998/09/22
- change default prompt. /[$%#>] $/ --> /[$%#>] \Z/
=== Version 0.14
1998/09/01
- IAC WILL SGA send EOL --> CR+NULL
- IAC WILL SGA IAC DO BIN send EOL --> CR
- NONE send EOL --> LF
- add Dump_log option.
=== Version 0.13
1998/08/25
- add print method.
=== Version 0.122
1998/08/05
- support for HP-UX 10.20 thanks to WATANABE Tetsuya <tetsu@jpn.hp.com>
- socket.<< --> socket.write
=== Version 0.121
1998/07/15
- string.+= --> string.concat
=== Version 0.12
1998/06/01
- add timeout, waittime.
=== Version 0.11
1998/04/21
- add realtime output.
=== Version 0.10
1998/04/13
- first release.
=end
require "socket"
require "delegate"
require "timeout"
class Telnet < SimpleDelegator
IAC = 255.chr # "\377" # "\xff" # interpret as command:
DONT = 254.chr # "\376" # "\xfe" # you are not to use option
DO = 253.chr # "\375" # "\xfd" # please, you use option
WONT = 252.chr # "\374" # "\xfc" # I won't use option
WILL = 251.chr # "\373" # "\xfb" # I will use option
SB = 250.chr # "\372" # "\xfa" # interpret as subnegotiation
GA = 249.chr # "\371" # "\xf9" # you may reverse the line
EL = 248.chr # "\370" # "\xf8" # erase the current line
EC = 247.chr # "\367" # "\xf7" # erase the current character
AYT = 246.chr # "\366" # "\xf6" # are you there
AO = 245.chr # "\365" # "\xf5" # abort output--but let prog finish
IP = 244.chr # "\364" # "\xf4" # interrupt process--permanently
BREAK = 243.chr # "\363" # "\xf3" # break
DM = 242.chr # "\362" # "\xf2" # data mark--for connect. cleaning
NOP = 241.chr # "\361" # "\xf1" # nop
SE = 240.chr # "\360" # "\xf0" # end sub negotiation
EOR = 239.chr # "\357" # "\xef" # end of record (transparent mode)
ABORT = 238.chr # "\356" # "\xee" # Abort process
SUSP = 237.chr # "\355" # "\xed" # Suspend process
EOF = 236.chr # "\354" # "\xec" # End of file
SYNCH = 242.chr # "\362" # "\xf2" # for telfunc calls
OPT_BINARY = 0.chr # "\000" # "\x00" # Binary Transmission
OPT_ECHO = 1.chr # "\001" # "\x01" # Echo
OPT_RCP = 2.chr # "\002" # "\x02" # Reconnection
OPT_SGA = 3.chr # "\003" # "\x03" # Suppress Go Ahead
OPT_NAMS = 4.chr # "\004" # "\x04" # Approx Message Size Negotiation
OPT_STATUS = 5.chr # "\005" # "\x05" # Status
OPT_TM = 6.chr # "\006" # "\x06" # Timing Mark
OPT_RCTE = 7.chr # "\a" # "\x07" # Remote Controlled Trans and Echo
OPT_NAOL = 8.chr # "\010" # "\x08" # Output Line Width
OPT_NAOP = 9.chr # "\t" # "\x09" # Output Page Size
OPT_NAOCRD = 10.chr # "\n" # "\x0a" # Output Carriage-Return Disposition
OPT_NAOHTS = 11.chr # "\v" # "\x0b" # Output Horizontal Tab Stops
OPT_NAOHTD = 12.chr # "\f" # "\x0c" # Output Horizontal Tab Disposition
OPT_NAOFFD = 13.chr # "\r" # "\x0d" # Output Formfeed Disposition
OPT_NAOVTS = 14.chr # "\016" # "\x0e" # Output Vertical Tabstops
OPT_NAOVTD = 15.chr # "\017" # "\x0f" # Output Vertical Tab Disposition
OPT_NAOLFD = 16.chr # "\020" # "\x10" # Output Linefeed Disposition
OPT_XASCII = 17.chr # "\021" # "\x11" # Extended ASCII
OPT_LOGOUT = 18.chr # "\022" # "\x12" # Logout
OPT_BM = 19.chr # "\023" # "\x13" # Byte Macro
OPT_DET = 20.chr # "\024" # "\x14" # Data Entry Terminal
OPT_SUPDUP = 21.chr # "\025" # "\x15" # SUPDUP
OPT_SUPDUPOUTPUT = 22.chr # "\026" # "\x16" # SUPDUP Output
OPT_SNDLOC = 23.chr # "\027" # "\x17" # Send Location
OPT_TTYPE = 24.chr # "\030" # "\x18" # Terminal Type
OPT_EOR = 25.chr # "\031" # "\x19" # End of Record
OPT_TUID = 26.chr # "\032" # "\x1a" # TACACS User Identification
OPT_OUTMRK = 27.chr # "\e" # "\x1b" # Output Marking
OPT_TTYLOC = 28.chr # "\034" # "\x1c" # Terminal Location Number
OPT_3270REGIME = 29.chr # "\035" # "\x1d" # Telnet 3270 Regime
OPT_X3PAD = 30.chr # "\036" # "\x1e" # X.3 PAD
OPT_NAWS = 31.chr # "\037" # "\x1f" # Negotiate About Window Size
OPT_TSPEED = 32.chr # " " # "\x20" # Terminal Speed
OPT_LFLOW = 33.chr # "!" # "\x21" # Remote Flow Control
OPT_LINEMODE = 34.chr # "\"" # "\x22" # Linemode
OPT_XDISPLOC = 35.chr # "#" # "\x23" # X Display Location
OPT_OLD_ENVIRON = 36.chr # "$" # "\x24" # Environment Option
OPT_AUTHENTICATION = 37.chr # "%" # "\x25" # Authentication Option
OPT_ENCRYPT = 38.chr # "&" # "\x26" # Encryption Option
OPT_NEW_ENVIRON = 39.chr # "'" # "\x27" # New Environment Option
OPT_EXOPL = 255.chr # "\377" # "\xff" # Extended-Options-List
NULL = "\000"
CR = "\015"
LF = "\012"
EOL = CR + LF
v = $-v
$-v = false
VERSION = "1.20"
RELEASE_DATE = "$Date: 2000/01/24 17:02:57 $"
$-v = v
def initialize(options)
@options = options
@options["Binmode"] = false unless @options.has_key?("Binmode")
@options["Host"] = "localhost" unless @options.has_key?("Host")
@options["Port"] = 23 unless @options.has_key?("Port")
@options["Prompt"] = /[$%#>] \z/n unless @options.has_key?("Prompt")
@options["Telnetmode"] = true unless @options.has_key?("Telnetmode")
@options["Timeout"] = 10 unless @options.has_key?("Timeout")
@options["Waittime"] = 0 unless @options.has_key?("Waittime")
@telnet_option = { "SGA" => false, "BINARY" => false }
if @options.has_key?("Output_log")
@log = File.open(@options["Output_log"], 'a+')
@log.sync = true
@log.binmode
end
if @options.has_key?("Dump_log")
@dumplog = File.open(@options["Dump_log"], 'a+')
@dumplog.sync = true
@dumplog.binmode
def @dumplog.log_dump(dir, x)
len = x.length
addr = 0
offset = 0
while 0 < len
if len < 16
line = x[offset, len]
else
line = x[offset, 16]
end
hexvals = line.unpack('H*')[0]
hexvals.concat ' ' * (32 - hexvals.length)
hexvals = format "%s %s %s %s " * 4, *hexvals.unpack('a2' * 16)
line.gsub! /[\000-\037\177-\377]/n, '.'
printf "%s 0x%5.5x: %s%s\n", dir, addr, hexvals, line
addr += 16
offset += 16
len -= 16
end
print "\n"
end
end
if @options.has_key?("Proxy")
if @options["Proxy"].kind_of?(Telnet)
@sock = @options["Proxy"].sock
elsif @options["Proxy"].kind_of?(TCPsocket)
@sock = @options["Proxy"]
else
raise "Error; Proxy is Telnet or TCPSocket object."
end
else
message = "Trying " + @options["Host"] + "...\n"
yield(message) if iterator?
@log.write(message) if @options.has_key?("Output_log")
@dumplog.log_dump('#', message) if @options.has_key?("Dump_log")
begin
if @options["Timeout"] == false
@sock = TCPsocket.open(@options["Host"], @options["Port"])
else
timeout(@options["Timeout"]){
@sock = TCPsocket.open(@options["Host"], @options["Port"])
}
end
rescue TimeoutError
raise TimeoutError, "timed-out; opening of the host"
rescue
@log.write($!.to_s + "\n") if @options.has_key?("Output_log")
@dumplog.log_dump('#', $!.to_s + "\n") if @options.has_key?("Dump_log")
raise
end
@sock.sync = true
@sock.binmode
message = "Connected to " + @options["Host"] + ".\n"
yield(message) if iterator?
@log.write(message) if @options.has_key?("Output_log")
@dumplog.log_dump('#', message) if @options.has_key?("Dump_log")
end
super(@sock)
end # initialize
attr :sock
def telnetmode(mode = 'turn')
if 'turn' == mode
@options["Telnetmode"] = @options["Telnetmode"] ? false : true
else
@options["Telnetmode"] = mode ? true : false
end
end
def binmode(mode = 'turn')
if 'turn' == mode
@options["Binmode"] = @options["Binmode"] ? false : true
else
@options["Binmode"] = mode ? true : false
end
end
def preprocess(string)
str = string.dup
# combine CR+NULL into CR
str.gsub!(/#{CR}#{NULL}/no, CR) if @options["Telnetmode"]
# combine EOL into "\n"
str.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
str.gsub!(/#{IAC}(
[#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]|
[#{DO}#{DONT}#{WILL}#{WONT}]
[#{OPT_BINARY}-#{OPT_NEW_ENVIRON}#{OPT_EXOPL}]|
#{SB}[^#{IAC}]*#{IAC}#{SE}
)/xno){
if IAC == $1 # handle escaped IAC characters
IAC
elsif AYT == $1 # respond to "IAC AYT" (are you there)
self.write("nobody here but us pigeons" + EOL)
''
elsif DO[0] == $1[0] # respond to "IAC DO x"
if OPT_BINARY[0] == $1[1]
@telnet_option["BINARY"] = true
self.write(IAC + WILL + OPT_BINARY)
else
self.write(IAC + WONT + $1[1..1])
end
''
elsif DONT[0] == $1[0] # respond to "IAC DON'T x" with "IAC WON'T x"
self.write(IAC + WONT + $1[1..1])
''
elsif WILL[0] == $1[0] # respond to "IAC WILL x"
if OPT_BINARY[0] == $1[1]
self.write(IAC + DO + OPT_BINARY)
elsif OPT_ECHO[0] == $1[1]
self.write(IAC + DO + OPT_ECHO)
elsif OPT_SGA[0] == $1[1]
@telnet_option["SGA"] = true
self.write(IAC + DO + OPT_SGA)
else
self.write(IAC + DONT + $1[1..1])
end
''
elsif WONT[0] == $1[0] # respond to "IAC WON'T x"
if OPT_ECHO[0] == $1[1]
self.write(IAC + DONT + OPT_ECHO)
elsif OPT_SGA[0] == $1[1]
@telnet_option["SGA"] = false
self.write(IAC + DONT + OPT_SGA)
else
self.write(IAC + DONT + $1[1..1])
end
''
else
''
end
}
str
end # preprocess
def waitfor(options)
time_out = @options["Timeout"]
waittime = @options["Waittime"]
if options.kind_of?(Hash)
prompt = if options.has_key?("Match")
options["Match"]
elsif options.has_key?("Prompt")
options["Prompt"]
elsif options.has_key?("String")
Regexp.new( Regexp.quote(options["String"]) )
end
time_out = options["Timeout"] if options.has_key?("Timeout")
waittime = options["Waittime"] if options.has_key?("Waittime")
else
prompt = options
end
if time_out == false
time_out = nil
end
line = ''
buf = ''
rest = ''
until(prompt === line and not IO::select([@sock], nil, nil, waittime))
unless IO::select([@sock], nil, nil, time_out)
raise TimeoutError, "timed-out; wait for the next data"
end
begin
c = @sock.sysread(1024 * 1024)
@dumplog.log_dump('<', c) if @options.has_key?("Dump_log")
if @options["Telnetmode"]
if Integer(c.rindex(/#{IAC}#{SE}/no)) <
Integer(c.rindex(/#{IAC}#{SB}/no))
buf = preprocess(rest + c[0 ... c.rindex(/#{IAC}#{SB}/no)])
rest = c[c.rindex(/#{IAC}#{SB}/no) .. -1]
elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no)
buf = preprocess(rest + c[0 ... pt])
rest = c[pt .. -1]
else
buf = preprocess(c)
rest = ''
end
end
@log.print(buf) if @options.has_key?("Output_log")
line.concat(buf)
yield buf if iterator?
rescue EOFError # End of file reached
if line == ''
line = nil
yield nil if iterator?
end
break
end
end
line
end
def write(string)
length = string.length
while 0 < length
IO::select(nil, [@sock])
@dumplog.log_dump('>', string[-length..-1]) if @options.has_key?("Dump_log")
length -= @sock.syswrite(string[-length..-1])
end
end
def print(string)
str = string.dup + "\n"
str.gsub!(/#{IAC}/no, IAC + IAC) if @options["Telnetmode"]
unless @options["Binmode"]
if @telnet_option["BINARY"] and @telnet_option["SGA"]
# IAC WILL SGA IAC DO BIN send EOL --> CR
str.gsub!(/\n/n, CR)
elsif @telnet_option["SGA"]
# IAC WILL SGA send EOL --> CR+NULL
str.gsub!(/\n/n, CR + NULL)
else
# NONE send EOL --> CR+LF
str.gsub!(/\n/n, EOL)
end
end
self.write(str)
end
def cmd(options)
match = @options["Prompt"]
time_out = @options["Timeout"]
if options.kind_of?(Hash)
string = options["String"]
match = options["Match"] if options.has_key?("Match")
time_out = options["Timeout"] if options.has_key?("Timeout")
else
string = options
end
self.print(string)
if iterator?
waitfor({"Prompt" => match, "Timeout" => time_out}){|c| yield c }
else
waitfor({"Prompt" => match, "Timeout" => time_out})
end
end
def login(options, password = nil)
if options.kind_of?(Hash)
username = options["Name"]
password = options["Password"]
else
username = options
end
if iterator?
line = waitfor(/login[: ]*\z/n){|c| yield c }
if password
line.concat( cmd({"String" => username,
"Match" => /Password[: ]*\z/n}){|c| yield c } )
line.concat( cmd(password){|c| yield c } )
else
line.concat( cmd(username){|c| yield c } )
end
else
line = waitfor(/login[: ]*\z/n)
if password
line.concat( cmd({"String" => username,
"Match" => /Password[: ]*\z/n}) )
line.concat( cmd(password) )
else
line.concat( cmd(username) )
end
end
line
end
end
Telnet = ::Net::Telnet

View file

@ -1,7 +1,10 @@
#
# thread.rb - thread support classes
# $Date$
# by Yukihiro Matsumoto <matz@caelum.co.jp>
# by Yukihiro Matsumoto <matz@netlab.co.jp>
#
# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
# Copyright (C) 2000 Information-technology Promotion Agancy, Japan
#
unless defined? Thread
@ -71,6 +74,7 @@ class Mutex
retry
end
Thread.critical = false
t.run if t
self
end

View file

@ -1,6 +1,9 @@
#
# timeout.rb -- execution timeout
#
# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
# Copyright (C) 2000 Information-technology Promotion Agancy, Japan
#
#= SYNOPSIS
#
# require 'timeout'

6
main.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
main.c -
@ -6,7 +6,9 @@
$Date$
created at: Fri Aug 19 13:19:58 JST 1994
************************************************/
Copyright (C) 1993-2000 Yukihiro Matsumoto
**********************************************************************/
#include "ruby.h"

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
marshal.c -
@ -6,7 +6,9 @@
$Date$
created at: Thu Apr 27 16:30:01 JST 1995
************************************************/
Copyright (C) 1993-2000 Yukihiro Matsumoto
**********************************************************************/
#include "ruby.h"
#include "rubyio.h"

4
math.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
math.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"
#include <math.h>

View file

@ -114,6 +114,31 @@
(defvar ruby-indent-level 2
"*Indentation of ruby statements.")
(eval-when-compile (require 'cl))
(defun ruby-imenu-create-index ()
(let ((index-alist '())
class-name class-begin method-name method-begin decl)
(goto-char (point-min))
(while (re-search-forward "^\\s *\\(class\\|def\\)\\s *\\([^(\n ]+\\)" nil t)
(setq decl (buffer-substring (match-beginning 1) (match-end 1)))
(cond
((string= "class" decl)
(setq class-begin (match-beginning 2))
(setq class-name (buffer-substring class-begin (match-end 2)))
(push (cons class-name (match-beginning 0)) index-alist)
(ruby-mark-defun)
(save-restriction
(narrow-to-region (region-beginning) (region-end))
(while (re-search-forward "^\\s *def\\s *\\([^(\n ]+\\)" nil t)
(setq method-begin (match-beginning 1))
(setq method-name (buffer-substring method-begin (match-end 1)))
(push (cons (concat class-name "#" method-name) (match-beginning 0)) index-alist))))
((string= "def" decl)
(setq method-begin (match-beginning 2))
(setq method-name (buffer-substring method-begin (match-end 2)))
(push (cons method-name (match-beginning 0)) index-alist))))
index-alist))
(defun ruby-mode-variables ()
(set-syntax-table ruby-mode-syntax-table)
(setq local-abbrev-table ruby-mode-abbrev-table)
@ -153,6 +178,9 @@ The variable ruby-indent-level controls the amount of indentation.
(setq major-mode 'ruby-mode)
(ruby-mode-variables)
(make-local-variable 'imenu-create-index-function)
(setq imenu-create-index-function 'ruby-imenu-create-index)
(run-hooks 'ruby-mode-hook))
(defun ruby-current-indentation ()
@ -250,8 +278,8 @@ The variable ruby-indent-level controls the amount of indentation.
(goto-char indent-point))))
((looking-at "/")
(cond
((and (not (eobp)) (ruby-expr-beg 'expr-arg))
(if (re-search-forward "[^\\]/" indent-point t)
((and (not (eobp)) (ruby-expr-beg))
(if (re-search-forward "[^\\]\\(\\\\\\\\\\)*/" indent-point t)
nil
(setq in-string (point))
(goto-char indent-point)))
@ -262,15 +290,21 @@ The variable ruby-indent-level controls the amount of indentation.
((and (not (eobp)) (ruby-expr-beg 'expr-arg)
(not (looking-at "%="))
(looking-at "%[Qqrxw]?\\(.\\)"))
(goto-char (match-beginning 1))
(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 ")"))
((string= w "<") (setq w ">")))
(goto-char (match-end 0))
(if (search-forward w indent-point t)
((string= w "<") (setq w ">"))
((member w '("*" "." "+" "?" "^" "$"))
(setq w (concat "\\" w))))
(if (re-search-forward
(if (string= w "\\")
"\\\\[^\\]*\\\\"
(concat "[^\\]\\(\\\\\\\\\\)*" w))
indent-point t)
nil
(setq in-string (point))
(goto-char indent-point)))

5
node.h
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
node.h -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#ifndef NODE_H
#define NODE_H
@ -119,6 +119,7 @@ enum node_type {
NODE_ALLOCA,
#endif
NODE_MEMO,
NODE_LAST
};
typedef struct RNode {

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
numeric.c -
@ -8,12 +8,12 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"
#include <math.h>
#include <stdio.h>
#if defined(FreeBSD) && __FreeBSD_version < 400012
#if defined(__FreeBSD__) && __FreeBSD__ < 4
#include <floatingpoint.h>
#endif
@ -28,10 +28,6 @@ VALUE rb_cFixnum;
VALUE rb_eZeroDivError;
VALUE rb_eFloatDomainError;
ID rb_frame_last_func();
VALUE rb_float_new();
double rb_big2dbl();
void
rb_num_zerodiv()
{
@ -1451,7 +1447,7 @@ fix_zero_p(num)
void
Init_Numeric()
{
#if defined(FreeBSD) && __FreeBSD_version < 400012
#if defined(__FreeBSD__) && __FreeBSD__ < 4
/* allow divide by zero -- Inf */
fpsetmask(fpgetmask() & ~(FP_X_DZ|FP_X_INV|FP_X_OFL));
#endif
@ -1459,7 +1455,7 @@ Init_Numeric()
to_i = rb_intern("to_i");
rb_eZeroDivError = rb_define_class("ZeroDivisionError", rb_eStandardError);
rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eStandardError);
rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eRangeError);
rb_cNumeric = rb_define_class("Numeric", rb_cObject);
rb_include_module(rb_cNumeric, rb_mComparable);

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
object.c -
@ -7,8 +7,10 @@
created at: Thu Jul 15 12:01:24 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
**********************************************************************/
#include "ruby.h"
#include "st.h"
@ -829,6 +831,7 @@ fail_to_type(arg)
arg->val == Qfalse ? "false" :
rb_class2name(CLASS_OF(arg->val)),
arg->s);
return Qnil; /* not reached */
}
VALUE
@ -1062,6 +1065,7 @@ Init_Object()
rb_define_method(rb_mKernel, "id", rb_obj_id, 0);
rb_define_method(rb_mKernel, "__id__", rb_obj_id, 0);
rb_define_method(rb_mKernel, "type", rb_obj_type, 0);
rb_define_method(rb_mKernel, "class", rb_obj_type, 0);
rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0);
rb_define_method(rb_mKernel, "dup", rb_obj_dup, 0);

4
pack.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
pack.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"
#include <sys/types.h>

20
parse.y
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
parse.y -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
%{
@ -360,7 +360,7 @@ stmt : block_call
$$ = 0;
}
}
| stmt kRESCUE_MOD expr
| stmt kRESCUE_MOD stmt
{
$$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
}
@ -1210,7 +1210,7 @@ primary : literal
if ($8) $5 = NEW_ENSURE($5, $8);
/* NOEX_PRIVATE for toplevel */
$$ = NEW_DEFN($2, $4, $5, class_nest?0:1);
$$ = NEW_DEFN($2, $4, $5, class_nest?NOEX_PUBLIC:NOEX_PRIVATE);
fixpos($$, $4);
local_pop();
cur_mid = 0;
@ -1655,10 +1655,6 @@ singleton : var_ref
if (nd_type($1) == NODE_SELF) {
$$ = NEW_SELF();
}
else if (nd_type($1) == NODE_NIL) {
yyerror("Can't define single method for nil.");
$$ = 0;
}
else {
$$ = $1;
}
@ -2454,9 +2450,13 @@ parse_quotedwords(term, paren)
c = '\\';
break;
default:
if (ISSPACE(c))
if (c == term) {
tokadd(c);
continue;
}
if (!ISSPACE(c))
tokadd('\\');
tokadd(c);
break;
}
}
else if (ISSPACE(c)) {

4
prec.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
prec.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
*************************************************/
**********************************************************************/
#include "ruby.h"

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
process.c -
@ -7,8 +7,10 @@
created at: Tue Aug 10 14:30:50 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
**********************************************************************/
#include "ruby.h"
#include "rubysig.h"

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
random.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
range.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"

6
re.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
re.c -
@ -7,7 +7,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"
#include "re.h"
@ -184,7 +184,7 @@ kcode_reset_option()
int
rb_reg_mbclen2(c, re)
unsigned char c;
unsigned int c;
VALUE re;
{
int len;

6
re.h
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
re.h -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#ifndef RE_H
#define RE_H
@ -39,6 +39,6 @@ void rb_match_busy _((VALUE));
extern int ruby_ignorecase;
int rb_reg_mbclen2 _((unsigned char, VALUE));
int rb_reg_mbclen2 _((unsigned int, VALUE));
#define mbclen2(c,re) rb_reg_mbclen2((c),(re))
#endif

View file

@ -70,7 +70,7 @@ void *xrealloc _((void*,size_t));
void free _((void*));
#endif
#define NO_ALLOCA */ /* try it out for now */
#define NO_ALLOCA /* /* try it out for now */
#ifndef NO_ALLOCA
/* Make alloca work the best possible way. */
#ifdef __GNUC__
@ -162,7 +162,7 @@ static char re_syntax_table[256];
static void init_syntax_once _((void));
static const unsigned char *translate = 0;
static void init_regs _((struct re_registers*, unsigned int));
static void bm_init_skip _((int *, unsigned char*, int, const char*));
static void bm_init_skip _((int *, unsigned char*, int, const unsigned char*));
static int current_mbctype = MBCTYPE_ASCII;
#undef P
@ -2618,7 +2618,7 @@ bm_init_skip(skip, pat, m, translate)
int *skip;
unsigned char *pat;
int m;
const char *translate;
const unsigned char *translate;
{
int j, c;

2
ruby.c
View file

@ -7,6 +7,8 @@
created at: Tue Aug 10 12:47:31 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/

8
ruby.h
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
ruby.h -
@ -6,8 +6,10 @@
created at: Thu Jun 10 14:26:32 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
*************************************************/
**********************************************************************/
#ifndef RUBY_H
#define RUBY_H
@ -552,7 +554,7 @@ rb_type(VALUE obj)
if (obj == Qnil) return T_NIL;
if (obj == Qfalse) return T_FALSE;
if (obj == Qtrue) return T_TRUE;
if (obj == Qtrue) return T_UNDEF;
if (obj == Qundef) return T_UNDEF;
if (SYMBOL_P(obj)) return T_SYMBOL;
return BUILTIN_TYPE(obj);
}

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
rubyio.h -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#ifndef IO_H
#define IO_H

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
rubysig.h -
@ -6,7 +6,10 @@
$Date$
created at: Wed Aug 16 01:15:38 JST 1995
************************************************/
Copyright (C) 1993-2000 Yukihiro Matsumoto
**********************************************************************/
#ifndef SIG_H
#define SIG_H

View file

@ -694,7 +694,11 @@ $x.each_byte {|i|
}
ok(!$bad)
check "asignment"
s = "a string"
s[0..s.size]="another string"
ok(s == "another string")
check "assignment"
a = nil
ok(defined?(a))
ok(a == nil)

View file

@ -6,6 +6,10 @@
$Date$
created at: Tue Dec 20 10:13:44 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
#include "ruby.h"

View file

@ -7,6 +7,8 @@
created at: Fri Oct 15 10:39:26 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
string.c -
@ -7,8 +7,10 @@
created at: Mon Aug 9 17:12:58 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
************************************************/
**********************************************************************/
#include "ruby.h"
#include "re.h"
@ -767,29 +769,36 @@ rb_str_succ(orig)
VALUE str, str2;
char *sbeg, *s;
int c = -1;
int n = 0;
str = rb_str_new(RSTRING(orig)->ptr, RSTRING(orig)->len);
OBJ_INFECT(str, orig);
if (RSTRING(str)->len == 0) return str;
sbeg = RSTRING(str)->ptr; s = sbeg + RSTRING(str)->len - 1;
while (sbeg <= s) {
if (ISALNUM(*s) && (c = succ_char(s)) == 0) break;
if (ISALNUM(*s)) {
if ((c = succ_char(s)) == 0) break;
n = s - sbeg;
}
s--;
}
if (s < sbeg) {
if (c == -1 && RSTRING(str)->len > 0) {
RSTRING(str)->ptr[RSTRING(str)->len-1] += 1;
}
else {
str2 = rb_str_new(0, RSTRING(str)->len+1);
RSTRING(str2)->ptr[0] = c;
memcpy(RSTRING(str2)->ptr+1, RSTRING(str)->ptr, RSTRING(str)->len);
str = str2;
if (c == -1) { /* str contains no alnum */
sbeg = RSTRING(str)->ptr; s = sbeg + RSTRING(str)->len - 1;
c = '\001';
while (sbeg <= s) {
*s += 1;
if (*s-- != 0) break;
}
}
if (OBJ_TAINTED(orig)) {
OBJ_TAINT(str);
if (s < sbeg) {
REALLOC_N(RSTRING(str)->ptr, char, RSTRING(str)->len + 1);
s = RSTRING(str)->ptr + n;
memmove(s+1, s, RSTRING(str)->len - n);
*s = c;
RSTRING(str)->len += 1;
}
return str;

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
struct.c -
@ -6,7 +6,9 @@
$Date$
created at: Tue Mar 22 18:44:30 JST 1995
************************************************/
Copyright (C) 1993-2000 Yukihiro Matsumoto
**********************************************************************/
#include "ruby.h"

4
time.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
time.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"
#include <sys/types.h>

4
util.c
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
util.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include <stdio.h>

5
util.h
View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
util.h -
@ -8,7 +8,8 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#ifndef UTIL_H
#define UTIL_H

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
variable.c -
@ -6,7 +6,11 @@
$Date$
created at: Tue Apr 19 23:55:15 JST 1994
************************************************/
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agancy, Japan
**********************************************************************/
#include "ruby.h"
#include "env.h"

View file

@ -1,4 +1,4 @@
/************************************************
/**********************************************************************
version.c -
@ -8,7 +8,7 @@
Copyright (C) 1993-2000 Yukihiro Matsumoto
************************************************/
**********************************************************************/
#include "ruby.h"
#include "version.h"

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.3"
#define RUBY_RELEASE_DATE "2000-04-11"
#define RUBY_RELEASE_DATE "2000-05-01"
#define RUBY_VERSION_CODE 153
#define RUBY_RELEASE_CODE 20000411
#define RUBY_RELEASE_CODE 20000501