summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1844
-rw-r--r--MANIFEST25
-rw-r--r--Makefile.in277
-rw-r--r--README26
-rw-r--r--README.EXT492
-rw-r--r--README.EXT.jp1168
-rw-r--r--README.jp46
-rw-r--r--ToDo33
-rw-r--r--array.c268
-rw-r--r--bignum.c94
-rw-r--r--class.c59
-rw-r--r--compar.c2
-rw-r--r--config.guess9
-rw-r--r--config.sub8
-rw-r--r--config_h.dj71
-rw-r--r--config_s.dj56
-rw-r--r--configure1474
-rw-r--r--configure.bat26
-rw-r--r--configure.in425
-rw-r--r--cygwin/GNUmakefile.in9
-rw-r--r--defines.h23
-rw-r--r--dir.c230
-rw-r--r--dln.c160
-rw-r--r--dln.h8
-rw-r--r--enum.c28
-rw-r--r--env.h4
-rw-r--r--error.c136
-rw-r--r--eval.c1591
-rw-r--r--file.c233
-rw-r--r--fnmatch.c243
-rw-r--r--fnmatch.h36
-rw-r--r--gc.c92
-rw-r--r--glob.c591
-rw-r--r--hash.c220
-rw-r--r--inits.c6
-rw-r--r--install-sh238
-rw-r--r--instruby.rb82
-rw-r--r--intern.h110
-rw-r--r--io.c1041
-rw-r--r--lex.c149
-rw-r--r--lib/Env.rb31
-rw-r--r--lib/README48
-rw-r--r--lib/cgi-lib.rb277
-rw-r--r--lib/complex.rb18
-rw-r--r--lib/date2.rb267
-rw-r--r--lib/debug.rb387
-rw-r--r--lib/delegate.rb10
-rw-r--r--lib/e2mmap.rb269
-rw-r--r--lib/final.rb41
-rw-r--r--lib/finalize.rb2
-rw-r--r--lib/ftools.rb28
-rw-r--r--lib/ftplib.rb87
-rw-r--r--lib/getoptlong.rb473
-rw-r--r--lib/getopts.rb18
-rw-r--r--lib/jcode.rb149
-rw-r--r--lib/mailread.rb2
-rw-r--r--lib/mathn.rb4
-rw-r--r--lib/matrix.rb130
-rw-r--r--lib/mkmf.rb436
-rw-r--r--lib/monitor.rb229
-rw-r--r--lib/mutex_m.rb226
-rw-r--r--lib/observer.rb4
-rw-r--r--lib/open3.rb55
-rw-r--r--lib/parsedate.rb23
-rw-r--r--lib/profile.rb55
-rw-r--r--lib/rational.rb2
-rw-r--r--lib/readbytes.rb36
-rw-r--r--lib/shellwords.rb2
-rw-r--r--lib/singleton.rb37
-rw-r--r--lib/sync.rb272
-rw-r--r--lib/telnet.rb636
-rw-r--r--lib/tempfile.rb94
-rw-r--r--lib/thread.rb68
-rw-r--r--lib/timeout.rb42
-rw-r--r--lib/tracer.rb2
-rw-r--r--lib/weakref.rb34
-rw-r--r--main.c9
-rw-r--r--marshal.c49
-rw-r--r--math.c2
-rw-r--r--misc/README5
-rw-r--r--misc/inf-ruby.el322
-rw-r--r--misc/ruby-mode.el724
-rw-r--r--misc/rubydb2x.el104
-rw-r--r--misc/rubydb3x.el113
-rw-r--r--missing/dup2.c69
-rw-r--r--missing/finite.c6
-rw-r--r--missing/fnmatch.c199
-rw-r--r--missing/fnmatch.h57
-rw-r--r--missing/isinf.c44
-rw-r--r--missing/isnan.c16
-rw-r--r--missing/memcmp.c21
-rw-r--r--missing/os2.c111
-rw-r--r--missing/strcasecmp.c1
-rw-r--r--missing/strchr.c45
-rw-r--r--missing/strftime.c30
-rw-r--r--missing/strncasecmp.c18
-rw-r--r--missing/strtod.c266
-rw-r--r--missing/vsnprintf.c1128
-rw-r--r--mkconfig.rb41
-rw-r--r--node.h22
-rw-r--r--numeric.c124
-rw-r--r--object.c157
-rw-r--r--pack.c787
-rw-r--r--parse.c7224
-rw-r--r--parse.y939
-rw-r--r--prec.c81
-rw-r--r--process.c154
-rw-r--r--random.c4
-rw-r--r--range.c201
-rw-r--r--re.c322
-rw-r--r--re.h2
-rw-r--r--regex.c5417
-rw-r--r--regex.h78
-rw-r--r--ruby.18
-rw-r--r--ruby.c225
-rw-r--r--ruby.h132
-rw-r--r--rubyio.h63
-rw-r--r--rubysig.h50
-rw-r--r--rubytest.rb20
-rw-r--r--sample/README56
-rw-r--r--sample/biorhythm.rb10
-rw-r--r--sample/cal.rb119
-rw-r--r--sample/fib.py10
-rw-r--r--sample/from.rb1
-rw-r--r--sample/goodfriday.rb35
-rw-r--r--sample/list.rb16
-rw-r--r--sample/mine.rb42
-rw-r--r--sample/rbc.rb8
-rw-r--r--sample/rcs.rb10
-rw-r--r--sample/rename.rb14
-rw-r--r--sample/sieve.rb21
-rw-r--r--sample/test.rb97
-rw-r--r--sample/trojan.rb3
-rw-r--r--sample/uumerge.rb4
-rw-r--r--signal.c131
-rw-r--r--sprintf.c32
-rw-r--r--st.c71
-rw-r--r--st.h2
-rw-r--r--string.c673
-rw-r--r--struct.c157
-rw-r--r--time.c490
-rw-r--r--top.sed14
-rw-r--r--util.c44
-rw-r--r--util.h30
-rw-r--r--variable.c125
-rw-r--r--version.c21
-rw-r--r--version.h6
-rw-r--r--win32/Makefile265
-rw-r--r--win32/config.h43
-rw-r--r--win32/config.status65
-rwxr-xr-xwin32/ntsetup.bat4
-rw-r--r--win32/ruby.def273
-rw-r--r--win32/sdbm.c981
-rw-r--r--win32/sdbm.h84
-rw-r--r--win32/win32.c192
-rw-r--r--win32/win32.h87
156 files changed, 21670 insertions, 18083 deletions
diff --git a/ChangeLog b/ChangeLog
index 6a317e294be..868572c52fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,1838 @@
+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
+ method.
+
+ * io.c (set_outfile): $stdout/$stderr may not be IO now.
+
+ * io.c (set_stdin): $stdin may not be IO now.
+
+ * range.c (rb_range_beg_len): round `end' to length as documented.
+
+ * io.c (Init_IO): preserve original stdin/stdout/stderr.
+
+Thu Aug 12 13:44:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (Init_load): require receives 1 argument.
+
+ * eval.c (frame_dup): should clear tmp to avoid dangling
+ references.
+
+Wed Aug 11 13:33:13 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * eval.c (rb_eval): no automatic aggregate initialization.
+
+ * eval.c (module_setup): ditto.
+
+Wed Aug 11 18:18:41 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * eval.c (yield_under_i): automatic aggregate initialization is an
+ ANSI feature.
+
+Wed Aug 11 10:10:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): parse `[].length==0' as `([].length)==0', not
+ `([].length=)=0'
+
+ * parse.y (yylex): parse `[].length!=0' as `([].length)!=0', not
+ `([].length!)=0'
+
+ * parse.y (peek): peek-in lexical buffer.
+
+Wed Aug 11 00:34:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): bug on backward jump adjustment concerning
+ stop_paren.
+
+Tue Aug 10 14:54:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/nkf/nkf.c (rb_nkf_guess): binary detection was wrong.
+
+Tue Aug 10 00:07:36 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_clone): should use CLONESETUP().
+
+Mon Aug 9 23:57:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h (CLONESETUP): should have copied generic instance
+ variables too.
+
+Mon Aug 9 10:46:54 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/extconf.rb: add check for <arpa/nameser.h> and
+ <resolv.h>.
+
+Sat Aug 7 13:19:06 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * numeric.c (flo_cmp): comparing NaN should not return value.
+ raises FloatDomainError.
+
+Sat Aug 7 03:09:08 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (blk_free): free copied frames too.
+
+ * eval.c (frame_dup): should copy previous frames from stack to
+ heap to preserve frame information.
+
+Fri Aug 6 15:01:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.7 - version 1.4 beta
+
+ * ext/socket/socket.c (s_recv): UDPsocket#recvfrom now returns
+ IPsocket#addr information.
+
+ * array.c (rb_ary_subary): ary[-3,3] should not return nil.
+
+Thu Aug 5 10:58:01 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_mark): protect old ruby_frame from GC during it
+ replaced by eval().
+
+ * eval.c (eval): do not modify frame.prev; binding should preserve
+ information about calling() too.
+
+ * eval.c (rb_yield_0): no arity check for mere yield; but only for
+ Proc#call.
+
+Tue Aug 3 22:07:13 1999 Kazuhiro HIWADA <hiwada@kuee.kyoto-u.ac.jp>
+
+ * object.c (rb_mod_clone): should check if iv_tbl, m_tbl are
+ initialized.
+
+Tue Aug 3 19:03:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_any_cmp): use rb_with_disable_interrupt() to ensure
+ clearance of rb_prohibit_interrupt even on failure.
+
+ * eval.c (rb_with_disable_interrupt): new function added.
+
+Sat Jul 31 23:23:44 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_create_0): set THREAD_RAISED flag on thread
+ termination by exception.
+
+ * eval.c (rb_thread_join): `$!' may not be nil for the threads
+ created in rescue clause.
+
+ * eval.c (rb_thread_status): ditto.
+
+ * eval.c (rb_thread_join): should re-raise exception for already
+ dead threads too.
+
+Fri Jul 30 17:56:54 1999 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
+
+ * object.c (rb_mod_ge): wrong comparison.
+
+Fri Jul 30 12:15:44 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/tcltklib/extconf.rb: win32 support.
+
+ * lib/mkmf.rb: use append_library().
+
+ * ext/extmk.rb.in: ditto.
+
+Fri Jul 30 02:11:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_delete): should return nil for deleting non
+ existing item.
+
+ * io.c (rb_io_close): call rb_sys_wait() on explicit close.
+
+ * 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
+ 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>
+
+ * Makefile.in: add -I$(hdrdir)/lib to install using ftools.
+
+ * util.c: use HAVE_FCNTL_H, not HAVE_FCNTL
+
+Wed Jul 28 18:24:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.6 - version 1.4 alpha
+
+Tue Jul 27 09:38:08 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * eval.c (rb_eval): reduce recursive rb_eval() calls by
+ NODE_BLOCKs.
+
+Tue Jul 27 01:20:40 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * file.c (rb_file_s_expand_path): drive letter patch.
+
+Mon Jul 26 02:36:31 1999 Shugo Maeda <shugo@netlab.co.jp>
+
+ * eval.c (rb_load): should clear ruby_nerr.
+
+ * eval.c (rb_thread_join): oldbt should not be empty to unshift.
+
+Sun Jul 25 12:09:16 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * dir.c (push_braces): should treat nested braces.
+
+Fri Jul 23 02:49:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_hash_clear): dummy argument added; suggested by
+ <eguchi@shizuokanet.ne.jp>. thanks.
+
+Thu Jul 22 19:37:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_join): get_backtrace() may retrun Qnil.
+ typecheck added.
+
+Tue Jul 20 14:36:43 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * range.c (range_each): do not treat String specially (for future
+ override).
+
+Tue Jul 20 02:28:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_gets): $_ should be nil, when get returns nil.
+
+ * io.c (rb_f_gets): ditto.
+
+Mon Jul 19 17:13:09 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_fastmap): should continue fastmap compile
+ for anychar_repeat, for it's repeat anyway.
+
+Mon Jul 26 13:33:45 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * lib/jcode.rb: replaced by faster code.
+
+Mon Jul 19 01:57:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/mkmf.rb: no longer use install program.
+
+ * ext/extmk.rb.in: use miniruby to install programs.
+
+Sat Jul 17 00:06:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (ipaddr): don't do reverse lookup if
+ attribute do_not_reverse_lookup is set for socket classes.
+ Experimental. Note this is a global attribute.
+
+Fri Jul 16 22:18:29 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_eof): use feof() to check EOF already met.
+
+ * io.c (read_all): should return nil at EOF.
+
+Fri Jul 16 13:39:42 1999 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/telnet.rb: version 0.231.
+
+Fri Jul 16 10:58:22 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * regex.c (re_match): debug print removed.
+
+Fri Jul 16 09:58:15 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * many files: clean up unsed variables found by gcc -Wall.
+
+ * lib/mkmf.rb: better cygwin support etc.
+
+ * ext/extmk.rb.in: ditto.
+
+ * instruby.rb: ditto.
+
+Fri Jul 16 01:37:50 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * string.c (rb_str_squeeze_bang): the type of local variable `c'
+ should be int, not char.
+
+ * string.c (rb_str_reverse): should always return copy.
+
+Thu Jul 15 23:25:57 1999 NAKAMURA Hiroshi <nakahiro@sarion.co.jp>
+
+ * lib/debug.rb: better display & frame treatment.
+
+Thu Jul 15 21:16:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_each): returns self for normal termination;
+ returns nil for break.
+
+ * string.c: non bang methods (e.g. String#sub) should always
+ return copy of the receiver.
+
+Thu Jul 15 21:09:15 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+
+ * eval.c (find_file): do not add empty string to the path.
+
+ * configure.in (with-search-path): should not add empty string if
+ the option is not supplied.
+
+Thu Jul 15 17:49:08 1999 Ryo HAYASAKA <hayasaka@univ21.u-aizu.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: move `#include "ruby.h"' forward.
+
+Thu Jul 15 16:54:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.5 - version 1.4 alpha
+
+Wed Jul 14 23:45:33 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * eval.c (ruby_init): initialize for the first time only.
+
+Tue Jul 13 00:15:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_hash_index): re-defined; method to retrieve a key
+ from the value.
+
+ * hash.c (Init_Hash): member? should be re-defined for Hash.
+
+Tue Jul 12 13:54:51 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * io.c (rb_file_sysopen): wrong number of argument.
+
+Mon Jul 12 11:52:35 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_f_missing): class name included in message.
+
+ * eval.c (print_undef): better error message.
+
+Sun Jul 11 05:36:17 1999 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * lib/debug.rb: patch to show proper position.
+
+Fri Jul 9 23:56:14 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * dln.c (dln_find_1): path conv. moved to conv_to_posix_path.
+
+ * dln.c (conv_to_posix_path): path conv. should be done.
+
+Fri Jul 9 10:26:47 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * random.c (RANDOM_NUMBER): should place parentheses.
+
+Fri Jul 8 11:00:51 1999 Shugo Maeda <shugo@netlab.co.jp>
+
+ * numeric.c (fix_div): division may be out of fixnum range.
+
+ * bignum.c (bigdivmod): proper sign calculation to result.
+
+Wed Jul 7 18:27:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * st.c (st_delete_safe): was modifying wrong slot.
+
+Mon Jul 5 13:17:46 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (rb_gc_call_finalizer_at_exit): close all files at exit.
+
+Fri Jul 2 18:00:21 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/Mail/README: Mail-0.3.0 added to the distribution.
+
+Fri Jul 2 01:45:32 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_fastmap): avoid allocation of register
+ variables for each invocation of re_match(). Suggested by
+ Zasukhin Ruslan <ruslan@paradigmasoft.com>. Thanks.
+
+Tue Jun 29 20:39:24 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ext/tk/lib/tk.rb (TkVariable): bug fix; should value type check
+ be added?
+
+ * string.c (rb_str_each_line): a bug in paragraph mode.
+
+ * ruby.c (load_file): shifted too much to skip #!.
+
+Tue Jun 29 06:50:21 1999 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/CGI.rb: 0.30 - cleanup release, incompatible.
+
+ * lib/telnet.rb: 0.22 - timeout added.
+
+Tue Jun 29 10:49:25 1999 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+
+ * configure.in: better Rhapsody support.
+
+ * lib/mkmf.rb: Rhapsody/NEXTSTEP support.
+
+Tue Jun 29 01:42:13 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/pty/pty.c (chld_changed): should use POSIX.1 style wait.
+
+Mon Jun 28 21:07:36 1999 KIMURA Koichi <kbk@kt.rim.or.jp>
+
+ * ext/extmk.rb.nt: wrong result for have_library().
+
+Mon Jun 28 15:24:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * missing/isinf.c: OSF/1 raises SIGFPE on one()/zero().
+
+ * regex.c (re_search): should search til EOS, for patterns may
+ match beyond the end of range.
+
+Mon Jun 28 12:49:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_f_select): should not accept Time objects as an
+ argument for it is time interval.
+
+ * process.c (rb_f_sleep): ditto.
+
+ * file.c (test_s): should return nil for false condition.
+
+Mon Jun 28 12:23:52 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * bignum.c (rb_dbl2big): typo.
+
+ * file.c (rb_f_test): ditto.
+
+ * string.c (rb_str_crypt): wrong message.
+
+Sun Jun 27 19:50:11 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * eval.c (rb_f_exit): should have treat signed integer status, not
+ VALUE.
+
+ * process.c (rb_f_exit_bang): should work like exit().
+
+Sun Jun 27 16:21:32 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * string.c (rb_str_rindex): wrong position to search.
+
+Sat Jun 26 04:05:30 1999 Takaaki Tateishi <ttate@jaist.ac.jp>
+
+ * configure.in (configure_args): --with-search-path to specify
+ additional ruby search path.
+
+ * ruby.c (ruby_prog_init): additional search path.
+
+Fri Jun 25 13:09:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_unpack): needed to initialize natint.
+
+ * regex.c (re_compile_pattern): add start_paren to avoid too much
+ finalization on maybe_finalize_jump.
+
+Fri Jun 25 13:07:20 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
+
+ * missing/isinf.c: include "config.h" added.
+
+Fri Jun 25 07:25:05 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * lib/mkmf.rb: initialize $(topdir).
+
+ * ext/extmk.rb.in (install_rb): install lib/*.rb properly.
+
+ * configure.in (linux): specifies -rpath on --enable-shared.
+
+ * configure.in (aix): ruby.imp must reside in $(topdir).
+
+Thu Jun 24 19:11:29 1999 Yoshida Masato <yoshidam@yoshidam.net>
+
+ * parse.y (rb_str_extend): multi-byte identifier in expression
+ interpolation in strings.
+
+ * parse.y (yylex): support multi-byte char identifiers.
+
+Thu Jun 24 15:27:13 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (f_arg): check duplicate argument names.
+
+ * gc.c (rb_gc_mark): marking wrong member for NODE_ARGS.
+
+ * string.c (rb_str_rindex): POSITION specifies start point, not
+ end point.
+
+Thu Jun 24 13:00:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (print_mbc): wrong boundary.
+
+ * pack.c (uv_to_utf8): raises ArgError for too big value.
+
+Thu Jun 24 11:02:51 1999 Yoshida Masato <yoshidam@yoshidam.net>
+
+ * pack.c (uv_to_utf8): mask needed.
+
+Wed Jun 23 21:03:56 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * ruby.h (struct RFile): remove iv_tbl from struct. instance
+ variables are handled as generic ivs.
+
+Wed Jun 23 22:06:26 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * pack.c (utf8_to_uv): pack to 7 bytes sequence.
+
+ * pack.c (uv_to_utf8): wrong boundary.
+
+ * pack.c (pack_unpack): should treat as unsigned long.
+
+Wed Jun 23 15:10:11 1999 Inaba Hiroto <inaba@sdd.tokyo-sc.toshiba.co.jp>
+
+ * parse.y (parse_string): failed to parse nested braces.
+
+ * parse.y (parse_regx): nested braces within #{} available.
+
+Wed Jun 23 11:18:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (slow_search): wrong shift width for mbcs.
+
+ * eval.c (rb_thread_save_context): should not clear th->locals.
+
+Wed Jun 23 02:06:14 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): UMINUS binds too tight with digits. changed so
+ that -2**2 => -4.
+
+ * parse.y (close_paren): `do' for expr termination now works it
+ used to be.
+
+Wed Jun 22 18:26:42 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * pack.c (pack_pack): should initialize local variable `j'.
+
+Wed Jun 22 15:24:59 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * parse.y (here_document): a bug for multiline heredoc.
+
+Tue Jun 22 15:06:36 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/socket/socket.c (ruby_socket): forgot to return fd
+ explicitly.
+
+Tue Jun 22 13:34:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * rubyio.h (MakeOpenFile): should initialize member `iv_tbl'.
+
+Wed Jun 22 10:35:51 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * io.c (rb_io_gets_internal): getc(3) may not set errno on
+ interrupt.
+
+Mon Jun 21 22:39:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (call_required_libraries): ruby_sourceline should be
+ cleared before loading libraries.
+
+ * io.c (set_stdin): do not use reopen(), so that we don't need to
+ dup original stdin before assigning $stdin.
+
+Mon Jun 21 18:04:27 1999 Ryo HAYASAKA <hayasaka@univ21.u-aizu.ac.jp>
+
+ * ext/dbm/dbm.c: include <cdefs.h> for solaris 2.6.
+
+Mon Jun 21 15:59:47 1999 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/socket/socket.c (ip_addrsetup): forgot to put `else'.
+
+Mon Jun 21 15:38:37 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (fptr_finalize): remove rb_syswait() invocation to avoid
+ wait4(2) within GC. rb_syswait() moved to rb_io_fptr_close().
+
+Mon Jun 21 12:05:59 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * dir.c (dir_s_glob): remove MAXPATHLEN restriction.
+
+ * ext/md5/md5init.c (md5_hexdigest): should have used "%02x".
+
+Sun Jun 20 19:50:38 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * string.c (rb_str_each_line): should have checked string
+ boundary.
+
+Sat Jun 19 22:24:12 1999 Kenji Nagasawa <kenn@hma.att.ne.jp>
+
+ * OS/2 patch improved.
+
+Fri Jun 18 08:30:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (r_byte): add data length check.
+
+ * ext/tcltklib/tcltklib.c (_timer_for_tcl): was doing busy-wait.
+
+Tue Jun 15 10:01:21 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * configure.in: remove trailing slash from interpreter embedded
+ shared library path.
+
+ * configure.in (INSTALL_DLLIB): install shared lib with 0555.
+
+ * instruby.rb: changed mode for shared library into 0555.
+
+Fri Jun 11 23:27:00 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * ext/etc/etc.c (etc_passwd): should return nil, not exception for
+ call after last passwd entry.
+
+Fri Jun 11 15:21:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (rb_gc_mark_locations): add safty margin 1.
+
+ * eval.c (ruby_run): should protect toplevel node tree.
+
+ * ext/etc/etc.c (etc_group): dumps core if there's no more group.
+
+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.
+
+Thu Jun 10 16:41:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c: do not call `initialize' for IO objects. So with Array,
+ Hash, Range, and Time objects.
+
+ * ext/curses/curses.c (curses_getch): made thread aware using
+ rb_read_check().
+
+ * ext/curses/curses.c (window_getch): ditto.
+
+ * ext/curses/curses.c (curses_getstr): made (partially) thread
+ aware using rb_read_check().
+
+ * ext/curses/curses.c (window_getstr): ditto.
+
+ * io.c (rb_read_check): new function to help making something
+ (like extension libraries) thread aware.
+
+ * eval.c (is_defined): `defined? super' should be true even for
+ private superclass methods.
+
+Fri Jun 10 13:42:10 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * pack.c (pack_pack): template `Z' should be allowed.
+
+Wed Jun 9 13:26:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_loading): modified to avoid nested race
+ condition of require().
+
+ * ext/tcltklib/tcltklib.c (ip_invoke): queue invocation on non
+ main threads.
+
+ * ext/tcltklib/tcltklib.c (lib_mainloop): flush invocation
+ queues periodically.
+
+ * version.c (ruby_show_version): now print the message to stdout.
+
+ * version.c (ruby_show_copyright): ditto.
+
+Tue Jun 8 00:00:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_unpack): append sentinel (NUL) to the string.
+
+ * ext/md5/md5init.c (md5_hexdigest): new method to obtain
+ printable hash string.
+
+ * ext/md5/md5init.c (md5_update): should return self.
+
+ * pack.c (pack_pack): undocumented template 'U' for UTF8.
+
+ * pack.c (pack_unpack): ditto.
+
+ * marshal.c (r_byte): should replace getc() with rb_getc().
+
+ * io.c (rb_getc): getc() replacement uses READ_DATA_PENDING() and
+ rb_thread_wait_fd().
+
+Mon Jun 7 23:23:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (rb_mod_clone): should call CLOSESETUP().
+
+ * eval.c (bind_clone): should call CLONESETUP() for new clone.
+
+Sat Jun 5 10:32:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_oct): binary (e.g. 0b10111) support.
+
+ * variable.c (rb_const_set): raise warning, not exception.
+
+ * parse.y (yycompile): initialize parser internal variables.
+
+ * parse.y (close_paren): set lex_state to EXPR_PAREN after closing
+ parenthesis.
+
+ * parse.y (yylex): returns kDO for `do' right after method_call.
+
+Thu Jun 3 11:05:30 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * regex.c (read_backslash): should decode \b within class.
+
+Thu Jun 3 01:06:18 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * dln.c (dln_load): AIX improvement (aix_findmain removed).
+
+Wed Jun 2 00:41:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_unpack): new undocumented template Z which strips
+ stuff after first null.
+
+ * pack.c (pack_pack): should preserve specified length of the
+ resulting string.
+
+Tue Jun 1 15:29:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (ruby_socket): retry after GC, if socket(2)
+ failed on EMFILE or ENFILE.
+
+ * ext/socket/socket.c (sock_s_socketpair): ditto.
+
+ * 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 detection.
+
+Sun May 30 22:19:12 1999 Kenji Nagasawa <kenn@tcp-ip.or.jp>
+
+ * ext/socket/socket.c: emx/gcc 0.9d now fixes things about
+ AF_UNIX.
+
+ * process.c: OS/2 EMX kludge.
+
+ * Makefile.in (strncasecmp.o): added dependency.
+
+Mon May 31 16:06:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.4 - preliminary release for 1.4
+
+Mon May 31 15:57:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_fptr_close): close on IO which main_thread is
+ waiting cause serious exception, that vanishes the actual fd
+ closing. Invocation of rb_thread_fd_close() is deferred
+ a little.
+
+Sat May 29 18:27:13 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * regex.c (re_match): stack boundary check needed.
+
+Sat May 29 12:27:00 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/tcltklib/tcltklib.c (ip_invoke): proper ref count management
+ to avoid leak. I HATE REF COUNTING!!
+
+ * eval.c (ruby_run): moved ruby_require_libraries() to handle `-r'
+ from ruby_options() to avoid stack corruption for threads
+ created in libraries.
+
+Sat May 29 02:22:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_yield_0): when `for' appeared in blocks, it
+ introduced new scope for local variables.
+
+Fri May 28 17:16:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_squeeze_bang): squeeze AND of the arguments.
+ UNDOCUMENTED.
+
+ * string.c (rb_str_count): new UNDOCUMENTED method.
+
+ * string.c (rb_str_delete_bang): delete AND of the arg ranges.
+ UNDOCUMENTED FEATURE for 1.3.x.
+
+ * ext/socket/socket.c (setipaddr): re-wrote using ip_addrsetup().
+
+ * ext/sockt/socket.c (ip_addrsetup): decode symbolic address
+ <broadcast>.
+
+Thu May 27 12:27:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (tr_trans): should handle NUL (\0) within strings.
+
+Tue May 25 16:45:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_f_syscall): syscall may return values other than zero
+ on success.
+
+ * regex.c (re_match): handle empty loop properly (hopefully).
+
+ * regex.c (re_match): remove empty group check, because it does
+ not help non-grouping parentheses (?:..).
+
+ * regex.c (re_compile_fastmap): treating try_next, finalize_push
+ wrong way.
+
+ * regex.c: remove some obsolete functions such as
+ group_match_null_string_p().
+
+Mon May 24 14:47:54 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (read_backslash): read backslash by regex.
+
+Sun May 23 19:44:58 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/pty/pty.c (getDevice): portability patch.
+
+Fri May 21 23:01:26 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/getaddrinfo.c (GET_AI): should set error code.
+
+Thu May 20 03:43:44 1999 Jun-ichiro itojun Hagino <itojun@itojun.org>
+
+ * ext/socket/socket.c: you should use sockaddr_storage to handle
+ IPv6 addresses.
+
+ * ext/socket/getaddrinfo.c (getaddrinfo): prevent retrieving
+ AF_INET6 address if hints.ai_flags == AI_PASSIVE.
+
+Wed May 19 12:27:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (exec_end_proc): should protect exceptions.
+
+ * gc.c (run_final): ditto.
+
+ * parse.y (f_rest_arg): allow just * for rest arg.
+
+ * parse.y (mlhs_basic): allow * without formal argument.
+
+ * regex.c (re_match): the variable `part' should be initialized.
+
+Tue May 18 15:25:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): a bug in range adjustment.
+
+Tue May 18 11:35:59 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * dln.c (conv_to_posix_path): path_len argument added.
+
+Mon May 17 12:26:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (fix_rev): should treat Fixnum as signed long.
+
+ * eval.c (massign): add strict number check for yield (and call).
+
+ * eval.c (proc_arity): new method to return number of arguments.
+
+ * eval.c (method_arity): new method to return number of arguments.
+
+ * parse.y (read_escape): char may be unsigned.
+
+ * string.c (rb_str_succ): ditto.
+
+ * string.c (tr_trans): ditto.
+
+ * object.c (Init_Object): methods `&', `|', `^' are added to nil.
+
+ * range.c (rb_range_beg_len): it should be OK for [0..-len-1].
+
+ * regex.c (re_search): search for byte literal within mbcs.
+
+ * regex.c (is_in_list): parsh
+
+ * regex.c (re_compile_fastmap): should have not alter the loop
+ variable `j' if TRASLATE_P().
+
+ * regex.c (re_compile_pattern): escaped characters should be read
+ by PATFETCH_RAW(c).
+
+Sat May 15 11:23:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): endline2 (\Z) should not match at the point
+ between a newline and end-of-line, like endline ($).
+
+ * class.c (include_class_new): should initialize iv_tbl to share
+ between module and iclass.
+
+Fri May 14 08:50:27 1999 Akira Endo <akendo@t3.rim.or.jp>
+
+ * regex.c (re_compile_fastmap): it should be k != 0 to skip.
+
+Fri May 14 12:46:56 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_load): a bug in old marshal format support.
+
+ * instruby.rb: make site_ruby directory.
+
+Fri May 14 10:18:02 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * regex.c (re_match): a bug in inline `.*' etc.
+
+Fri May 14 09:58:46 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * ruby.c (addpath): should have specified string length.
+
+Thu May 13 10:40:44 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval_string_wrap): new function.
+
+ * regex.c (re_compile_pattern): POSIX line match should alter
+ behavior for `^' and `$' to begbuf and endbuf2 respectively.
+
+ * ext/pty/pty.c: un-ANSI-fy function arguments.
+
+Wed May 12 14:19:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * struct.c (iv_get): in case of inheritance of generated struct
+ class, __member__ and __size__ should also be inherited.
+ Thanks for Pros Yeboah <yeboah@tu-harburg.de>.
+
+ * io.c (rb_f_gets_internal): should check number of arguments
+ before checking rb_rs == rb_default_rs. Thanks for Koji Arai
+ <JCA02266@nifty.ne.jp>.
+
+Tue May 11 08:29:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): .?, .+ did not work.
+
+Mon May 10 00:59:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/jcode.rb: forgot to squeeze on reverse (complement) case.
+
+ * string.c (tr_squeeze): should not set modify flag to be honest,
+ if the string is not modified.
+
+ * signal.c (Init_signal): SIGTERM should not be handled.
+
+ * regex.c (re_match): seeking for longest match is now optional,
+ which can be set using RE_OPTION_POSIXMATCH. This satisfies
+ POSIX longest match as much as Emacs's posix-* functions, which
+ are known to be incomplete.
+
+Sun May 9 13:04:01 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/socket.c (sock_s_getaddrinfo): conversion from
+ Fixnums to C integers needed.
+
+Sun May 9 11:51:43 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * range.c (range_eqq): reverse condition.
+
+ * range.c (range_s_new): default should be end inclusive.
+
+Sat May 8 03:27:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (thread_connect): replace nasty
+ rb_thread_fd_writable() with rb_thread_select().
+
+Fri May 7 20:49:00 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/getaddrinfo.c (inet_pton): wrong parameter to
+ inet_aton().
+
+ * ext/socket/addrinfo.h (__P): silly cut and paste typo.
+
+Fri May 7 17:03:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * dir.c (glob): removed GPL'ed glob.c completely.
+
+Fri May 7 08:17:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/sdbm/extconf.rb: sdbm extension added to the distribution.
+
+Fri May 7 01:42:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (tcp_s_gethostbyname): aboid using struct
+ sockaddr_storage.
+
+Thu May 6 13:21:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_indexes): should not use rb_ary_concat().
+
+Thu May 4 12:34:18 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * parse.y (parse_string): there shuould be newline escape by
+ backslashes in strings.
+
+ * parse.y (parse_qstring): ditto.
+
+Mon May 3 04:37:20 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ext/tcltklib/extconf.rb: better search for libX11.
+
+ * range.c (range_s_new): embarrassing =/== typo.
+
+ * re.c (Init_Regexp): failed to set default kcode.
+
+Mon May 3 02:39:55 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * ext/socket/socket.c (open_inet): typo (res and res0).
+
+Tue May 4 02:07:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * mkconfig.rb: leave undefined $(VARIABLE) unexpanded in the
+ Config::CONFIG hash table.
+
+Mon May 3 09:37:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): expand exactn{n} at compile time.
+ handles stop_paren specially.
+
+ * regex.c (re_compile_pattern): expand x{n} at compile time.
+
+ * regex.c (re_search): posix line match should be checked.
+
+ * regex.c (re_search): a bug in anchor condition.
+
+Fri Apr 30 18:57:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.3
+
+ * string.c (rb_str_rindex): position should be END point, not
+ START point.
+
+ * re.c (rb_reg_search): pos means end point on reverse now.
+
+ * array.c (rb_ary_s_create): should clear ary->ptr to avoid
+ potential gc crash.
+
+Fri Apr 30 15:24:58 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/addrinfo.h: compatibility hack for ipv4.
+
+ * ext/socket/socket.c: itojun's ipv6 patches applied.
+
+ * ext/socket/extconf.rb: detect ipv6 features based on itojun's
+ ipv6 patches.
+
+ * ext/extmk.rb.in (enable_config): can handle --enable-xxx now.
+
+ * lib/mkmf.rb (enable_config): ditto.
+
+Fri Apr 30 05:22:23 1999 Shugo Maeda <shugo@netlab.co.jp>
+
+ * string.c (rb_str_aset): last index should not append.
+
+Thu Apr 29 18:55:31 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * dln.c (conv_to_posix_path): remove const from args.
+
+ * ruby.c (rubylib_mangle): remove Fatal(), the obsolete function.
+
+Tue Apr 27 14:11:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (fname): lazy workaround for keywords did not work well.
+
+ * ext/extmk.rb.in: `--with-xxx=yyy' argument configuration.
+
+ * lib/mkmf.rb: ditto.
+
+ * misc/ruby-mode.el: forgot to handle $`.
+
+ * ext/extmk.rb.in: better AIX link support proposed by
+ <komatsu@sarion.co.jp>.
+
+Mon Apr 26 16:46:59 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/extmk.rb.in: AIX shared library support modified.
+
+ * ext/aix_mksym.rb: ditto.
+
+ * configure.in: ditto.
+
+ * sprintf.c (rb_f_sprintf): should allocate proper sized buffer
+ for float numbers.
+
+Sat Apr 24 00:00:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (operation): syntax like `a.[]=(1,2)' is allowed.
+
+Fri Apr 23 23:54:09 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (argf_binmode): binmode method added to ARGF.
+
+Fri Apr 23 13:55:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_f_chomp): should assign the result to $_. or maybe
+ sub/gsub/chop/chomp should NOT assign $_ altogether.
+
+Thu Apr 22 16:50:54 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_callcc): call scope_dup() for all scopes in
+ the interpreter stack.
+
+Tue Apr 20 11:24:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_dump): `#' should be escaped.
+
+Tue Apr 20 02:32:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (parse_regx): option /p for posix match added.
+
+ * re.c (rb_reg_desc): did not print options properly.
+
+ * io.c (rb_file_s_open): intialize was called twice.
+
+Mon Apr 19 18:56:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * configure.in (DEFAULT_KCODE): can specify default code for
+ $KCODE by --with-default-kcode=(euc|sjis|utf8|none).
+
+ * regex.c (IS_A_LETTER): a byte sequence shorter than mbc should
+ not match with \w etc.
+
+Mon Apr 19 13:49:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (eval): should restore ruby_dyna_vars.
+
+Fri Apr 16 21:40:43 1999 Nobuyoshi Nakada <gea02117@nifty.ne.jp>
+
+ * io.c (f_backquote): pipe_open may return nil.
+
+ * io.c (f_open): rb_io_open may return nil.
+
+ * io.c (io_s_foreach): ditto.
+
+ * io.c (io_s_readlines): ditto.
+
+ * io.c (io_defset): wrong message.
+
+Fri Apr 16 15:09:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (rb_str2inum): strtoul() returns long, not int.
+
+ * eval.c (rb_load): size of VALUE and ID may be different.
+
+ * util.c (mmprepare): int is too small to cast from pointers.
+
+ * config.guess: avoid 'linux-gnu' for alpha-unknown-linux.
+
+Thu Apr 15 23:46:20 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ruby.c (rubylib_mangle): mangle path by RUBYLIB_PREFIX.
+
+Wed Apr 14 23:52:51 1999 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+
+ * node.h (NODE_LMASK): should be long to avoid overflow.
+
+Wed Apr 14 13:14:35 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * dln.c: AIX dynamic link.
+
+ * ext/aix_ld.rb: ditto.
+
+Wed Apr 14 12:19:09 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/thread.rb: Queue#{enq,deq} added.
+
+Tue Apr 13 17:43:56 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_hash_s_create): Hash::[] acts more like casting.
+
+Tue Apr 13 00:33:52 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_stdio_set): warning for assignment to the variables
+ $std{in,out,err}.
+
+Mon Apr 12 23:12:32 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_reopen): check for reopening same IO.
+
+Fri Apr 9 17:45:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (rb_compile_string): bug for nested eval().
+
+ * regex.c (re_match): should pop non-greedy stack items on
+ failure, after best_regs are fixed.
+
+Thu Apr 8 17:30:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (PACK_LENGTH_ADJUST): need to adjust for `*' length.
+
+Tue Apr 6 23:28:44 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (void_check): add void context checks.
+
+Mon Apr 5 12:23:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_s_at): should copy gmt-mode.
+
+ * eval.c (eval_node): preserve ruby_eval_tree.
+
+Fri Apr 2 14:00:34 1999 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * lib/debug.rb: wrong command interpreting.
+
+Fri Apr 2 11:46:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.2
+
+Fri Apr 2 10:40:04 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_s_pipe): forgot to define IO::pipe.
+
+Thu Apr 1 14:40:46 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (assign): modified for rhs change.
+
+ * parse.y (stmt): unparenthesisized method calls can be right hand
+ side expression of the assignment.
+
+Sat Mar 27 22:42:47 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ext/nkf/nkf.c (rb_nkf_kconv): check size output_ctr before
+ decrement.
+
+Thu Mar 25 09:11:03 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_s_at): preserve gmt-mode for result.
+
+ * parse.y (rb_compile_string): do not use cur_mid, use
+ compile_for_eval instead.
+
+ * st.c (PTR_NOT_EQUAL): wrong logical condition.
+
+Wed Mar 24 13:06:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yycompile): should clear cur_mid after compilation.
+
+ * io.c (next_argv): need to check type for ARGV.shift.
+
+ * eval.c (blk_copy_prev): need to preverse outer scope as well as
+ outer frames.
+
+ * parse.y (rb_compile_string): return can appear within eval().
+
+Tue Mar 23 10:15:07 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * configure.in: AC_C_CONST check added.
+
+Tue Mar 23 02:07:35 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_plus): preserve gmt-mode for result.
+
+Mon Mar 22 01:32:37 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): adjust line numbers before expression
+ interpolation within strings.
+
+ * eval.c (rb_eval): defined? returns nil for false condition.
+
+ * numeric.c (num_nonzero_p): returns nil for false condition.
+
+Sat Mar 20 13:07:43 1999 Keiju Ishitsuka <keiju@rational.com>
+
+ * lib/weakref.rb: avoid leak for two weakrefs for one object.
+
+Fri Mar 19 11:26:45 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * eval.c (ruby_run): needed to eval END{} on exit.
+
+ * eval.c (rb_exit): ditto.
+
+Fri Mar 19 02:17:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * signal.c (Init_signal): handles terminating signals HUP, TERM,
+ QUIT, PIPE, etc.
+
+Thu Mar 18 15:47:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (rb_big_and): bug in sign calculation.
+
+ * bignum.c (rb_big_or): ditto.
+
+ * io.c (rb_f_select): forgot to use to_io to retrieve IO, after
+ calling select(2).
+
+Tue Mar 16 19:54:31 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/extmk.rb.in: static linking cause infinite make loop.
+
+Tue Mar 16 18:50:04 1999 Yoshida Masato <yoshidam@yoshidam.net>
+
+ * ext/socket/socket.c (tcp_s_gethostbyname): typo, not NUM2INT(),
+ but INT2NUM().
+
+ * ext/socket/socket.c (mkhostent): ditto.
+
+Tue Mar 16 12:31:44 1999 Ryo HAYASAKA <hayasaka@cheer.u-aizu.ac.jp>
+
+ * file.c (utime_internal): suppress warning by const.
+
+ * time.c (time_gmtime): ditto.
+
+Tue Mar 16 10:23:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_clone): Time object can be cloned.
+
+Tue Mar 16 03:13:10 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ruby.c (load_file): argv[argc] should be NULL.
+
+Mon Mar 15 22:12:08 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * sprintf.c (rb_f_sprintf): typo in arg_num check at exit.
+
+Mon Mar 15 16:42:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_dup): dup2 should copy class too.
+
+Mon Mar 15 15:12:53 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+
+ * lib/mkmf.rb: install program relative path check.
+
+Mon Mar 15 14:05:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_s_new): 2nd argument is now option.
+ Regexp::EXTENDED can be specified.
+
+Fri Mar 12 10:47:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_index): str.index("") should always match at
+ offset point.
+
+ * string.c (rb_str_upto): can specify end point exclusion.
+
+ * string.c (rb_str_index): negative offset.
+
+ * regex.c (re_match): begline should not match at the point
+ between a newline and end-of-string. endline neither.
+
+ * regex.c (re_compile_pattern): context_indep_anchors .
+
+ * parse.y (parse_regx): need not to push backslashes before
+ escaped characters.
+
+ * eval.c (rb_thread_join): re-raises exception within target.
+
+Fri Mar 12 01:09:36 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ext/readline/readline.c (readline_s_vi_editing_mode): wrong
+ number of arguments.
+
+Fri Mar 12 02:12:50 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (PACK_ITEM_ADJUST): "a".unpack("C3") => [97, nil, nil]
+
+Thu Mar 11 18:23:50 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * ext/socket/socket.c (Init_socket): UDPsocket was ommited.
+
+Thu Mar 11 16:43:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (PACK_LENGTH_ADJUST): push fixed number of items per
+ template to result array.
+
+ * pack.c (pack_unpack): I/N/C etc. push nil in the array for "".
+
+Tue Mar 9 00:19:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (ruby_unsetenv): use ruby_setenv(name, 0).
+
+ * hash.c (env_delete): ditto.
+
+ * string.c (rb_str_upto): do not check `beg<end' to generate
+ strings for the pattern like "a".upto("#a").
+
+ * range.c (range_each): treat strings as special case.
+
+ * range.c (range_each): no longer use upto for generic cases.
+
+Sun Mar 7 14:21:32 1999 IKARASHI Akira <ikarashi@itlb.te.noda.sut.ac.jp>
+
+ * string.c (rb_str_index): wrong end point calculation.
+
+Sat Mar 6 02:19:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (match_index): MatchingData#index(n) added.
+
+ * array.c (rb_ary_subseq): ary[n..-1] returns an sub-array unless
+ n is too small negative index.
+
+ * re.c (rb_reg_match_method): Regexp#match(str) added.
+
+ * array.c (rb_ary_indexes): understands ranges as indexes.
+
+ * re.c (match_size): MatchingData#size added.
+
+Fri Mar 5 01:04:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_fill): modified for range.
+
+ * array.c (rb_ary_aset): a[n..m] revisited.
+
+Thu Mar 4 14:23:29 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_subseq): a[n..m] revisited.
+
+ * parse.y (method_call): allow Const::method{}.
+
+ * array.c (rb_ary_replace_method): should replace original array.
+
+Thu Mar 4 02:30:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * configure.in: remove --disable-thread, thread feature is no
+ longer optional.
+
+Thu Mar 4 00:32:17 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+
+ * parse.y (read_escape): wrong arguments for scan_oct,scan_hex.
+
+Wed Mar 3 11:51:53 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (Init_socket): rename class names as
+ TCPsocket -> TCPSocket etc.
+
+Tue Mar 2 19:46:42 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * configure.in (LDSHARED): use gcc -Wl,-G for solaris with gcc.
+
+Tue Mar 2 17:04:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): backslashes do not concatenate comment lines
+ anymore.
+
+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.
+
+Sun Feb 28 14:04:07 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * parse.y (nextc): backslash at the eof cause infinite loop
+
+Sun Feb 28 11:01:26 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * time.c (make_time_t): month range check added.
+
+Sat Feb 27 02:36:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (Init_Regexp): add escape as alias of quote.
+
+ * re.c (rb_reg_s_quote): char-code can be specified now.
+
+Fri Feb 26 18:45:36 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+
+ * eval.c (error_print): bug for error message with newlines.
+
+Fri Feb 26 12:00:04 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (make_time_t): future check modified to allow 1969-12-31
+ at certain timezone.
+
+ * time.c (time_arg): year >= 1000 should be past.
+
+ * version.c (Init_version): constant RELEASE_DATE added.
+
+Fri Feb 26 01:08:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_substr): returns nil for out-of-range access.
+
+ * array.c (rb_ary_subseq): returns nil for out-of-range access.
+
+ * array.c (rb_ary_store): negative index message has changed.
+
+ * string.c (rb_str_aset): reallocation needed.
+
+ * string.c (rb_str_aset): allow char append to the string.
+
+Thu Feb 25 23:30:17 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * time.c (time_load): tm_year should be packed in 17 bits, not 18.
+
+Thu Feb 25 12:50:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * missing/dup2.c: replaced by public domain version.
+
+ * time.c (make_time_t): add `future check' in loops.
+
+ * object.c (rb_num2dbl): forbid implicit conversion from nil, or
+ strings. thus `Time.now + str' should raise error.
+
+ * object.c (rb_Float): convert nil into 0.0.
+
+ * object.c (rb_Integer): conversion method improved.
+
+Thu Feb 25 03:27:50 1999 Shugo Maeda <shugo@netlab.co.jp>
+
+ * eval.c (rb_call): should handle T_ICLASS properly.
+
+Thu Feb 25 00:04:00 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * error.c (Init_Exception): global function Exception() removed.
+
+ * variable.c (rb_class2name): returns "nil"/"true"/"false" for them.
+
+ * time.c (time_dump): time marshaling format compressed size from
+ 11 bytes to 8 bytes. thanx to tadf@kt.rim.or.jp.
+
+ * eval.c (rb_obj_call_init): should specify arguments explicitly.
+
+Wed Feb 24 15:43:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): comment concatenation requires preceding space
+ before backslash at the end of line.
+
+ * io.c (rb_f_pipe): global pipe is obsolete now.
+
+ * object.c (Init_Object): remove true.to_i, false.to_i.
+
+Tue Feb 23 14:21:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): warn if identifier! immediately followed by `='.
+
+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 (find_file): tilde expandion added.
+
+Tue Feb 23 10:50:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (require_method): require can handle multiple fnames.
+
+ * hash.c (rb_hash_foreach_iter): hash key may be nil.
+
+Mon Feb 22 17:44:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): should not pop failure point on success for
+ non-greedy matches.
+
+ * io.c (Init_IO): remove global_functions getc, readchar, ungetc,
+ seek, tell, rewind.
+
+Sat Feb 20 22:54:26 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (rb_num2long): no implicit conversion from boolean.
+
+Sat Feb 20 09:58:42 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * numeric.c (flo_to_s): portable Infinity and NaN support.
+
+Sat Feb 20 07:13:31 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * io.c (rb_file_sysopen): forgot to initialize a local variable.
+
+Fri Feb 19 23:05:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_subseq): range check changed.
+
+ * marshal.c: increment MARSHAL_MINOR for Time format change.
+
+ * time.c (time_old_load): support old marshal format.
+
+ * time.c (time_load): changed for new format Y/M/D/h/m/s/usec.
+
+ * time.c (time_dump): marshal dump format has changed.
+
+Fri Feb 19 00:25:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_arg): should reject "sep\0" and such.
+
+ * time.c (time_plus): Time#+ should not receive Time object
+ operand.
+
+ * string.c (rb_str_substr): nagative 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.
+
+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 (rb_strftime): zero length format.
+
+ * time.c (time_to_a): yday start with 1 now.
+
+ * time.c (time_zone): support for long timezone name.
+
+ * time.c (time_yday): yday start with 1 now.
+
+ * time.c (time_minus): minus calculation was wrong.
+
+ * time.c (time_minus): sec, usec should be at least `long', maybe
+ they should be `time_t'.
+
+ * time.c (time_plus): addition with float was wrong.
+
+ * time.c (time_to_s): support for long timezone name.
+
+ * time.c (time_gm_or_local): too far future check moved.
+
+ * time.c (time_arg): treat 2 digit year as 69-99 => 1969-1999,
+ 00-68 => 2000-2068
+
+Thu Feb 18 03:56:47 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * missing/fnmatch.c: moved to missing directory.
+
+Wed Feb 17 16:22:26 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * struct.c (rb_struct_alloc): actual initialization now be done in
+ `initialize'.
+
+Wed Feb 17 09:47:15 1999 okabe katsuyuki <hgc02147@nifty.ne.jp>
+
+ * regex.c (re_search): use mbclen() instead of ismbchar().
+
+ * re.c (rb_reg_s_quote): should handle mbchars properly.
+
+Wed Feb 17 01:25:26 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): stop comment concatenation by backslash follows
+ after >= 0x80 char. may cause problem with Latin chars.
+
+ * eval.c (error_print): exception in rb_obj_as_string() caused
+ SEGV. protect it by PUSH_TAG/POP_TAG.
+
+ * error.c (exc_exception): `Exception#exception' should return self.
+
+Wed Feb 17 01:12:22 1999 Hirotaka Ichikawa <hirotaka.ichikawa@tosmec.toshiba.co.jp>
+
+ * configure.in: BeOS patch.
+
+Tue Feb 16 14:25:00 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): should reallocate mbc space for
+ character class unless current_mbctype is ASCII.
+
+Mon Feb 15 15:48:30 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * configure.in: specify `-Wl,-E' only for GNU ld.
+
+Mon Feb 15 11:43:22 1999 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
+
+ * array.c (rb_inspecting_p): should return Qfalse.
+
+Sun Feb 14 22:36:40 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * sprintf.c (rb_f_sprintf): `%G' was ommited.
+
+Sun Feb 14 12:47:48 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * numeric.c (Init_Numeric): allow divide by zero on FreeBSD.
+
+ * numeric.c (Init_Numeric): FloatDomainError added.
+
+ * configure.in (AC_REPLACE_FUNCS): add checks for functions
+ insinf, isnan, and finite.
+
+Sat Feb 13 01:24:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_create_0): should protect th->thread.
+
+Fri Feb 12 16:16:47 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+
+ * string.c (rb_str_inspect): wrong mbc position.
+
+Fri Feb 12 16:21:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_fd_close):
+
+ * io.c (rb_io_fptr_close): tell scheduler that fd is closed.
+
+ * io.c (rb_io_reopen): ditto.
+
+ * io.c (READ_CHECK): check if closed after thread context switch.
+
+ * ext/socket/socket.c (bsock_close_read): do not check
+ the return value from shutdown(2).
+
+ * ext/socket/socket.c (bsock_close_write): ditto.
+
+ * ext/socket/socket.c (sock_new): need to dup(fd) for close_read
+ and close_write.
+
+ * parse.y (here_document): handle newlines within #{}.
+
+ * regex.h: should replace symbols for ruby.
+
+Fri Feb 12 00:46:28 1999 Shugo Maeda <shugo@netlab.co.jp>
+
+ * marshal.c (r_object): should update the method name in message.
+
+ * marshal.c (w_object): limit should be converted into Fixnum.
+
+Wed Feb 10 15:20:03 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): empty pattern should not cause infinite
+ pattern match loop.
+
+ * regex.c (re_compile_pattern): RE_OPTIMIZE_ANCHOR for /.*/, not
+ for /(.|\n)/.
+
+ * numeric.c (fix_pow): `fixnum**nil' should raise TypeError.
+
+ * bignum.c (rb_big_pow): need to normalize results.
+
+Wed Feb 10 01:42:41 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * numeric.c (fix_pow): `(5**1).type' should be Integer.
+
+Tue Feb 9 01:22:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): do not ignore newlines in mbchars.
+
+ * io.c (rb_file_s_open): mode can be specified by flags like
+ open(2), e.g. File::open(path, File::CREAT|File::WRONLY).
+
+ * io.c (rb_f_open): bit-wise mode flags for pipes
+
+ * io.c (Init_IO): bit flags for open.
+
+Sat Feb 6 22:56:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_sub_bang): should not overwrite match data by
+ regexp match within the block.
+
+ * string.c (rb_str_gsub_bang): ditto.
+
+Sat Feb 6 03:06:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (match_getter): accessng $~ without matching caused SEGV.
+
+Fri Feb 5 22:11:08 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * parse.y (yylex): binary literal support, like 0b01001.
+
+ * parse.y (yylex): octal numbers can contain `_'s.
+
+ * parse.y (yylex): warns if non-octal number follows immediately
+ after octal literal.
+
+ * parse.y (yylex): now need at least one digit after prefix such
+ as 0x, or 0b.
+
+ * bignum.c (rb_str2inum): recognize binary numbers like 0b0101.
+
+Fri Feb 5 03:26:56 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+
+ * ruby.c (proc_options): -e without program prints error.
+
+Fri Feb 5 00:01:50 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (terms): needed to clear heredoc_end.
+
+ * numeric.c (flo_div): allow float division by zero.
+
+Thu Feb 4 11:56:24 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * missing/strtod.c: for compatibility.
+
+ * configure.in (strtod): add strtod compatible check.
+
+ * numeric.c (rb_num2long): missing/vsnprintf.c does not supprt
+ floating points.
+
+ * numeric.c (flo_to_s): ditto.
+
+Wed Feb 3 23:02:12 1999 Yoshida Masato <yoshidam@yoshidam.net>
+
+ * regex.c (re_compile_pattern): use ismbchar() to get next char.
+
+ * regex.c (re_search): wrong mbchar shift.
+
+ * re.c (rb_reg_search): needed to reset $KCODE after match.
+
+ * regex.c (re_compile_fastmap): mbchars should match with \w.
+
+Wed Feb 3 22:35:12 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * parse.y (yylex): too big float raise warning, not error.
+
+Tue Feb 2 23:41:42 1999 Yoshida Masato <yoshidam@yoshidam.net>
+
+ * regex.c (re_match): wrong boundary.
+
+ * regex.c (IS_A_LETTER): re_mbctab[c] may not be 1 for mbc.
+
+ * regex.c (re_search): mbchar support for shifting ranges.
+
+ * regex.c (MBC2WC): wrong conversion.
+
+Wed Feb 3 15:03:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (parse_regx): need to escape parens if terminators are
+ not any kind of parenthesis.
+
+ * parse.y (parse_qstring): ditto.
+
+ * parse.y (parse_string): ditto.
+
+Tue Feb 2 17:11:26 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * string.c (rb_str_gsub_bang): too small realoc condition.
+
+Mon Feb 1 10:01:17 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * parse.y (yylex): range check for the float literal.
+
+Sat Jan 30 18:34:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (usage): -h option to show brief command description.
+
+Sat Jan 30 08:45:16 1999 IKARASHI Akira <ikarashi@itlb.te.noda.sut.ac.jp>
+
+ * lib/cgi-lib.rb: cookie support added.
+
+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.
+
+ * regex.c (re_match): \w should match with multi byte characters,
+ not its first byte.
+
+Sat Jan 30 10:06:41 1999 Yoshida Masato <yoshidam@yoshidam.net>
+
+ * re.c (rb_reg_s_new): UTF-8 flag handle (/u, /U).
+
+ * re.c (rb_kcode): $KCODE handle for UTF-8.
+
+Sat Jan 30 01:51:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_delete_if): RTEST() missing.
+
+ * hash.c (delete_if_i): ditto.
+
+ * enum.c (Init_Enumerable): select (=find_all), detect (=find)
+ added as aliases.
+
+Fri Jan 29 21:32:19 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * hash.c (rb_f_setenv): SEGV caused by small typo.
+
+Fri Jan 29 00:15:58 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/parsedate.rb (parsedate): support date format like
+ 23-Feb-93, which is required by HTTP/1.1.
+
+ * variable.c (find_class_path): avoid calling rb_iv_set().
+
+ * eval.c (backtrace): do not need to modify $SAFE internally.
+
+ * variable.c (classname): inline __classid__ access.
+
+ * eval.c (THREAD_ALLOC): needed to initialize wrapper.
+
+ * lib/ftools.rb (makedirs): allows slash at the end of the path.
+
+ * numeric.c (rb_fix_induced_from): ensure result to be Fixnum.
+
+Thu Jan 28 17:31:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (flo_to_s): float format changed to "%16.10g".
+
+Thu Jan 28 02:13:11 1999 Yoshinori Toki <toki@freedom.ne.jp>
+
+ * array.c (rb_ary_store): expand allocated buffer by 3/2.
+
+Wed Jan 27 17:50:02 1999 Kazuhiro HIWADA <hiwada@kuee.kyoto-u.ac.jp>
+
+ * bignum.c (dbl2big): raised error if double is too big to cast
+ into long. check added.
+
+Wed Jan 27 03:16:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_mod_const_at): can't list constants of the
+ untainted objects in safe mode.
+
+ * class.c (method_list): can't list methods of untainted objects
+ in safe mode.
+
+Tue Jan 26 02:40:41 1999 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
+
+ * prec.c: Precision support for numbers.
+
+Thu Jan 21 19:08:14 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_f_raise): calls `exception' method, not `new'.
+
+ * error.c (exc_exception): renamed from `new'.
+
Wed Jan 20 03:39:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y (yycompile): rb_in_compile renamed to ruby_in_compile.
@@ -14,7 +1849,7 @@ Tue Jan 19 05:01:16 1999 Koji Arai <JCA02266@nifty.ne.jp>
* array.c (beg_len): round range value too much.
-Mon Jan 18 13:02:27 1999 Kuroda Jun <jkuro@dwe.co.j>
+Mon Jan 18 13:02:27 1999 Kuroda Jun <jkuro@dwe.co.jp>
* hash.c (env_keys): strchr() may return NULL.
@@ -435,7 +2270,7 @@ Sat Oct 31 23:18:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (rb_str_split_method): if LIMIT is unspecified,
trailing null fields are stripped.
-Sat Oct 31 04:16:14 1998 Inaba Hiroto <inaba@st.rim.or.jp>
+Sat Oct 31 04:16:14 1998 Inaba Hiroto <inaba@st.rim.or.jp>
* string.c (str_aref): regexp index SEGVed.
@@ -662,7 +2497,6 @@ Fri Sep 4 11:27:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_search): wrong return value for \A.
->>>>>>> 1.1.1.2.2.154
Thu Sep 3 14:08:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* version 1.1c4 released.
@@ -697,7 +2531,7 @@ Sat Aug 29 16:31:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_compile_pattern): mask \nnn over 256.
-Sat Aug 29 02:09:46 1998 1998 Koji Arai <JCA02266@nifty.ne.jp>
+Sat Aug 29 02:09:46 1998 Koji Arai <JCA02266@nifty.ne.jp>
* sprintf.c (f_sprintf): wrong buffer size check.
@@ -1285,7 +3119,7 @@ Thu May 14 14:03:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* random.c (f_rand): use drand48 if possible.
-Wed May 13 19:05:20 1998 1998 MAEDA shugo <shugo@aianet.ne.jp>
+Wed May 13 19:05:20 1998 MAEDA shugo <shugo@aianet.ne.jp>
* BeOS patches for io.c, error.c and config.guess.
diff --git a/MANIFEST b/MANIFEST
index 5c697d612f5..1b9e448360f 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,5 @@
COPYING
+COPYING.LIB
ChangeLog
MANIFEST
Makefile.in
@@ -28,10 +29,7 @@ env.h
error.c
eval.c
file.c
-fnmatch.c
-fnmatch.h
gc.c
-glob.c
hash.c
inits.c
install-sh
@@ -50,6 +48,7 @@ object.c
pack.c
parse.c
parse.y
+prec.c
process.c
random.c
range.c
@@ -77,14 +76,16 @@ variable.c
version.c
version.h
beos/ruby.def.in
+cygwin/GNUmakefile.in
ext/Setup
ext/Setup.dj
+ext/Setup.emx
ext/Setup.nt
ext/Setup.x68
-ext/aix_ld.rb
-ext/cygwin32_ld.rb
+ext/aix_mksym.rb
+ext/mswin32_extmk.rb
ext/extmk.rb.in
-ext/extmk.rb.nt
+lib/CGI.rb
lib/English.rb
lib/Env.rb
lib/README
@@ -142,16 +143,24 @@ missing/crypt.c
missing/dir.h
missing/dup2.c
missing/file.h
+missing/finite.c
missing/flock.c
+missing/fnmatch.c
+missing/fnmatch.h
+missing/isinf.c
+missing/isnan.c
missing/memcmp.c
missing/memmove.c
missing/mkdir.c
+missing/os2.c
missing/strcasecmp.c
+missing/strncasecmp.c
missing/strchr.c
missing/strdup.c
missing/strerror.c
missing/strftime.c
missing/strstr.c
+missing/strtod.c
missing/strtol.c
missing/strtoul.c
missing/vsnprintf.c
@@ -163,6 +172,8 @@ sample/cbreak.rb
sample/clnt.rb
sample/dbmtest.rb
sample/dir.rb
+sample/dualstack-fetch.rb
+sample/dualstack-httpd.rb
sample/eval.rb
sample/export.rb
sample/exyacc.rb
@@ -196,6 +207,7 @@ sample/rbc.rb
sample/rcs.awk
sample/rcs.dat
sample/rcs.rb
+sample/rd2html.rb
sample/regx.rb
sample/sieve.rb
sample/svr.rb
@@ -206,6 +218,7 @@ sample/tsvr.rb
sample/uumerge.rb
win32/Makefile
win32/config.h
+win32/config.status
win32/ntsetup.bat
win32/ruby.def
win32/sdbm.c
diff --git a/Makefile.in b/Makefile.in
index 628b0e0778e..865318ba703 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -14,105 +14,115 @@ AUTOCONF = autoconf
prefix = @prefix@
CFLAGS = @CFLAGS@ -I. -I@srcdir@ -I@includedir@
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
+XLDFLAGS = @XLDFLAGS@
EXTLIBS =
LIBS = @LIBS@ $(EXTLIBS)
MISSING = @LIBOBJS@ @ALLOCA@
-LDSHARED = @LDSHARED@
-DLDFLAGS = @DLDFLAGS@
+LDSHARED = @LIBRUBY_LDSHARED@
+DLDFLAGS = @LIBRUBY_DLDFLAGS@
SOLIBS = @SOLIBS@
-binsuffix = @binsuffix@
+RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
+EXEEXT = @EXEEXT@
+PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
#### End of system configuration section. ####
+MAJOR= @MAJOR@
+MINOR= @MINOR@
+TEENY= @TEENY@
+LIBRUBY_A = @LIBRUBY_A@
+LIBRUBY_SO = @LIBRUBY_SO@
+LIBRUBY_ALIASES= @LIBRUBY_ALIASES@
LIBRUBY = @LIBRUBY@
LIBRUBYARG = @LIBRUBYARG@
EXTOBJS =
-MAINOBJ = main.o
-
-OBJS = array.o \
- bignum.o \
- class.o \
- compar.o \
- dir.o \
- dln.o \
- enum.o \
- error.o \
- eval.o \
- file.o \
- fnmatch.o \
- gc.o \
- glob.o \
- hash.o \
- inits.o \
- io.o \
- marshal.o \
- math.o \
- numeric.o \
- object.o \
- pack.o \
- parse.o \
- process.o \
- random.o \
- range.o \
- re.o \
- regex.o \
- ruby.o \
- signal.o \
- sprintf.o \
- st.o \
- string.o \
- struct.o \
- time.o \
- util.o \
- variable.o \
- version.o \
+MAINOBJ = main.@OBJEXT@
+
+OBJS = array.@OBJEXT@ \
+ bignum.@OBJEXT@ \
+ class.@OBJEXT@ \
+ compar.@OBJEXT@ \
+ dir.@OBJEXT@ \
+ dln.@OBJEXT@ \
+ enum.@OBJEXT@ \
+ error.@OBJEXT@ \
+ eval.@OBJEXT@ \
+ file.@OBJEXT@ \
+ gc.@OBJEXT@ \
+ hash.@OBJEXT@ \
+ inits.@OBJEXT@ \
+ io.@OBJEXT@ \
+ marshal.@OBJEXT@ \
+ math.@OBJEXT@ \
+ numeric.@OBJEXT@ \
+ object.@OBJEXT@ \
+ pack.@OBJEXT@ \
+ parse.@OBJEXT@ \
+ process.@OBJEXT@ \
+ prec.@OBJEXT@ \
+ random.@OBJEXT@ \
+ range.@OBJEXT@ \
+ re.@OBJEXT@ \
+ regex.@OBJEXT@ \
+ ruby.@OBJEXT@ \
+ signal.@OBJEXT@ \
+ sprintf.@OBJEXT@ \
+ st.@OBJEXT@ \
+ string.@OBJEXT@ \
+ struct.@OBJEXT@ \
+ time.@OBJEXT@ \
+ util.@OBJEXT@ \
+ variable.@OBJEXT@ \
+ version.@OBJEXT@ \
$(MISSING)
-all: miniruby$(binsuffix) rbconfig.rb
- @./miniruby$(binsuffix) -Xext extmk.rb @EXTSTATIC@
+all: miniruby$(EXEEXT) rbconfig.rb
+ @./miniruby$(EXEEXT) -Xext extmk.rb @EXTSTATIC@
-miniruby$(binsuffix): libruby.a $(MAINOBJ) dmyext.o
+miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) dmyext.@OBJEXT@
@rm -f $@
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.o libruby.a $(LIBS) -o $@
+ $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.@OBJEXT@ $(LIBRUBY_A) $(LIBS) -o $@
-ruby$(binsuffix): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS)
+$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS)
@rm -f $@
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
+ $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
-libruby.a: $(OBJS) dmyext.o
- @AR@ rcu $@ $(OBJS) dmyext.o
+$(LIBRUBY_A): $(OBJS) dmyext.@OBJEXT@
+ @AR@ rcu $@ $(OBJS) dmyext.@OBJEXT@
@-@RANLIB@ $@ 2> /dev/null || true
-libruby.so: $(OBJS) dmyext.o
- $(LDSHARED) $(DLDFLAGS) $(SOLIBS) $(OBJS) dmyext.o -o $@
+$(LIBRUBY_SO): $(OBJS) dmyext.@OBJEXT@
+ $(LDSHARED) $(DLDFLAGS) $(SOLIBS) $(OBJS) dmyext.@OBJEXT@ -o $@
+ @-./miniruby -e 'ARGV.each{|link| File.delete link if File.exist? link; \
+ File.symlink "$(LIBRUBY_SO)", link}' \
+ $(LIBRUBY_ALIASES) || true
install: rbconfig.rb
- ./miniruby$(binsuffix) $(srcdir)/instruby.rb $(DESTDIR)
+ ./miniruby$(EXEEXT) $(srcdir)/instruby.rb $(DESTDIR)
-clean:; @rm -f $(OBJS) $(LIBRUBY) $(MAINOBJ) rbconfig.rb
- @rm -f ext/extinit.c ext/extinit.o dmyext.o
- @if test -f ./miniruby$(binsuffix); then \
- ./miniruby$(binsuffix) -Xext extmk.rb clean; \
- fi
+clean:; @rm -f $(OBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES) $(MAINOBJ) rbconfig.rb
+ @rm -f ext/extinit.c ext/extinit.@OBJEXT@ dmyext.@OBJEXT@
+ @-./miniruby$(EXEEXT) -Xext extmk.rb clean 2> /dev/null || true
+ @rm -f $(PROGRAM) miniruby$(EXEEXT)
distclean: clean
@rm -f Makefile ext/extmk.rb config.h
@rm -f ext/config.cache config.cache config.log config.status
- @rm -f parse.c *~ core *.core gmon.out y.tab.c y.output
- @rm -f ruby$(binsuffix) miniruby$(binsuffix)
+ @rm -f *~ core *.core gmon.out y.tab.c y.output ruby.imp
realclean: distclean
+ @rm -f parse.c
@rm -f lex.c
-test: miniruby$(binsuffix)
- @./miniruby$(binsuffix) $(srcdir)/rubytest.rb
+test: miniruby$(EXEEXT)
+ @./miniruby$(EXEEXT) $(srcdir)/rubytest.rb
-rbconfig.rb: config.status miniruby$(binsuffix)
- @./miniruby$(binsuffix) $(srcdir)/mkconfig.rb rbconfig.rb
+rbconfig.rb: miniruby$(EXEEXT)
+ @./miniruby$(EXEEXT) $(srcdir)/mkconfig.rb rbconfig.rb
config.status: $(srcdir)/configure
$(SHELL) ./config.status --recheck
@@ -120,7 +130,7 @@ config.status: $(srcdir)/configure
$(srcdir)/configure: $(srcdir)/configure.in
cd $(srcdir) && $(AUTOCONF)
-.c.o:
+.c.@OBJEXT@:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
lex.c: keywords
@@ -130,100 +140,123 @@ parse.c: parse.y
$(YACC) $<
mv -f y.tab.c parse.c
-alloca.o: @srcdir@/missing/alloca.c
+alloca.@OBJEXT@: @srcdir@/missing/alloca.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/alloca.c
-crypt.o: @srcdir@/missing/crypt.c
+crypt.@OBJEXT@: @srcdir@/missing/crypt.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/crypt.c
-dup2.o: @srcdir@/missing/dup2.c
+dup2.@OBJEXT@: @srcdir@/missing/dup2.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/dup2.c
-flock.o: @srcdir@/missing/flock.c
+finite.@OBJEXT@: @srcdir@/missing/finite.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/finite.c
+
+flock.@OBJEXT@: @srcdir@/missing/flock.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/flock.c
-memcmp.o: @srcdir@/missing/memcmp.c
+isinf.@OBJEXT@: @srcdir@/missing/isinf.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/isinf.c
+
+isnan.@OBJEXT@: @srcdir@/missing/isnan.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/isnan.c
+
+fnmatch.@OBJEXT@: @srcdir@/missing/fnmatch.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/fnmatch.c
+
+memcmp.@OBJEXT@: @srcdir@/missing/memcmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/memcmp.c
-memmove.o: @srcdir@/missing/memmove.c
+memmove.@OBJEXT@: @srcdir@/missing/memmove.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/memmove.c
-mkdir.o: @srcdir@/missing/mkdir.c
+mkdir.@OBJEXT@: @srcdir@/missing/mkdir.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/mkdir.c
-vsnprintf.o: @srcdir@/missing/vsnprintf.c
+vsnprintf.@OBJEXT@: @srcdir@/missing/vsnprintf.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/vsnprintf.c
-strcasecmp.o: @srcdir@/missing/strcasecmp.c
+strcasecmp.@OBJEXT@: @srcdir@/missing/strcasecmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strcasecmp.c
-strchr.o: @srcdir@/missing/strchr.c
+strncasecmp.@OBJEXT@: @srcdir@/missing/strncasecmp.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strncasecmp.c
+
+strchr.@OBJEXT@: @srcdir@/missing/strchr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strchr.c
-strdup.o: @srcdir@/missing/strdup.c
+strdup.@OBJEXT@: @srcdir@/missing/strdup.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strdup.c
-strerror.o: @srcdir@/missing/strerror.c
+strerror.@OBJEXT@: @srcdir@/missing/strerror.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strerror.c
-strftime.o: @srcdir@/missing/strftime.c
+strftime.@OBJEXT@: @srcdir@/missing/strftime.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strftime.c
-strstr.o: @srcdir@/missing/strstr.c
+strstr.@OBJEXT@: @srcdir@/missing/strstr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strstr.c
-strtol.o: @srcdir@/missing/strtol.c
+strtod.@OBJEXT@: @srcdir@/missing/strtod.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtod.c
+
+strtol.@OBJEXT@: @srcdir@/missing/strtol.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtol.c
-strtoul.o: @srcdir@/missing/strtoul.c
+strtoul.@OBJEXT@: @srcdir@/missing/strtoul.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtoul.c
-nt.o: @srcdir@/missing/nt.c
+nt.@OBJEXT@: @srcdir@/missing/nt.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/nt.c
-x68.o: @srcdir@/missing/x68.c
+x68.@OBJEXT@: @srcdir@/missing/x68.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/x68.c
+os2.@OBJEXT@: @srcdir@/missing/os2.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/os2.c
+
+dl_os2.@OBJEXT@: @srcdir@/missing/dl_os2.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/dl_os2.c
+
# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
###
-parse.o: parse.y ruby.h config.h defines.h intern.h env.h node.h st.h regex.h util.h lex.c
+parse.@OBJEXT@: parse.y ruby.h config.h defines.h intern.h env.h node.h st.h regex.h util.h lex.c
###
-array.o: array.c ruby.h config.h defines.h intern.h
-bignum.o: bignum.c ruby.h config.h defines.h intern.h
-class.o: class.c ruby.h config.h defines.h intern.h node.h st.h
-compar.o: compar.c ruby.h config.h defines.h intern.h
-dir.o: dir.c ruby.h config.h defines.h intern.h
-dln.o: dln.c config.h defines.h dln.h
-dmyext.o: dmyext.c
-enum.o: enum.c ruby.h config.h defines.h intern.h
-error.o: error.c ruby.h config.h defines.h intern.h env.h
-eval.o: eval.c ruby.h config.h defines.h intern.h node.h env.h rubysig.h st.h dln.h
-file.o: file.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
-fnmatch.o: fnmatch.c config.h fnmatch.h
-gc.o: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h
-glob.o: config.h glob.c fnmatch.h
-hash.o: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h
-inits.o: inits.c ruby.h config.h defines.h intern.h
-io.o: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
-main.o: main.c ruby.h config.h defines.h intern.h
-marshal.o: marshal.c ruby.h config.h defines.h intern.h rubyio.h st.h
-math.o: math.c ruby.h config.h defines.h intern.h
-numeric.o: numeric.c ruby.h config.h defines.h intern.h
-object.o: object.c ruby.h config.h defines.h intern.h st.h
-pack.o: pack.c ruby.h config.h defines.h intern.h
-process.o: process.c ruby.h config.h defines.h intern.h rubysig.h st.h
-random.o: random.c ruby.h config.h defines.h intern.h
-range.o: range.c ruby.h config.h defines.h intern.h
-re.o: re.c ruby.h config.h defines.h intern.h re.h regex.h
-regex.o: regex.c config.h regex.h util.h
-ruby.o: ruby.c ruby.h config.h defines.h intern.h dln.h util.h
-signal.o: signal.c ruby.h config.h defines.h intern.h rubysig.h
-sprintf.o: sprintf.c ruby.h config.h defines.h intern.h
-st.o: st.c config.h st.h
-string.o: string.c ruby.h config.h defines.h intern.h re.h regex.h
-struct.o: struct.c ruby.h config.h defines.h intern.h
-time.o: time.c ruby.h config.h defines.h intern.h
-util.o: util.c ruby.h config.h defines.h intern.h util.h
-variable.o: variable.c ruby.h config.h defines.h intern.h env.h node.h st.h
-version.o: version.c ruby.h config.h defines.h intern.h version.h
+array.@OBJEXT@: array.c ruby.h config.h defines.h intern.h
+bignum.@OBJEXT@: bignum.c ruby.h config.h defines.h intern.h
+class.@OBJEXT@: class.c ruby.h config.h defines.h intern.h node.h st.h
+compar.@OBJEXT@: compar.c ruby.h config.h defines.h intern.h
+dir.@OBJEXT@: dir.c ruby.h config.h defines.h intern.h
+dln.@OBJEXT@: dln.c config.h defines.h dln.h
+dmyext.@OBJEXT@: dmyext.c
+enum.@OBJEXT@: enum.c ruby.h config.h defines.h intern.h
+error.@OBJEXT@: error.c ruby.h config.h defines.h intern.h env.h
+eval.@OBJEXT@: eval.c ruby.h config.h defines.h intern.h node.h env.h rubysig.h st.h dln.h
+file.@OBJEXT@: file.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
+gc.@OBJEXT@: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h
+hash.@OBJEXT@: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h util.h
+inits.@OBJEXT@: inits.c ruby.h config.h defines.h intern.h
+io.@OBJEXT@: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h env.h
+main.@OBJEXT@: main.c ruby.h config.h defines.h intern.h
+marshal.@OBJEXT@: marshal.c ruby.h config.h defines.h intern.h rubyio.h st.h
+prec.@OBJEXT@: prec.c ruby.h config.h defines.h intern.h
+math.@OBJEXT@: math.c ruby.h config.h defines.h intern.h
+numeric.@OBJEXT@: numeric.c ruby.h config.h defines.h intern.h
+object.@OBJEXT@: object.c ruby.h config.h defines.h intern.h st.h
+pack.@OBJEXT@: pack.c ruby.h config.h defines.h intern.h
+process.@OBJEXT@: process.c ruby.h config.h defines.h intern.h rubysig.h st.h
+random.@OBJEXT@: random.c ruby.h config.h defines.h intern.h
+range.@OBJEXT@: range.c ruby.h config.h defines.h intern.h
+re.@OBJEXT@: re.c ruby.h config.h defines.h intern.h re.h regex.h
+regex.@OBJEXT@: regex.c config.h regex.h util.h
+ruby.@OBJEXT@: ruby.c ruby.h config.h defines.h intern.h dln.h util.h
+signal.@OBJEXT@: signal.c ruby.h config.h defines.h intern.h rubysig.h
+sprintf.@OBJEXT@: sprintf.c ruby.h config.h defines.h intern.h
+st.@OBJEXT@: st.c config.h st.h
+string.@OBJEXT@: string.c ruby.h config.h defines.h intern.h re.h regex.h
+struct.@OBJEXT@: struct.c ruby.h config.h defines.h intern.h
+time.@OBJEXT@: time.c ruby.h config.h defines.h intern.h
+util.@OBJEXT@: util.c ruby.h config.h defines.h intern.h util.h
+variable.@OBJEXT@: variable.c ruby.h config.h defines.h intern.h env.h node.h st.h
+version.@OBJEXT@: version.c ruby.h config.h defines.h intern.h version.h
diff --git a/README b/README
index dd93c592be6..2a99cae28bb 100644
--- a/README
+++ b/README
@@ -20,10 +20,28 @@ Perl). It is simple, straight-forward, and extensible.
* How to get Ruby
-The Ruby distribution can be found on
+The Ruby distribution can be found on:
ftp://ftp.netlab.co.jp/pub/lang/ruby/
+You can get it by anonymous CVS. How to check out is:
+
+ $ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs login
+ (Logging in to anonymous@cvs.netlab.co.jp)
+ CVS password: guest
+ $ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs checkout ruby
+
+* Mailing list
+
+There is a mailing list to talk about Ruby.
+To subscribe this list, please send the following phrase
+
+ subscribe Your-Last-Name Your-First-Name
+e.g.
+ subscribe Joseph Smith
+
+in the mail body (not subject) to the address <ruby-talk-ctl@netlab.co.jp>.
+
* How to compile and install
This is what you need to do to compile and install Ruby:
@@ -98,9 +116,9 @@ You can redistribute it and/or modify it under either the terms of the GPL
4. You may modify and include the part of the software into any other
software (possibly commercial). But some files in the distribution
are not written by the author, so that they are not under this terms.
- They are gc.c(partly), utils.c(partly), regex.[ch], fnmatch.[ch],
- glob.c, st.[ch] and some files under the ./missing directory. See
- each file for the copying condition.
+ They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
+ files under the ./missing directory. See each file for the copying
+ condition.
5. The scripts and library files supplied as input to or produced as
output from the software do not automatically fall under the
diff --git a/README.EXT b/README.EXT
index f169e549952..241d6fa8cdd 100644
--- a/README.EXT
+++ b/README.EXT
@@ -1,8 +1,8 @@
.\" README.EXT - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995
-This document explains how to make extention modules for Ruby.
+This document explains how to make extention libraries for Ruby.
-1.Basic knowledge
+1. Basic knowledge
In C, variables have types and data do not have types. In contrast,
Ruby variables do not have static type and data themselves have
@@ -109,35 +109,29 @@ bugs.
1.4 Convert C data into VALUE
-VALUEの実際の構造は
+To convert C data to the values of Ruby:
- * FIXNUMの場合
+ * FIXNUM
- 1bit右シフトして,LSBを立てる.
+ left shift 1 bit, and turn on LSB.
- * その他のポインタの場合
+ * Other pointer values
- そのままVALUEにキャストする.
+ cast to VALUE.
-となっています.よって,LSBをチェックすればVALUEがFIXNUMかど
-うかわかるわけです(ポインタのLSBが立っていないことを仮定して
-いる).
+You can determine whether VALUE is pointer or not, by checking LSB.
-ですから,FIXNUM以外のRubyのオブジェクトの構造体は単にVALUE
-にキャストするだけでVALUEに変換出来ます.ただし,任意の構造
-体がVALUEにキャスト出来るわけではありません.キャストするの
-はRubyの知っている構造体(ruby.hで定義されているstruct RXxxx
-のもの)だけにしておいてください.
+Notice Ruby does not allow arbitrary pointer value to be VALUE. They
+should be pointers to the structures which Ruby knows. The known
+structures are defined in <ruby.h>.
-FIXNUMに関しては変換マクロを経由する必要があります.Cの整数
-からVALUEに変換するマクロは以下のものがあります.必要に応じ
-て使い分けてください.
+To convert C numbers to Ruby value, use these macros.
- INT2FIX() もとの整数が31bit以内に収まる時
- INT2NUM() 任意の整数からVALUEへ
+ INT2FIX() for intergers within 31bits.
+ INT2NUM() for arbitrary sized integer.
-INT2NUM()は整数がFIXNUMの範囲に収まらない場合,Bignumに変換
-してくれます(が,少し遅い).
+INT2NUM() converts integers into Bignums, if it is out of FIXNUM
+range, but bit slower.
1.5 Manipulate Ruby data
@@ -190,23 +184,15 @@ interpreter. Useful functions are listed below (not all):
2. Extend Ruby with C
-原理的にRubyで書けることはCでも書けます.RubyそのものがCで記
-述されているんですから,当然といえば当然なんですけど.ここで
-はRubyの拡張に使うことが多いだろうと予測される機能を中心に紹
-介します.
-
2.1 Add new features to Ruby
-Rubyで提供されている関数を使えばRubyインタプリタに新しい機能
-を追加することができます.Rubyでは以下の機能を追加する関数が
-提供されています.
+You can add new features (classes, methods, etc.) to the Ruby
+interpreter. Ruby provides the API to define things below:
* Classes, Modules
* Methods, Singleton Methods
* Constants
-では順に紹介します.
-
2.1.1 Class/module definition
To define class or module, use functions below:
@@ -327,9 +313,9 @@ by the symbol mid.
2.2.4 Accessing the variables and constants
-Cから関数を使って参照・更新できるのは,クラス定数,インスタ
-ンス変数です.大域変数は一部のものはCの大域変数としてアクセ
-スできます.ローカル変数を参照する方法は公開していません.
+You can access class variables, and instance variables using access
+functions. Also, global variables can be shared between both worlds.
+There's no way to access Ruby's local variables.
The functions to access/modify instance variables are below:
@@ -346,9 +332,7 @@ See 2.1.3 for defining new constant.
3. Informatin sharing between Ruby and C
-C言語とRubyの間で情報を共有する方法について解説します.
-
-3.1 Ruby constant that Cから参照できるRubyの定数
+3.1 Ruby constant that C can be accessed from C
Following Ruby constants can be referred from C.
@@ -363,43 +347,35 @@ Ruby nil in C scope.
3.2 Global variables shared between C and Ruby
-CとRubyで大域変数を使って情報を共有できます.共有できる大域
-変数にはいくつかの種類があります.そのなかでもっとも良く使わ
-れると思われるのはrb_define_variable()です.
+Information can be shared between two worlds, using shared global
+variables. To define them, you can use functions listed below:
void rb_define_variable(char *name, VALUE *var)
-この関数はRubyとCとで共有する大域変数を定義します.変数名が
-`$'で始まらない時には自動的に追加されます.この変数の値を変
-更すると自動的にRubyの対応する変数の値も変わります.
+This function defines the variable which is shared by the both world.
+The value of the global variable pointerd by `var', can be accessed
+through Ruby's global variable named `name'.
-またRuby側からは更新できない変数もあります.このread onlyの
-変数は以下の関数で定義します.
+You can define read-only (from Ruby, of course) variable by the
+function below.
void rb_define_readonly_variable(char *name, VALUE *var)
-これら変数の他にhookをつけた大域変数を定義できます.hook付き
-の大域変数は以下の関数を用いて定義します.hook付き大域変数の
-値の参照や設定はhookで行う必要があります.
+You can defined hooked variables. The accessor functions (getter and
+setter) are called on access to the hooked variables.
void rb_define_hooked_variable(char *name, VALUE *var,
VALUE (*getter)(), VALUE (*setter)())
-この関数はCの関数によってhookのつけられた大域変数を定義しま
-す.変数が参照された時には関数getterが,変数に値がセットされ
-た時には関数setterが呼ばれる.hookを指定しない場合はgetterや
-setterに0を指定します.
-
-# getterもsetterも0ならばrb_define_variable()と同じになる.
-
-それから,Cの関数によって実現されるRubyの大域変数を定義する
-関数があります.
+If you need to supply either setter or getter, just supply 0 for the
+hook you don't need. If both hooks are 0, rb_define_hooked_variable()
+works just like rb_define_variable().
void rb_define_virtual_variable(char *name,
VALUE (*getter)(), VALUE (*setter)())
-この関数によって定義されたRubyの大域変数が参照された時には
-getterが,変数に値がセットされた時にはsetterが呼ばれます.
+This function defines the Ruby global variable without corresponding C
+variable. The value of the variable will be set/get only by hooks.
The prototypes of the getter and setter functions are as following:
@@ -408,54 +384,44 @@ The prototypes of the getter and setter functions are as following:
3.3 Encapsulate C data into Ruby object
-Cの世界で定義されたデータ(構造体)をRubyのオブジェクトとして
-取り扱いたい場合がありえます.このような場合には,Dataという
-RubyオブジェクトにCの構造体(へのポインタ)をくるむことでRuby
-オブジェクトとして取り扱えるようになります.
-
-Dataオブジェクトを生成して構造体をRubyオブジェクトにカプセル
-化するためには,以下のマクロを使います.
+To wrapping and objectify the C pointer as Ruby object (so called
+DATA), use Data_Wrap_Struct().
Data_Wrap_Struct(class,mark,free,ptr)
-このマクロの戻り値は生成されたDataオブジェクトです.
-
-classはこのDataオブジェクトのクラスです.ptrはカプセル化する
-Cの構造体へのポインタです.markはこの構造体がRubyのオブジェ
-クトへの参照がある時に使う関数です.そのような参照を含まない
-時には0を指定します.
+Data_Wrap_Struct() returns a created DATA object. The class argument
+is the class for the DATA object. The mark argument is the function
+to mark Ruby objects pointed by this data. The free argument is the
+function to free the pointer allocation. The functions, mark and
+free, will be called from garbage collector.
-# そのような参照は勧められません.
-
-freeはこの構造体がもう不要になった時に呼ばれる関数です.この
-関数がガーベージコレクタから呼ばれます.
-
-Cの構造体の割当とDataオブジェクトの生成を同時に行うマクロと
-して以下のものが提供されています.
+You can allocate and wrap the structure in one step.
Data_Make_Struct(class, type, mark, free, sval)
-このマクロの戻り値は生成されたDataオブジェクトです.
+This macro returns an allocated Data object, wrapping the pointer to
+the structure, which is also allocated. This macro works like:
+
+ (sval = ALLOC(type), Data_Wrap_Struct(class, mark, free, sval))
-class, mark, freeはData_Wrap_Structと同じ働きをします.type
-は割り当てるC構造体の型です.割り当てられた構造体は変数sval
-に代入されます.この変数の型は (type*) である必要があります.
+Arguments, class, mark, free, works like thier counterpart of
+Data_Wrap_Struct(). The pointer to allocated structure will be
+assigned to sval, which should be the pointer to the type specified.
-Dataオブジェクトからポインタを取り出すのは以下のマクロを用い
-ます.
+To retrieve the C pointer from the Data object, use the macro
+Data_Get_Struct().
Data_Get_Struct(obj, type, sval)
-Cの構造体へのポインタは変数svalに代入されます.
+The pointer to the structure will be assigned to the variable sval.
-これらのDataの使い方はちょっと分かりにくいので,後で説明する
-例題を参照してください.
+See example below for detail.
-4.Example - Create dbm module
+4. Example - Creating dbm extension
-ここまでの説明でとりあえず拡張ライブラリは作れるはずです.
-Rubyのextディレクトリにすでに含まれているdbmモジュールを例に
-して段階的に説明します.
+OK, here's the example to make extension library. This is the
+extension to access dbm. The full source is included in ext/
+directory in the Ruby's source tree.
(1) make the directory
@@ -477,17 +443,17 @@ You need to design the library features, before making it.
(4) write C code.
-拡張ライブラリ本体となるC言語のソースを書きます.C言語のソー
-スがひとつの時には「モジュール名.c」を選ぶと良いでしょう.C
-言語のソースが複数の場合には逆に「モジュール名.c」というファ
-イル名は避ける必要があります.オブジェクトファイルとモジュー
-ル生成時に中間的に生成される「モジュール名.o」というファイル
-とが衝突するからです.
+You need to write C code for your extension library. If your library
+has only one source file, choosing ``LIBRARY.c'' as a file name is
+preferred. On the other hand, in case your library has prural source
+files, avoid chooing ``LIBRARY.c'' for a file name. It may conflict
+with intermediate file ``LIBRARY.o'' on some platforms.
-Rubyは拡張ライブラリをロードする時に「Init_モジュール名」と
-いう関数を自動的に実行します.dbmモジュールの場合「Init_dbm」
-です.この関数の中でクラス,モジュール,メソッド,定数などの
-定義を行います.dbm.cから一部引用します.
+Ruby will execute the initializing function named ``Init_LIBRARY'' in
+the library. For exapmle, ``Init_dbm()'' will be executed when loading
+the library.
+
+Here's the example of an initializing function.
--
Init_dbm()
@@ -509,11 +475,7 @@ Init_dbm()
}
--
-DBMモジュールはdbmのデータと対応するオブジェクトになるはずで
-すから,Cの世界のdbmをRubyの世界に取り込む必要があります.
-
-
-dbm.cではData_Make_Structを以下のように使っています.
+The dbm extension wrap dbm struct in C world using Data_Make_Struct.
--
struct dbmdata {
@@ -525,12 +487,10 @@ struct dbmdata {
obj = Data_Make_Struct(class,struct dbmdata,0,free_dbm,dbmp);
--
-ここではdbmstruct構造体へのポインタをDataにカプセル化してい
-ます.DBM*を直接カプセル化しないのはclose()した時の処理を考
-えてのことです.
+This code wraps dbmdata structure into Ruby object. We avoid wrapping
+DBM* directly, because we want to cache size information.
-Dataオブジェクトからdbmstruct構造体のポインタを取り出すため
-に以下のマクロを使っています.
+To retrieve dbmdata structure from Ruby object, we define the macro below:
--
#define GetDBM(obj, dbmp) {\
@@ -539,14 +499,11 @@ Dataオブジェクトからdbmstruct構造体のポインタを取り出すため
}
--
-ちょっと複雑なマクロですが,要するにdbmdata構造体のポインタ
-の取り出しと,closeされているかどうかのチェックをまとめてい
-るだけです.
+This sort of complicated macro do the retrieving and close check for
+the DBM.
-DBMクラスにはたくさんメソッドがありますが,分類すると3種類の
-引数の受け方があります.ひとつは引数の数が固定のもので,例と
-してはdeleteメソッドがあります.deleteメソッドを実装している
-fdbm_delete()はこのようになっています.
+There are three kind of way to receiving method arguments. First, the
+methods with fixed number of arguments receives arguments like this:
--
static VALUE
@@ -557,13 +514,11 @@ fdbm_delete(obj, keystr)
}
--
-引数の数が固定のタイプは第1引数がself,第2引数以降がメソッド
-の引数となります.
+The first argument of the C function is the self, the rest are the
+arguments to the method.
-引数の数が不定のものはCの配列で受けるものとRubyの配列で受け
-るものとがあります.dbmモジュールの中で,Cの配列で受けるもの
-はDBMのクラスメソッドであるopen()です.これを実装している関
-数fdbm_s_open()はこうなっています.
+Second, the methods with arbtrary number of arguments receives
+arguments like this:
--
static VALUE
@@ -580,36 +535,28 @@ fdbm_s_open(argc, argv, class)
}
--
-このタイプの関数は第1引数が与えられた引数の数,第2引数が与え
-られた引数の入っている配列になります.selfは第3引数として与
-えられます.
+The first argument is the number of method arguments. the second
+argument is the C array of the method arguments. And the third
+argument is the receiver of the method.
-この配列で与えられた引数を解析するための関数がopen()でも使わ
-れているrb_scan_args()です.第3引数に指定したフォーマットに
-従い,第4変数以降に指定した変数に値を代入してくれます.この
-フォーマットは,第1文字目が省略できない引数の数,第2文字目が
-省略できる引数の数,第3文字目が対応する相手が無いあまりの引
-数があるかどうかを示す"*"です.2文字目と3文字目は省略できま
-す.dbm.cの例では,フォーマットは"11"ですから,引数は最低1つ
-で,2つまで許されるという意味になります.省略されている時の
-変数の値はnil(C言語のレベルではQnil)になります.
+You can use the function rb_scan_args() to check and retrieve the
+arguments. For exapmle "11" means, the method requires at least one
+argument, and at most receives two arguments.
-Rubyの配列で引数を受け取るものはindexesがあります.実装はこ
-うです.
+The methods with arbtrary number of arguments can receives arguments
+by Ruby's array, like this:
--
static VALUE
fdbm_indexes(obj, args)
- VALUE obj;
- struct RArray *args;
+ VALUE obj, args;
{
:
}
--
-第1引数はself,第2引数はRubyの配列です.ここではキャストを減
-らすため struct RArray* で受けていますが,VALUEでも同じこと
-です.
+The first argument is the receiver, the second one is the Ruby array
+which contains the arguments to the method.
** Notice
@@ -620,72 +567,82 @@ not exported to the Ruby world. You need to protect them by
(5) prepare extconf.rb
-もしディレクトリに「extconf.rb」というファイルが存在すれば,
-make時に実行されます.なければ適当にMakefileが生成されます.
+If there exists the file named extconf.rb, it will be executed to
+generate Makefile. If not, compilation scheme try to generate
+Makefile anyway.
-extconf.rbはモジュールのコンパイルに必要な条件のチェックなど
-を行うことが目的です.extconf.rbの中では以下のRuby関数を使う
-ことが出来ます.
+The extconf.rb is the file to check compilation condition etc. You
+need to put
- have_library(lib, func): ライブラリの存在チェック
- have_func(func): 関数の存在チェック
- have_header(header): ヘッダファイルの存在チェック
- create_makefile(target): Makefileの生成
+ require 'mkmf'
-以下の変数を使うことができます.
+at the top of the file. You can use the funcitons below to check the
+condition.
- $CFLAGS: コンパイル時に追加的に指定するフラグ(-Iなど)
- $LDFLAGS: リンク時に追加的に指定するフラグ(-Lなど)
+ have_library(lib, func): check whether library containing function exists.
+ have_func(func): check whether function exists
+ have_header(header): check whether header file exists
+ create_makefile(target): generate Makefile
-モジュールをコンパイルする条件が揃わなず,そのモジュールはコ
-ンパイルしない時にはcreate_makefileを呼ばなければMakefileは
-生成されず,コンパイルも行われません.
+The value of variables below will affect Makefile.
+
+ $CFLAGS: included in CFLAGS make variable (such as -I)
+ $LDFLAGS: included in LDFLAGS make variable (such as -L)
+
+If compilation condition is not fulfilled, you do not call
+``create_makefile''. Makefile will not generated, compilation will
+not be done.
(6) prepare depend (optional)
-もし,ディレクトリにdependというファイルが存在すれば,
-Makefileが依存関係をチェックしてくれます.
+If the file named depend exists, Makefile will include that file to
+check dependency. You can make this file by invoking
% gcc -MM *.c > depend
-などで作ることが出来ます.あって損は無いでしょう.
+It's no harm. Prepare it.
-(7) MANIFESTファイルにファイル名を入れる
+(7) put file names into MANIFEST (optional)
- % ls > MANIFEST
+ % find * -type f -print > MANIFEST
% vi MANIFEST
-*.o, *~など不必要なファイル以外はMANIFESTに追加しておきます.
-make時にはMANIFESTの内容は参照しませんので,空のままでも問題
-は起きませんが,パッケージングの時に参照することがあるのと,
-必要なファイルを区別できるので,用意しておいた方が良いでしょ
-う.
+Append file names into MANIFEST. The compilation scheme requires
+MANIFEST only to be exist. But, you'd better take this step to
+distinguish required files.
+
+(8) generate Makefile
+
+Try generate Makefile by:
+
+ ruby extconf.rb
+
+You don't need this step, if you put extension library under ext
+directory of the ruby source tree. In that case, compilation of the
+interpreter will do this step for you.
+
+(9) make
-(8) make
+Type
-Rubyのディレクトリでmakeを実行するとMakefileを生成からmake,
-必要によってはそのモジュールのRubyへのリンクまで自動的に実行
-してくれます.extconf.rbを書き換えるなどしてMakefileの再生成
-が必要な時はまたRubyディレクトリでmakeしてください.
+ make
+
+to compile your extension. You don't need this step neither, if you
+put extension library under ext directory of the ruby source tree.
(9) debug
-You may need to rb_debug the module. The modules can be linked
-statically by adding directory name in the ext/Setup file,
-so that you can inspect the module by the debugger.
+You may need to rb_debug the extension. The extensions can be linked
+statically by adding directory name in the ext/Setup file, so that you
+can inspect the extension with the debugger.
(10) done, now you have the extension library
-後はこっそり使うなり,広く公開するなり,売るなり,ご自由にお
-使いください.Rubyの作者は拡張ライブラリに関して一切の権利を
-主張しません.
-
-Appendix A. Rubyのソースコードの分類
+You can do anything you want with your library. The author of Ruby
+will not claim any restriction about your code depending Ruby API.
+Feel free to use, modify, distribute or sell your program.
-Rubyのソースはいくつかに分類することが出来ます.このうちクラ
-スライブラリの部分は基本的に拡張ライブラリと同じ作り方になっ
-ています.これらのソースは今までの説明でほとんど理解できると
-思います.
+Appendix A. Ruby source files overview
ruby language core
@@ -737,18 +694,15 @@ class library
struct.c
time.c
-Appendix B. 拡張用関数リファレンス
-
-C言語からRubyの機能を利用するAPIは以下の通りである.
+Appendix B. Ruby extension API reference
-** 型
+** Types
VALUE
-Rubyオブジェクトを表現する型.必要に応じてキャストして用いる.
-組み込み型を表現するCの型はruby.hに記述してあるRで始まる構造
-体である.VALUE型をこれらにキャストするためにRで始まる構造体
-名を全て大文字にした名前のマクロが用意されている.
+The type for Ruby object. Actual structures are defined in ruby.h,
+such as struct RString, etc. To refer the values in structures, use
+casting macros like RSTRING(obj).
** Variables and constants
@@ -758,58 +712,58 @@ const: nil object
Qtrue
-const: Qtrue object(default true value)
+const: true object(default true value)
Qfalse
-const: Qfalse object
+const: false object
-** Cデータのカプセル化
+** C pointer wrapping
Data_Wrap_Struct(VALUE class, void (*mark)(), void (*free)(), void *sval)
-Cの任意のポインタをカプセル化したRubyオブジェクトを返す.こ
-のポインタがRubyからアクセスされなくなった時,freeで指定した
-関数が呼ばれる.また,このポインタの指すデータが他のRubyオブ
-ジェクトを指している場合,markに指定する関数でマークする必要
-がある.
+Wrap C pointer into Ruby object. If object has references to other
+Ruby object, they should be marked by using mark function during GC
+process. Otherwise, mark should be 0. When this object is no longer
+referred by anywhere, the pointer will be discarded by free function.
Data_Make_Struct(class, type, mark, free, sval)
-type型のメモリをmallocし,変数svalに代入した後,それをカプセ
-ル化したデータを返すマクロ.
+This macro allocates memory using malloc(), assigns it to the variable
+sval, and returns the DATA encapsulating the pointer to memory region.
Data_Get_Struct(data, type, sval)
-dataからtype型のポインタを取り出し変数svalに代入するマクロ.
+This macro retrieves the pointer value from DATA, and assigns it to
+the variable sval.
-** クラス/モジュール定義
+** defining class/module
VALUE rb_define_class(char *name, VALUE super)
-superのサブクラスとして新しいRubyクラスを定義する.
+Defines new Ruby class as subclass of super.
VALUE rb_define_class_under(VALUE module, char *name, VALUE super)
-superのサブクラスとして新しいRubyクラスを定義し,moduleの定
-数として定義する.
+Creates new Ruby class as subclass of super, under the module's
+namespace.
VALUE rb_define_module(char *name)
-新しいRubyモジュールを定義する.
+Defines new Ruby module.
VALUE rb_define_module_under(VALUE module, char *name, VALUE super)
-新しいRubyモジュールを定義し,moduleの定数として定義する.
+Defines new Ruby module, under the modules's namespace.
void rb_include_module(VALUE class, VALUE module)
-モジュールをインクルードする.classがすでにmoduleをインクルー
-ドしている時には何もしない(多重インクルードの禁止).
+Includes module into class. If class already includes it, just
+ignore.
void rb_extend_object(VALUE object, VALUE module)
-オブジェクトをモジュール(で定義されているメソッド)で拡張する.
+Extend the object with module's attribute.
** Defining Global Variables
@@ -871,115 +825,118 @@ Defines global contant. This is just work as
rb_define_method(VALUE class, char *name, VALUE (*func)(), int argc)
-メソッドを定義する.argcはselfを除く引数の数.argcが-1の時,
-関数には引数の数(selfを含まない)を第1引数, 引数の配列を第2引
-数とする形式で与えられる(第3引数はself).argcが-2の時, 第1引
-数がself, 第2引数がargs(argsは引数を含むRubyの配列)という形
-式で与えられる.
+Defines a method for the class. func is the function pointer. argc
+is the number of arguments. if argc is -1, the function will receive
+3 arguments argc, argv, and self. if argc is -2, the function will
+receive 2 arguments, self and args, where args is the Ruby array of
+the method arguments.
rb_define_private_method(VALUE class, char *name, VALUE (*func)(), int argc)
-privateメソッドを定義する.引数はrb_define_method()と同じ.
+Defines a private method for the class. Arguments are same as
+rb_define_method().
rb_define_singleton_method(VALUE class, char *name, VALUE (*func)(), int argc)
-特異メソッドを定義する.引数はrb_define_method()と同じ.
+Defines a singleton method. Arguments are same as rb_define_method().
- rb_scan_args(int atgc, VALUE *argv, char *fmt, ...)
+ rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
-argc,argv形式で与えられた引数を分解する.fmtは必須引数の数,
-付加引数の数, 残りの引数があるかを指定する文字列で, "数字数
-字*"という形式である. 2 番目の数字と"*"はそれぞれ省略可能で
-ある.必須引数が一つもない場合は0を指定する.第3引数以降は変
-数へのポインタで, 該当する要素がその変数に格納される.付加引
-数に対応する引数が与えられていない場合は変数にQnilが代入され
-る.
+Retrieve argument from argc, argv. The fmt is the format string for
+the arguments, such as "12" for 1 non-optinal argument, 2 optinal
+aruguments. If `*' appears at the end of fmt, it means the rest of
+the arguments are assigned to corresponding variable, packed in
+array.
-** Rubyメソッド呼び出し
+** Invoking Ruby method
VALUE rb_funcall(VALUE recv, ID mid, int narg, ...)
-メソッド呼び出し.文字列からmidを得るためにはrb_intern()を使う.
+Invokes the method. To retrieve mid from method name, use rb_intern().
VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv)
-メソッド呼び出し.引数をargc,argv形式で渡す.
+Invokes method, passing arguments by array of values.
VALUE rb_eval_string(char *str)
-文字列をRubyとスクリプトしてコンパイル・実行する.
+Compiles and executes the string as Ruby program.
ID rb_intern(char *name)
-文字列に対応するIDを返す.
+Returns ID corresponding the name.
char *rb_id2name(ID id)
-IDに対応する文字列を返す(デバッグ用).
+Returns the name corresponding ID.
char *rb_class2name(VALUE class)
-classの名前を返す(デバッグ用).classが名前を持たない時には,
-祖先を遡って名前を持つクラスの名前を返す.
+Returns the name of the class.
-** インスタンス変数
+** Instance Variables
VALUE rb_iv_get(VALUE obj, char *name)
-objのインスタンス変数の値を得る.`@'で始まらないインスタンス
-変数は Rubyプログラムからアクセスできない「隠れた」インスタ
-ンス変数になる.
+Retrieve the value of the instance variable. If the name is not
+prefixed by `@', that variable shall be inaccessible from Ruby.
VALUE rb_iv_set(VALUE obj, char *name, VALUE val)
-objのインスタンス変数をvalにセットする.
+Sets the value of the instance variable.
-** 制御構造
+** Control Structure
VALUE rb_iterate(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
-func2をブロックとして設定し, func1をイテレータとして呼ぶ.
-func1には arg1が引数として渡され, func2には第1引数にイテレー
-タから与えられた値, 第2引数にarg2が渡される.
+Calls the function func1, supplying func2 as the block. func1 will be
+called with the argument arg1. func2 receives the value from yield as
+the first argument, arg2 as the second argument.
+
VALUE rb_yield(VALUE val)
-valを値としてイテレータブロックを呼び出す.
+Evaluates the block with value val.
VALUE rb_rescue(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
-関数func1をarg1を引数に呼び出す.func1の実行中に例外が発生し
-た時には func2をarg2を引数として呼ぶ.戻り値は例外が発生しな
-かった時はfunc1の戻り値, 例外が発生した時にはfunc2の戻り値で
-ある.
+Calls the function func1, with arg1 as the argument. If exception
+occurs during func1, it calls func2 with arg2 as the argument. The
+return value of rb_rescue() is the return value from func1 if no
+exception occurs, from func2 otherwise.
VALUE rb_ensure(VALUE (*func1)(), void *arg1, void (*func2)(), void *arg2)
-関数func1をarg1を引数として実行し, 実行終了後(たとえ例外が発
-生しても) func2をarg2を引数として実行する.戻り値はfunc1の戻
-り値である(例外が発生した時は戻らない).
+Calls the function func1 with arg1 as the argument, then calls func2
+with arg2, whenever execution terminated. The return value from
+rb_ensure() is that of func1.
+
+** Exceptions and Errors
+
+ void rb_warn(char *fmt, ...)
-** 例外・エラー
+Prints warning message according to the printf-like format.
void rb_warning(char *fmt, ...)
-rb_verbose時に標準エラー出力に警告情報を表示する.引数はprintf()と同じ.
+Prints warning message according to the printf-like format, if
+$VERBOSE is true.
- void rb_raise(rb_eRuntimeError, char *fmt, ...)
+ void rb_raise(VALUE exception, char *fmt, ...)
-例外を発生させる.引数はprintf()と同じ.
+Raises an exception of class exception. The fmt is the format string
+just like printf().
void rb_fatal(char *fmt, ...)
-致命的例外を発生させる.通常の例外処理は行なわれず, インター
-プリタが終了する(ただしensureで指定されたコードは終了前に実
-行される).
+Raises fatal error, terminates the interpreter. No exception handling
+will be done for fatal error, but ensure blocks will be executed.
void rb_bug(char *fmt, ...)
-インタープリタなどプログラムのバグでしか発生するはずのない状
-況の時呼ぶ.インタープリタはコアダンプし直ちに終了する.例外
-処理は一切行なわれない.
+Termintates the interpreter immediately. This function should be
+called under the situation caused by the bug in the interpreter. No
+exception handling nor ensure execution will be done.
** Initialize and Starts the Interpreter
@@ -999,8 +956,7 @@ Specifies the name of the script ($0).
Appendix B. Functions Available in extconf.rb
-extconf.rbの中では利用可能なコンパイル条件チェックの関数は以
-下の通りである.
+These functions are available in extconf.rb:
have_library(lib, func)
@@ -1024,6 +980,6 @@ this method, the compilation will not be done.
/*
* Local variables:
- * fill-column: 60
+ * fill-column: 70
* end:
*/
diff --git a/README.EXT.jp b/README.EXT.jp
new file mode 100644
index 00000000000..da3902b8cc1
--- /dev/null
+++ b/README.EXT.jp
@@ -0,0 +1,1168 @@
+.\" README.EXT - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995
+
+Rubyの拡張ライブラリの作り方を説明します.
+
+1.基礎知識
+
+Cの変数には型があり,データには型がありません.ですから,た
+とえばポインタをintの変数に代入すると,その値は整数として取
+り扱われます.逆にRubyの変数には型がなく,データに型がありま
+す.この違いのため,CとRubyは相互に変換しなければ,お互いの
+データをアクセスできません.
+
+RubyのデータはVALUEというCの型で表現されます.VALUE型のデー
+タはそのデータタイプを自分で知っています.このデータタイプと
+いうのはデータ(オブジェクト)の実際の構造を意味していて,Ruby
+のクラスとはまた違ったものです.
+
+VALUEからCにとって意味のあるデータを取り出すためには
+
+ (1) VALUEのデータタイプを知る
+ (2) VALUEをCのデータに変換する
+
+の両方が必要です.(1)を忘れると間違ったデータの変換が行われ
+て,最悪プログラムがcore dumpします.
+
+1.1 データタイプ
+
+Rubyにはユーザが使う可能性のある以下のタイプがあります.
+
+ T_NIL nil
+ T_OBJECT 通常のオブジェクト
+ T_CLASS クラス
+ T_MODULE モジュール
+ T_FLOAT 浮動小数点数
+ T_STRING 文字列
+ T_REGEXP 正規表現
+ T_ARRAY 配列
+ T_FIXNUM Fixnum(31bit長整数)
+ T_HASH 連想配列
+ T_STRUCT (Rubyの)構造体
+ T_BIGNUM 多倍長整数
+ T_FILE 入出力
+ T_TRUE 真
+ T_FALSE 偽
+ T_DATA データ
+
+その他に内部で利用されている以下のタイプがあります.
+
+ T_ICLASS
+ T_MATCH
+ T_VARMAP
+ T_SCOPE
+ T_NODE
+
+ほとんどのタイプはCの構造体で実装されています.
+
+1.2 VALUEのデータタイプをチェックする
+
+ruby.hではTYPE()というマクロが定義されていて,VALUEのデータ
+タイプを知ることが出来ます.TYPE()マクロは上で紹介したT_XXXX
+の形式の定数を返します.VALUEのデータタイプに応じて処理する
+場合には,TYPE()の値で分岐することになります.
+
+ switch (TYPE(obj)) {
+ case T_FIXNUM:
+ /* FIXNUMの処理 */
+ break;
+ case T_STRING:
+ /* 文字列の処理 */
+ break;
+ case T_ARRAY:
+ /* 配列の処理 */
+ break;
+ default:
+ /* 例外を発生させる */
+ TypeError("not valid value");
+ break;
+ }
+
+それとデータタイプをチェックして,正しくなければ例外を発生す
+る関数が用意されています.
+
+ void Check_Type(VALUE value, int type)
+
+この関数はvalueがtypeで無ければ,例外を発生させます.引数と
+して与えられたVALUEのデータタイプが正しいかどうかチェックす
+るためには,この関数を使います.
+
+FIXNUMとNILに関してはより高速な判別マクロが用意されています.
+
+ FIXNUM_P(obj)
+ NIL_P(obj)
+
+1.3 VALUEをCのデータに変換する
+
+データタイプがT_NIL, T_FALSE, T_TRUEである時,データはそれぞ
+れnil, false, trueです.このデータタイプのオブジェクトはひと
+つずつしか存在しません.
+
+データタイプがT_FIXNUMの時,これは31bitのサイズを持つ整数で
+す.FIXNUMをCの整数に変換するためにはマクロ「FIX2INT()」を使
+います.それから,FIXNUMに限らずRubyのデータを整数に変換する
+「NUM2INT()」というマクロがあります.このマクロはデータタイ
+プのチェック無しで使えます(整数に変換できない場合には例外が
+発生する).
+
+同様にチェック無しで使える変換マクロはdoubleを取り出す
+「NUM2DBL()」とchar*を取り出す「STR2CSTR()」があります.
+
+それ以外のデータタイプは対応するCの構造体があります.対応す
+る構造体のあるVALUEはそのままキャスト(型変換)すれば構造体の
+ポインタに変換できます.
+
+構造体は「struct RXxxxx」という名前でruby.hで定義されていま
+す.例えば文字列は「struct RString」です.実際に使う可能性が
+あるのは文字列と配列くらいだと思います.
+
+ruby.hでは構造体へキャストするマクロも「RXXXXX()」(全部大文
+字にしたもの)という名前で提供されています(例: RSTRING()).
+
+例えば,文字列strの長さを得るためには「RSTRING(str)->len」と
+し,文字列strをchar*として得るためには「RSTRING(str)->ptr」
+とします.配列の場合には,それぞれ「RARRAY(ary)->len」,
+「RARRAY(ary)->ptr」となります.
+
+Rubyの構造体を直接アクセスする時に気をつけなければならないこ
+とは,配列や文字列の構造体の中身は参照するだけで,直接変更し
+ないことです.直接変更した場合,オブジェクトの内容の整合性が
+とれなくなって,思わぬバグの原因になります.
+
+1.4 CのデータをVALUEに変換する
+
+VALUEの実際の構造は
+
+ * FIXNUMの場合
+
+ 1bit左シフトして,LSBを立てる.
+
+ * その他のポインタの場合
+
+ そのままVALUEにキャストする.
+
+となっています.よって,LSBをチェックすればVALUEがFIXNUMかど
+うかわかるわけです(ポインタのLSBが立っていないことを仮定して
+いる).
+
+ですから,FIXNUM以外のRubyのオブジェクトの構造体は単にVALUE
+にキャストするだけでVALUEに変換出来ます.ただし,任意の構造
+体がVALUEにキャスト出来るわけではありません.キャストするの
+はRubyの知っている構造体(ruby.hで定義されているstruct RXxxx
+のもの)だけです.
+
+FIXNUMに関しては変換マクロを経由する必要があります.Cの整数
+からVALUEに変換するマクロは以下のものがあります.必要に応じ
+て使い分けてください.
+
+ INT2FIX() もとの整数が31bit以内に収まる自信がある時
+ INT2NUM() 任意の整数からVALUEへ
+
+INT2NUM()は整数がFIXNUMの範囲に収まらない場合,Bignumに変換
+してくれます(が,少し遅い).
+
+1.5 Rubyのデータを操作する
+
+先程も述べた通り,Rubyの構造体をアクセスする時に内容の更新を
+行うことは勧められません.で,Rubyのデータを操作する時には
+Rubyが用意している関数を用いてください.
+
+ここではもっとも使われるであろう文字列と配列の生成/操作を行
+い関数をあげます(全部ではないです).
+
+ 文字列に対する関数
+
+ rb_str_new(char *ptr, int len)
+
+ 新しいRubyの文字列を生成する.
+
+ rb_str_new2(char *ptr)
+
+ Cの文字列からRubyの文字列を生成する.この関数の機能は
+ rb_str_new(ptr, strlen(ptr))と同等である.
+
+ rb_str_cat(VALUE str, char *ptr, int len)
+
+ Rubyの文字列strにlenバイトの文字列ptrを追加する.
+
+ 配列に対する関数
+
+ rb_ary_new()
+
+ 要素が0の配列を生成する.
+
+ rb_ary_new2(int len)
+
+ 要素が0の配列を生成する.len要素分の領域をあらかじめ割り
+ 当てておく.
+
+ rb_ary_new3(int n, ...)
+
+ 引数で指定したn要素を含む配列を生成する.
+
+ rb_ary_new4(int n, VALUE *elts)
+
+ 配列で与えたn要素の配列を生成する.
+
+ rb_ary_push(VALUE ary, VALUE val)
+ rb_ary_pop(VALUE ary)
+ rb_ary_shift(VALUE ary)
+ rb_ary_unshift(VALUE ary, VALUE val)
+ rb_ary_entry(VALUE ary, int idx)
+
+ Arrayの同名のメソッドと同じ働きをする関数.第1引数は必ず
+ 配列でなければならない.
+
+2.Rubyの機能を使う
+
+原理的にRubyで書けることはCでも書けます.RubyそのものがCで記
+述されているんですから,当然といえば当然なんですけど.ここで
+はRubyの拡張に使うことが多いだろうと予測される機能を中心に紹
+介します.
+
+2.1 Rubyに機能を追加する
+
+Rubyで提供されている関数を使えばRubyインタプリタに新しい機能
+を追加することができます.Rubyでは以下の機能を追加する関数が
+提供されています.
+
+ * クラス,モジュール
+ * メソッド,特異メソッドなど
+ * 定数
+
+では順に紹介します.
+
+2.1.1 クラス/モジュール定義
+
+クラスやモジュールを定義するためには,以下の関数を使います.
+
+ VALUE rb_define_class(char *name, VALUE super)
+ VALUE rb_define_module(char *name)
+
+これらの関数は新しく定義されたクラスやモジュールを返します.
+メソッドや定数の定義にこれらの値が必要なので,ほとんどの場合
+は戻り値を変数に格納しておく必要があるでしょう.
+
+クラスやモジュールを他のクラスの内部にネストして定義する時に
+は以下の関数を使います.
+
+ VALUE rb_define_class(VALUE outer, char *name, VALUE super)
+ VALUE rb_define_module(VALUE outer, char *name)
+
+2.1.2 メソッド/特異メソッド定義
+
+メソッドや特異メソッドを定義するには以下の関数を使います.
+
+ void rb_define_method(VALUE class, char *name,
+ VALUE (*func)(), int argc)
+
+ void rb_define_singleton_method(VALUE object, char *name,
+ VALUE (*func)(), int argc)
+
+
+念のため説明すると「特異メソッド」とは,その特定のオブジェク
+トに対してだけ有効なメソッドです.RubyではよくSmalltalkにお
+けるクラスメソッドとして,クラスに対する特異メソッドが使われ
+ます.
+
+これらの関数の argcという引数はCの関数へ渡される引数の数(と
+形式)を決めます.argcが0以上の時は関数に引き渡す引数の数を意
+味します.16個以上の引数は使えません(が,要りませんよね,そ
+んなに).実際の関数には先頭の引数としてselfが与えられますの
+で,指定した数より1多い引数を持つことになります.
+
+argcが負の時は引数の数ではなく,形式を指定したことになります.
+argcが-1の時は引数を配列に入れて渡されます.argcが-2の時は引
+数はRubyの配列として渡されます.
+
+メソッドを定義する関数はもう二つあります.ひとつはprivateメ
+ソッドを定義する関数で,引数はrb_define_method()と同じです.
+
+ void rb_define_private_method(VALUE class, char *name,
+ VALUE (*func)(), int argc)
+
+privateメソッドとは関数形式でしか呼び出すことの出来ないメソッ
+ドです.
+
+もうひとつはモジュール関数を定義するものです.モジュール関数
+とはモジュールの特異メソッドであり,同時にprivateメソッドで
+もあるものです.例をあげるとMathモジュールのsqrt()などがあげ
+られます.このメソッドは
+
+ Math.sqrt(4)
+
+という形式でも
+
+ include Math
+ sqrt(4)
+
+という形式でも使えます.モジュール関数を定義する関数は以下の
+通りです.
+
+ void rb_define_module_function(VALUE module, char *name,
+ VALUE (*func)(), int argc)
+
+関数的メソッド(Kernelモジュールのprivate method)を定義するた
+めの関数は以下の通りです.
+
+ void rb_define_global_function(char *name, VALUE (*func)(), int argc)
+
+
+2.1.3 定数定義
+
+拡張ライブラリが必要な定数はあらかじめ定義しておいた方が良い
+でしょう.定数を定義する関数は二つあります.
+
+ void rb_define_const(VALUE class, char *name, VALUE val)
+ void rb_define_global_const(char *name, VALUE val)
+
+前者は特定のクラス/モジュールに属する定数を定義するもの,後
+者はグローバルな定数を定義するものです.
+
+2.2 Rubyの機能をCから呼び出す
+
+既に『1.5 Rubyのデータを操作する』で一部紹介したような関数を
+使えば,Rubyの機能を実現している関数を直接呼び出すことが出来
+ます.
+
+# このような関数の一覧表はいまのところありません.ソースを見
+# るしかないですね.
+
+それ以外にもRubyの機能を呼び出す方法はいくつかあります.
+
+2.2.1 Rubyのプログラムをevalする
+
+CからRubyの機能を呼び出すもっとも簡単な方法として,文字列で
+与えられたRubyのプログラムを評価する以下の関数があります.
+
+ VALUE rb_eval_string(char *str)
+
+この評価は現在の環境で行われます.つまり,現在のローカル変数
+などを受け継ぎます.
+
+2.2.2 IDまたはシンボル
+
+Cから文字列を経由せずにRubyのメソッドを呼び出すこともできま
+す.その前に,Rubyインタプリタ内でメソッドや変数名を指定する
+時に使われているIDについて説明しておきましょう.
+
+IDとは変数名,メソッド名を表す整数です.Rubyの中では
+
+ :識別子
+
+でアクセスできます.Cからこの整数を得るためには関数
+
+ rb_intern(char *name)
+
+を使います.また一文字の演算子はその文字コードがそのままシン
+ボルになっています.Rubyから引数として与えられたシンボル(ま
+たは文字列)をIDに変換するには以下の関数を使います.
+
+ rb_to_id(VALUE symbol)
+
+2.2.3 CからRubyのメソッドを呼び出す
+
+Cから文字列を経由せずにRubyのメソッドを呼び出すためには以下
+の関数を使います.
+
+ VALUE rb_funcall(VALUE recv, ID mid, int argc, ...)
+
+この関数はオブジェクトrecvのmidで指定されるメソッドを呼び出
+します.その他に引数の指定の仕方が違う以下の関数もあります.
+
+ VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv)
+ VALUE rb_apply(VALUE recv, ID mid, VALUE args)
+
+applyには引数としてRubyの配列を与えます.
+
+2.2.4 変数/定数を参照/更新する
+
+Cから関数を使って参照・更新できるのは,定数,インスタンス変
+数です.大域変数は一部のものはCの大域変数としてアクセスでき
+ます.ローカル変数を参照する方法は公開していません.
+
+オブジェクトのインスタンス変数を参照・更新する関数は以下の通
+りです.
+
+ VALUE rb_ivar_get(VALUE obj, ID id)
+ VALUE rb_ivar_set(VALUE obj, ID id, VALUE val)
+
+idはrb_intern()で得られるものを使ってください.
+
+定数を参照するには以下の関数を使ってください.
+
+ VALUE rb_const_get(VALUE obj, ID id)
+
+定数を新しく定義するためには『2.1.3 定数定義』で紹介さ
+れている関数を使ってください.
+
+3.RubyとCとの情報共有
+
+C言語とRubyの間で情報を共有する方法について解説します.
+
+3.1 Cから参照できるRubyの定数
+
+以下のRubyの定数はCのレベルから参照できます.
+
+ Qtrue
+ Qfalse
+
+ 真偽値.QfalseはC言語でも偽とみなされます(つまり0).
+
+ Qnil
+
+ C言語から見た「nil」.
+
+3.2 CとRubyで共有される大域変数
+
+CとRubyで大域変数を使って情報を共有できます.共有できる大域
+変数にはいくつかの種類があります.そのなかでもっとも良く使わ
+れると思われるのはrb_define_variable()です.
+
+ void rb_define_variable(char *name, VALUE *var)
+
+この関数はRubyとCとで共有する大域変数を定義します.変数名が
+`$'で始まらない時には自動的に追加されます.この変数の値を変
+更すると自動的にRubyの対応する変数の値も変わります.
+
+またRuby側からは更新できない変数もあります.このread onlyの
+変数は以下の関数で定義します.
+
+ void rb_define_readonly_variable(char *name, VALUE *var)
+
+これら変数の他にhookをつけた大域変数を定義できます.hook付き
+の大域変数は以下の関数を用いて定義します.hook付き大域変数の
+値の参照や設定はhookで行う必要があります.
+
+ void rb_define_hooked_variable(char *name, VALUE *var,
+ VALUE (*getter)(), VALUE (*setter)())
+
+この関数はCの関数によってhookのつけられた大域変数を定義しま
+す.変数が参照された時には関数getterが,変数に値がセットされ
+た時には関数setterが呼ばれる.hookを指定しない場合はgetterや
+setterに0を指定します.
+
+# getterもsetterも0ならばrb_define_variable()と同じになる.
+
+それから,Cの関数によって実現されるRubyの大域変数を定義する
+関数があります.
+
+ void rb_define_virtual_variable(char *name,
+ VALUE (*getter)(), VALUE (*setter)())
+
+この関数によって定義されたRubyの大域変数が参照された時には
+getterが,変数に値がセットされた時にはsetterが呼ばれます.
+
+getterとsetterの仕様は以下の通りです.
+
+ (*getter)(ID id, void *data, struct global_entry* entry);
+ (*setter)(VALUE val, ID id, void *data, struct global_entry* entry);
+
+3.3 CのデータをRubyオブジェクトにする
+
+Cの世界で定義されたデータ(構造体)をRubyのオブジェクトとして
+取り扱いたい場合がありえます.このような場合には,Dataという
+RubyオブジェクトにCの構造体(へのポインタ)をくるむことでRuby
+オブジェクトとして取り扱えるようになります.
+
+Dataオブジェクトを生成して構造体をRubyオブジェクトにカプセル
+化するためには,以下のマクロを使います.
+
+ Data_Wrap_Struct(class,mark,free,ptr)
+
+このマクロの戻り値は生成されたDataオブジェクトです.
+
+classはこのDataオブジェクトのクラスです.ptrはカプセル化する
+Cの構造体へのポインタです.markはこの構造体がRubyのオブジェ
+クトへの参照がある時に使う関数です.そのような参照を含まない
+時には0を指定します.
+
+# そのような参照は勧められません.
+
+freeはこの構造体がもう不要になった時に呼ばれる関数です.この
+関数がガーベージコレクタから呼ばれます.
+
+Cの構造体の割当とDataオブジェクトの生成を同時に行うマクロと
+して以下のものが提供されています.
+
+ Data_Make_Struct(class, type, mark, free, sval)
+
+このマクロの戻り値は生成されたDataオブジェクトです.
+
+class, mark, freeはData_Wrap_Structと同じ働きをします.type
+は割り当てるC構造体の型です.割り当てられた構造体は変数sval
+に代入されます.この変数の型は (type*) である必要があります.
+
+Dataオブジェクトからポインタを取り出すのは以下のマクロを用い
+ます.
+
+ Data_Get_Struct(obj, type, sval)
+
+Cの構造体へのポインタは変数svalに代入されます.
+
+これらのDataの使い方はちょっと分かりにくいので,後で説明する
+例題を参照してください.
+
+4.例題 - dbmパッケージを作る
+
+ここまでの説明でとりあえず拡張ライブラリは作れるはずです.
+Rubyのextディレクトリにすでに含まれているdbmライブラリを例に
+して段階的に説明します.
+
+(1) ディレクトリを作る
+
+ % mkdir ext/dbm
+
+Ruby 1.1からは任意のディレクトリでダイナミックライブラリを作
+ることができるようになりました.Rubyに静的にリンクする場合に
+はRubyを展開したディレクトリの下,extディレクトリの中に拡張
+ライブラリ用のディレクトリを作る必要があります.名前は適当に
+選んで構いません.
+
+(2) MANIFESTファイルを作る
+
+ % cd ext/dbm
+ % touch MANIFEST
+
+拡張ライブラリのディレクトリの下にはMANIFESTというファイルが
+必要なので,とりあえず空のファイルを作っておきます.後でこの
+ファイルには必要なファイル一覧が入ることになります.
+
+MANIFESTというファイルは,静的リンクのmakeの時にディレクトリ
+が拡張ライブラリを含んでいるかどうか判定するために使われれて
+います.ダイナミックライブラリを作る場合には必ずしも必要では
+ありません.
+
+(3) 設計する
+
+まあ,当然なんですけど,どういう機能を実現するかどうかまず設
+計する必要があります.どんなクラスをつくるか,そのクラスには
+どんなメソッドがあるか,クラスが提供する定数などについて設計
+します.dbmクラスについてはext/dbm.docを参照してください.
+
+(4) Cコードを書く
+
+拡張ライブラリ本体となるC言語のソースを書きます.C言語のソー
+スがひとつの時には「ライブラリ名.c」を選ぶと良いでしょう.C
+言語のソースが複数の場合には逆に「ライブラリ名.c」というファ
+イル名は避ける必要があります.オブジェクトファイルとモジュー
+ル生成時に中間的に生成される「ライブラリ名.o」というファイル
+とが衝突するからです.
+
+Rubyは拡張ライブラリをロードする時に「Init_ライブラリ名」と
+いう関数を自動的に実行します.dbmライブラリの場合「Init_dbm」
+です.この関数の中でクラス,モジュール,メソッド,定数などの
+定義を行います.dbm.cから一部引用します.
+
+--
+Init_dbm()
+{
+ /* DBMクラスを定義する */
+ cDBM = rb_define_class("DBM", rb_cObject);
+ /* DBMはEnumerateモジュールをインクルードする */
+ rb_include_module(cDBM, rb_mEnumerable);
+
+ /* DBMクラスのクラスメソッドopen(): 引数はCの配列で受ける */
+ rb_define_singleton_method(cDBM, "open", fdbm_s_open, -1);
+
+ /* DBMクラスのメソッドclose(): 引数はなし */
+ rb_define_method(cDBM, "close", fdbm_close, 0);
+ /* DBMクラスのメソッド[]: 引数は1個 */
+ rb_define_method(cDBM, "[]", fdbm_fetch, 1);
+ :
+
+ /* DBMデータを格納するインスタンス変数名のためのID */
+ id_dbm = rb_intern("dbm");
+}
+--
+
+DBMライブラリはdbmのデータと対応するオブジェクトになるはずで
+すから,Cの世界のdbmをRubyの世界に取り込む必要があります.
+
+
+dbm.cではData_Make_Structを以下のように使っています.
+
+--
+struct dbmdata {
+ int di_size;
+ DBM *di_dbm;
+};
+
+
+obj = Data_Make_Struct(class,struct dbmdata,0,free_dbm,dbmp);
+--
+
+ここではdbmstruct構造体へのポインタをDataにカプセル化してい
+ます.DBM*を直接カプセル化しないのはclose()した時の処理を考
+えてのことです.
+
+Dataオブジェクトからdbmstruct構造体のポインタを取り出すため
+に以下のマクロを使っています.
+
+--
+#define GetDBM(obj, dbmp) {\
+ Data_Get_Struct(obj, struct dbmdata, dbmp);\
+ if (dbmp->di_dbm == 0) closed_dbm();\
+}
+--
+
+ちょっと複雑なマクロですが,要するにdbmdata構造体のポインタ
+の取り出しと,closeされているかどうかのチェックをまとめてい
+るだけです.
+
+DBMクラスにはたくさんメソッドがありますが,分類すると3種類の
+引数の受け方があります.ひとつは引数の数が固定のもので,例と
+してはdeleteメソッドがあります.deleteメソッドを実装している
+fdbm_delete()はこのようになっています.
+
+--
+static VALUE
+fdbm_delete(obj, keystr)
+ VALUE obj, keystr;
+{
+ :
+}
+--
+
+引数の数が固定のタイプは第1引数がself,第2引数以降がメソッド
+の引数となります.
+
+引数の数が不定のものはCの配列で受けるものとRubyの配列で受け
+るものとがあります.dbmライブラリの中で,Cの配列で受けるもの
+はDBMのクラスメソッドであるopen()です.これを実装している関
+数fdbm_s_open()はこうなっています.
+
+--
+static VALUE
+fdbm_s_open(argc, argv, class)
+ int argc;
+ VALUE *argv;
+ VALUE class;
+{
+ :
+ if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
+ mode = 0666; /* default value */
+ }
+ :
+}
+--
+
+このタイプの関数は第1引数が与えられた引数の数,第2引数が与え
+られた引数の入っている配列になります.selfは第3引数として与
+えられます.
+
+この配列で与えられた引数を解析するための関数がopen()でも使わ
+れているrb_scan_args()です.第3引数に指定したフォーマットに
+従い,第4変数以降に指定した変数に値を代入してくれます.この
+フォーマットは,第1文字目が省略できない引数の数,第2文字目が
+省略できる引数の数,第3文字目が対応する相手が無いあまりの引
+数があるかどうかを示す"*"です.2文字目と3文字目は省略できま
+す.dbm.cの例では,フォーマットは"11"ですから,引数は最低1つ
+で,2つまで許されるという意味になります.省略されている時の
+変数の値はnil(C言語のレベルではQnil)になります.
+
+Rubyの配列で引数を受け取るものはindexesがあります.実装はこ
+うです.
+
+--
+static VALUE
+fdbm_indexes(obj, args)
+ VALUE obj, args;
+{
+ :
+}
+--
+
+第1引数はself,第2引数はRubyの配列です.
+
+** 注意事項
+
+Rubyと共有はしないがRubyのオブジェクトを格納する可能性のある
+Cの大域変数は以下の関数を使ってRubyインタプリタに変数の存在
+を教えてあげてください.でないとGCでトラブルを起こします.
+
+ void rb_global_variable(VALUE *var)
+
+(5) extconf.rbを用意する
+
+Makefileを作る場合の雛型になるextconf.rbというファイルを作り
+ます.extconf.rbはライブラリのコンパイルに必要な条件のチェッ
+クなどを行うことが目的です.まず,
+
+ require 'mkmf'
+
+をextconf.rbの先頭に置きます.extconf.rbの中では以下のRuby関
+数を使うことが出来ます.
+
+ have_library(lib, func): ライブラリの存在チェック
+ have_func(func): 関数の存在チェック
+ have_header(header): ヘッダファイルの存在チェック
+ create_makefile(target): Makefileの生成
+
+以下の変数を使うことができます.
+
+ $CFLAGS: コンパイル時に追加的に指定するフラグ(-Iなど)
+ $LDFLAGS: リンク時に追加的に指定するフラグ(-Lなど)
+
+ライブラリをコンパイルする条件が揃わず,そのライブラリをコン
+パイルしない時にはcreate_makefileを呼ばなければMakefileは生
+成されず,コンパイルも行われません.
+
+(6) dependを用意する
+
+もし,ディレクトリにdependというファイルが存在すれば,
+Makefileが依存関係をチェックしてくれます.
+
+ % gcc -MM *.c > depend
+
+などで作ることが出来ます.あって損は無いでしょう.
+
+(7) MANIFESTファイルにファイル名を入れる
+
+ % find * -type f -print > MANIFEST
+ % vi MANIFEST
+
+*.o, *~など不必要なファイル以外はMANIFESTに追加しておきます.
+make時にはMANIFESTの内容は参照しませんので,空のままでも問題
+は起きませんが,パッケージングの時に参照することがあるのと,
+必要なファイルを区別できるので,用意しておいた方が良いでしょ
+う.
+
+(8) Makefileを生成する
+
+Makefileを実際に生成するためには
+
+ ruby extconf.rb
+
+とします.extconf.rbに require 'mkmf' の行がない場合にはエラー
+になりますので,引数を追加して
+
+ ruby -r mkmf extconf.rb
+
+としてください.
+
+ディレクトリをext以下に用意した場合にはRuby全体のmakeの時に
+自動的にMakefileが生成されますので,このステップは不要です.
+
+(9) makeする
+
+動的リンクライブラリを生成する場合にはその場でmakeしてくださ
+い.必要であれば make install でインストールされます.
+
+ext以下にディレクトリを用意した場合は,Rubyのディレクトリで
+makeを実行するとMakefileを生成からmake,必要によってはそのモ
+ジュールのRubyへのリンクまで自動的に実行してくれます.
+extconf.rbを書き換えるなどしてMakefileの再生成が必要な時はま
+たRubyディレクトリでmakeしてください.
+
+拡張ライブラリはmake installでRubyライブラリのディレクトリの
+下にコピーされます.もし拡張ライブラリと協調して使うRubyで記
+述されたプログラムがあり,Rubyライブラリに置きたい場合には,
+拡張ライブラリ用のディレクトリの下に lib というディレクトリ
+を作り,そこに 拡張子 .rb のファイルを置いておけば同時にイン
+ストールされます.
+
+(10) デバッグ
+
+まあ,デバッグしないと動かないでしょうね.ext/Setupにディレ
+クトリ名を書くと静的にリンクするのでデバッガが使えるようにな
+ります.その分コンパイルが遅くなりますけど.
+
+(11) できあがり
+
+後はこっそり使うなり,広く公開するなり,売るなり,ご自由にお
+使いください.Rubyの作者は拡張ライブラリに関して一切の権利を
+主張しません.
+
+Appendix A. Rubyのソースコードの分類
+
+Rubyのソースはいくつかに分類することが出来ます.このうちクラ
+スライブラリの部分は基本的に拡張ライブラリと同じ作り方になっ
+ています.これらのソースは今までの説明でほとんど理解できると
+思います.
+
+Ruby言語のコア
+
+ class.c
+ error.c
+ eval.c
+ gc.c
+ object.c
+ parse.y
+ variable.c
+
+ユーティリティ関数
+
+ dln.c
+ fnmatch.c
+ glob.c
+ regex.c
+ st.c
+ util.c
+
+Rubyコマンドの実装
+
+ dmyext.c
+ inits.c
+ main.c
+ ruby.c
+ version.c
+
+クラスライブラリ
+
+ array.c
+ bignum.c
+ compar.c
+ dir.c
+ enum.c
+ file.c
+ hash.c
+ io.c
+ marshal.c
+ math.c
+ numeric.c
+ pack.c
+ process.c
+ random.c
+ range.c
+ re.c
+ signal.c
+ sprintf.c
+ string.c
+ struct.c
+ time.c
+
+Appendix B. 拡張用関数リファレンス
+
+C言語からRubyの機能を利用するAPIは以下の通りである.
+
+** 型
+
+VALUE
+
+ Rubyオブジェクトを表現する型.必要に応じてキャストして用いる.
+ 組み込み型を表現するCの型はruby.hに記述してあるRで始まる構造
+ 体である.VALUE型をこれらにキャストするためにRで始まる構造体
+ 名を全て大文字にした名前のマクロが用意されている.
+
+** 変数・定数
+
+Qnil
+
+ 定数: nilオブジェクト
+
+Qtrue
+
+ 定数: trueオブジェクト(真のデフォルト値)
+
+Qfalse
+
+ 定数: falseオブジェクト
+
+** Cデータのカプセル化
+
+Data_Wrap_Struct(VALUE class, void (*mark)(), void (*free)(), void *sval)
+
+ Cの任意のポインタをカプセル化したRubyオブジェクトを返す.こ
+ のポインタがRubyからアクセスされなくなった時,freeで指定した
+ 関数が呼ばれる.また,このポインタの指すデータが他のRubyオブ
+ ジェクトを指している場合,markに指定する関数でマークする必要
+ がある.
+
+Data_Make_Struct(class, type, mark, free, sval)
+
+ type型のメモリをmallocし,変数svalに代入した後,それをカプセ
+ ル化したデータを返すマクロ.
+
+Data_Get_Struct(data, type, sval)
+
+ dataからtype型のポインタを取り出し変数svalに代入するマクロ.
+
+** 型チェック
+
+TYPE(value)
+FIXNUM_P(value)
+NIL_P(value)
+void Check_Type(VALUE value, int type)
+void Check_SafeStr(VALUE value)
+
+** 型変換
+
+FIX2INT(value)
+INT2FIX(i)
+NUM2INT(value)
+INT2NUM(i)
+NUM2DBL(value)
+rb_float_new(f)
+STR2CSTR(value)
+rb_str_new2(s)
+
+** クラス/モジュール定義
+
+VALUE rb_define_class(char *name, VALUE super)
+
+ superのサブクラスとして新しいRubyクラスを定義する.
+
+VALUE rb_define_class_under(VALUE module, char *name, VALUE super)
+
+ superのサブクラスとして新しいRubyクラスを定義し,moduleの
+ 定数として定義する.
+
+VALUE rb_define_module(char *name)
+
+ 新しいRubyモジュールを定義する.
+
+VALUE rb_define_module_under(VALUE module, char *name, VALUE super)
+
+ 新しいRubyモジュールを定義し,moduleの定数として定義する.
+
+void rb_include_module(VALUE class, VALUE module)
+
+ モジュールをインクルードする.classがすでにmoduleをインク
+ ルードしている時には何もしない(多重インクルードの禁止).
+
+void rb_extend_object(VALUE object, VALUE module)
+
+ オブジェクトをモジュール(で定義されているメソッド)で拡張する.
+
+** 大域変数定義
+
+void rb_define_variable(char *name, VALUE *var)
+
+ RubyとCとで共有するグローバル変数を定義する.変数名が`$'で
+ 始まらない時には自動的に追加される.nameとしてRubyの識別子
+ として許されない文字(例えば` ')を含む場合にはRubyプログラ
+ ムからは見えなくなる.
+
+void rb_define_readonly_variable(char *name, VALUE *var)
+
+ RubyとCとで共有するread onlyのグローバル変数を定義する.
+ read onlyであること以外はrb_define_variable()と同じ.
+
+void rb_define_virtual_variable(char *name,
+ VALUE (*getter)(), VALUE (*setter)())
+
+ 関数によって実現されるRuby変数を定義する.変数が参照された
+ 時にはgetterが,変数に値がセットされた時にはsetterが呼ばれ
+ る.
+
+void rb_define_hooked_variable(char *name, VALUE *var,
+ VALUE (*getter)(), VALUE (*setter)())
+
+ 関数によってhookのつけられたグローバル変数を定義する.変数
+ が参照された時にはgetterが,関数に値がセットされた時には
+ setterが呼ばれる.getterやsetterに0を指定した時にはhookを
+ 指定しないのと同じ事になる.
+
+void rb_global_variable(VALUE *var)
+
+ GCのため,Rubyプログラムからはアクセスされないが, Rubyオブ
+ ジェクトを含む大域変数をマークする.
+
+** 定数
+
+void rb_define_const(VALUE klass, char *name, VALUE val)
+
+ 定数を定義する.
+
+void rb_define_global_const(char *name, VALUE val)
+
+ 大域定数を定義する.
+
+ rb_define_const(cKernal, name, val)
+
+ と同じ意味.
+
+** メソッド定義
+
+rb_define_method(VALUE class, char *name, VALUE (*func)(), int argc)
+
+ メソッドを定義する.argcはselfを除く引数の数.argcが-1の時,
+ 関数には引数の数(selfを含まない)を第1引数, 引数の配列を第2
+ 引数とする形式で与えられる(第3引数はself).argcが-2の時,
+ 第1引数がself, 第2引数がargs(argsは引数を含むRubyの配列)と
+ いう形式で与えられる.
+
+rb_define_private_method(VALUE class, char *name, VALUE (*func)(), int argc)
+
+ privateメソッドを定義する.引数はrb_define_method()と同じ.
+
+rb_define_singleton_method(VALUE class, char *name, VALUE (*func)(), int argc)
+
+ 特異メソッドを定義する.引数はrb_define_method()と同じ.
+
+rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
+
+ argc,argv形式で与えられた引数を分解する.fmtは必須引数の数,
+ 付加引数の数, 残りの引数があるかを指定する文字列で, "数字
+ 数字*"という形式である. 2 番目の数字と"*"はそれぞれ省略可
+ 能である.必須引数が一つもない場合は0を指定する.第3引数以
+ 降は変数へのポインタで, 該当する要素がその変数に格納される.
+ 付加引数に対応する引数が与えられていない場合は変数にQnilが
+ 代入される.
+
+** Rubyメソッド呼び出し
+
+VALUE rb_funcall(VALUE recv, ID mid, int narg, ...)
+
+ メソッド呼び出し.文字列からmidを得るためにはrb_intern()を
+ 使う.
+
+VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv)
+
+ メソッド呼び出し.引数をargc,argv形式で渡す.
+
+VALUE rb_eval_string(char *str)
+
+ 文字列をRubyとスクリプトしてコンパイル・実行する.
+
+ID rb_intern(char *name)
+
+ 文字列に対応するIDを返す.
+
+char *rb_id2name(ID id)
+
+ IDに対応する文字列を返す(デバッグ用).
+
+char *rb_class2name(VALUE class)
+
+ classの名前を返す(デバッグ用).classが名前を持たない時には,
+ 祖先を遡って名前を持つクラスの名前を返す.
+
+** インスタンス変数
+
+VALUE rb_iv_get(VALUE obj, char *name)
+
+ objのインスタンス変数の値を得る.`@'で始まらないインスタン
+ ス変数は Rubyプログラムからアクセスできない「隠れた」イン
+ スタンス変数になる.定数は大文字の名前を持つクラス(または
+ モジュール)のインスタンス変数として実装されている.
+
+VALUE rb_iv_set(VALUE obj, char *name, VALUE val)
+
+ objのインスタンス変数をvalにセットする.
+
+** 制御構造
+
+VALUE rb_iterate(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
+
+ func2をブロックとして設定し, func1をイテレータとして呼ぶ.
+ func1には arg1が引数として渡され, func2には第1引数にイテレー
+ タから与えられた値, 第2引数にarg2が渡される.
+
+VALUE rb_yield(VALUE val)
+
+ valを値としてイテレータブロックを呼び出す.
+
+VALUE rb_rescue(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
+
+ 関数func1をarg1を引数に呼び出す.func1の実行中に例外が発生
+ した時には func2をarg2を引数として呼ぶ.戻り値は例外が発生
+ しなかった時はfunc1の戻り値, 例外が発生した時にはfunc2の戻
+ り値である.
+
+VALUE rb_ensure(VALUE (*func1)(), void *arg1, void (*func2)(), void *arg2)
+
+ 関数func1をarg1を引数として実行し, 実行終了後(たとえ例外が
+ 発生しても) func2をarg2を引数として実行する.戻り値はfunc1
+ の戻り値である(例外が発生した時は戻らない).
+
+** 例外・エラー
+
+void rb_warning(char *fmt, ...)
+
+ rb_verbose時に標準エラー出力に警告情報を表示する.引数は
+ printf()と同じ.
+
+void rb_raise(rb_eRuntimeError, char *fmt, ...)
+
+ RuntimeError例外を発生させる.引数はprintf()と同じ.
+
+void rb_raise(VALUE exception, char *fmt, ...)
+
+ exceptionで指定した例外を発生させる.fmt以下の引数は
+ printf()と同じ.
+
+void rb_fatal(char *fmt, ...)
+
+ 致命的例外を発生させる.通常の例外処理は行なわれず, インター
+ プリタが終了する(ただしensureで指定されたコードは終了前に
+ 実行される).
+
+void rb_bug(char *fmt, ...)
+
+ インタープリタなどプログラムのバグでしか発生するはずのない
+ 状況の時呼ぶ.インタープリタはコアダンプし直ちに終了する.
+ 例外処理は一切行なわれない.
+
+** Rubyの初期化・実行
+
+Rubyをアプリケーションに埋め込む場合には以下のインタフェース
+を使う.通常の拡張ライブラリには必要ない.
+
+void ruby_init(int argc, char **argv, char **envp)
+
+ Rubyインタプリタの初期化を行なう.
+
+void ruby_run()
+
+ Rubyインタプリタを実行する.
+
+void ruby_script(char *name)
+
+ Rubyのスクリプト名($0)を設定する.
+
+
+Appendix B. extconf.rbで使える関数たち
+
+extconf.rbの中では利用可能なコンパイル条件チェックの関数は以
+下の通りである.
+
+have_library(lib, func)
+
+ 関数funcを定義しているライブラリlibの存在をチェックする.
+ ライブラリが存在する時,trueを返す.
+
+find_library(lib, func, path...)
+
+ 関数funcを定義しているライブラリlibの存在を -Lpath を追加
+ しながらチェックする.ライブラリが見付かった時,trueを返す.
+ 結果をキャッシュしない.
+
+have_func(func)
+
+ 関数funcの存在をチェックする.funcが標準ではリンクされない
+ ライブラリ内のものである時には先にhave_libraryでそのライブ
+ ラリをチェックしておく事.関数が存在する時trueを返す.
+
+have_header(header)
+
+ ヘッダファイルの存在をチェックする.ヘッダファイルが存在す
+ る時trueを返す.
+
+find_header(header)
+
+ ヘッダファイルの存在を -Ipath を追加しながらチェックする.
+ ヘッダファイルが見付かった時trueを返す.結果をキャッシュし
+ ない.
+
+create_makefile(target)
+
+ 拡張ライブラリ用のMakefileを生成する.この関数を呼ばなけれ
+ ばそのライブラリはコンパイルされない.targetはモジュール名
+ を表す.
+
+with_config(withval[, default=nil])
+
+ --with-<withval>で指定されたオプション値を得る.
+
+dir_config(target)
+
+ --with-<target>-dir, --with-<target>-include, --with-<target>-lib
+ のいずれかで指定されるディレクトリを $CFLAGS や $LDFLAGS
+ に追加する.
+
+/*
+ * Local variables:
+ * fill-column: 60
+ * end:
+ */
diff --git a/README.jp b/README.jp
index d137a435d88..8115dc45a08 100644
--- a/README.jp
+++ b/README.jp
@@ -32,24 +32,45 @@ Rubyはテキスト処理関係の能力などに優れ,Perlと同じくらい強力
ftp://ftp.netlab.co.jp/pub/lang/ruby/
+** CVSで
+
+ $ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs login
+ (Logging in to anonymous@cvs.netlab.co.jp)
+ CVS password: guest
+ $ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs checkout ruby
* ホームページ
- RubyのホームページのURLは
+RubyのホームページのURLは
http://www.netlab.co.jp/ruby/jp/
- です.
+です.
* メーリングリスト
- Rubyに関わる話題のためのメーリングリストを開設しました.ア
- ドレスは
+Rubyのメーリングリストがあります。参加希望の方は
+
+ ruby-list-ctl@netlab.co.jp
+
+まで本文に
+
+ subscribe YourFirstName YourFamilyName
+
+と書いて送って下さい。
+
+Ruby開発者向けメーリングリストもあります。こちらではrubyのバ
+グ、将来の仕様拡張など実装上の問題について議論されています。
+参加希望の方は
+
+ ruby-dev-ctl@netlab.co.jp
- ruby-list@netlab.co.jp
+までruby-listと同様の方法でメールしてください。
- です.このアドレスにメールを送れば,自動的に登録されます.
+Ruby拡張モジュールについて話し合うruby-extメーリングリストと
+英語で話し合うruby-talkメーリングリストもあります。参加方法
+はどれも同じです。
* コンパイル・インストール
@@ -142,22 +163,21 @@ Licence)または以下に示す条件でRubyを再配布できます.GPLにつ
(b) 機械可読なソースコードを添付する.
- (c) 変更を行ったバイナリは名前を変更したうえ,ソースの
- 入手法を明示する.
+ (c) 変更を行ったバイナリは名前を変更したうえ,オリジナ
+ ルのソースコードの入手法を明示する.
(d) その他の配布条件を作者と合意する.
4. 他のプログラムへの引用はいかなる目的であれ自由です.た
だし,Rubyに含まれる他の作者によるコードは,それぞれの
作者の意向による制限が加えられます.具体的にはgc.c(一部),
- util.c(一部),st.[ch],regex.[ch], fnmatch.[ch], glob.c
- および./missingディレクトリ下のファイル群が該当します.
- それぞれの配布条件などに付いては各ファイルを参照してく
- ださい.
+ util.c(一部),st.[ch],regex.[ch] および. /missingディ
+ レクトリ下のファイル群が該当します.それぞれの配布条件
+ などに付いては各ファイルを参照してください.
5. Rubyへの入力となるスクリプトおよび,Rubyからの出力の権
利はRubyの作者ではなく,それぞれの入出力を生成した人に
- 属します.また,Rubyに組み込むための拡張モジュールにつ
+ 属します.また,Rubyに組み込むための拡張ライブラリにつ
いても同様です.
6. Rubyは無保証です.作者はRubyをサポートする意志はありま
diff --git a/ToDo b/ToDo
index 3bc78874890..1ecd529b3ee 100644
--- a/ToDo
+++ b/ToDo
@@ -1,8 +1,17 @@
Language Spec.
+* compile time string concatenation, "hello" "world" => "helloworld"
+* ../... outside condition invokes operator method too.
+* %w(a\ b\ c abc) => ["a b c", "abc"]
* package or access control for global variables
-* named arguments like foo(nation:="german").
-* multiple return values, yield values. maybe imcompatible
+* class variable (prefix?)
+* named arguments like foo(nation:="german") or foo(nation: "german").
+* method to retrieve argument information (need new C API)
+* multiple return values, yield values. maybe incompatible ???
+* cascading method invocation ???
+* def Class#method .. end ??
+* class Foo::Bar<Baz .. end, module Boo::Bar .. end
+* def Foo::Bar::baz() .. end ??
Hacking Interpreter
@@ -12,17 +21,28 @@ Hacking Interpreter
* remove rb_eval() recursions
* syntax tree -> bytecode ???
* scrambled script, or script filter
-* regular expression bug /(?:\s+\d+){2}/ URGENT!!
+* setuid ruby
+
+Standard Libraries
+
+* Struct::new([name,]member,...) ??
+* String#scanf(?)
+* Object#fmt(?)
+* Time::strptime
+* Integer[num], Float[num]; Fixnum[num]?
+* method to detect non-number trailer for to_i/to_f.
+* Stream or Port, abstract superclass of IO ?
+* String#{pred,prev}, String#downto
+* optional stepsize argument for succ()
Extension Libraries
-* mod_ruby, FastCGI ruby
-* InterBase module
+* FastCGI ruby
* ptk.rb pTk wrapper that is compatible to tk.rb
Ruby Libraries
-* CGI.rb
+* net/pop.rb net/smtp.rb
* httplib.rb, urllib.rb, nttplib.rb, etc.
* format like perl's
@@ -33,5 +53,4 @@ Tools
Misc
-* translate README.EXT fully into English
* publish Ruby books
diff --git a/array.c b/array.c
index 8f6c0c223f0..9cc0ac1815b 100644
--- a/array.c
+++ b/array.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Aug 6 09:46:12 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -49,7 +49,7 @@ rb_ary_modify(ary)
rb_raise(rb_eTypeError, "can't modify frozen array");
if (FL_TEST(ary, ARY_TMPLOCK))
rb_raise(rb_eTypeError, "can't modify array during sort");
- if (rb_safe_level() >= 4 && !FL_TEST(ary, FL_TAINT))
+ if (!FL_TEST(ary, FL_TAINT) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify array");
}
@@ -72,7 +72,7 @@ rb_ary_frozen_p(ary)
VALUE
rb_ary_new2(len)
- size_t len;
+ long len;
{
NEWOBJ(ary, struct RArray);
OBJSETUP(ary, rb_cArray, T_ARRAY);
@@ -86,6 +86,7 @@ rb_ary_new2(len)
ary->len = 0;
ary->capa = len;
ary->ptr = 0;
+ if (len == 0) len++;
ary->ptr = ALLOC_N(VALUE, len);
return (VALUE)ary;
@@ -107,16 +108,16 @@ rb_ary_new()
VALUE
#ifdef HAVE_STDARG_PROTOTYPES
-rb_ary_new3(size_t n, ...)
+rb_ary_new3(long n, ...)
#else
rb_ary_new3(n, va_alist)
- size_t n;
+ long n;
va_dcl
#endif
{
va_list ar;
VALUE ary;
- size_t i;
+ long i;
if (n < 0) {
rb_raise(rb_eIndexError, "negative number of items(%d)", n);
@@ -135,7 +136,7 @@ rb_ary_new3(n, va_alist)
VALUE
rb_ary_new4(n, elts)
- size_t n;
+ long n;
VALUE *elts;
{
VALUE ary;
@@ -169,7 +170,7 @@ rb_ary_s_new(argc, argv, klass)
VALUE *argv;
VALUE klass;
{
- size_t len = 0;
+ long len = 0;
VALUE size, val;
NEWOBJ(ary, struct RArray);
OBJSETUP(ary, klass, T_ARRAY);
@@ -180,7 +181,7 @@ rb_ary_s_new(argc, argv, klass)
ary->capa = ARY_DEFAULT_SIZE;
}
else {
- size_t capa = NUM2UINT(size);
+ long capa = NUM2LONG(size);
if (capa < 0) {
rb_raise(rb_eArgError, "negative array size");
@@ -194,7 +195,6 @@ rb_ary_s_new(argc, argv, klass)
ary->ptr = ALLOC_N(VALUE, ary->capa);
memfill(ary->ptr, len, val);
ary->len = len;
- rb_obj_call_init((VALUE)ary);
return (VALUE)ary;
}
@@ -208,8 +208,7 @@ rb_ary_s_create(argc, argv, klass)
NEWOBJ(ary, struct RArray);
OBJSETUP(ary, klass, T_ARRAY);
- ary->len = argc;
- ary->capa = argc;
+ ary->len = ary->capa = 0;
if (argc == 0) {
ary->ptr = 0;
}
@@ -217,6 +216,7 @@ rb_ary_s_create(argc, argv, klass)
ary->ptr = ALLOC_N(VALUE, argc);
MEMCPY(ary->ptr, argv, VALUE, argc);
}
+ ary->len = ary->capa = argc;
return (VALUE)ary;
}
@@ -224,19 +224,24 @@ rb_ary_s_create(argc, argv, klass)
void
rb_ary_store(ary, idx, val)
VALUE ary;
- size_t idx;
+ long idx;
VALUE val;
{
rb_ary_modify(ary);
if (idx < 0) {
- idx = RARRAY(ary)->len + idx;
+ idx += RARRAY(ary)->len;
if (idx < 0) {
- rb_raise(rb_eIndexError, "negative index of array");
+ rb_raise(rb_eIndexError, "index %d out of array",
+ idx - RARRAY(ary)->len);
}
}
if (idx >= RARRAY(ary)->capa) {
- RARRAY(ary)->capa = idx + ARY_DEFAULT_SIZE;
+ long capa_inc = RARRAY(ary)->capa / 2;
+ if (capa_inc < ARY_DEFAULT_SIZE) {
+ capa_inc = ARY_DEFAULT_SIZE;
+ }
+ RARRAY(ary)->capa = idx + capa_inc;
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
}
if (idx > RARRAY(ary)->len) {
@@ -310,7 +315,11 @@ rb_ary_unshift(ary, item)
{
rb_ary_modify(ary);
if (RARRAY(ary)->len >= RARRAY(ary)->capa) {
- RARRAY(ary)->capa+=ARY_DEFAULT_SIZE;
+ long capa_inc = RARRAY(ary)->capa / 2;
+ if (capa_inc < ARY_DEFAULT_SIZE) {
+ capa_inc = ARY_DEFAULT_SIZE;
+ }
+ RARRAY(ary)->capa+=capa_inc;
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
}
@@ -326,7 +335,7 @@ rb_ary_unshift(ary, item)
VALUE
rb_ary_entry(ary, offset)
VALUE ary;
- size_t offset;
+ long offset;
{
if (RARRAY(ary)->len == 0) return Qnil;
@@ -341,25 +350,25 @@ rb_ary_entry(ary, offset)
}
static VALUE
-rb_ary_subseq(ary, beg, len)
+rb_ary_subary(ary, beg, len)
VALUE ary;
- size_t beg, len;
+ long beg, len;
{
VALUE ary2;
- if (len <= 0) {
- return rb_ary_new2(0);
- }
+ if (beg > RARRAY(ary)->len) return Qnil;
if (beg < 0) {
len += beg;
beg = 0;
}
+ if (len < 0) return Qnil;
if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
}
if (len < 0) {
len = 0;
}
+ if (len == 0) return rb_ary_new2(0);
ary2 = rb_ary_new2(len);
MEMCPY(RARRAY(ary2)->ptr, RARRAY(ary)->ptr+beg, VALUE, len);
@@ -368,39 +377,6 @@ rb_ary_subseq(ary, beg, len)
return ary2;
}
-static VALUE
-beg_len(range, begp, lenp, len)
- VALUE range;
- size_t *begp, *lenp;
- size_t len;
-{
- size_t beg, end;
- size_t b, e;
-
- if (!rb_range_beg_end(range, &beg, &end)) return Qfalse;
- b = beg; e = end;
-
- if (beg < 0) {
- beg = len + beg;
- }
- if (end < 0) {
- end = len + end;
- }
- if (beg > end) {
- rb_raise(rb_eIndexError, "end smaller than beg [%d..%d]", b, e);
- }
-
- *begp = beg;
- if (beg > len) {
- *lenp = 0;
- }
- else {
- len = end - beg +1;
- *lenp = len;
- }
- return Qtrue;
-}
-
VALUE
rb_ary_aref(argc, argv, ary)
int argc;
@@ -408,29 +384,36 @@ rb_ary_aref(argc, argv, ary)
VALUE ary;
{
VALUE arg1, arg2;
- size_t beg, len;
+ long beg, len;
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
- beg = NUM2UINT(arg1);
- len = NUM2UINT(arg2);
+ beg = NUM2LONG(arg1);
+ len = NUM2LONG(arg2);
if (beg < 0) {
beg = RARRAY(ary)->len + beg;
}
- return rb_ary_subseq(ary, beg, len);
+ return rb_ary_subary(ary, beg, len);
}
/* special case - speeding up */
if (FIXNUM_P(arg1)) {
- return rb_ary_entry(ary, FIX2UINT(arg1));
+ return rb_ary_entry(ary, FIX2LONG(arg1));
}
else if (TYPE(arg1) == T_BIGNUM) {
rb_raise(rb_eIndexError, "index too big");
}
- else if (beg_len(arg1, &beg, &len, RARRAY(ary)->len)) {
+ else {
/* check if idx is Range */
- return rb_ary_subseq(ary, beg, len);
+ switch (rb_range_beg_len(arg1, &beg, &len, RARRAY(ary)->len, 0)) {
+ case Qfalse:
+ break;
+ case Qnil:
+ return Qnil;
+ default:
+ return rb_ary_subary(ary, beg, len);
+ }
}
- return rb_ary_entry(ary, NUM2UINT(arg1));
+ return rb_ary_entry(ary, NUM2LONG(arg1));
}
static VALUE
@@ -438,11 +421,11 @@ rb_ary_index(ary, val)
VALUE ary;
VALUE val;
{
- size_t i;
+ long i;
for (i=0; i<RARRAY(ary)->len; i++) {
if (rb_equal(RARRAY(ary)->ptr[i], val))
- return INT2FIX(i);
+ return INT2NUM(i);
}
return Qnil;
}
@@ -452,11 +435,11 @@ rb_ary_rindex(ary, val)
VALUE ary;
VALUE val;
{
- size_t i = RARRAY(ary)->len;
+ long i = RARRAY(ary)->len;
while (i--) {
if (rb_equal(RARRAY(ary)->ptr[i], val))
- return INT2FIX(i);
+ return INT2NUM(i);
}
return Qnil;
}
@@ -468,11 +451,11 @@ rb_ary_indexes(argc, argv, ary)
VALUE ary;
{
VALUE new_ary;
- size_t i;
+ long i;
new_ary = rb_ary_new2(argc);
for (i=0; i<argc; i++) {
- rb_ary_store(new_ary, i, rb_ary_entry(ary, NUM2UINT(argv[i])));
+ rb_ary_push(new_ary, rb_ary_aref(1, argv+i, ary));
}
return new_ary;
@@ -481,24 +464,24 @@ rb_ary_indexes(argc, argv, ary)
static void
rb_ary_replace(ary, beg, len, rpl)
VALUE ary, rpl;
- size_t beg, len;
+ long beg, len;
{
- if (len < 0) {
- rb_raise(rb_eIndexError, "negative length %d", len);
+ if (len < 0) rb_raise(rb_eIndexError, "negative length %d", len);
+ if (beg < 0) {
+ beg += RARRAY(ary)->len;
+ }
+ if (beg < 0) {
+ beg -= RARRAY(ary)->len;
+ rb_raise(rb_eIndexError, "index %d out of array", beg);
+ }
+ if (beg + len > RARRAY(ary)->len) {
+ len = RARRAY(ary)->len - beg;
}
if (TYPE(rpl) != T_ARRAY) {
rpl = rb_Array(rpl);
}
- if (beg + len < 0 || (beg < 0 && beg <= -len)) {
- rb_raise(rb_eIndexError, "index %d out of range", beg);
- }
- if (beg < 0) {
- len += beg;
- beg = 0;
- }
-
rb_ary_modify(ary);
if (beg >= RARRAY(ary)->len) {
len = beg + RARRAY(rpl)->len;
@@ -511,7 +494,7 @@ rb_ary_replace(ary, beg, len, rpl)
RARRAY(ary)->len = len;
}
else {
- size_t alen;
+ long alen;
if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
@@ -539,24 +522,17 @@ rb_ary_aset(argc, argv, ary)
VALUE ary;
{
VALUE arg1, arg2, arg3;
- size_t offset;
- size_t beg, len;
+ long offset, beg, len;
if (rb_scan_args(argc, argv, "21", &arg1, &arg2, &arg3) == 3) {
- beg = NUM2UINT(arg1);
- len = NUM2UINT(arg2);
-
- if (beg < 0) {
- beg = RARRAY(ary)->len + beg;
- }
- rb_ary_replace(ary, beg, len, arg3);
+ rb_ary_replace(ary, NUM2LONG(arg1), NUM2LONG(arg2), arg3);
return arg3;
}
else if (FIXNUM_P(arg1)) {
- offset = FIX2UINT(arg1);
+ offset = FIX2LONG(arg1);
goto fixnum;
}
- else if (beg_len(arg1, &beg, &len, RARRAY(ary)->len)) {
+ else if (rb_range_beg_len(arg1, &beg, &len, RARRAY(ary)->len, 1)) {
/* check if idx is Range */
rb_ary_replace(ary, beg, len, arg2);
return arg2;
@@ -565,7 +541,7 @@ rb_ary_aset(argc, argv, ary)
rb_raise(rb_eIndexError, "index too big");
}
- offset = NUM2UINT(arg1);
+ offset = NUM2LONG(arg1);
fixnum:
rb_ary_store(ary, offset, arg2);
return arg2;
@@ -575,43 +551,43 @@ VALUE
rb_ary_each(ary)
VALUE ary;
{
- size_t i;
+ long i;
for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(RARRAY(ary)->ptr[i]);
}
- return Qnil;
+ return ary;
}
static VALUE
rb_ary_each_index(ary)
VALUE ary;
{
- size_t i;
+ long i;
for (i=0; i<RARRAY(ary)->len; i++) {
- rb_yield(INT2FIX(i));
+ rb_yield(INT2NUM(i));
}
- return Qnil;
+ return ary;
}
static VALUE
rb_ary_reverse_each(ary)
VALUE ary;
{
- size_t len = RARRAY(ary)->len;
+ long len = RARRAY(ary)->len;
while (len--) {
rb_yield(RARRAY(ary)->ptr[len]);
}
- return Qnil;
+ return ary;
}
static VALUE
rb_ary_length(ary)
VALUE ary;
{
- return INT2FIX(RARRAY(ary)->len);
+ return INT2NUM(RARRAY(ary)->len);
}
static VALUE
@@ -639,7 +615,7 @@ static VALUE
rb_ary_dup(ary)
VALUE ary;
{
- return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr);
+ return rb_ary_s_create(RARRAY(ary)->len, RARRAY(ary)->ptr, CLASS_OF(ary));
}
static VALUE
@@ -663,7 +639,7 @@ VALUE
rb_ary_join(ary, sep)
VALUE ary, sep;
{
- size_t i;
+ long i;
VALUE result, tmp;
if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
@@ -742,11 +718,7 @@ rb_ary_to_s(ary)
return str;
}
-#ifdef USE_THREAD
static ID inspect_key;
-#else
-static VALUE inspect_tbl;
-#endif
struct inspect_arg {
VALUE (*func)();
@@ -764,11 +736,9 @@ static VALUE
inspect_ensure(obj)
VALUE obj;
{
-#ifdef USE_THREAD
VALUE inspect_tbl;
inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
-#endif
rb_ary_pop(inspect_tbl);
return 0;
}
@@ -780,7 +750,6 @@ rb_protect_inspect(func, obj, arg)
{
struct inspect_arg iarg;
-#ifdef USE_THREAD
VALUE inspect_tbl;
if (!inspect_key) {
@@ -791,12 +760,6 @@ rb_protect_inspect(func, obj, arg)
inspect_tbl = rb_ary_new();
rb_thread_local_aset(rb_thread_current(), inspect_key, inspect_tbl);
}
-#else
- if (!inspect_tbl) {
- inspect_tbl = rb_ary_new();
- rb_global_variable(&inspect_tbl);
- }
-#endif
rb_ary_push(inspect_tbl, obj);
iarg.func = func;
iarg.arg1 = obj;
@@ -808,15 +771,11 @@ VALUE
rb_inspecting_p(obj)
VALUE obj;
{
-#ifdef USE_THREAD
VALUE inspect_tbl;
if (!inspect_key) return Qfalse;
inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
if (NIL_P(inspect_tbl)) return Qfalse;
-#else
- if (!inspect_tbl) return Qnil;
-#endif
return rb_ary_includes(inspect_tbl, obj);
}
@@ -824,7 +783,7 @@ static VALUE
inspect_ary(ary)
VALUE ary;
{
- size_t i = 0;
+ long i = 0;
VALUE s, str;
str = rb_str_new2("[");
@@ -953,7 +912,7 @@ rb_ary_delete(ary, item)
VALUE ary;
VALUE item;
{
- size_t i1, i2;
+ long i1, i2;
rb_ary_modify(ary);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
@@ -981,11 +940,11 @@ rb_ary_delete_at(ary, at)
VALUE ary;
VALUE at;
{
- size_t i1, i2, pos;
+ long i1, i2, pos;
VALUE del = Qnil;
rb_ary_modify(ary);
- pos = NUM2UINT(at);
+ pos = NUM2LONG(at);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
if (i1 == pos) {
del = RARRAY(ary)->ptr[i1];
@@ -1005,11 +964,11 @@ static VALUE
rb_ary_delete_if(ary)
VALUE ary;
{
- size_t i1, i2;
+ long i1, i2;
rb_ary_modify(ary);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
- if (rb_yield(RARRAY(ary)->ptr[i1])) continue;
+ if (RTEST(rb_yield(RARRAY(ary)->ptr[i1]))) continue;
if (i1 != i2) {
RARRAY(ary)->ptr[i2] = RARRAY(ary)->ptr[i1];
}
@@ -1024,7 +983,7 @@ static VALUE
rb_ary_filter(ary)
VALUE ary;
{
- size_t i;
+ long i;
rb_ary_modify(ary);
for (i = 0; i < RARRAY(ary)->len; i++) {
@@ -1038,7 +997,7 @@ rb_ary_replace_method(ary, ary2)
VALUE ary, ary2;
{
ary2 = to_ary(ary2);
- rb_ary_replace(ary, 0, RARRAY(ary2)->len, ary2);
+ rb_ary_replace(ary, 0, RARRAY(ary)->len, ary2);
return ary;
}
@@ -1061,20 +1020,28 @@ rb_ary_fill(argc, argv, ary)
VALUE ary;
{
VALUE item, arg1, arg2;
- size_t beg, len, end;
+ long beg, end, len;
VALUE *p, *pend;
- if (rb_scan_args(argc, argv, "12", &item, &arg1, &arg2) == 2 &&
- beg_len(arg1, &beg, &len, RARRAY(ary)->len)) {
- /* beg and len set already */
- }
- else {
- beg = NIL_P(arg1)?0:NUM2UINT(arg1);
+ rb_scan_args(argc, argv, "12", &item, &arg1, &arg2);
+ switch (argc) {
+ case 1:
+ beg = 0;
+ len = RARRAY(ary)->len - beg;
+ break;
+ case 2:
+ if (rb_range_beg_len(arg1, &beg, &len, RARRAY(ary)->len, 1)) {
+ break;
+ }
+ /* fall through */
+ case 3:
+ beg = NIL_P(arg1)?0:NUM2LONG(arg1);
if (beg < 0) {
beg = RARRAY(ary)->len + beg;
if (beg < 0) beg = 0;
}
- len = NIL_P(arg2)?RARRAY(ary)->len - beg:NUM2UINT(arg2);
+ len = NIL_P(arg2)?RARRAY(ary)->len - beg:NUM2LONG(arg2);
+ break;
}
rb_ary_modify(ary);
end = beg + len;
@@ -1138,13 +1105,13 @@ rb_ary_times(ary, times)
VALUE times;
{
VALUE ary2;
- size_t i, len;
+ long i, len;
if (TYPE(times) == T_STRING) {
return rb_ary_join(ary, times);
}
- len = NUM2UINT(times);
+ len = NUM2LONG(times);
if (len < 0) {
rb_raise(rb_eArgError, "negative argument");
}
@@ -1200,7 +1167,7 @@ static VALUE
rb_ary_equal(ary1, ary2)
VALUE ary1, ary2;
{
- size_t i;
+ long i;
if (TYPE(ary2) != T_ARRAY) return Qfalse;
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
@@ -1215,7 +1182,7 @@ static VALUE
rb_ary_eql(ary1, ary2)
VALUE ary1, ary2;
{
- size_t i;
+ long i;
if (TYPE(ary2) != T_ARRAY) return Qfalse;
if (RARRAY(ary1)->len != RARRAY(ary2)->len)
@@ -1231,7 +1198,7 @@ static VALUE
rb_ary_hash(ary)
VALUE ary;
{
- size_t i;
+ long i;
int h;
h = RARRAY(ary)->len;
@@ -1247,7 +1214,7 @@ rb_ary_includes(ary, item)
VALUE ary;
VALUE item;
{
- size_t i;
+ long i;
for (i=0; i<RARRAY(ary)->len; i++) {
if (rb_equal(RARRAY(ary)->ptr[i], item)) {
return Qtrue;
@@ -1261,7 +1228,7 @@ rb_ary_cmp(ary, ary2)
VALUE ary;
VALUE ary2;
{
- size_t i, len;
+ long i, len;
ary2 = to_ary(ary2);
len = RARRAY(ary)->len;
@@ -1285,7 +1252,7 @@ rb_ary_diff(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
- size_t i;
+ long i;
ary2 = to_ary(ary2);
ary3 = rb_ary_new();
@@ -1302,7 +1269,7 @@ rb_ary_and(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
- size_t i;
+ long i;
ary2 = to_ary(ary2);
ary3 = rb_ary_new();
@@ -1320,7 +1287,7 @@ rb_ary_or(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
- size_t i;
+ long i;
if (TYPE(ary2) != T_ARRAY) {
if (rb_ary_includes(ary1, ary2)) return ary1;
@@ -1414,7 +1381,7 @@ static VALUE
rb_ary_nitems(ary)
VALUE ary;
{
- size_t n = 0;
+ long n = 0;
VALUE *p, *pend;
p = RARRAY(ary)->ptr;
@@ -1423,14 +1390,14 @@ rb_ary_nitems(ary)
if (!NIL_P(*p)) n++;
p++;
}
- return INT2FIX(n);
+ return INT2NUM(n);
}
static VALUE
rb_ary_flatten_bang(ary)
VALUE ary;
{
- size_t i;
+ long i;
int mod = 0;
rb_ary_modify(ary);
@@ -1504,6 +1471,7 @@ Init_Array()
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at, 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_method, 1);
rb_define_method(rb_cArray, "clear", rb_ary_clear, 0);
diff --git a/bignum.c b/bignum.c
index 770e86ad807..36a46af3fdb 100644
--- a/bignum.c
+++ b/bignum.c
@@ -26,7 +26,7 @@ typedef unsigned short USHORT;
static VALUE
bignew_1(klass, len, sign)
VALUE klass;
- size_t len;
+ long len;
char sign;
{
NEWOBJ(big, struct RBignum);
@@ -54,7 +54,7 @@ void
rb_big_2comp(x) /* get 2's complement */
VALUE x;
{
- int i = RBIGNUM(x)->len;
+ long i = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(x);
long num;
@@ -79,7 +79,7 @@ static VALUE
bignorm(x)
VALUE x;
{
- size_t len = RBIGNUM(x)->len;
+ long len = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(x);
while (len-- && !ds[len]) ;
@@ -165,13 +165,13 @@ rb_int2inum(n)
VALUE
rb_str2inum(str, base)
- char *str;
+ const char *str;
int base;
{
char sign = 1, c;
unsigned long num;
- size_t len, blen = 1;
- int i;
+ long len, blen = 1;
+ long i;
VALUE z;
USHORT *zds;
@@ -191,6 +191,10 @@ rb_str2inum(str, base)
str++;
base = 16;
}
+ else if (*str == 'b' || *str == 'B') {
+ str++;
+ base = 2;
+ }
else {
base = 8;
}
@@ -204,16 +208,19 @@ rb_str2inum(str, base)
while (str[0] == '0') str++;
len = 3*strlen(str)*sizeof(char);
}
- else { /* base == 10 or 16 */
+ else { /* base == 10, 2 or 16 */
if (base == 16 && str[0] == '0' && (str[1] == 'x'||str[1] == 'X')) {
str += 2;
}
+ if (base == 2 && str[0] == '0' && (str[1] == 'b'||str[1] == 'B')) {
+ str += 2;
+ }
while (str[0] == '0') str++;
len = 4*strlen(str)*sizeof(char);
}
if (len <= (sizeof(VALUE)*CHAR_BIT)) {
- unsigned int val = strtoul((char*)str, 0, base);
+ unsigned long val = strtoul((char*)str, 0, base);
if (POSFIXABLE(val)) {
if (sign) return INT2FIX(val);
@@ -278,7 +285,7 @@ rb_big2str(x, base)
{
VALUE t;
USHORT *ds;
- unsigned int i, j, hbase;
+ unsigned long i, j, hbase;
VALUE ss;
char *s, c;
@@ -316,7 +323,7 @@ rb_big2str(x, base)
s[0] = RBIGNUM(x)->sign ? '+' : '-';
while (i && j) {
- int k = i;
+ long k = i;
unsigned long num = 0;
while (k--) {
num = BIGUP(num) + ds[k];
@@ -352,7 +359,7 @@ rb_big2ulong(x)
VALUE x;
{
unsigned long num;
- size_t len = RBIGNUM(x)->len;
+ long len = RBIGNUM(x)->len;
USHORT *ds;
if (len > sizeof(long)/sizeof(USHORT))
@@ -390,13 +397,20 @@ VALUE
rb_dbl2big(d)
double d;
{
- unsigned int i = 0;
+ unsigned long i = 0;
long c;
USHORT *digits;
VALUE z;
double u = (d < 0)?-d:d;
- while (0 != (long)u) {
+ if (isinf(d)) {
+ rb_raise(rb_eFloatDomainError, d < 0 ? "-Infinity" : "Infinity");
+ }
+ if (isnan(d)) {
+ rb_raise(rb_eFloatDomainError, "NaN");
+ }
+
+ while (!POSFIXABLE(u) || 0 != (long)u) {
u /= (double)(BIGRAD);
i++;
}
@@ -417,7 +431,7 @@ rb_big2dbl(x)
VALUE x;
{
double d = 0.0;
- size_t i = RBIGNUM(x)->len;
+ long i = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(x);
while (i--) {
@@ -438,7 +452,7 @@ static VALUE
rb_big_cmp(x, y)
VALUE x, y;
{
- size_t xlen = RBIGNUM(x)->len;
+ long xlen = RBIGNUM(x)->len;
switch (TYPE(y)) {
case T_FIXNUM:
@@ -490,7 +504,7 @@ rb_big_neg(x)
VALUE x;
{
VALUE z = rb_big_clone(x);
- size_t i = RBIGNUM(x)->len;
+ long i = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(z);
if (!RBIGNUM(x)->sign) rb_big_2comp(z);
@@ -508,7 +522,7 @@ bigsub(x, y)
VALUE z = 0;
USHORT *zds;
long num;
- size_t i;
+ long i;
i = RBIGNUM(x)->len;
/* if x is larger than y, swap */
@@ -556,7 +570,7 @@ bigadd(x, y, sign)
{
VALUE z;
long num;
- size_t i, len;
+ long i, len;
sign = (sign == RBIGNUM(y)->sign);
if (RBIGNUM(x)->sign != sign) {
@@ -636,7 +650,7 @@ VALUE
rb_big_mul(x, y)
VALUE x, y;
{
- size_t i, j;
+ long i, j;
unsigned long n = 0;
VALUE z;
USHORT *zds;
@@ -685,11 +699,11 @@ bigdivmod(x, y, div, mod, modulo)
VALUE *div, *mod;
int modulo;
{
- size_t nx = RBIGNUM(x)->len, ny = RBIGNUM(y)->len;
- int i, j;
+ long nx = RBIGNUM(x)->len, ny = RBIGNUM(y)->len;
+ long i, j;
VALUE yy, z;
USHORT *xds, *yds, *zds, *tds;
- size_t t2;
+ unsigned long t2;
long num;
USHORT dd, q;
@@ -711,10 +725,11 @@ bigdivmod(x, y, div, mod, modulo)
zds[i] = (USHORT)(t2 / dd);
t2 %= dd;
}
+ RBIGNUM(z)->sign = RBIGNUM(x)->sign==RBIGNUM(y)->sign;
if (div) *div = bignorm(z);
if (mod) {
if (!RBIGNUM(y)->sign) t2 = -(long)t2;
- *mod = INT2FIX(t2);
+ *mod = INT2NUM(t2);
}
return;
}
@@ -798,7 +813,7 @@ bigdivmod(x, y, div, mod, modulo)
RBIGNUM(*mod)->len = ny;
RBIGNUM(*mod)->sign = RBIGNUM(x)->sign;
if (modulo && RBIGNUM(x)->sign != RBIGNUM(y)->sign) {
- size_t len = ny;
+ long len = ny;
zds = BDIGITS(*mod);
while (len-- && !zds[len]);
if (len > 0) {
@@ -936,6 +951,7 @@ rb_big_pow(x, y)
}
z = rb_big_mul(z, x);
}
+ if (!FIXNUM_P(z)) z = bignorm(z);
return z;
}
d = (double)yy;
@@ -953,7 +969,7 @@ rb_big_and(x, y)
{
VALUE z;
USHORT *ds1, *ds2, *zds;
- size_t i, l1, l2;
+ long i, l1, l2;
char sign;
if (FIXNUM_P(y)) {
@@ -985,7 +1001,7 @@ rb_big_and(x, y)
ds2 = BDIGITS(y);
sign = RBIGNUM(x)->sign;
}
- z = bignew(l2, RBIGNUM(x)->sign && RBIGNUM(y)->sign);
+ z = bignew(l2, RBIGNUM(x)->sign || RBIGNUM(y)->sign);
zds = BDIGITS(z);
for (i=0; i<l1; i++) {
@@ -1004,7 +1020,7 @@ rb_big_or(x, y)
{
VALUE z;
USHORT *ds1, *ds2, *zds;
- unsigned int i, l1, l2;
+ unsigned long i, l1, l2;
char sign;
if (FIXNUM_P(y)) {
@@ -1036,7 +1052,7 @@ rb_big_or(x, y)
ds2 = BDIGITS(y);
sign = RBIGNUM(x)->sign;
}
- z = bignew(l2, RBIGNUM(x)->sign || RBIGNUM(y)->sign);
+ z = bignew(l2, RBIGNUM(x)->sign && RBIGNUM(y)->sign);
zds = BDIGITS(z);
for (i=0; i<l1; i++) {
@@ -1112,11 +1128,11 @@ rb_big_lshift(x, y)
{
USHORT *xds, *zds;
int shift = NUM2INT(y);
- size_t s1 = shift/BITSPERDIG;
- size_t s2 = shift%BITSPERDIG;
+ int s1 = shift/BITSPERDIG;
+ int s2 = shift%BITSPERDIG;
VALUE z;
unsigned long num = 0;
- size_t len, i;
+ long len, i;
if (shift < 0) return rb_big_rshift(x, INT2FIX(-shift));
xds = BDIGITS(x);
@@ -1141,12 +1157,12 @@ rb_big_rshift(x, y)
{
USHORT *xds, *zds;
int shift = NUM2INT(y);
- size_t s1 = shift/BITSPERDIG;
- size_t s2 = shift%BITSPERDIG;
+ int s1 = shift/BITSPERDIG;
+ int s2 = shift%BITSPERDIG;
VALUE z;
unsigned long num = 0;
- size_t i = RBIGNUM(x)->len;
- size_t j;
+ long i = RBIGNUM(x)->len;
+ long j;
if (shift < 0) return rb_big_lshift(x, INT2FIX(-shift));
if (s1 > RBIGNUM(x)->len) {
@@ -1173,7 +1189,7 @@ rb_big_aref(x, y)
{
USHORT *xds;
int shift = NUM2INT(y);
- size_t s1, s2;
+ int s1, s2;
if (shift < 0) return INT2FIX(0);
s1 = shift/BITSPERDIG;
@@ -1197,7 +1213,7 @@ static VALUE
rb_big_hash(x)
VALUE x;
{
- size_t i, len;
+ long i, len;
int key;
USHORT *digits;
@@ -1216,7 +1232,7 @@ rb_big_coerce(x, y)
return rb_assoc_new(rb_int2big(FIX2LONG(y)), x);
}
else {
- rb_raise(rb_eTypeError, "can't coerce %s to Bignum",
+ rb_raise(rb_eTypeError, "Can't coerce %s to Bignum",
rb_class2name(CLASS_OF(y)));
}
/* not reached */
@@ -1243,7 +1259,7 @@ rb_big_rand(max)
VALUE max;
{
struct RBignum *v;
- size_t len;
+ long len;
len = RBIGNUM(max)->len;
v = RBIGNUM(bignew(len,1));
diff --git a/class.c b/class.c
index 86ac8c5ae79..32dc0e13728 100644
--- a/class.c
+++ b/class.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Aug 10 15:05:44 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -105,7 +105,7 @@ rb_define_class_id(id, super)
VALUE
rb_define_class(name, super)
- char *name;
+ const char *name;
VALUE super;
{
VALUE klass;
@@ -122,7 +122,7 @@ rb_define_class(name, super)
VALUE
rb_define_class_under(outer, name, super)
VALUE outer;
- char *name;
+ const char *name;
VALUE super;
{
VALUE klass;
@@ -164,7 +164,7 @@ rb_define_module_id(id)
VALUE
rb_define_module(name)
- char *name;
+ const char *name;
{
VALUE module;
ID id;
@@ -179,7 +179,7 @@ rb_define_module(name)
VALUE
rb_define_module_under(outer, name)
VALUE outer;
- char *name;
+ const char *name;
{
VALUE module;
ID id;
@@ -199,8 +199,11 @@ include_class_new(module, super)
NEWOBJ(klass, struct RClass);
OBJSETUP(klass, rb_cClass, T_ICLASS);
- klass->m_tbl = RCLASS(module)->m_tbl;
+ if (!RCLASS(module)->iv_tbl) {
+ RCLASS(module)->iv_tbl = st_init_numtable();
+ }
klass->iv_tbl = RCLASS(module)->iv_tbl;
+ klass->m_tbl = RCLASS(module)->m_tbl;
klass->super = super;
if (TYPE(module) == T_ICLASS) {
RBASIC(klass)->klass = RBASIC(module)->klass;
@@ -365,6 +368,8 @@ method_list(mod, option, func)
VALUE klass;
VALUE *p, *q, *pend;
+ if (!FL_TEST(mod, FL_TAINT) && rb_safe_level() >= 4)
+ rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
ary = rb_ary_new();
for (klass = mod; klass; klass = RCLASS(klass)->super) {
st_foreach(RCLASS(klass)->m_tbl, func, ary);
@@ -426,6 +431,8 @@ rb_obj_singleton_methods(obj)
VALUE klass;
VALUE *p, *q, *pend;
+ if (rb_safe_level() >= 4 && !FL_TEST(obj, FL_TAINT))
+ rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
ary = rb_ary_new();
klass = CLASS_OF(obj);
while (klass && FL_TEST(klass, FL_SINGLETON)) {
@@ -458,7 +465,7 @@ rb_define_method_id(klass, name, func, argc)
void
rb_define_method(klass, name, func, argc)
VALUE klass;
- char *name;
+ const char *name;
VALUE (*func)();
int argc;
{
@@ -472,7 +479,7 @@ rb_define_method(klass, name, func, argc)
void
rb_define_protected_method(klass, name, func, argc)
VALUE klass;
- char *name;
+ const char *name;
VALUE (*func)();
int argc;
{
@@ -483,7 +490,7 @@ rb_define_protected_method(klass, name, func, argc)
void
rb_define_private_method(klass, name, func, argc)
VALUE klass;
- char *name;
+ const char *name;
VALUE (*func)();
int argc;
{
@@ -494,7 +501,7 @@ rb_define_private_method(klass, name, func, argc)
void
rb_undef_method(klass, name)
VALUE klass;
- char *name;
+ const char *name;
{
rb_add_method(klass, rb_intern(name), 0, NOEX_UNDEF);
}
@@ -504,7 +511,7 @@ rb_singleton_class(obj)
VALUE obj;
{
if (rb_special_const_p(obj)) {
- rb_raise(rb_eTypeError, "cannot define singleton");
+ rb_raise(rb_eTypeError, "can't define singleton");
}
if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON)) {
return RBASIC(obj)->klass;
@@ -517,7 +524,7 @@ rb_singleton_class(obj)
void
rb_define_singleton_method(obj, name, func, argc)
VALUE obj;
- char *name;
+ const char *name;
VALUE (*func)();
int argc;
{
@@ -527,7 +534,7 @@ rb_define_singleton_method(obj, name, func, argc)
void
rb_define_module_function(module, name, func, argc)
VALUE module;
- char *name;
+ const char *name;
VALUE (*func)();
int argc;
{
@@ -537,7 +544,7 @@ rb_define_module_function(module, name, func, argc)
void
rb_define_global_function(name, func, argc)
- char *name;
+ const char *name;
VALUE (*func)();
int argc;
{
@@ -547,7 +554,7 @@ rb_define_global_function(name, func, argc)
void
rb_define_alias(klass, name1, name2)
VALUE klass;
- char *name1, *name2;
+ const char *name1, *name2;
{
rb_alias(klass, rb_intern(name1), rb_intern(name2));
}
@@ -555,7 +562,7 @@ rb_define_alias(klass, name1, name2)
void
rb_define_attr(klass, name, read, write)
VALUE klass;
- char *name;
+ const char *name;
int read, write;
{
rb_attr(klass, rb_intern(name), read, write, Qfalse);
@@ -571,17 +578,17 @@ rb_define_attr(klass, name, read, write)
int
#ifdef HAVE_STDARG_PROTOTYPES
-rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
+rb_scan_args(int argc, VALUE *argv, const char *fmt, ...)
#else
rb_scan_args(argc, argv, fmt, va_alist)
int argc;
VALUE *argv;
- char *fmt;
+ const char *fmt;
va_dcl
#endif
{
int n, i;
- char *p = fmt;
+ const char *p = fmt;
VALUE *var;
va_list vargs;
@@ -596,10 +603,10 @@ rb_scan_args(argc, argv, fmt, va_alist)
if (ISDIGIT(*p)) {
n = *p - '0';
if (n > argc)
- rb_raise(rb_eArgError, "Wrong # of arguments (%d for %d)", argc, n);
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for %d)", argc, n);
for (i=0; i<n; i++) {
var = va_arg(vargs, VALUE*);
- *var = argv[i];
+ if (var) *var = argv[i];
}
p++;
}
@@ -612,10 +619,10 @@ rb_scan_args(argc, argv, fmt, va_alist)
for (; i<n; i++) {
var = va_arg(vargs, VALUE*);
if (argc > i) {
- *var = argv[i];
+ if (var) *var = argv[i];
}
else {
- *var = Qnil;
+ if (var) *var = Qnil;
}
}
p++;
@@ -624,15 +631,15 @@ rb_scan_args(argc, argv, fmt, va_alist)
if(*p == '*') {
var = va_arg(vargs, VALUE*);
if (argc > i) {
- *var = rb_ary_new4(argc-i, argv+i);
+ if (var) *var = rb_ary_new4(argc-i, argv+i);
}
else {
- *var = rb_ary_new();
+ if (var) *var = rb_ary_new();
}
}
else if (*p == '\0') {
if (argc > i) {
- rb_raise(rb_eArgError, "Wrong # of arguments(%d for %d)", argc, i);
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)", argc, i);
}
}
else {
diff --git a/compar.c b/compar.c
index a6212a86bbf..50e4fa3a874 100644
--- a/compar.c
+++ b/compar.c
@@ -6,7 +6,7 @@
$Date$
created at: Thu Aug 26 14:39:48 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
diff --git a/config.guess b/config.guess
index 042d209871e..7e23afe37be 100644
--- a/config.guess
+++ b/config.guess
@@ -62,6 +62,9 @@ trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:OS/2:*:*)
+ echo "i386-pc-os2_emx"
+ exit 0;;
alpha:OSF1:*:*)
if test $UNAME_RELEASE = "V4.0"; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -379,7 +382,7 @@ EOF
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/6?? | 9000/7?? | 9000/80[24] | 9000/8?[13679] | 9000/892 )
+ 9000/[678]?? )
sed 's/^ //' << EOF >dummy.c
#include <stdlib.h>
#include <unistd.h>
@@ -621,11 +624,11 @@ EOF
objdump --private-headers dummy | \
grep ld.so.1 > /dev/null
if test "$?" = 0 ; then
- LIBC="libc1"
+ LIBC="-libc1"
fi
fi
rm -f dummy.s dummy
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
+ echo ${UNAME_MACHINE}-unknown-linux${LIBC} ; exit 0
elif test "${UNAME_MACHINE}" = "mips" ; then
cat >dummy.c <<EOF
main(argc, argv)
diff --git a/config.sub b/config.sub
index 858aba7aa5f..aa2241272b3 100644
--- a/config.sub
+++ b/config.sub
@@ -151,7 +151,7 @@ case $basic_machine in
# Some are omitted here because they have special meanings below.
tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
| arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
- | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 | hppa2.0 \
+ | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w \
| alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
@@ -178,7 +178,7 @@ case $basic_machine in
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
| power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
- | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* \
+ | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
| alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
| ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
| sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
@@ -705,6 +705,8 @@ case $os in
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
+ -os2_emx)
+ ;;
# First accept the basic system types.
# The portable systems comes first.
# Each alternative MUST END IN A *, to match a version number.
@@ -721,7 +723,7 @@ case $os in
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux* | -uxpv* | -beos*)
+ | -mingw32* | -linux* | -uxpv* | -beos* | -rhapsody* )
# Remember, each alternative MUST END IN *, to match a version number.
;;
-sunos5*)
diff --git a/config_h.dj b/config_h.dj
new file mode 100644
index 00000000000..36b80537fd1
--- /dev/null
+++ b/config_h.dj
@@ -0,0 +1,71 @@
+#define USE_THREAD 1
+#define SIZEOF_INT 4
+#define SIZEOF_SHORT 2
+#define SIZEOF_LONG 4
+#define SIZEOF_VOIDP 4
+#define SIZEOF_FLOAT 4
+#define SIZEOF_DOUBLE 8
+#define HAVE_PROTOTYPES 1
+#define TOKEN_PASTE(x,y) x##y
+#define HAVE_STDARG_PROTOTYPES 1
+#define HAVE_ATTR_NORETURN 1
+#define HAVE_DIRENT_H 1
+#define STDC_HEADERS 1
+#define HAVE_STDLIB_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_LIMITS_H 1
+#define HAVE_SYS_FILE_H 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_PWD_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_TIMES_H 1
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_WAIT_H 1
+#define HAVE_STRING_H 1
+#define HAVE_UTIME_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_DIRECT_H 1
+#define HAVE_ST_BLKSIZE 1
+#define HAVE_ST_RDEV 1
+#define GETGROUPS_T gid_t
+#define RETSIGTYPE void
+#define HAVE_ALLOCA 1
+#define vfork fork
+#define HAVE_DUP2 1
+#define HAVE_SETENV 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MKDIR 1
+#define HAVE_STRCASECMP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRFTIME 1
+#define HAVE_STRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_STRTOUL 1
+#define HAVE_STRDUP 1
+#define HAVE_ISINF 1
+#define HAVE_ISNAN 1
+#define HAVE_FINITE 1
+#define HAVE_FMOD 1
+#define HAVE_RANDOM 1
+#define HAVE_WAITPID 1
+#define HAVE_GETCWD 1
+#define HAVE_TRUNCATE 1
+#define HAVE_CHSIZE 1
+#define HAVE_TIMES 1
+#define HAVE_UTIMES 1
+#define HAVE_FCNTL_H 1
+/*#define HAVE_SETITIMER 1*/
+#define HAVE_GETGROUPS 1
+#define HAVE_SIGPROCMASK 1
+#define HAVE_SIGACTION 1
+#define HAVE_SETSID 1
+#define POSIX_SIGNAL 1
+#define BSD_SETPGRP setpgrp
+#define RSHIFT(x,y) ((x)>>y)
+#define FILE_COUNT _cnt
+#define DLEXT ".o"
+#define RUBY_LIB "/usr/local/lib/ruby/1.4"
+#define RUBY_SITE_LIB "/usr/local/lib/ruby/1.4/site_ruby"
+#define RUBY_PLATFORM "i386-djgpp"
+#define RUBY_ARCHLIB "/usr/local/lib/ruby/1.4/i386-djgpp"
+#define RUBY_SITE_ARCHLIB "/usr/local/lib/ruby/1.4/site_ruby/i386-djgpp"
diff --git a/config_s.dj b/config_s.dj
new file mode 100644
index 00000000000..7ba18e43765
--- /dev/null
+++ b/config_s.dj
@@ -0,0 +1,56 @@
+s%@CFLAGS@%-O2%g
+s%@CPPFLAGS@%%g
+s%@CXXFLAGS@%%g
+s%@DEFS@% -DUSE_THREAD=1 -DSIZEOF_INT=4 -DSIZEOF_LONG=4 -DSIZEOF_VOIDP=4 -DHAVE_PROTOTYPES=1 -DHAVE_STDARG_PROTOTYPES=1 -DHAVE_ATTR_NORETURN=1 -DHAVE_DIRENT_H=1 -DSTDC_HEADERS=1 -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_PWD_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_TIMES_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_WAIT_H=1 -DHAVE_STRING_H=1 -DHAVE_UTIME_H=1 -DHAVE_MEMORY_H=1 -DHAVE_DIRECT_H=1 -DHAVE_ST_BLKSIZE=1 -DHAVE_ST_RDEV=1 -DGETGROUPS_T=gid_t -DRETSIGTYPE=void -DHAVE_ALLOCA=1 -Dvfork=fork -DHAVE_DUP2=1 -DHAVE_SETENV=1 -DHAVE_MEMMOVE=1 -DHAVE_MKDIR=1 -DHAVE_STRCASECMP=1 -DHAVE_STRERROR=1 -DHAVE_STRFTIME=1 -DHAVE_STRCHR=1 -DHAVE_STRSTR=1 -DHAVE_STRTOUL=1 -DHAVE_STRDUP=1 -DHAVE_FMOD=1 -DHAVE_RANDOM=1 -DHAVE_WAITPID=1 -DHAVE_GETCWD=1 -DHAVE_TRUNCATE=1 -DHAVE_CHSIZE=1 -DHAVE_TIMES=1 -DHAVE_UTIMES=1 -DHAVE_FCNTL=1 -DHAVE_SETITIMER=1 -DHAVE_GETGROUPS=1 -DHAVE_SIGPROCMASK=1 -DHAVE_SIGACTION=1 -DHAVE_SETSID=1 -DPOSIX_SIGNAL=1 -DBSD_SETPGRP=setpgrp -DRSHIFT=\(x,y\)\ \(\(x\)\>\>y\) -DFILE_COUNT=_cnt -DDLEXT=\".so\" -DRUBY_LIB=\"/usr/local/lib/ruby\" -DRUBY_SITE_LIB=\"/usr/local/lib/ruby/site_ruby\" -DRUBY_ARCHLIB=\"/usr/local/lib/ruby/i386-djgpp\" -DRUBY_SITE_ARCHLIB=\"/usr/local/lib/ruby/site_ruby/i386-djgpp\" -DRUBY_PLATFORM=\"i386-djgpp\" %g
+s%@LDFLAGS@%%g
+s%@LIBS@%-lm %g
+s%@exec_prefix@%${prefix}%g
+s%@prefix@%/usr/local%g
+s%@program_transform_name@%s,x,x,%g
+s%@bindir@%${exec_prefix}/bin%g
+s%@sbindir@%${exec_prefix}/sbin%g
+s%@libexecdir@%${exec_prefix}/libexec%g
+s%@datadir@%${prefix}/share%g
+s%@sysconfdir@%${prefix}/etc%g
+s%@sharedstatedir@%${prefix}/com%g
+s%@localstatedir@%${prefix}/var%g
+s%@libdir@%${exec_prefix}/lib%g
+s%@includedir@%${prefix}/include%g
+s%@oldincludedir@%/usr/include%g
+s%@infodir@%${prefix}/info%g
+s%@mandir@%${prefix}/man%g
+s%@host@%i386-pc-djgpp%g
+s%@host_alias@%i386-djgpp%g
+s%@host_cpu@%i386%g
+s%@host_vendor@%pc%g
+s%@host_os@%djgpp%g
+s%@CC@%gcc%g
+s%@CPP@%gcc -E%g
+s%@YACC@%bison -y%g
+s%@RANLIB@%ranlib%g
+s%@AR@%ar%g
+s%@INSTALL_PROGRAM@%${INSTALL}%g
+s%@INSTALL_DATA@%${INSTALL} -m 644%g
+s%@SET_MAKE@%%g
+s%@LIBOBJS@% crypt.o flock.o fnmatch.o snprintf.o%g
+s%@ALLOCA@%%g
+s%@DEFAULT_KCODE@%%g
+s%@EXEEXT@%.exe%g
+s%@OBJEXT@%o%g
+s%@DLDFLAGS@%%g
+s%@STATIC@%%g
+s%@CCDLFLAGS@%%g
+s%@LDSHARED@%ld%g
+s%@DLEXT@%o%g
+s%@STRIP@%strip%g
+s%@EXTSTATIC@%%g
+s%@binsuffix@%.exe%g
+s%@setup@%Setup%g
+s%@LIBRUBY@%libruby.a%g
+s%@LIBRUBY_A@%libruby.a%g
+s%@LIBRUBYARG@%libruby.a%g
+s%@LIBRUBY_SO@%%g
+s%@SOLIBS@%%g
+s%@srcdir%.%g
+s%@arch@%i386-djgpp%g
+ac_given_srcdir=.
diff --git a/configure b/configure
index 31a40f05e8f..700b05c4968 100644
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12.2
+# Generated automatically using autoconf version 2.13
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
@@ -14,13 +14,17 @@ ac_default_prefix=/usr/local
ac_help="$ac_help
--without-gcc never use gcc"
ac_help="$ac_help
---disable-thread never use user-level thread"
-ac_help="$ac_help
--enable-fat-binary build a NeXT/Apple Multi Architecture Binary. "
ac_help="$ac_help
+--with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)"
+ac_help="$ac_help
--with-dln-a-out use dln_a_out if possible"
ac_help="$ac_help
--with-static-linked-ext link external modules statically"
+ac_help="$ac_help
+--enable-shared build a shared library for Ruby. "
+ac_help="$ac_help
+--with-search-path specify the additional search path"
# Initialize some variables set by options.
# The variables have the same names as the options, with
@@ -343,7 +347,7 @@ EOF
verbose=yes ;;
-version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.12.2"
+ echo "configure generated by autoconf version 2.13"
exit 0 ;;
-with-* | --with-*)
@@ -532,6 +536,13 @@ fi
+rb_version=`grep RUBY_VERSION $srcdir/version.h`
+MAJOR=`expr "$rb_version" : '#define RUBY_VERSION "\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*"'`
+MINOR=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*"'`
+TEENY=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)"'`
+
+
+
# Check whether --with-gcc or --without-gcc was given.
if test "${with_gcc+set}" = set; then
withval="$with_gcc"
@@ -554,22 +565,6 @@ then
(it is also a good idea to do 'make clean' before compiling)" 1>&2; exit 1; }
fi
-rb_thread=yes
-# Check whether --enable-thread or --disable-thread was given.
-if test "${enable_thread+set}" = set; then
- enableval="$enable_thread"
-
- rb_thread=$enableval
-
-fi
-
-if test $rb_thread = yes; then
- cat >> confdefs.h <<\EOF
-#define USE_THREAD 1
-EOF
-
-fi
-
ac_aux_dir=
for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
if test -f $ac_dir/install-sh; then
@@ -596,7 +591,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:600: checking host system type" >&5
+echo "configure:595: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@@ -621,30 +616,22 @@ fat_binary=no
# Check whether --enable-fat-binary or --disable-fat-binary was given.
if test "${enable_fat_binary+set}" = set; then
enableval="$enable_fat_binary"
- fat_binary=$enableval
+ fat_binary=$enableval
fi
if test "$fat_binary" = yes ; then
- echo $ac_n "checking target architecture ""... $ac_c" 1>&6
-echo "configure:631: checking target architecture " >&5
+ echo $ac_n "checking target architecture""... $ac_c" 1>&6
+echo "configure:626: checking target architecture" >&5
case "$host_os" in
rhapsody*)
echo -n "MacOS X Server: "
- if test "$TARGET_ARCHS" = "" ; then
- TARGET_ARCHS="ppc i386"
- fi
+ if test "$TARGET_ARCHS" = "" ; then
+ TARGET_ARCHS="ppc i386"
+ fi
;;
nextstep*|openstep*)
- echo -n "NeXTSTEP/OPENSTEP: "
-
- if test "$host_os" = "rhapsody" ; then
- echo -n "Rhapsody: "
- if test "$TARGET_ARCHS" = "" ; then
- TARGET_ARCHS="ppc i486"
- fi
- else
echo -n "NeXTSTEP/OPENSTEP: "
if test "$TARGET_ARCHS" = "" ; then
if test `/usr/bin/arch` = "m68k" ; then
@@ -653,7 +640,6 @@ echo "configure:631: checking target architecture " >&5
TARGET_ARCHS="m68k `/usr/bin/arch`"
fi
fi
- fi
;;
esac
# /usr/lib/arch_tool -archify_list $TARGET_ARCHS
@@ -663,7 +649,7 @@ echo "configure:631: checking target architecture " >&5
echo -n " $archs"
done
cat >> confdefs.h <<\EOF
-#define NEXT_FAT_BINARY 1
+#define NEXT_FAT_BINARY 1
EOF
echo "."
@@ -692,7 +678,7 @@ test "$program_transform_name" = "" && program_transform_name="s,x,x,"
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:696: checking for $ac_word" >&5
+echo "configure:682: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -722,7 +708,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:726: checking for $ac_word" >&5
+echo "configure:712: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -773,7 +759,7 @@ fi
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:777: checking for $ac_word" >&5
+echo "configure:763: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -805,7 +791,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:809: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:795: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -816,12 +802,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
-#line 820 "configure"
+#line 806 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -847,12 +833,12 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:851: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:837: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:856: checking whether we are using GNU C" >&5
+echo "configure:842: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -861,7 +847,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:865: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:851: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -880,7 +866,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:884: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:870: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -912,7 +898,7 @@ else
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:916: checking how to run the C preprocessor" >&5
+echo "configure:902: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -927,13 +913,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 931 "configure"
+#line 917 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:937: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:923: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -944,13 +930,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 948 "configure"
+#line 934 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:954: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:940: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -961,13 +947,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 965 "configure"
+#line 951 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:971: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:957: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -993,13 +979,13 @@ echo "$ac_t""$CPP" 1>&6
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:997: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:983: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
-#line 1003 "configure"
+#line 989 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -1017,7 +1003,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
-#line 1021 "configure"
+#line 1007 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -1043,7 +1029,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1047: checking for $ac_word" >&5
+echo "configure:1033: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1076,7 +1062,7 @@ test -n "$YACC" || YACC="yacc"
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1080: checking for $ac_word" >&5
+echo "configure:1066: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1109,7 +1095,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1113: checking for $ac_word" >&5
+echo "configure:1099: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1139,72 +1125,30 @@ test -n "$AR" && break
done
test -n "$AR" || AR="ar"
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# ./install, which can be erroneously created by make from ./install.sh.
-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1155: checking for a BSD compatible install" >&5
-if test -z "$INSTALL"; then
-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+
+echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+echo "configure:1131: checking whether ln -s works" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
- for ac_dir in $PATH; do
- # Account for people who put trailing slashes in PATH elements.
- case "$ac_dir/" in
- /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- # Don't use installbsd from OSF since it installs stuff as root
- # by default.
- for ac_prog in ginstall scoinst install; do
- if test -f $ac_dir/$ac_prog; then
- if test $ac_prog = install &&
- grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- else
- ac_cv_path_install="$ac_dir/$ac_prog -c"
- break 2
- fi
- fi
- done
- ;;
- esac
- done
- IFS="$ac_save_IFS"
-
+ rm -f conftestdata
+if ln -s X conftestdata 2>/dev/null
+then
+ rm -f conftestdata
+ ac_cv_prog_LN_S="ln -s"
+else
+ ac_cv_prog_LN_S=ln
fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL="$ac_cv_path_install"
- else
- # As a last resort, use the slow shell script. We don't cache a
- # path for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the path is relative.
- INSTALL="$ac_install_sh"
- fi
fi
-echo "$ac_t""$INSTALL" 1>&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+LN_S="$ac_cv_prog_LN_S"
+if test "$ac_cv_prog_LN_S" = "ln -s"; then
+ echo "$ac_t""yes" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1208: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1152: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1231,20 +1175,140 @@ else
fi
+echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
+echo "configure:1180: checking for Cygwin environment" >&5
+if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1185 "configure"
+#include "confdefs.h"
+
+int main() {
+
+#ifndef __CYGWIN__
+#define __CYGWIN__ __CYGWIN32__
+#endif
+return __CYGWIN__;
+; return 0; }
+EOF
+if { (eval echo configure:1196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_cygwin=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_cygwin=no
+fi
+rm -f conftest*
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_cygwin" 1>&6
+CYGWIN=
+test "$ac_cv_cygwin" = yes && CYGWIN=yes
+echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
+echo "configure:1213: checking for mingw32 environment" >&5
+if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1218 "configure"
+#include "confdefs.h"
+
+int main() {
+return __MINGW32__;
+; return 0; }
+EOF
+if { (eval echo configure:1225: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_mingw32=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_mingw32=no
+fi
+rm -f conftest*
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_mingw32" 1>&6
+MINGW32=
+test "$ac_cv_mingw32" = yes && MINGW32=yes
+
+
+echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
+echo "configure:1244: checking for executable suffix" >&5
+if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
+ ac_cv_exeext=.exe
+else
+ rm -f conftest*
+ echo 'int main () { return 0; }' > conftest.$ac_ext
+ ac_cv_exeext=
+ if { (eval echo configure:1254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+ for file in conftest.*; do
+ case $file in
+ *.c | *.o | *.obj) ;;
+ *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
+ esac
+ done
+ else
+ { echo "configure: error: installation or configuration problem: compiler cannot create executables." 1>&2; exit 1; }
+ fi
+ rm -f conftest*
+ test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
+fi
+fi
+
+EXEEXT=""
+test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
+echo "$ac_t""${ac_cv_exeext}" 1>&6
+ac_exeext=$EXEEXT
+
+echo $ac_n "checking for object suffix""... $ac_c" 1>&6
+echo "configure:1275: checking for object suffix" >&5
+if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ rm -f conftest*
+echo 'int i = 1;' > conftest.$ac_ext
+if { (eval echo configure:1281: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ for ac_file in conftest.*; do
+ case $ac_file in
+ *.c) ;;
+ *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;;
+ esac
+ done
+else
+ { echo "configure: error: installation or configuration problem; compiler does not work" 1>&2; exit 1; }
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_objext" 1>&6
+OBJEXT=$ac_cv_objext
+ac_objext=$ac_cv_objext
+
+
# checks for UNIX variants that set C preprocessor variables
ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6
-echo "configure:1238: checking for minix/config.h" >&5
+echo "configure:1302: checking for minix/config.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1243 "configure"
+#line 1307 "configure"
#include "confdefs.h"
#include <minix/config.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1248: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1312: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1283,7 +1347,7 @@ fi
echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:1287: checking size of int" >&5
+echo "configure:1351: checking size of int" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1291,7 +1355,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1295 "configure"
+#line 1359 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -1302,7 +1366,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1306: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1370: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_int=`cat conftestval`
else
@@ -1321,8 +1385,47 @@ cat >> confdefs.h <<EOF
EOF
+echo $ac_n "checking size of short""... $ac_c" 1>&6
+echo "configure:1390: checking size of short" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1398 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(short));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_short=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_short=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_short" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+EOF
+
+
echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:1326: checking size of long" >&5
+echo "configure:1429: checking size of long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1330,7 +1433,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1334 "configure"
+#line 1437 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -1341,7 +1444,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1448: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long=`cat conftestval`
else
@@ -1361,7 +1464,7 @@ EOF
echo $ac_n "checking size of void*""... $ac_c" 1>&6
-echo "configure:1365: checking size of void*" >&5
+echo "configure:1468: checking size of void*" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_voidp'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1369,7 +1472,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1373 "configure"
+#line 1476 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -1380,7 +1483,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1384: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_voidp=`cat conftestval`
else
@@ -1399,21 +1502,99 @@ cat >> confdefs.h <<EOF
EOF
+echo $ac_n "checking size of float""... $ac_c" 1>&6
+echo "configure:1507: checking size of float" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1515 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(float));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_float=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_float=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_float" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_FLOAT $ac_cv_sizeof_float
+EOF
+
+
+echo $ac_n "checking size of double""... $ac_c" 1>&6
+echo "configure:1546: checking size of double" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1554 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(double));
+ exit(0);
+}
+EOF
+if { (eval echo configure:1565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_double=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_double=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_double" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_DOUBLE $ac_cv_sizeof_double
+EOF
+
+
echo $ac_n "checking for prototypes""... $ac_c" 1>&6
-echo "configure:1405: checking for prototypes" >&5
+echo "configure:1586: checking for prototypes" >&5
if eval "test \"`echo '$''{'rb_cv_have_prototypes'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1410 "configure"
+#line 1591 "configure"
#include "confdefs.h"
int foo(int x) { return 0; }
int main() {
return foo(10);
; return 0; }
EOF
-if { (eval echo configure:1417: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1598: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_have_prototypes=yes
else
@@ -1433,13 +1614,51 @@ EOF
fi
+echo $ac_n "checking token paste string""... $ac_c" 1>&6
+echo "configure:1619: checking token paste string" >&5
+if eval "test \"`echo '$''{'rb_cv_tokenpaste'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1624 "configure"
+#include "confdefs.h"
+#define paste(a,b) a##b
+int main() {
+int xy = 1; return paste(x,y);
+; return 0; }
+EOF
+if { (eval echo configure:1631: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ rb_cv_tokenpaste=ansi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ rb_cv_tokenpaste=knr
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$rb_cv_tokenpaste" 1>&6
+if test "$rb_cv_tokenpaste" = ansi; then
+ cat >> confdefs.h <<\EOF
+#define TOKEN_PASTE(x,y) x##y
+EOF
+
+else
+ cat >> confdefs.h <<\EOF
+#define TOKEN_PASTE(x,y) x/**/y
+EOF
+
+fi
+
echo $ac_n "checking for variable length prototypes and stdarg.h""... $ac_c" 1>&6
-echo "configure:1438: checking for variable length prototypes and stdarg.h" >&5
+echo "configure:1657: checking for variable length prototypes and stdarg.h" >&5
if eval "test \"`echo '$''{'rb_cv_stdarg'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1443 "configure"
+#line 1662 "configure"
#include "confdefs.h"
#include <stdarg.h>
@@ -1456,7 +1675,7 @@ int main() {
return foo(10, "", 3.14);
; return 0; }
EOF
-if { (eval echo configure:1460: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1679: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_stdarg=yes
else
@@ -1477,19 +1696,19 @@ EOF
fi
echo $ac_n "checking for gcc attribute noreturn""... $ac_c" 1>&6
-echo "configure:1481: checking for gcc attribute noreturn" >&5
+echo "configure:1700: checking for gcc attribute noreturn" >&5
if eval "test \"`echo '$''{'rb_cv_have_attr_noreturn'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1486 "configure"
+#line 1705 "configure"
#include "confdefs.h"
void exit(int x) __attribute__ ((noreturn));
int main() {
; return 0; }
EOF
-if { (eval echo configure:1493: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1712: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_have_attr_noreturn=yes
else
@@ -1515,10 +1734,11 @@ openstep*) ;;
rhapsody*) ;;
human*) ;;
beos*) ;;
+cygwin*) ;;
*) LIBS="-lm $LIBS";;
esac
echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:1522: checking for crypt in -lcrypt" >&5
+echo "configure:1742: checking for crypt in -lcrypt" >&5
ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1526,7 +1746,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lcrypt $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1530 "configure"
+#line 1750 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1537,7 +1757,7 @@ int main() {
crypt()
; return 0; }
EOF
-if { (eval echo configure:1541: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1565,7 +1785,7 @@ else
fi
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:1569: checking for dlopen in -ldl" >&5
+echo "configure:1789: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1573,7 +1793,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1577 "configure"
+#line 1797 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1584,7 +1804,7 @@ int main() {
dlopen()
; return 0; }
EOF
-if { (eval echo configure:1588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1612,7 +1832,7 @@ else
fi
# Dynamic linking for SunOS/Solaris and SYSV
echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
-echo "configure:1616: checking for shl_load in -ldld" >&5
+echo "configure:1836: checking for shl_load in -ldld" >&5
ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1620,7 +1840,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldld $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1624 "configure"
+#line 1844 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1631,7 +1851,7 @@ int main() {
shl_load()
; return 0; }
EOF
-if { (eval echo configure:1635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1659,7 +1879,7 @@ else
fi
# Dynamic linking for HP-UX
echo $ac_n "checking for setlocale in -lxpg4""... $ac_c" 1>&6
-echo "configure:1663: checking for setlocale in -lxpg4" >&5
+echo "configure:1883: checking for setlocale in -lxpg4" >&5
ac_lib_var=`echo xpg4'_'setlocale | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1667,7 +1887,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lxpg4 $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1671 "configure"
+#line 1891 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1678,7 +1898,7 @@ int main() {
setlocale()
; return 0; }
EOF
-if { (eval echo configure:1682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1711,12 +1931,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:1715: checking for $ac_hdr that defines DIR" >&5
+echo "configure:1935: checking for $ac_hdr that defines DIR" >&5
if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1720 "configure"
+#line 1940 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_hdr>
@@ -1724,7 +1944,7 @@ int main() {
DIR *dirp = 0;
; return 0; }
EOF
-if { (eval echo configure:1728: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1948: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_header_dirent_$ac_safe=yes"
else
@@ -1749,7 +1969,7 @@ done
# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
if test $ac_header_dirent = dirent.h; then
echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:1753: checking for opendir in -ldir" >&5
+echo "configure:1973: checking for opendir in -ldir" >&5
ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1757,7 +1977,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldir $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1761 "configure"
+#line 1981 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1768,7 +1988,7 @@ int main() {
opendir()
; return 0; }
EOF
-if { (eval echo configure:1772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1790,7 +2010,7 @@ fi
else
echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:1794: checking for opendir in -lx" >&5
+echo "configure:2014: checking for opendir in -lx" >&5
ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1798,7 +2018,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lx $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1802 "configure"
+#line 2022 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1809,7 +2029,7 @@ int main() {
opendir()
; return 0; }
EOF
-if { (eval echo configure:1813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2033: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1832,12 +2052,12 @@ fi
fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1836: checking for ANSI C header files" >&5
+echo "configure:2056: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1841 "configure"
+#line 2061 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -1845,7 +2065,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1849: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2069: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1862,7 +2082,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1866 "configure"
+#line 2086 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -1880,7 +2100,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1884 "configure"
+#line 2104 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -1901,7 +2121,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 1905 "configure"
+#line 2125 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1912,7 +2132,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:1916: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2136: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -1935,23 +2155,65 @@ EOF
fi
-for ac_hdr in stdlib.h unistd.h limits.h sys/file.h sys/ioctl.h pwd.h \
- sys/select.h sys/time.h sys/times.h sys/param.h sys/wait.h\
- syscall.h a.out.h string.h utime.h memory.h direct.h
+echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
+echo "configure:2160: checking for sys/wait.h that is POSIX.1 compatible" >&5
+if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2165 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif
+#ifndef WIFEXITED
+#define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+int main() {
+int s;
+wait (&s);
+s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
+; return 0; }
+EOF
+if { (eval echo configure:2181: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_header_sys_wait_h=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_sys_wait_h=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_sys_wait_h" 1>&6
+if test $ac_cv_header_sys_wait_h = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_SYS_WAIT_H 1
+EOF
+
+fi
+
+for ac_hdr in stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
+ fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
+ syscall.h pwd.h a.out.h utime.h memory.h direct.h fnmatch.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1945: checking for $ac_hdr" >&5
+echo "configure:2207: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1950 "configure"
+#line 2212 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1955: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2217: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1979,12 +2241,12 @@ done
echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:1983: checking for uid_t in sys/types.h" >&5
+echo "configure:2245: checking for uid_t in sys/types.h" >&5
if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1988 "configure"
+#line 2250 "configure"
#include "confdefs.h"
#include <sys/types.h>
EOF
@@ -2013,12 +2275,12 @@ EOF
fi
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:2017: checking for size_t" >&5
+echo "configure:2279: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2022 "configure"
+#line 2284 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -2046,12 +2308,12 @@ EOF
fi
echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6
-echo "configure:2050: checking for st_blksize in struct stat" >&5
+echo "configure:2312: checking for st_blksize in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2055 "configure"
+#line 2317 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -2059,7 +2321,7 @@ int main() {
struct stat s; s.st_blksize;
; return 0; }
EOF
-if { (eval echo configure:2063: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2325: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_blksize=yes
else
@@ -2081,12 +2343,12 @@ fi
save_LIBOJBS="$LIBOBJS"
echo $ac_n "checking for st_blocks in struct stat""... $ac_c" 1>&6
-echo "configure:2085: checking for st_blocks in struct stat" >&5
+echo "configure:2347: checking for st_blocks in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_blocks'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2090 "configure"
+#line 2352 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -2094,7 +2356,7 @@ int main() {
struct stat s; s.st_blocks;
; return 0; }
EOF
-if { (eval echo configure:2098: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2360: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_blocks=yes
else
@@ -2118,12 +2380,12 @@ fi
LIBOBJS="$save_LIBOBJS"
echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6
-echo "configure:2122: checking for st_rdev in struct stat" >&5
+echo "configure:2384: checking for st_rdev in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2127 "configure"
+#line 2389 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -2131,7 +2393,7 @@ int main() {
struct stat s; s.st_rdev;
; return 0; }
EOF
-if { (eval echo configure:2135: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2397: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_rdev=yes
else
@@ -2153,7 +2415,7 @@ fi
echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6
-echo "configure:2157: checking type of array argument to getgroups" >&5
+echo "configure:2419: checking type of array argument to getgroups" >&5
if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2161,7 +2423,7 @@ else
ac_cv_type_getgroups=cross
else
cat > conftest.$ac_ext <<EOF
-#line 2165 "configure"
+#line 2427 "configure"
#include "confdefs.h"
/* Thanks to Mike Rendell for this test. */
@@ -2186,7 +2448,7 @@ main()
}
EOF
-if { (eval echo configure:2190: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_type_getgroups=gid_t
else
@@ -2200,7 +2462,7 @@ fi
if test $ac_cv_type_getgroups = cross; then
cat > conftest.$ac_ext <<EOF
-#line 2204 "configure"
+#line 2466 "configure"
#include "confdefs.h"
#include <unistd.h>
EOF
@@ -2224,12 +2486,12 @@ EOF
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:2228: checking return type of signal handlers" >&5
+echo "configure:2490: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2233 "configure"
+#line 2495 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -2246,7 +2508,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:2250: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2512: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -2267,19 +2529,19 @@ EOF
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:2271: checking for working alloca.h" >&5
+echo "configure:2533: checking for working alloca.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2276 "configure"
+#line 2538 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = alloca(2 * sizeof(int));
; return 0; }
EOF
-if { (eval echo configure:2283: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_header_alloca_h=yes
else
@@ -2300,12 +2562,12 @@ EOF
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:2304: checking for alloca" >&5
+echo "configure:2566: checking for alloca" >&5
if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2309 "configure"
+#line 2571 "configure"
#include "confdefs.h"
#ifdef __GNUC__
@@ -2333,7 +2595,7 @@ int main() {
char *p = (char *) alloca(1);
; return 0; }
EOF
-if { (eval echo configure:2337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_func_alloca_works=yes
else
@@ -2365,12 +2627,12 @@ EOF
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:2369: checking whether alloca needs Cray hooks" >&5
+echo "configure:2631: checking whether alloca needs Cray hooks" >&5
if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2374 "configure"
+#line 2636 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@@ -2395,12 +2657,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2399: checking for $ac_func" >&5
+echo "configure:2661: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2404 "configure"
+#line 2666 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2423,7 +2685,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2689: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2450,7 +2712,7 @@ done
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:2454: checking stack direction for C alloca" >&5
+echo "configure:2716: checking stack direction for C alloca" >&5
if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2458,7 +2720,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
-#line 2462 "configure"
+#line 2724 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@@ -2477,7 +2739,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
-if { (eval echo configure:2481: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2743: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@@ -2499,12 +2761,12 @@ EOF
fi
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2503: checking for pid_t" >&5
+echo "configure:2765: checking for pid_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2508 "configure"
+#line 2770 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -2533,17 +2795,17 @@ fi
ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:2537: checking for vfork.h" >&5
+echo "configure:2799: checking for vfork.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2542 "configure"
+#line 2804 "configure"
#include "confdefs.h"
#include <vfork.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2547: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2809: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2568,18 +2830,18 @@ else
fi
echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:2572: checking for working vfork" >&5
+echo "configure:2834: checking for working vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$cross_compiling" = yes; then
echo $ac_n "checking for vfork""... $ac_c" 1>&6
-echo "configure:2578: checking for vfork" >&5
+echo "configure:2840: checking for vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2583 "configure"
+#line 2845 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vfork(); below. */
@@ -2602,7 +2864,7 @@ vfork();
; return 0; }
EOF
-if { (eval echo configure:2606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2868: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_vfork=yes"
else
@@ -2624,7 +2886,7 @@ fi
ac_cv_func_vfork_works=$ac_cv_func_vfork
else
cat > conftest.$ac_ext <<EOF
-#line 2628 "configure"
+#line 2890 "configure"
#include "confdefs.h"
/* Thanks to Paul Eggert for this test. */
#include <stdio.h>
@@ -2719,7 +2981,7 @@ main() {
}
}
EOF
-if { (eval echo configure:2723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_vfork_works=yes
else
@@ -2742,7 +3004,7 @@ EOF
fi
echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:2746: checking for 8-bit clean memcmp" >&5
+echo "configure:3008: checking for 8-bit clean memcmp" >&5
if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2750,7 +3012,7 @@ else
ac_cv_func_memcmp_clean=no
else
cat > conftest.$ac_ext <<EOF
-#line 2754 "configure"
+#line 3016 "configure"
#include "confdefs.h"
main()
@@ -2760,7 +3022,7 @@ main()
}
EOF
-if { (eval echo configure:2764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3026: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_memcmp_clean=yes
else
@@ -2777,16 +3039,17 @@ fi
echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
-for ac_func in dup2 memmove mkdir strcasecmp strerror strftime\
- strchr strstr strtoul strdup crypt flock vsnprintf
+for ac_func in dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
+ strchr strstr strtoul strdup crypt flock vsnprintf\
+ fnmatch isinf isnan finite
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2785: checking for $ac_func" >&5
+echo "configure:3048: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2790 "configure"
+#line 3053 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2809,7 +3072,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2838,16 +3101,16 @@ done
for ac_func in fmod killpg drand48 random wait4 waitpid syscall getcwd\
truncate chsize times utimes fcntl lockf setitimer\
setruid seteuid setreuid setrgid setegid setregid\
- setpgrp2 getpgid setpgid getgroups getpriority\
- dlopen sigprocmask sigaction _setjmp setpgrp setsid
+ getpgrp setpgrp getpgid setpgid getgroups getpriority\
+ dlopen sigprocmask sigaction _setjmp setsid
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2846: checking for $ac_func" >&5
+echo "configure:3109: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2851 "configure"
+#line 3114 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2870,7 +3133,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2874: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2894,14 +3157,13 @@ else
fi
done
-if test "$ac_cv_func_strftime" = no; then
- echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:2900: checking whether struct tm is in sys/time.h or time.h" >&5
+echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
+echo "configure:3162: checking whether struct tm is in sys/time.h or time.h" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2905 "configure"
+#line 3167 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <time.h>
@@ -2909,7 +3171,7 @@ int main() {
struct tm *tp; tp->tm_sec;
; return 0; }
EOF
-if { (eval echo configure:2913: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3175: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm=time.h
else
@@ -2930,12 +3192,12 @@ EOF
fi
echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:2934: checking for tm_zone in struct tm" >&5
+echo "configure:3196: checking for tm_zone in struct tm" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2939 "configure"
+#line 3201 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_cv_struct_tm>
@@ -2943,7 +3205,7 @@ int main() {
struct tm tm; tm.tm_zone;
; return 0; }
EOF
-if { (eval echo configure:2947: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3209: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm_zone=yes
else
@@ -2963,12 +3225,12 @@ EOF
else
echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:2967: checking for tzname" >&5
+echo "configure:3229: checking for tzname" >&5
if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2972 "configure"
+#line 3234 "configure"
#include "confdefs.h"
#include <time.h>
#ifndef tzname /* For SGI. */
@@ -2978,7 +3240,7 @@ int main() {
atoi(*tzname);
; return 0; }
EOF
-if { (eval echo configure:2982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var_tzname=yes
else
@@ -2999,15 +3261,16 @@ EOF
fi
fi
+if test "$ac_cv_func_strftime" = no; then
cat > conftest.$ac_ext <<EOF
-#line 3004 "configure"
+#line 3267 "configure"
#include "confdefs.h"
int main() {
extern int daylight; int i = daylight;
; return 0; }
EOF
-if { (eval echo configure:3011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
cat >> confdefs.h <<\EOF
#define HAVE_DAYLIGHT 1
@@ -3027,15 +3290,15 @@ EOF
else
echo $ac_n "checking for BSD signal semantics""... $ac_c" 1>&6
-echo "configure:3031: checking for BSD signal semantics" >&5
- if eval "test \"`echo '$''{'rb_cv_bsd_signal'+set}'`\" = set"; then
+echo "configure:3294: checking for BSD signal semantics" >&5
+if eval "test \"`echo '$''{'rb_cv_bsd_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+ rb_cv_bsd_signal=no
else
cat > conftest.$ac_ext <<EOF
-#line 3039 "configure"
+#line 3302 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -3057,7 +3320,7 @@ main()
}
EOF
-if { (eval echo configure:3061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3324: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
rb_cv_bsd_signal=yes
else
@@ -3071,7 +3334,7 @@ fi
fi
- echo "$ac_t""$rb_cv_bsd_signal" 1>&6
+echo "$ac_t""$rb_cv_bsd_signal" 1>&6
if test "$rb_cv_bsd_signal" = yes; then
cat >> confdefs.h <<\EOF
#define BSD_SIGNAL 1
@@ -3080,92 +3343,211 @@ EOF
fi
fi
-if test "$ac_cv_func_setpgrp2" = yes; then
- cat >> confdefs.h <<\EOF
-#define BSD_GETPGRP getpgrp2
+echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
+echo "configure:3348: checking whether getpgrp takes no argument" >&5
+if eval "test \"`echo '$''{'ac_cv_func_getpgrp_void'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: cannot check getpgrp if cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3356 "configure"
+#include "confdefs.h"
+
+/*
+ * If this system has a BSD-style getpgrp(),
+ * which takes a pid argument, exit unsuccessfully.
+ *
+ * Snarfed from Chet Ramey's bash pgrp.c test program
+ */
+#include <stdio.h>
+#include <sys/types.h>
+
+int pid;
+int pg1, pg2, pg3, pg4;
+int ng, np, s, child;
+
+main()
+{
+ pid = getpid();
+ pg1 = getpgrp(0);
+ pg2 = getpgrp();
+ pg3 = getpgrp(pid);
+ pg4 = getpgrp(1);
+
+ /*
+ * If all of these values are the same, it's pretty sure that
+ * we're on a system that ignores getpgrp's first argument.
+ */
+ if (pg2 == pg4 && pg1 == pg3 && pg2 == pg3)
+ exit(0);
+
+ child = fork();
+ if (child < 0)
+ exit(1);
+ else if (child == 0) {
+ np = getpid();
+ /*
+ * If this is Sys V, this will not work; pgrp will be
+ * set to np because setpgrp just changes a pgrp to be
+ * the same as the pid.
+ */
+ setpgrp(np, pg1);
+ ng = getpgrp(0); /* Same result for Sys V and BSD */
+ if (ng == pg1) {
+ exit(1);
+ } else {
+ exit(0);
+ }
+ } else {
+ wait(&s);
+ exit(s>>8);
+ }
+}
+
EOF
+if { (eval echo configure:3411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_getpgrp_void=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_getpgrp_void=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_func_getpgrp_void" 1>&6
+if test $ac_cv_func_getpgrp_void = yes; then
cat >> confdefs.h <<\EOF
-#define BSD_SETPGRP setpgrp2
+#define GETPGRP_VOID 1
EOF
-else
- echo $ac_n "checking whether getpgrp() has arg""... $ac_c" 1>&6
-echo "configure:3095: checking whether getpgrp() has arg" >&5
- if eval "test \"`echo '$''{'rb_cv_bsdgetpgrp'+set}'`\" = set"; then
+fi
+
+echo $ac_n "checking whether setpgrp takes no argument""... $ac_c" 1>&6
+echo "configure:3435: checking whether setpgrp takes no argument" >&5
+if eval "test \"`echo '$''{'ac_cv_func_setpgrp_void'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: cannot check setpgrp if cross compiling" 1>&2; exit 1; }
+else
cat > conftest.$ac_ext <<EOF
-#line 3100 "configure"
+#line 3443 "configure"
#include "confdefs.h"
+
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
-int main() {
-getpgrp(0);
-; return 0; }
+#endif
+
+/*
+ * If this system has a BSD-style setpgrp, which takes arguments, exit
+ * successfully.
+ */
+main()
+{
+ if (setpgrp(1,1) == -1)
+ exit(0);
+ else
+ exit(1);
+}
+
EOF
-if { (eval echo configure:3107: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- rb_cv_bsdgetpgrp=yes
+if { (eval echo configure:3463: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_setpgrp_void=no
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
- rm -rf conftest*
- rb_cv_bsdgetpgrp=no
+ rm -fr conftest*
+ ac_cv_func_setpgrp_void=yes
fi
-rm -f conftest*
+rm -fr conftest*
fi
- echo "$ac_t""$rb_cv_bsdgetpgrp" 1>&6
- if test "$rb_cv_bsdgetpgrp" = yes; then
- cat >> confdefs.h <<\EOF
-#define BSD_GETPGRP getpgrp
+
+fi
+
+echo "$ac_t""$ac_cv_func_setpgrp_void" 1>&6
+if test $ac_cv_func_setpgrp_void = yes; then
+ cat >> confdefs.h <<\EOF
+#define SETPGRP_VOID 1
EOF
- fi
+fi
+
- echo $ac_n "checking whether setpgrp() has args""... $ac_c" 1>&6
-echo "configure:3128: checking whether setpgrp() has args" >&5
- if eval "test \"`echo '$''{'rb_cv_bsdsetpgrp'+set}'`\" = set"; then
+echo $ac_n "checking for working strtod""... $ac_c" 1>&6
+echo "configure:3488: checking for working strtod" >&5
+if eval "test \"`echo '$''{'rb_cv_func_strtod'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
+ if test "$cross_compiling" = yes; then
+ rb_cv_func_strtod=no
+else
cat > conftest.$ac_ext <<EOF
-#line 3133 "configure"
+#line 3496 "configure"
#include "confdefs.h"
-#include <unistd.h>
-int main() {
-setpgrp(1, 1);
-; return 0; }
+
+double strtod ();
+int
+main()
+{
+ {
+ /* Some versions of Linux strtod mis-parse strings with leading '+'. */
+ char *string = " +69";
+ char *term;
+ double value;
+ value = strtod(string, &term);
+ if (value != 69 || term != (string + 4))
+ exit(1);
+ }
+
+ {
+ /* Under Solaris 2.4, strtod returns the wrong value for the
+ terminating character under some conditions. */
+ char *string = "NaN";
+ char *term;
+ strtod(string, &term);
+ if (term != string && *(term - 1) == 0)
+ exit(1);
+ }
+ exit(0);
+}
+
EOF
-if { (eval echo configure:3140: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- rb_cv_bsdsetpgrp=yes
+if { (eval echo configure:3526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ rb_cv_func_strtod=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
- rm -rf conftest*
- rb_cv_bsdsetpgrp=no
+ rm -fr conftest*
+ rb_cv_func_strtod=no
fi
-rm -f conftest*
+rm -fr conftest*
fi
- echo "$ac_t""$rb_cv_bsdsetpgrp" 1>&6
- if test "$rb_cv_bsdsetpgrp" = yes; then
- cat >> confdefs.h <<\EOF
-#define BSD_SETPGRP setpgrp
-EOF
-
- fi
fi
+echo "$ac_t""$rb_cv_func_strtod" 1>&6
+test $rb_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o"
+
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:3162: checking whether byte ordering is bigendian" >&5
+echo "configure:3544: checking whether byte ordering is bigendian" >&5
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
cat > conftest.$ac_ext <<EOF
-#line 3169 "configure"
+#line 3551 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -3176,11 +3558,11 @@ int main() {
#endif
; return 0; }
EOF
-if { (eval echo configure:3180: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3562: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
# It does; now see whether it defined to BIG_ENDIAN or not.
cat > conftest.$ac_ext <<EOF
-#line 3184 "configure"
+#line 3566 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -3191,7 +3573,7 @@ int main() {
#endif
; return 0; }
EOF
-if { (eval echo configure:3195: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3577: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
@@ -3211,7 +3593,7 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3215 "configure"
+#line 3597 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
@@ -3224,7 +3606,7 @@ main () {
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
-if { (eval echo configure:3228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_bigendian=no
else
@@ -3247,15 +3629,90 @@ EOF
fi
+echo $ac_n "checking for working const""... $ac_c" 1>&6
+echo "configure:3634: checking for working const" >&5
+if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3639 "configure"
+#include "confdefs.h"
+
+int main() {
+
+/* Ultrix mips cc rejects this. */
+typedef int charset[2]; const charset x;
+/* SunOS 4.1.1 cc rejects this. */
+char const *const *ccp;
+char **p;
+/* NEC SVR4.0.2 mips cc rejects this. */
+struct point {int x, y;};
+static struct point const zero = {0,0};
+/* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in an arm
+ of an if-expression whose if-part is not a constant expression */
+const char *g = "string";
+ccp = &g + (g ? g-g : 0);
+/* HPUX 7.0 cc rejects these. */
+++ccp;
+p = (char**) ccp;
+ccp = (char const *const *) p;
+{ /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+}
+{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+}
+{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+}
+{ /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+}
+{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:3688: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_const=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_c_const=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_c_const" 1>&6
+if test $ac_cv_c_const = no; then
+ cat >> confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6
-echo "configure:3252: checking whether char is unsigned" >&5
+echo "configure:3709: checking whether char is unsigned" >&5
if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$GCC" = yes; then
# GCC predefines this symbol on systems where it applies.
cat > conftest.$ac_ext <<EOF
-#line 3259 "configure"
+#line 3716 "configure"
#include "confdefs.h"
#ifdef __CHAR_UNSIGNED__
yes
@@ -3277,7 +3734,7 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3281 "configure"
+#line 3738 "configure"
#include "confdefs.h"
/* volatile prevents gcc2 from optimizing the test away on sparcs. */
#if !defined(__STDC__) || __STDC__ != 1
@@ -3287,7 +3744,7 @@ main() {
volatile char c = 255; exit(c < 0);
}
EOF
-if { (eval echo configure:3291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_char_unsigned=yes
else
@@ -3312,15 +3769,15 @@ fi
echo $ac_n "checking whether right shift preserve sign bit""... $ac_c" 1>&6
-echo "configure:3316: checking whether right shift preserve sign bit" >&5
+echo "configure:3773: checking whether right shift preserve sign bit" >&5
if eval "test \"`echo '$''{'rb_cv_rshift_sign'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+ rb_cv_rshift_sign=yes
else
cat > conftest.$ac_ext <<EOF
-#line 3324 "configure"
+#line 3781 "configure"
#include "confdefs.h"
int
@@ -3332,7 +3789,7 @@ main()
}
EOF
-if { (eval echo configure:3336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
rb_cv_rshift_sign=yes
else
@@ -3346,7 +3803,7 @@ fi
fi
- echo "$ac_t""$rb_cv_rshift_sign" 1>&6
+echo "$ac_t""$rb_cv_rshift_sign" 1>&6
if test "$rb_cv_rshift_sign" = yes; then
cat >> confdefs.h <<\EOF
#define RSHIFT(x,y) ((x)>>y)
@@ -3360,19 +3817,19 @@ EOF
fi
echo $ac_n "checking count field in FILE structures""... $ac_c" 1>&6
-echo "configure:3364: checking count field in FILE structures" >&5
+echo "configure:3821: checking count field in FILE structures" >&5
if eval "test \"`echo '$''{'rb_cv_fcnt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3369 "configure"
+#line 3826 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->_cnt = 0;
; return 0; }
EOF
-if { (eval echo configure:3376: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3833: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="_cnt"
else
@@ -3382,14 +3839,14 @@ fi
rm -f conftest*
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3386 "configure"
+#line 3843 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->__cnt = 0;
; return 0; }
EOF
-if { (eval echo configure:3393: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3850: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="__cnt"
else
@@ -3400,14 +3857,14 @@ rm -f conftest*
fi
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3404 "configure"
+#line 3861 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->_r = 0;
; return 0; }
EOF
-if { (eval echo configure:3411: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3868: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="_r"
else
@@ -3418,19 +3875,37 @@ rm -f conftest*
fi
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3422 "configure"
+#line 3879 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->readCount = 0;
; return 0; }
EOF
-if { (eval echo configure:3429: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3886: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="readCount"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+fi
+if test "$rb_cv_fcnt" = ""; then
+ cat > conftest.$ac_ext <<EOF
+#line 3897 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int main() {
+FILE *f = stdin; f->_rcount = 0;
+; return 0; }
+EOF
+if { (eval echo configure:3904: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ rb_cv_fcnt="_rcount"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
rm -rf conftest*
rb_cv_fcnt="not found"
fi
@@ -3448,6 +3923,32 @@ EOF
fi
+
+# Check whether --with-default-kcode or --without-default-kcode was given.
+if test "${with_default_kcode+set}" = set; then
+ withval="$with_default_kcode"
+ case $withval in
+ utf8) cat >> confdefs.h <<\EOF
+#define DEFAULT_KCODE KCODE_UTF8
+EOF
+;;
+ euc) cat >> confdefs.h <<\EOF
+#define DEFAULT_KCODE KCODE_EUC
+EOF
+;;
+ sjis) cat >> confdefs.h <<\EOF
+#define DEFAULT_KCODE KCODE_SJIS
+EOF
+;;
+ none) cat >> confdefs.h <<\EOF
+#define DEFAULT_KCODE KCODE_NONE
+EOF
+;;
+ *) echo "configure: warning: $withval is not valid kcode; ignored" 1>&2;;
+ esac
+fi
+
+
# Check whether --with-dln-a-out or --without-dln-a-out was given.
if test "${with_dln_a_out+set}" = set; then
withval="$with_dln_a_out"
@@ -3461,18 +3962,19 @@ else
fi
+
case "$host_os" in
linux*)
echo $ac_n "checking whether ELF binaries are produced""... $ac_c" 1>&6
-echo "configure:3468: checking whether ELF binaries are produced" >&5
- if eval "test \"`echo '$''{'rb_cv_linux_elf'+set}'`\" = set"; then
+echo "configure:3970: checking whether ELF binaries are produced" >&5
+if eval "test \"`echo '$''{'rb_cv_binary_elf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$cross_compiling" = yes; then
- :
+ rb_cv_binary_elf=yes
else
cat > conftest.$ac_ext <<EOF
-#line 3476 "configure"
+#line 3978 "configure"
#include "confdefs.h"
/* Test for whether ELF binaries are produced */
@@ -3492,24 +3994,24 @@ main() {
}
EOF
-if { (eval echo configure:3496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
- rb_cv_linux_elf=yes
+ rb_cv_binary_elf=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -fr conftest*
- rb_cv_linux_elf=no
+ rb_cv_binary_elf=no
fi
rm -fr conftest*
fi
fi
- echo "$ac_t""$rb_cv_linux_elf" 1>&6
- if test "$rb_cv_linux_elf" = no; then
+echo "$ac_t""$rb_cv_binary_elf" 1>&6
+ if test "$rb_cv_binary_elf" = no; then
with_dln_a_out=yes
- host_os=linux-a.out
+ host_os=${host_os}-a_out
else
LDFLAGS="-rdynamic"
fi;;
@@ -3522,22 +4024,28 @@ STATIC=
if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=unknown
echo $ac_n "checking whether OS depend dynamic link works""... $ac_c" 1>&6
-echo "configure:3526: checking whether OS depend dynamic link works" >&5
+echo "configure:4028: checking whether OS depend dynamic link works" >&5
if test "$GCC" = yes; then
case "$host_os" in
nextstep*) ;;
openstep*) ;;
rhapsody*) ;;
human*) ;;
- cygwin*) CCDLFLAGS=-DDLLIMPORT;;
- *) CCDLFLAGS=-fpic;;
+ bsdi3*) ;;
+ cygwin*) ;;
+ netbsd*) CCDLFLAGS=-fpic
+ case "$host_cpu" in
+ mips*) CCDLFLAGS=-fPIC ;;
+ *) ;;
+ esac ;;
+ *) CCDLFLAGS=-fPIC;;
esac
else
case "$host_os" in
hpux*) CCDLFLAGS='+z';;
- solaris*|irix*) CCDLFLAGS='-K pic' ;;
- sunos*) CCDLFLAGS='-pic' ;;
- esix*|uxpds*) CCDLFLAGS='-Kpic' ;;
+ solaris*|irix*) CCDLFLAGS='-K PIC' ;;
+ sunos*) CCDLFLAGS='-PIC' ;;
+ esix*|uxpds*) CCDLFLAGS='-KPIC' ;;
*) CCDLFLAGS='' ;;
esac
fi
@@ -3547,7 +4055,12 @@ echo "configure:3526: checking whether OS depend dynamic link works" >&5
LDSHARED='ld -b'
LDFLAGS="-Wl,-E"
rb_cv_dlopen=yes;;
- solaris*) LDSHARED='ld -G'
+ solaris*) if test "$GCC" = yes; then
+ LDSHARED='$(CC) -Wl,-G'
+ `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null && LDFLAGS="-Wl,-E"
+ else
+ LDSHARED='ld -G'
+ fi
rb_cv_dlopen=yes;;
sunos*) LDSHARED='ld -assert nodefinitions'
rb_cv_dlopen=yes;;
@@ -3557,19 +4070,29 @@ echo "configure:3526: checking whether OS depend dynamic link works" >&5
rb_cv_dlopen=yes;;
esix*|uxpds*) LDSHARED="ld -G"
rb_cv_dlopen=yes ;;
- linux*) LDSHARED="gcc -shared"
+ osf*) LDSHARED="$CC -shared"
rb_cv_dlopen=yes ;;
- freebsd3*) LDSHARED="ld -Bshareable"
- LDFLAGS="-rdynamic"
+ linux*) LDSHARED="$CC -shared"
rb_cv_dlopen=yes ;;
- freebsd*) LDSHARED="ld -Bshareable"
+ freebsd*) LDSHARED="$CC -shared"
+ if test -x /usr/bin/objformat && \
+ test `/usr/bin/objformat` = "elf" ; then
+ LDFLAGS="-rdynamic"
+ DLDFLAGS='-Wl,-soname,$(.TARGET)'
+ rb_cv_freebsd_elf=yes
+ else
+ test "$GCC" = yes && `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null || LDSHARED="ld -Bshareable"
+ fi
rb_cv_dlopen=yes ;;
- netbsd*) LDSHARED="ld -Bshareable"
+ netbsd*) LDSHARED="ld -shared"
rb_cv_dlopen=yes ;;
openbsd*) LDSHARED="ld -Bforcearchive -Bshareable"
- CCDLFLAGS=-fPIC
rb_cv_dlopen=yes ;;
- nextstep*) LDSHARED='cc -r'
+ bsdi3*) case "$CC" in
+ *shlicc*) LDSHARED="$CC -r"
+ rb_cv_dlopen=yes ;;
+ esac ;;
+ nextstep*) LDSHARED='cc -r -nostdlib'
LDFLAGS="-u libsys_s"
DLDFLAGS="$ARCH_FLAG"
rb_cv_dlopen=yes ;;
@@ -3581,22 +4104,30 @@ echo "configure:3526: checking whether OS depend dynamic link works" >&5
LDFLAGS=""
DLDFLAGS="$ARCH_FLAG"
rb_cv_dlopen=yes ;;
- aix*) LDSHARED='../../miniruby ../aix_ld.rb $(TARGET)'
+ aix*) LDSHARED='/usr/ccs/bin/ld'
+ XLDFLAGS='-Wl,-bE:ruby.imp'
+ DLDFLAGS='-eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 -lc'
rb_cv_dlopen=yes ;;
+
human*) DLDFLAGS=''
LDSHARED=''
- LDFLAGS='' ;;
- beos*) LDSHARED="ld -xms"
- case "$host_cpu" in
+ LDFLAGS=''
+ rb_cv_dlopen=yes ;;
+ beos*) case "$host_cpu" in
powerpc*)
+ LDSHARED="ld -xms"
DLDFLAGS="-f ruby.exp -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
;;
+ i586*)
+ LDSHARED="ld -shared"
+ DLDFLAGS="-L/boot/develop/lib/x86 -lbe -lroot"
+ ;;
*)
DLDFLAGS="ruby.def -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
- ;;
esac
rb_cv_dlopen=yes ;;
- cygwin*) LDSHARED='../../miniruby ../cygwin32_ld.rb' ;;
+ cygwin*) LDSHARED='dllwrap --export-all -s'
+ rb_cv_dlopen=yes ;;
*) LDSHARED='ld' ;;
esac
echo "$ac_t""$rb_cv_dlopen" 1>&6
@@ -3605,14 +4136,14 @@ fi
dln_a_out_works=no
if test "$ac_cv_header_a_out_h" = yes; then
if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then
- echo $ac_n "checking whether matz's dln works""... $ac_c" 1>&6
-echo "configure:3610: checking whether matz's dln works" >&5
cat confdefs.h > config.h
- if eval "test \"`echo '$''{'rb_cv_dln_a_out'+set}'`\" = set"; then
+ echo $ac_n "checking whether matz's dln works""... $ac_c" 1>&6
+echo "configure:4142: checking whether matz's dln works" >&5
+if eval "test \"`echo '$''{'rb_cv_dln_a_out'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3616 "configure"
+#line 4147 "configure"
#include "confdefs.h"
#define USE_DLN_A_OUT
@@ -3622,7 +4153,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:3626: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4157: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_dln_a_out=yes
else
@@ -3634,7 +4165,7 @@ fi
rm -f conftest*
fi
- echo "$ac_t""$rb_cv_dln_a_out" 1>&6
+echo "$ac_t""$rb_cv_dln_a_out" 1>&6
if test "$rb_cv_dln_a_out" = yes; then
dln_a_out_works=yes
cat >> confdefs.h <<\EOF
@@ -3651,9 +4182,9 @@ if test "$dln_a_out_works" = yes; then
else
STATIC=-Bstatic
fi
- DLEXT=o
+ DLEXT=so
cat >> confdefs.h <<\EOF
-#define DLEXT ".o"
+#define DLEXT ".so"
EOF
CCDLFLAGS=
@@ -3664,9 +4195,9 @@ else
#define DLEXT ".sl"
EOF
;;
- nextstep*) DLEXT=o
+ nextstep*) DLEXT=bundle
cat >> confdefs.h <<\EOF
-#define DLEXT ".o"
+#define DLEXT ".bundle"
EOF
;;
openstep*) DLEXT=bundle
@@ -3684,6 +4215,11 @@ EOF
#define DLEXT ".dll"
EOF
;;
+ os2_emx) DLEXT=o
+ cat >> confdefs.h <<\EOF
+#define DLEXT ".so"
+EOF
+;;
*) DLEXT=so
cat >> confdefs.h <<\EOF
#define DLEXT ".so"
@@ -3724,7 +4260,7 @@ fi
case "$host_os" in
human*)
echo $ac_n "checking for _harderr in -lsignal""... $ac_c" 1>&6
-echo "configure:3728: checking for _harderr in -lsignal" >&5
+echo "configure:4264: checking for _harderr in -lsignal" >&5
ac_lib_var=`echo signal'_'_harderr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3732,7 +4268,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsignal $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3736 "configure"
+#line 4272 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3743,7 +4279,7 @@ int main() {
_harderr()
; return 0; }
EOF
-if { (eval echo configure:3747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4283: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3771,7 +4307,7 @@ else
fi
echo $ac_n "checking for hmemset in -lhmem""... $ac_c" 1>&6
-echo "configure:3775: checking for hmemset in -lhmem" >&5
+echo "configure:4311: checking for hmemset in -lhmem" >&5
ac_lib_var=`echo hmem'_'hmemset | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3779,7 +4315,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lhmem $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3783 "configure"
+#line 4319 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3790,7 +4326,7 @@ int main() {
hmemset()
; return 0; }
EOF
-if { (eval echo configure:3794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4330: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3820,12 +4356,12 @@ fi
for ac_func in select
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3824: checking for $ac_func" >&5
+echo "configure:4360: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3829 "configure"
+#line 4365 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3848,7 +4384,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4388: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -3873,15 +4409,15 @@ fi
done
echo $ac_n "checking whether PD libc _dtos18 fail to convert big number""... $ac_c" 1>&6
-echo "configure:3877: checking whether PD libc _dtos18 fail to convert big number" >&5
- if eval "test \"`echo '$''{'rb_cv_missing__dtos18'+set}'`\" = set"; then
+echo "configure:4413: checking whether PD libc _dtos18 fail to convert big number" >&5
+if eval "test \"`echo '$''{'rb_cv_missing__dtos18'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+ rb_cv_missing__dtos18=no
else
cat > conftest.$ac_ext <<EOF
-#line 3885 "configure"
+#line 4421 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -3893,7 +4429,7 @@ main ()
}
EOF
-if { (eval echo configure:3897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4433: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
rb_cv_missing__dtos18=yes
else
@@ -3907,7 +4443,7 @@ fi
fi
- echo "$ac_t""$rb_cv_missing__dtos18" 1>&6
+echo "$ac_t""$rb_cv_missing__dtos18" 1>&6
if test "$rb_cv_missing__dtos18" = yes; then
cat >> confdefs.h <<\EOF
#define MISSING__DTOS18 1
@@ -3915,15 +4451,15 @@ EOF
fi
echo $ac_n "checking whether PD libc fconvert fail to round""... $ac_c" 1>&6
-echo "configure:3919: checking whether PD libc fconvert fail to round" >&5
- if eval "test \"`echo '$''{'rb_cv_missing_fconvert'+set}'`\" = set"; then
+echo "configure:4455: checking whether PD libc fconvert fail to round" >&5
+if eval "test \"`echo '$''{'rb_cv_missing_fconvert'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+ rb_cv_missing_fconvert=no
else
cat > conftest.$ac_ext <<EOF
-#line 3927 "configure"
+#line 4463 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -3936,7 +4472,7 @@ main ()
}
EOF
-if { (eval echo configure:3940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
rb_cv_missing_fconvert=yes
else
@@ -3950,7 +4486,7 @@ fi
fi
- echo "$ac_t""$rb_cv_missing_fconvert" 1>&6
+echo "$ac_t""$rb_cv_missing_fconvert" 1>&6
if test "$rb_cv_missing_fconvert" = yes; then
cat >> confdefs.h <<\EOF
#define MISSING_FCONVERT 1
@@ -3959,24 +4495,24 @@ EOF
fi
LIBOBJS="$LIBOBJS x68.o"
CFLAGS="$CFLAGS -fansi-only -cc1-stack=196608 -cpp-stack=2694144"
- binsuffix=.x
+ EXEEXT=.x
+ OBJEXT=o
setup=Setup.x68
;;
+ os2_emx)
+ LIBOBJS="$LIBOBJS os2.o"
+ setup=Setup.emx
+ ;;
cygwin*)
- binsuffix=.exe
setup=Setup
;;
*)
- binsuffix=
setup=Setup
;;
esac
-
-
-
if test "$prefix" = NONE; then
prefix=$ac_default_prefix
fi
@@ -3985,18 +4521,22 @@ if test "$fat_binary" = yes ; then
CFLAGS="$CFLAGS $ARCH_FLAG"
fi
-LIBRUBY='libruby.a'
-LIBRUBYARG='libruby.a'
+LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
+LIBRUBY='$(LIBRUBY_A)'
+LIBRUBYARG='$(LIBRUBY_A)'
SOLIBS=
if test "$host_os" = "beos"; then
- CFLAGS="$CFLAGS -relax_pointers"
- LIBRUBY='libruby.so'
- LIBRUBYARG='-lruby'
+ LIBRUBY='$(LIBRUBY_SO)'
+ LIBRUBYARG='-l$(RUBY_INSTALL_NAME)'
SOLIBS='-lnet'
echo creating ruby.def
case "$host_cpu" in
powerpc*)
cp beos/ruby.def.in ruby.exp
+ CFLAGS="$CFLAGS -relax_pointers"
+ ;;
+ i586*)
+ LDFLAGS="$LDFLAGS -L."
;;
*)
echo EXPORTS > ruby.def
@@ -4005,9 +4545,75 @@ if test "$host_os" = "beos"; then
esac
fi
+FIRSTMAKEFILE=""
+LIBRUBY_LDSHARED=$LDSHARED
+LIBRUBY_DLDFLAGS=$DLDFLAGS
+LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
+LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
+# Check whether --enable-enable-shared or --disable-enable-shared was given.
+if test "${enable_enable_shared+set}" = set; then
+ enableval="$enable_enable_shared"
+ enable_shared=$enableval
+fi
+
if test "$enable_shared" = 'yes'; then
- LIBRUBY='libruby.so'
- LIBRUBYARG='-L./ -lruby'
+ LIBRUBY='$(LIBRUBY_SO)'
+ LIBRUBYARG='-L. -l$(RUBY_INSTALL_NAME)'
+ CFLAGS="$CFLAGS $CCDLFLAGS"
+ case "$host_os" in
+ sunos4*)
+ LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
+ ;;
+ linux*)
+ XLDFLAGS='-Wl,-rpath,${prefix}/lib':/usr/lib:/lib
+ LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
+ ;;
+ freebsd*)
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR)'
+ if test "$rb_cv_freebsd_elf" != "yes" ; then
+ LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)"
+ LIBRUBY_ALIASES=''
+ fi
+ ;;
+ netbsd*)
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)'
+ case "$host_cpu" in
+ alpha|mipsel|mipseb|powerpc|sparc64) # ELF platforms
+ LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR) lib$(RUBY_INSTALL_NAME).so' ;;
+ *) LIBRUBY_ALIASES= ;; # a.out platforms
+ esac
+ ;;
+ solaris*)
+ XLDFLAGS='-R${prefix}/lib'
+ ;;
+ hpux*)
+ XLDFLAGS='-Wl,+s,+b,$(prefix)/lib'
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
+ LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl'
+ ;;
+ aix*)
+ if test "$GCC" = yes; then
+ LIBRUBY_LDSHARED='$(CC) -shared'
+ LIBRUBY_DLDFLAGS='-Wl,-bE:ruby.imp'
+ else
+ LIBRUBY_LDSHARED='/usr/ccs/bin/ld'
+ LIBRUBY_DLDFLAGS='-bE:ruby.imp -bM:SRE -bnoentry'
+ fi
+ LIBRUBYARG='-L${prefix}/lib -Wl,lib$(RUBY_INSTALL_NAME).so'
+ SOLIBS='-lm -lc'
+ ;;
+ cygwin*)
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).a'
+ LIBRUBY_ALIASES=''
+ LIBRUBY_A='lib$(RUBY_INSTALL_NAME)s.a'
+ LIBRUBYARG='-L. -l$(RUBY_INSTALL_NAME)'
+ FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
+ LIBOBJS="$LIBOBJS strftime.o"
+ CCDLFLAGS=-DUSEIMPORTLIB
+ ;;
+ *)
+ ;;
+ esac
fi
case "$host_os" in
@@ -4029,6 +4635,11 @@ esac
+
+
+
+
+
ri_prefix=
test "$program_prefix" != NONE &&
ri_prefix=$program_prefix
@@ -4038,52 +4649,60 @@ test "$program_suffix" != NONE &&
ri_suffix=$program_suffix
RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
+RUBY_LIB_PATH="${prefix}/lib/ruby/${MAJOR}.${MINOR}"
cat >> confdefs.h <<EOF
-#define RUBY_LIB "${prefix}/lib/${RUBY_INSTALL_NAME}"
+#define RUBY_LIB "${RUBY_LIB_PATH}"
EOF
+RUBY_SITE_LIB_PATH="${RUBY_LIB_PATH}/site_ruby"
cat >> confdefs.h <<EOF
-#define RUBY_SITE_LIB "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby"
+#define RUBY_SITE_LIB "${RUBY_SITE_LIB_PATH}"
EOF
+configure_args=$ac_configure_args
+
if test "$fat_binary" = yes ; then
arch="fat-${host_os}"
cat >> confdefs.h <<EOF
-#define RUBY_THIN_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/" __ARCHITECTURE__ "-${host_os}"
+#define RUBY_THIN_ARCHLIB "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${host_os}"
EOF
cat >> confdefs.h <<EOF
-#define RUBY_SITE_THIN_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/" __ARCHITECTURE__ "-${host_os}"
+#define RUBY_SITE_THIN_ARCHLIB "${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${host_os}"
EOF
-
cat >> confdefs.h <<EOF
-#define RUBY_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/${arch}"
+#define RUBY_PLATFORM __ARCHITECTURE__ "-${host_os}"
EOF
+else
+ arch="${host_cpu}-${host_os}"
cat >> confdefs.h <<EOF
-#define RUBY_SITE_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby/${arch}"
+#define RUBY_PLATFORM "${arch}"
EOF
- cat >> confdefs.h <<EOF
-#define RUBY_PLATFORM __ARCHITECTURE__ "-${host_os}"
+fi
+cat >> confdefs.h <<EOF
+#define RUBY_ARCHLIB "${RUBY_LIB_PATH}/${arch}"
EOF
-else
- arch="${host_cpu}-${host_os}"
- cat >> confdefs.h <<EOF
-#define RUBY_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/${arch}"
+cat >> confdefs.h <<EOF
+#define RUBY_SITE_ARCHLIB "${RUBY_SITE_LIB_PATH}/${arch}"
EOF
- cat >> confdefs.h <<EOF
-#define RUBY_SITE_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby/${arch}"
-EOF
+# Check whether --with-search-path or --without-search-path was given.
+if test "${with_search_path+set}" = set; then
+ withval="$with_search_path"
+ search_path=$withval
+fi
+
+if test "$search_path" != ""; then
cat >> confdefs.h <<EOF
-#define RUBY_PLATFORM "${arch}"
+#define RUBY_SEARCH_PATH "$search_path"
EOF
fi
@@ -4193,7 +4812,7 @@ do
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.12.2"
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
@@ -4202,9 +4821,8 @@ do
done
ac_given_srcdir=$srcdir
-ac_given_INSTALL="$INSTALL"
-trap 'rm -fr `echo "Makefile ext/extmk.rb" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+trap 'rm -fr `echo "$FIRSTMAKEFILE Makefile ext/extmk.rb" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
@@ -4236,6 +4854,9 @@ s%@includedir@%$includedir%g
s%@oldincludedir@%$oldincludedir%g
s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
+s%@MAJOR@%$MAJOR%g
+s%@MINOR@%$MINOR%g
+s%@TEENY@%$TEENY%g
s%@host@%$host%g
s%@host_alias@%$host_alias%g
s%@host_cpu@%$host_cpu%g
@@ -4246,12 +4867,14 @@ s%@CPP@%$CPP%g
s%@YACC@%$YACC%g
s%@RANLIB@%$RANLIB%g
s%@AR@%$AR%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@LN_S@%$LN_S%g
s%@SET_MAKE@%$SET_MAKE%g
+s%@EXEEXT@%$EXEEXT%g
+s%@OBJEXT@%$OBJEXT%g
s%@LIBOBJS@%$LIBOBJS%g
s%@ALLOCA@%$ALLOCA%g
+s%@DEFAULT_KCODE@%$DEFAULT_KCODE%g
+s%@XLDFLAGS@%$XLDFLAGS%g
s%@DLDFLAGS@%$DLDFLAGS%g
s%@STATIC@%$STATIC%g
s%@CCDLFLAGS@%$CCDLFLAGS%g
@@ -4259,12 +4882,18 @@ s%@LDSHARED@%$LDSHARED%g
s%@DLEXT@%$DLEXT%g
s%@STRIP@%$STRIP%g
s%@EXTSTATIC@%$EXTSTATIC%g
-s%@binsuffix@%$binsuffix%g
s%@setup@%$setup%g
+s%@LIBRUBY_LDSHARED@%$LIBRUBY_LDSHARED%g
+s%@LIBRUBY_DLDFLAGS@%$LIBRUBY_DLDFLAGS%g
+s%@RUBY_INSTALL_NAME@%$RUBY_INSTALL_NAME%g
+s%@LIBRUBY_A@%$LIBRUBY_A%g
+s%@LIBRUBY_SO@%$LIBRUBY_SO%g
+s%@LIBRUBY_ALIASES@%$LIBRUBY_ALIASES%g
s%@LIBRUBY@%$LIBRUBY%g
s%@LIBRUBYARG@%$LIBRUBYARG%g
s%@SOLIBS@%$SOLIBS%g
s%@arch@%$arch%g
+s%@configure_args@%$configure_args%g
CEOF
EOF
@@ -4306,7 +4935,7 @@ EOF
cat >> $CONFIG_STATUS <<EOF
-CONFIG_FILES=\${CONFIG_FILES-"Makefile ext/extmk.rb"}
+CONFIG_FILES=\${CONFIG_FILES-"$FIRSTMAKEFILE Makefile ext/extmk.rb"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
@@ -4341,10 +4970,6 @@ for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
top_srcdir="$ac_dots$ac_given_srcdir" ;;
esac
- case "$ac_given_INSTALL" in
- [/$]*) INSTALL="$ac_given_INSTALL" ;;
- *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
- esac
echo creating "$ac_file"
rm -f "$ac_file"
@@ -4360,7 +4985,6 @@ for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
s%@configure_input@%$configure_input%g
s%@srcdir@%$srcdir%g
s%@top_srcdir@%$top_srcdir%g
-s%@INSTALL@%$INSTALL%g
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
fi; done
rm -f conftest.s*
diff --git a/configure.bat b/configure.bat
index 093d43549d3..ce0aa8bd9f1 100644
--- a/configure.bat
+++ b/configure.bat
@@ -1,6 +1,24 @@
@echo off
-sed -f top.sed Makefile.in >Makefile
-sed -f top.sed ext/extmk.rb.in > ext\extmk.rb
-copy ext\Setup.dj ext\Setup
+grep -qs MAJOR top.sed
+if errorlevel 1 goto seen
+if errorlevel 0 goto not_seen
+:seen
+ sed -n "/VERSION /s/[^0-9.]//gp" < version.h > version.out
+ cut -d. -f1 version.out > major.out
+ cut -d. -f2 version.out > minor.out
+ cut -d. -f3 version.out > teeny.out
+ sed "s/^/s,@MAJOR@,/;s/$/,/g" major.out >> top.sed
+ sed "s/^/s,@MINOR@,/;s/$/,/g" minor.out >> top.sed
+ sed "s/^/s,@TEENY@,/;s/$/,/g" teeny.out >> top.sed
+ rm version.out major.out minor.out teeny.out
+:not_seen
+sed -f top.sed < Makefile.in > Makefile
+sed -f top.sed < ext\extmk.rb.in > ext\extmk.rb
copy config_h.dj config.h
-copy config_s.dj config.status
+if not (%OS%) == (Windows_NT) goto LFN
+ copy missing\vsnprintf.c missing\vsnprint.c
+ copy config_s.dj config.sta
+goto end
+:LFN
+ copy config_s.dj config.status
+:end
diff --git a/configure.in b/configure.in
index 0477ade03e0..8e86e42e4e4 100644
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,13 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(ruby.h)
+rb_version=`grep RUBY_VERSION $srcdir/version.h`
+MAJOR=`expr "$rb_version" : '#define RUBY_VERSION "\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*"'`
+MINOR=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*"'`
+TEENY=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)"'`
+AC_SUBST(MAJOR)
+AC_SUBST(MINOR)
+AC_SUBST(TEENY)
dnl checks for alternative programs
AC_ARG_WITH(gcc, [--without-gcc never use gcc], [
case $withval in
@@ -18,42 +25,25 @@ then
(it is also a good idea to do 'make clean' before compiling))
fi
-dnl checks for thread
-rb_thread=yes
-AC_ARG_ENABLE(thread, [--disable-thread never use user-level thread], [
- rb_thread=$enableval
-])
-if test $rb_thread = yes; then
- AC_DEFINE(USE_THREAD)
-fi
-
AC_CANONICAL_HOST
dnl checks for fat-binary
fat_binary=no
-AC_ARG_ENABLE( fat-binary,
+AC_ARG_ENABLE(fat-binary,
[--enable-fat-binary build a NeXT/Apple Multi Architecture Binary. ],
- [ fat_binary=$enableval ] )
+ [fat_binary=$enableval])
if test "$fat_binary" = yes ; then
- AC_MSG_CHECKING( target architecture )
+ AC_MSG_CHECKING(target architecture)
case "$host_os" in
rhapsody*)
echo -n "MacOS X Server: "
- if test "$TARGET_ARCHS" = "" ; then
- TARGET_ARCHS="ppc i386"
- fi
+ if test "$TARGET_ARCHS" = "" ; then
+ TARGET_ARCHS="ppc i386"
+ fi
;;
nextstep*|openstep*)
- echo -n "NeXTSTEP/OPENSTEP: "
-
- if test "$host_os" = "rhapsody" ; then
- echo -n "Rhapsody: "
- if test "$TARGET_ARCHS" = "" ; then
- TARGET_ARCHS="ppc i486"
- fi
- else
echo -n "NeXTSTEP/OPENSTEP: "
if test "$TARGET_ARCHS" = "" ; then
if test `/usr/bin/arch` = "m68k" ; then
@@ -62,7 +52,6 @@ AC_ARG_ENABLE( fat-binary,
TARGET_ARCHS="m68k `/usr/bin/arch`"
fi
fi
- fi
;;
esac
# /usr/lib/arch_tool -archify_list $TARGET_ARCHS
@@ -71,7 +60,7 @@ AC_ARG_ENABLE( fat-binary,
ARCH_FLAG="$ARCH_FLAG -arch $archs "
echo -n " $archs"
done
- AC_DEFINE( NEXT_FAT_BINARY )
+ AC_DEFINE(NEXT_FAT_BINARY)
echo "."
fi
@@ -84,28 +73,43 @@ AC_PROG_YACC
AC_PROG_RANLIB
AC_SUBST(AR)
AC_CHECK_PROGS(AR, ar aal, ar)
-AC_PROG_INSTALL
+
+AC_PROG_LN_S
AC_PROG_MAKE_SET
+AC_EXEEXT
+AC_OBJEXT
+
# checks for UNIX variants that set C preprocessor variables
AC_MINIX
AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(void*)
+AC_CHECK_SIZEOF(float)
+AC_CHECK_SIZEOF(double)
-AC_MSG_CHECKING(for prototypes)
-AC_CACHE_VAL(rb_cv_have_prototypes,
+AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
[AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
rb_cv_have_prototypes=yes,
rb_cv_have_prototypes=no)])
-AC_MSG_RESULT($rb_cv_have_prototypes)
if test "$rb_cv_have_prototypes" = yes; then
AC_DEFINE(HAVE_PROTOTYPES)
fi
-AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
-AC_CACHE_VAL(rb_cv_stdarg,
+AC_CACHE_CHECK(token paste string, rb_cv_tokenpaste,
+ [AC_TRY_COMPILE([#define paste(a,b) a##b],
+ [int xy = 1; return paste(x,y);],
+ rb_cv_tokenpaste=ansi,
+ rb_cv_tokenpaste=knr)])
+if test "$rb_cv_tokenpaste" = ansi; then
+ AC_DEFINE(TOKEN_PASTE(x,y),[x##y])
+else
+ AC_DEFINE(TOKEN_PASTE(x,y),[x/**/y])
+fi
+
+AC_CACHE_CHECK(for variable length prototypes and stdarg.h, rb_cv_stdarg,
[AC_TRY_COMPILE([
#include <stdarg.h>
int foo(int x, ...) {
@@ -119,17 +123,14 @@ int foo(int x, ...) {
], [return foo(10, "", 3.14);],
rb_cv_stdarg=yes,
rb_cv_stdarg=no)])
-AC_MSG_RESULT($rb_cv_stdarg)
if test "$rb_cv_stdarg" = yes; then
AC_DEFINE(HAVE_STDARG_PROTOTYPES)
fi
-AC_MSG_CHECKING(for gcc attribute noreturn)
-AC_CACHE_VAL(rb_cv_have_attr_noreturn,
+AC_CACHE_CHECK(for gcc attribute noreturn, rb_cv_have_attr_noreturn,
[AC_TRY_COMPILE([void exit(int x) __attribute__ ((noreturn));], [],
rb_cv_have_attr_noreturn=yes,
rb_cv_have_attr_noreturn=no)])
-AC_MSG_RESULT($rb_cv_have_attr_noreturn)
if test "$rb_cv_have_attr_noreturn" = yes; then
AC_DEFINE(HAVE_ATTR_NORETURN)
fi
@@ -141,6 +142,7 @@ openstep*) ;;
rhapsody*) ;;
human*) ;;
beos*) ;;
+cygwin*) ;;
*) LIBS="-lm $LIBS";;
esac
AC_CHECK_LIB(crypt, crypt)
@@ -151,9 +153,10 @@ AC_CHECK_LIB(xpg4, setlocale) # FreeBSD needs this
dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
-AC_CHECK_HEADERS(stdlib.h unistd.h limits.h sys/file.h sys/ioctl.h pwd.h \
- sys/select.h sys/time.h sys/times.h sys/param.h sys/wait.h\
- syscall.h a.out.h string.h utime.h memory.h direct.h)
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
+ fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
+ syscall.h pwd.h a.out.h utime.h memory.h direct.h fnmatch.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UID_T
@@ -170,15 +173,16 @@ AC_TYPE_SIGNAL
AC_FUNC_ALLOCA
AC_FUNC_VFORK
AC_FUNC_MEMCMP
-AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strerror strftime\
- strchr strstr strtoul strdup crypt flock vsnprintf)
+AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
+ strchr strstr strtoul strdup crypt flock vsnprintf\
+ fnmatch isinf isnan finite)
AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd\
truncate chsize times utimes fcntl lockf setitimer\
setruid seteuid setreuid setrgid setegid setregid\
- setpgrp2 getpgid setpgid getgroups getpriority\
- dlopen sigprocmask sigaction _setjmp setpgrp setsid)
+ getpgrp setpgrp getpgid setpgid getgroups getpriority\
+ dlopen sigprocmask sigaction _setjmp setsid)
+AC_STRUCT_TIMEZONE
if test "$ac_cv_func_strftime" = no; then
- AC_STRUCT_TIMEZONE
AC_TRY_LINK([],
[extern int daylight; int i = daylight;], AC_DEFINE(HAVE_DAYLIGHT))
fi
@@ -186,8 +190,7 @@ fi
if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
AC_DEFINE(POSIX_SIGNAL)
else
- AC_MSG_CHECKING(for BSD signal semantics)
- AC_CACHE_VAL(rb_cv_bsd_signal,
+ AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
[AC_TRY_RUN([
#include <stdio.h>
#include <signal.h>
@@ -208,43 +211,51 @@ main()
}
],
rb_cv_bsd_signal=yes,
+ rb_cv_bsd_signal=no,
rb_cv_bsd_signal=no)])
- AC_MSG_RESULT($rb_cv_bsd_signal)
if test "$rb_cv_bsd_signal" = yes; then
AC_DEFINE(BSD_SIGNAL)
fi
fi
-if test "$ac_cv_func_setpgrp2" = yes; then
- AC_DEFINE(BSD_GETPGRP, getpgrp2)
- AC_DEFINE(BSD_SETPGRP, setpgrp2)
-else
- AC_MSG_CHECKING(whether getpgrp() has arg)
- AC_CACHE_VAL(rb_cv_bsdgetpgrp,
- [AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);],
- rb_cv_bsdgetpgrp=yes,
- rb_cv_bsdgetpgrp=no)])
- AC_MSG_RESULT($rb_cv_bsdgetpgrp)
- if test "$rb_cv_bsdgetpgrp" = yes; then
- AC_DEFINE(BSD_GETPGRP, getpgrp)
- fi
+AC_FUNC_GETPGRP
+AC_FUNC_SETPGRP
- AC_MSG_CHECKING(whether setpgrp() has args)
- AC_CACHE_VAL(rb_cv_bsdsetpgrp,
- [AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(1, 1);],
- rb_cv_bsdsetpgrp=yes,
- rb_cv_bsdsetpgrp=no)])
- AC_MSG_RESULT($rb_cv_bsdsetpgrp)
- if test "$rb_cv_bsdsetpgrp" = yes; then
- AC_DEFINE(BSD_SETPGRP, setpgrp)
- fi
-fi
+AC_CACHE_CHECK(for working strtod, rb_cv_func_strtod,
+[AC_TRY_RUN([
+double strtod ();
+int
+main()
+{
+ {
+ /* Some versions of Linux strtod mis-parse strings with leading '+'. */
+ char *string = " +69";
+ char *term;
+ double value;
+ value = strtod(string, &term);
+ if (value != 69 || term != (string + 4))
+ exit(1);
+ }
+
+ {
+ /* Under Solaris 2.4, strtod returns the wrong value for the
+ terminating character under some conditions. */
+ char *string = "NaN";
+ char *term;
+ strtod(string, &term);
+ if (term != string && *(term - 1) == 0)
+ exit(1);
+ }
+ exit(0);
+}
+], rb_cv_func_strtod=yes, rb_cv_func_strtod=no, rb_cv_func_strtod=no)])
+test $rb_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o"
AC_C_BIGENDIAN
+AC_C_CONST
AC_CHAR_UNSIGNED
-AC_MSG_CHECKING(whether right shift preserve sign bit)
-AC_CACHE_VAL(rb_cv_rshift_sign,
+AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
[AC_TRY_RUN([
int
main()
@@ -255,15 +266,15 @@ main()
}
],
rb_cv_rshift_sign=yes,
- rb_cv_rshift_sign=no)])
- AC_MSG_RESULT($rb_cv_rshift_sign)
+ rb_cv_rshift_sign=no,
+ rb_cv_rshift_sign=yes)])
if test "$rb_cv_rshift_sign" = yes; then
AC_DEFINE(RSHIFT(x,y), ((x)>>y))
else
AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
fi
-AC_MSG_CHECKING([count field in FILE structures])
+AC_MSG_CHECKING(count field in FILE structures)
AC_CACHE_VAL(rb_cv_fcnt,
[AC_TRY_COMPILE([#include <stdio.h>],
[FILE *f = stdin; f->_cnt = 0;], rb_cv_fcnt="_cnt", )
@@ -278,7 +289,13 @@ fi
if test "$rb_cv_fcnt" = ""; then
AC_TRY_COMPILE([#include <stdio.h>],
[FILE *f = stdin; f->readCount = 0;],
- rb_cv_fcnt="readCount", rb_cv_fcnt="not found")
+ rb_cv_fcnt="readCount", )
+fi
+dnl for emx0.9c
+if test "$rb_cv_fcnt" = ""; then
+ AC_TRY_COMPILE([#include <stdio.h>],
+ [FILE *f = stdin; f->_rcount = 0;],
+ rb_cv_fcnt="_rcount", rb_cv_fcnt="not found")
fi])
if test "$rb_cv_fcnt" = "not found"; then
AC_MSG_RESULT([not found(OK if using GNU libc)])
@@ -287,17 +304,31 @@ else
AC_DEFINE_UNQUOTED(FILE_COUNT, $rb_cv_fcnt)
fi
+dnl default value for $KANJI
+AC_SUBST(DEFAULT_KCODE)
+AC_ARG_WITH(default-kcode,
+ [--with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)],
+ [case $withval in
+ utf8) AC_DEFINE(DEFAULT_KCODE, KCODE_UTF8);;
+ euc) AC_DEFINE(DEFAULT_KCODE, KCODE_EUC);;
+ sjis) AC_DEFINE(DEFAULT_KCODE, KCODE_SJIS);;
+ none) AC_DEFINE(DEFAULT_KCODE, KCODE_NONE);;
+ *) AC_MSG_WARN($withval is not valid kcode; ignored);;
+ esac])
+
dnl wheather use dln_a_out ot not
-AC_ARG_WITH(dln-a-out, [--with-dln-a-out use dln_a_out if possible], [
+AC_ARG_WITH(dln-a-out,
+ [--with-dln-a-out use dln_a_out if possible], [
case $withval in
yes) with_dln_a_out=yes;;
*) with_dln_a_out=no;;
esac], [with_dln_a_out=no])
+AC_SUBST(XLDFLAGS)dnl
+
case "$host_os" in
linux*)
- AC_MSG_CHECKING(whether ELF binaries are produced)
- AC_CACHE_VAL(rb_cv_linux_elf,
+ AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
[AC_TRY_RUN([
/* Test for whether ELF binaries are produced */
#include <fcntl.h>
@@ -315,13 +346,12 @@ main() {
exit(0); /* succeed (yes, it's ELF) */
}
],
- rb_cv_linux_elf=yes,
- rb_cv_linux_elf=no,
- [:])])
- AC_MSG_RESULT($rb_cv_linux_elf)
- if test "$rb_cv_linux_elf" = no; then
+ rb_cv_binary_elf=yes,
+ rb_cv_binary_elf=no,
+ rb_cv_binary_elf=yes)])
+ if test "$rb_cv_binary_elf" = no; then
with_dln_a_out=yes
- host_os=linux-a.out
+ host_os=${host_os}-a_out
else
LDFLAGS="-rdynamic"
fi;;
@@ -345,15 +375,21 @@ if test "$with_dln_a_out" != yes; then
openstep*) ;;
rhapsody*) ;;
human*) ;;
- cygwin*) CCDLFLAGS=-DDLLIMPORT;;
- *) CCDLFLAGS=-fpic;;
+ bsdi3*) ;;
+ cygwin*) ;;
+ netbsd*) CCDLFLAGS=-fpic
+ case "$host_cpu" in
+ mips*) CCDLFLAGS=-fPIC ;;
+ *) ;;
+ esac ;;
+ *) CCDLFLAGS=-fPIC;;
esac
else
case "$host_os" in
hpux*) CCDLFLAGS='+z';;
- solaris*|irix*) CCDLFLAGS='-K pic' ;;
- sunos*) CCDLFLAGS='-pic' ;;
- esix*|uxpds*) CCDLFLAGS='-Kpic' ;;
+ solaris*|irix*) CCDLFLAGS='-K PIC' ;;
+ sunos*) CCDLFLAGS='-PIC' ;;
+ esix*|uxpds*) CCDLFLAGS='-KPIC' ;;
*) CCDLFLAGS='' ;;
esac
fi
@@ -363,7 +399,12 @@ if test "$with_dln_a_out" != yes; then
LDSHARED='ld -b'
LDFLAGS="-Wl,-E"
rb_cv_dlopen=yes;;
- solaris*) LDSHARED='ld -G'
+ solaris*) if test "$GCC" = yes; then
+ LDSHARED='$(CC) -Wl,-G'
+ `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null && LDFLAGS="-Wl,-E"
+ else
+ LDSHARED='ld -G'
+ fi
rb_cv_dlopen=yes;;
sunos*) LDSHARED='ld -assert nodefinitions'
rb_cv_dlopen=yes;;
@@ -373,19 +414,29 @@ if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=yes;;
esix*|uxpds*) LDSHARED="ld -G"
rb_cv_dlopen=yes ;;
- linux*) LDSHARED="gcc -shared"
+ osf*) LDSHARED="$CC -shared"
rb_cv_dlopen=yes ;;
- freebsd3*) LDSHARED="ld -Bshareable"
- LDFLAGS="-rdynamic"
+ linux*) LDSHARED="$CC -shared"
rb_cv_dlopen=yes ;;
- freebsd*) LDSHARED="ld -Bshareable"
+ freebsd*) LDSHARED="$CC -shared"
+ if test -x /usr/bin/objformat && \
+ test `/usr/bin/objformat` = "elf" ; then
+ LDFLAGS="-rdynamic"
+ DLDFLAGS='-Wl,-soname,$(.TARGET)'
+ rb_cv_freebsd_elf=yes
+ else
+ test "$GCC" = yes && `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null || LDSHARED="ld -Bshareable"
+ fi
rb_cv_dlopen=yes ;;
- netbsd*) LDSHARED="ld -Bshareable"
+ netbsd*) LDSHARED="ld -shared"
rb_cv_dlopen=yes ;;
openbsd*) LDSHARED="ld -Bforcearchive -Bshareable"
- CCDLFLAGS=-fPIC
rb_cv_dlopen=yes ;;
- nextstep*) LDSHARED='cc -r'
+ bsdi3*) case "$CC" in
+ *shlicc*) LDSHARED="$CC -r"
+ rb_cv_dlopen=yes ;;
+ esac ;;
+ nextstep*) LDSHARED='cc -r -nostdlib'
LDFLAGS="-u libsys_s"
DLDFLAGS="$ARCH_FLAG"
rb_cv_dlopen=yes ;;
@@ -397,22 +448,30 @@ if test "$with_dln_a_out" != yes; then
LDFLAGS=""
DLDFLAGS="$ARCH_FLAG"
rb_cv_dlopen=yes ;;
- aix*) LDSHARED='../../miniruby ../aix_ld.rb $(TARGET)'
+ aix*) LDSHARED='/usr/ccs/bin/ld'
+ XLDFLAGS='-Wl,-bE:ruby.imp'
+ DLDFLAGS='-eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 -lc'
rb_cv_dlopen=yes ;;
+
human*) DLDFLAGS=''
LDSHARED=''
- LDFLAGS='' ;;
- beos*) LDSHARED="ld -xms"
- case "$host_cpu" in
+ LDFLAGS=''
+ rb_cv_dlopen=yes ;;
+ beos*) case "$host_cpu" in
powerpc*)
+ LDSHARED="ld -xms"
DLDFLAGS="-f ruby.exp -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
;;
+ i586*)
+ LDSHARED="ld -shared"
+ DLDFLAGS="-L/boot/develop/lib/x86 -lbe -lroot"
+ ;;
*)
DLDFLAGS="ruby.def -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
- ;;
esac
rb_cv_dlopen=yes ;;
- cygwin*) LDSHARED='../../miniruby ../cygwin32_ld.rb' ;;
+ cygwin*) LDSHARED='dllwrap --export-all -s'
+ rb_cv_dlopen=yes ;;
*) LDSHARED='ld' ;;
esac
AC_MSG_RESULT($rb_cv_dlopen)
@@ -421,9 +480,8 @@ fi
dln_a_out_works=no
if test "$ac_cv_header_a_out_h" = yes; then
if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then
- AC_MSG_CHECKING(whether matz's dln works)
cat confdefs.h > config.h
- AC_CACHE_VAL(rb_cv_dln_a_out,
+ AC_CACHE_CHECK(whether matz's dln works, rb_cv_dln_a_out,
[AC_TRY_COMPILE([
#define USE_DLN_A_OUT
#include "dln.c"
@@ -431,7 +489,6 @@ if test "$ac_cv_header_a_out_h" = yes; then
[],
rb_cv_dln_a_out=yes,
rb_cv_dln_a_out=no)])
- AC_MSG_RESULT($rb_cv_dln_a_out)
if test "$rb_cv_dln_a_out" = yes; then
dln_a_out_works=yes
AC_DEFINE(USE_DLN_A_OUT)
@@ -445,21 +502,23 @@ if test "$dln_a_out_works" = yes; then
else
STATIC=-Bstatic
fi
- DLEXT=o
- AC_DEFINE(DLEXT, ".o")
+ DLEXT=so
+ AC_DEFINE(DLEXT, ".so")
CCDLFLAGS=
else
case "$host_os" in
hpux*) DLEXT=sl
AC_DEFINE(DLEXT, ".sl");;
- nextstep*) DLEXT=o
- AC_DEFINE(DLEXT, ".o");;
+ nextstep*) DLEXT=bundle
+ AC_DEFINE(DLEXT, ".bundle");;
openstep*) DLEXT=bundle
AC_DEFINE(DLEXT, ".bundle");;
rhapsody*) DLEXT=bundle
AC_DEFINE(DLEXT, ".bundle");;
cygwin*) DLEXT=dll
AC_DEFINE(DLEXT, ".dll");;
+ os2_emx) DLEXT=o
+ AC_DEFINE(DLEXT, ".so");;
*) DLEXT=so
AC_DEFINE(DLEXT, ".so");;
esac
@@ -498,8 +557,8 @@ case "$host_os" in
AC_CHECK_LIB(signal, _harderr)
AC_CHECK_LIB(hmem, hmemset)
AC_CHECK_FUNCS(select)
- AC_MSG_CHECKING(whether PD libc _dtos18 fail to convert big number)
- AC_CACHE_VAL(rb_cv_missing__dtos18,
+ AC_CACHE_CHECK(whether PD libc _dtos18 fail to convert big number,
+ rb_cv_missing__dtos18,
[AC_TRY_RUN(
changequote(<<, >>)dnl
<<
@@ -512,13 +571,12 @@ main ()
}
>>,
changequote([, ])dnl
-rb_cv_missing__dtos18=yes, rb_cv_missing__dtos18=no)])
- AC_MSG_RESULT($rb_cv_missing__dtos18)
+rb_cv_missing__dtos18=yes, rb_cv_missing__dtos18=no, rb_cv_missing__dtos18=no)])
if test "$rb_cv_missing__dtos18" = yes; then
AC_DEFINE(MISSING__DTOS18)
fi
- AC_MSG_CHECKING(whether PD libc fconvert fail to round)
- AC_CACHE_VAL(rb_cv_missing_fconvert,
+ AC_CACHE_CHECK(whether PD libc fconvert fail to round,
+ rb_cv_missing_fconvert,
[AC_TRY_RUN(
changequote(<<, >>)dnl
<<
@@ -532,29 +590,29 @@ main ()
}
>>,
changequote([, ])dnl
-rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no)])
- AC_MSG_RESULT($rb_cv_missing_fconvert)
+rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no, rb_cv_missing_fconvert=no)])
if test "$rb_cv_missing_fconvert" = yes; then
AC_DEFINE(MISSING_FCONVERT)
fi
LIBOBJS="$LIBOBJS x68.o"
CFLAGS="$CFLAGS -fansi-only -cc1-stack=196608 -cpp-stack=2694144"
- binsuffix=.x
+ EXEEXT=.x
+ OBJEXT=o
setup=Setup.x68
;;
+ dnl OS/2 environment w/ Autoconf 2.1x for EMX
+ os2_emx)
+ LIBOBJS="$LIBOBJS os2.o"
+ setup=Setup.emx
+ ;;
cygwin*)
- binsuffix=.exe
setup=Setup
;;
*)
- binsuffix=
setup=Setup
;;
esac
-
-
-AC_SUBST(binsuffix)
AC_SUBST(setup)
if test "$prefix" = NONE; then
@@ -565,18 +623,22 @@ if test "$fat_binary" = yes ; then
CFLAGS="$CFLAGS $ARCH_FLAG"
fi
-LIBRUBY='libruby.a'
-LIBRUBYARG='libruby.a'
+LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
+LIBRUBY='$(LIBRUBY_A)'
+LIBRUBYARG='$(LIBRUBY_A)'
SOLIBS=
if test "$host_os" = "beos"; then
- CFLAGS="$CFLAGS -relax_pointers"
- LIBRUBY='libruby.so'
- LIBRUBYARG='-lruby'
+ LIBRUBY='$(LIBRUBY_SO)'
+ LIBRUBYARG='-l$(RUBY_INSTALL_NAME)'
SOLIBS='-lnet'
echo creating ruby.def
case "$host_cpu" in
powerpc*)
cp beos/ruby.def.in ruby.exp
+ CFLAGS="$CFLAGS -relax_pointers"
+ ;;
+ i586*)
+ LDFLAGS="$LDFLAGS -L."
;;
*)
echo EXPORTS > ruby.def
@@ -585,9 +647,72 @@ if test "$host_os" = "beos"; then
esac
fi
+FIRSTMAKEFILE=""
+LIBRUBY_LDSHARED=$LDSHARED
+LIBRUBY_DLDFLAGS=$DLDFLAGS
+LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
+LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
+AC_ARG_ENABLE(enable-shared,
+ [--enable-shared build a shared library for Ruby. ],
+ [enable_shared=$enableval])
if test "$enable_shared" = 'yes'; then
- LIBRUBY='libruby.so'
- LIBRUBYARG='-L./ -lruby'
+ LIBRUBY='$(LIBRUBY_SO)'
+ LIBRUBYARG='-L. -l$(RUBY_INSTALL_NAME)'
+ CFLAGS="$CFLAGS $CCDLFLAGS"
+ case "$host_os" in
+ sunos4*)
+ LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
+ ;;
+ linux*)
+ XLDFLAGS='-Wl,-rpath,${prefix}/lib':/usr/lib:/lib
+ LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
+ ;;
+ freebsd*)
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR)'
+ if test "$rb_cv_freebsd_elf" != "yes" ; then
+ LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)"
+ LIBRUBY_ALIASES=''
+ fi
+ ;;
+ netbsd*)
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)'
+ case "$host_cpu" in
+ alpha|mipsel|mipseb|powerpc|sparc64) # ELF platforms
+ LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR) lib$(RUBY_INSTALL_NAME).so' ;;
+ *) LIBRUBY_ALIASES= ;; # a.out platforms
+ esac
+ ;;
+ solaris*)
+ XLDFLAGS='-R${prefix}/lib'
+ ;;
+ hpux*)
+ XLDFLAGS='-Wl,+s,+b,$(prefix)/lib'
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
+ LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl'
+ ;;
+ aix*)
+ if test "$GCC" = yes; then
+ LIBRUBY_LDSHARED='$(CC) -shared'
+ LIBRUBY_DLDFLAGS='-Wl,-bE:ruby.imp'
+ else
+ LIBRUBY_LDSHARED='/usr/ccs/bin/ld'
+ LIBRUBY_DLDFLAGS='-bE:ruby.imp -bM:SRE -bnoentry'
+ fi
+ LIBRUBYARG='-L${prefix}/lib -Wl,lib$(RUBY_INSTALL_NAME).so'
+ SOLIBS='-lm -lc'
+ ;;
+ cygwin*)
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).a'
+ LIBRUBY_ALIASES=''
+ LIBRUBY_A='lib$(RUBY_INSTALL_NAME)s.a'
+ LIBRUBYARG='-L. -l$(RUBY_INSTALL_NAME)'
+ FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
+ LIBOBJS="$LIBOBJS strftime.o"
+ CCDLFLAGS=-DUSEIMPORTLIB
+ ;;
+ *)
+ ;;
+ esac
fi
case "$host_os" in
@@ -604,7 +729,12 @@ case "$host_os" in
;;
esac
-
+AC_SUBST(LIBRUBY_LDSHARED)
+AC_SUBST(LIBRUBY_DLDFLAGS)
+AC_SUBST(RUBY_INSTALL_NAME)
+AC_SUBST(LIBRUBY_A)
+AC_SUBST(LIBRUBY_SO)
+AC_SUBST(LIBRUBY_ALIASES)
AC_SUBST(LIBRUBY)
AC_SUBST(LIBRUBYARG)
AC_SUBST(SOLIBS)
@@ -618,30 +748,39 @@ test "$program_suffix" != NONE &&
ri_suffix=$program_suffix
RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
-AC_DEFINE_UNQUOTED(RUBY_LIB, "${prefix}/lib/${RUBY_INSTALL_NAME}")
-AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby")
+RUBY_LIB_PATH="${prefix}/lib/ruby/${MAJOR}.${MINOR}"
+AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
+RUBY_SITE_LIB_PATH="${RUBY_LIB_PATH}/site_ruby"
+AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
AC_SUBST(arch)dnl
+configure_args=$ac_configure_args
+AC_SUBST(configure_args)dnl
+
if test "$fat_binary" = yes ; then
arch="fat-${host_os}"
AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB,
- "${prefix}/lib/${RUBY_INSTALL_NAME}/" __ARCHITECTURE__ "-${host_os}" )
+ "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${host_os}")
AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB,
- "${prefix}/lib/${RUBY_INSTALL_NAME}/" __ARCHITECTURE__ "-${host_os}" )
-
- AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/${arch}")
- AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby/${arch}")
- AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${host_os}" )
+ "${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${host_os}")
+ AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${host_os}")
else
arch="${host_cpu}-${host_os}"
- AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/${arch}")
- AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby/${arch}")
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}")
fi
+AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
+AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH}/${arch}")
+
+AC_ARG_WITH(search-path,
+ [--with-search-path specify the additional search path],
+ [search_path=$withval])
+if test "$search_path" != ""; then
+ AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path")
+fi
echo "creating config.h"
cat confdefs.h > config.h
-AC_OUTPUT(Makefile ext/extmk.rb)
+AC_OUTPUT($FIRSTMAKEFILE Makefile ext/extmk.rb)
diff --git a/cygwin/GNUmakefile.in b/cygwin/GNUmakefile.in
new file mode 100644
index 00000000000..970e90e24a9
--- /dev/null
+++ b/cygwin/GNUmakefile.in
@@ -0,0 +1,9 @@
+include Makefile
+
+RUBYCWDLL=rubycw.dll
+
+miniruby$(EXEEXT): $(RUBYCWDLL)
+
+$(RUBYCWDLL): $(OBJS) dmyext.o
+ dllwrap -o $(RUBYCWDLL) --export-all --output-lib=$(LIBRUBY_SO) --dllname=$(RUBYCWDLL) -Wl,-e,__cygwin_noncygwin_dll_entry@12 --add-stdcall-alias -s $(OBJS) dmyext.o
+ nm --extern-only $(OBJS) dmyext.o | sed -n '/^........ [CD] _\(.*\)$$/s//#define \1 (*__imp_\1)/p' >import.h
diff --git a/defines.h b/defines.h
index fb10d628b4d..8e6eb83ca75 100644
--- a/defines.h
+++ b/defines.h
@@ -13,12 +13,12 @@
#define RUBY
/* define RUBY_USE_EUC/SJIS for default kanji-code */
-#if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__) || defined(__MACOS__)
-#undef RUBY_USE_EUC
-#define RUBY_USE_SJIS
+#ifndef DEFAULT_KCODE
+#if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__) || defined(__MACOS__) || defined(__EMX__) || defined(OS2)
+#define DEFAULT_KCODE KCODE_SJIS
#else
-#define RUBY_USE_EUC
-#undef RUBY_USE_SJIS
+#define DEFAULT_KCODE KCODE_EUC
+#endif
#endif
#ifdef NeXT
@@ -31,7 +31,7 @@
#endif /* NeXT */
#ifdef NT
-#include "missing/nt.h"
+#include "win32/win32.h"
#endif
#ifndef EXTERN
@@ -44,11 +44,16 @@
#define FLUSH_REGISTER_WINDOWS /* empty */
#endif
-#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__MACOS__)
-#define RUBY_PATH_SEP ";"
+#if defined(MSDOS) || defined(_WIN32) || defined(__human68k__) || defined(__EMX__)
+#define DOSISH 1
+#endif
+
+#if defined(MSDOS) || defined(NT) || defined(__human68k__)
+#define PATH_SEP ";"
#else
-#define RUBY_PATH_SEP ":"
+#define PATH_SEP ":"
#endif
+#define PATH_SEP_CHAR PATH_SEP[0]
#if defined(__human68k__) || defined(__CYGWIN32__)
#undef HAVE_RANDOM
diff --git a/dir.c b/dir.c
index 51d7f9e3448..31116a9fffe 100644
--- a/dir.c
+++ b/dir.c
@@ -6,7 +6,7 @@
$Date$
created at: Wed Jan 5 09:51:01 JST 1994
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -47,14 +47,23 @@
# endif
#endif
+#ifdef HAVE_FNMATCH_H
+#include <fnmatch.h>
+#else
+#include "missing/fnmatch.h"
+#endif
+
#include <errno.h>
+#ifdef USE_CWGUSI
+# include <sys/errno.h>
+#endif
-#ifndef NT
+#ifndef HAVE_STDLIB_H
char *getenv();
#endif
-#ifdef USE_CWGUSI
-# include <sys/errno.h>
+#ifndef HAVE_STRING_H
+char *strchr _((char*,char));
#endif
VALUE rb_cDir;
@@ -149,10 +158,10 @@ static VALUE
dir_tell(dir)
VALUE dir;
{
+#if !defined(__CYGWIN32__) && !defined(__BEOS__)
DIR *dirp;
- int pos;
+ long pos;
-#if !defined(__CYGWIN32__) && !defined(__BEOS__)
GetDIR(dir, dirp);
pos = telldir(dirp);
return rb_int2inum(pos);
@@ -248,7 +257,7 @@ static VALUE
dir_s_chroot(dir, path)
VALUE dir, path;
{
-#if !defined(DJGPP) && !defined(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__)
+#if !defined(DJGPP) && !defined(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__) && !defined(__EMX__)
rb_secure(2);
Check_SafeStr(path);
@@ -303,29 +312,169 @@ dir_s_rmdir(obj, dir)
return Qtrue;
}
-#define isdelim(c) ((c)==' '||(c)=='\t'||(c)=='\n'||(c)=='\0')
+/* Return nonzero if S has any special globbing chars in it. */
+static int
+has_magic(s, send)
+ char *s, *send;
+{
+ register char *p = s;
+ register char c;
+ int open = 0;
+
+ while ((c = *p++) != '\0') {
+ switch (c) {
+ case '?':
+ case '*':
+ return Qtrue;
+
+ case '[': /* Only accept an open brace if there is a close */
+ open++; /* brace to match it. Bracket expressions must be */
+ continue; /* complete, according to Posix.2 */
+ case ']':
+ if (open)
+ return Qtrue;
+ continue;
+
+ case '\\':
+ if (*p++ == '\0')
+ return Qfalse;
+ }
+
+ if (send && p >= send) break;
+ }
+ return Qfalse;
+}
+
+static char*
+extract_path(p, pend)
+ char *p, *pend;
+{
+ char *alloc;
+ int len;
+
+ len = pend - p;
+ alloc = ALLOC_N(char, len+1);
+ memcpy(alloc, p, len);
+ if (len > 0 && pend[-1] == '/') {
+ alloc[len-1] = 0;
+ }
+ else {
+ alloc[len] = 0;
+ }
+
+ return alloc;
+}
+
+static char*
+extract_elem(path)
+ char *path;
+{
+ char *pend;
+
+ pend = strchr(path, '/');
+ if (!pend) pend = path + strlen(path);
+
+ return extract_path(path, pend);
+}
+
+#ifndef S_ISDIR
+# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
+#endif
+
+static void
+glob(path, func, arg)
+ char *path;
+ void (*func)();
+ VALUE arg;
+{
+ struct stat st;
+ char *p, *m;
+
+ if (!has_magic(path, 0)) {
+ if (stat(path, &st) == 0) {
+ (*func)(path, arg);
+ }
+ return;
+ }
+
+ p = path;
+ while (p) {
+ if (*p == '/') p++;
+ m = strchr(p, '/');
+ if (has_magic(p, m)) {
+ char *dir, *base, *magic;
+ DIR *dirp;
+ struct dirent *dp;
+
+ struct d_link {
+ char *path;
+ struct d_link *next;
+ } *tmp, *link = 0;
+
+ base = extract_path(path, p);
+ if (path == p) dir = ".";
+ else dir = base;
+
+ dirp = opendir(dir);
+ if (dirp == NULL) {
+ free(base);
+ break;
+ }
+ magic = extract_elem(p);
+ for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
+ if (fnmatch(magic, dp->d_name, FNM_PERIOD|FNM_PATHNAME) == 0) {
+ char *fix = ALLOC_N(char, strlen(base)+NAMLEN(dp)+2);
+
+ sprintf(fix, "%s%s%s", base, (*base)?"/":"", dp->d_name);
+ if (!m) {
+ (*func)(fix, arg);
+ free(fix);
+ continue;
+ }
+ tmp = ALLOC(struct d_link);
+ tmp->path = fix;
+ tmp->next = link;
+ link = tmp;
+ }
+ }
+ closedir(dirp);
+ free(base);
+ free(magic);
+ while (link) {
+ stat(link->path, &st); /* should success */
+ if (S_ISDIR(st.st_mode)) {
+ int len = strlen(link->path);
+ int mlen = strlen(m);
+ char *t = ALLOC_N(char, len+mlen+1);
+
+ sprintf(t, "%s%s", link->path, m);
+ glob(t, func, arg);
+ free(t);
+ }
+ tmp = link;
+ link = link->next;
+ free(tmp->path);
+ free(tmp);
+ }
+ }
+ p = m;
+ }
+}
-char **glob_filename();
-extern char *glob_error_return;
+static void
+push_pattern(path, ary)
+ char *path;
+ VALUE ary;
+{
+ rb_ary_push(ary, rb_tainted_str_new2(path));
+}
static void
push_globs(ary, s)
VALUE ary;
char *s;
{
- char **fnames, **ff;
-
- fnames = glob_filename(s);
- if (fnames == (char**)-1) rb_sys_fail(s);
- ff = fnames;
- while (*ff) {
- rb_ary_push(ary, rb_tainted_str_new2(*ff));
- free(*ff);
- ff++;
- }
- if (fnames != &glob_error_return) {
- free(fnames);
- }
+ glob(s, push_pattern, ary);
}
static void
@@ -333,9 +482,10 @@ push_braces(ary, s)
VALUE ary;
char *s;
{
- char buf[MAXPATHLEN];
+ char buffer[MAXPATHLEN], *buf = buffer;
char *p, *t, *b;
char *lbrace, *rbrace;
+ int nest = 0;
p = s;
lbrace = rbrace = 0;
@@ -347,7 +497,8 @@ push_braces(ary, s)
p++;
}
while (*p) {
- if (*p == '}' && lbrace) {
+ if (*p == '{') nest++;
+ if (*p == '}' && --nest == 0) {
rbrace = p;
break;
}
@@ -355,6 +506,9 @@ push_braces(ary, s)
}
if (lbrace) {
+ int len = strlen(s);
+ if (len >= MAXPATHLEN)
+ buf = xmalloc(len + 1);
memcpy(buf, s, lbrace-s);
b = buf + (lbrace-s);
p = lbrace;
@@ -368,46 +522,44 @@ push_braces(ary, s)
strcpy(b+(p-t), rbrace+1);
push_braces(ary, buf);
}
+ if (buf != buffer)
+ free(buf);
}
else {
push_globs(ary, s);
}
}
+#define isdelim(c) ((c)==' '||(c)=='\t'||(c)=='\n'||(c)=='\0')
+
static VALUE
dir_s_glob(dir, str)
VALUE dir, str;
{
char *p, *pend;
- char buf[MAXPATHLEN];
- char *t, *t0;
+ char buffer[MAXPATHLEN], *buf = buffer;
+ char *t;
int nest;
VALUE ary;
Check_SafeStr(str);
- if (RSTRING(str)->len > MAXPATHLEN) {
- rb_raise(rb_eArgError, "pathname too long (%d bytes)",
- RSTRING(str)->len);
- }
ary = rb_ary_new();
+ if (RSTRING(str)->len >= MAXPATHLEN)
+ buf = xmalloc(RSTRING(str)->len + 1);
p = RSTRING(str)->ptr;
pend = p + RSTRING(str)->len;
while (p < pend) {
t = buf;
+ nest = 0;
while (p < pend && isdelim(*p)) p++;
while (p < pend && !isdelim(*p)) {
+ if (*p == '{') nest+=2;
+ if (*p == '}') nest+=3;
*t++ = *p++;
}
*t = '\0';
- t0 = buf;
- nest = 0;
- while (t0 < t) {
- if (*t0 == '{') nest+=2;
- if (*t0 == '}') nest+=3;
- t0++;
- }
if (nest == 0) {
push_globs(ary, buf);
}
@@ -416,6 +568,8 @@ dir_s_glob(dir, str)
}
/* else unmatched braces */
}
+ if (buf != buffer)
+ free(buf);
return ary;
}
diff --git a/dln.c b/dln.c
index 858291d5b79..e6c7adde70f 100644
--- a/dln.c
+++ b/dln.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Jan 18 17:05:06 JST 1994
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -30,9 +30,11 @@ char *dln_argv0;
# include <strings.h>
#endif
+#ifndef xmalloc
void *xmalloc();
void *xcalloc();
void *xrealloc();
+#endif
#include <stdio.h>
#ifndef NT
@@ -56,7 +58,6 @@ void *xrealloc();
#endif
#ifndef NT
-char *strdup();
char *getenv();
#endif
@@ -64,6 +65,7 @@ char *getenv();
# include <TextUtils.h>
# include <CodeFragments.h>
# include <Aliases.h>
+# include "macruby_private.h"
#endif
#ifdef __BEOS__
@@ -78,7 +80,7 @@ int eaccess();
#endif
#ifndef FUNCNAME_PATTERN
-# if defined(__hp9000s300) || defined(__NetBSD__) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(NeXT) || defined(__WATCOMC__)
+# if defined(__hp9000s300) || (defined(__NetBSD__) && (!defined(__alpha__) && !defined(__mips__))) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__)
# define FUNCNAME_PATTERN "_Init_%.200s"
# else
# define FUNCNAME_PATTERN "Init_%.200s"
@@ -87,7 +89,8 @@ int eaccess();
static void
init_funcname(buf, file)
- char *buf, *file;
+ char *buf;
+ char *file;
{
char *p, *slash;
@@ -100,7 +103,7 @@ init_funcname(buf, file)
#endif
sprintf(buf, FUNCNAME_PATTERN, slash + 1);
- for (p = buf; *p; p++) { /* Delete suffix it it exists */
+ for (p = buf; *p; p++) { /* Delete suffix if it exists */
if (*p == '.') {
*p = '\0'; break;
}
@@ -315,7 +318,7 @@ sym_hash(hdrp, syms)
static int
dln_init(prog)
- char *prog;
+ const char *prog;
{
char *file;
int fd;
@@ -423,7 +426,7 @@ load_text_data(fd, hdrp, bss, disp)
}
static int
-underb_f_print(key, value)
+undef_print(key, value)
char *key, *value;
{
fprintf(stderr, " %s\n", key);
@@ -434,7 +437,7 @@ static void
dln_print_undef()
{
fprintf(stderr, " Undefined symbols:\n");
- st_foreach(undef_tbl, underb_f_print, NULL);
+ st_foreach(undef_tbl, undef_print, NULL);
}
static void
@@ -462,7 +465,7 @@ struct undef {
static st_table *reloc_tbl = NULL;
static void
link_undef(name, base, reloc)
- char *name;
+ const char *name;
long base;
struct relocation_info *reloc;
{
@@ -492,7 +495,7 @@ link_undef(name, base, reloc)
}
struct reloc_arg {
- char *name;
+ const char *name;
long value;
};
@@ -562,7 +565,7 @@ reloc_undef(no, undef, arg)
static void
unlink_undef(name, value)
- char *name;
+ const char *name;
long value;
{
struct reloc_arg arg;
@@ -595,7 +598,7 @@ static int
load_1(fd, disp, need_init)
int fd;
long disp;
- char *need_init;
+ const char *need_init;
{
static char *libc = LIBC_NAME;
struct exec hdr;
@@ -873,7 +876,7 @@ load_1(fd, disp, need_init)
static int target_offset;
static int
search_undef(key, value, lib_tbl)
- char *key;
+ const char *key;
int value;
st_table *lib_tbl;
{
@@ -893,7 +896,7 @@ char *dln_librrb_ary_path = DLN_DEFAULT_LIB_PATH;
static int
load_lib(lib)
- char *lib;
+ const char *lib;
{
char *path, *file;
char armagic[SARMAG];
@@ -1030,7 +1033,7 @@ load_lib(lib)
static int
load(file)
- char *file;
+ const char *file;
{
int fd;
int result;
@@ -1056,7 +1059,7 @@ load(file)
void*
dln_sym(name)
- char *name;
+ const char *name;
{
struct nlist *sym;
@@ -1076,7 +1079,7 @@ dln_sym(name)
# endif
#endif
-#ifdef hpux
+#ifdef __hpux
#include <errno.h>
#include "dl.h"
#endif
@@ -1094,12 +1097,16 @@ dln_sym(name)
#include <mach-o/dyld.h>
#endif
#endif
+#ifdef __APPLE__
+#include <mach-o/dyld.h>
+#endif
+
#ifdef _WIN32
#include <windows.h>
#endif
-static char *
+static const char *
dln_strerror()
{
#ifdef USE_DLN_A_OUT
@@ -1152,7 +1159,7 @@ dln_strerror()
#if defined(_AIX)
static void
-aix_loaderror(char *pathname)
+aix_loaderror(const char *pathname)
{
char *message[8], errbuf[1024];
int i,j;
@@ -1184,11 +1191,11 @@ aix_loaderror(char *pathname)
ERRBUF_APPEND(strerror(errno));
for(i = 0; message[i] && *message[i]; i++) {
int nerr = atoi(message[i]);
- for (j=0; j<LOAD_ERRTAB_LEN ; j++) {
+ for (j=0; j<LOAD_ERRTAB_LEN; j++) {
if (nerr == load_errtab[i].errno && load_errtab[i].errstr)
ERRBUF_APPEND(load_errtab[i].errstr);
}
- while (isdigit(*message[i])) message[i]++ ;
+ while (isdigit(*message[i])) message[i]++;
ERRBUF_APPEND(message[i]);
ERRBUF_APPEND("\n");
}
@@ -1200,7 +1207,7 @@ aix_loaderror(char *pathname)
void
dln_load(file)
- char *file;
+ const char *file;
{
#ifdef _WIN32
HINSTANCE handle;
@@ -1277,7 +1284,7 @@ dln_load(file)
}
#endif /* USE_DLN_DLOPEN */
-#ifdef hpux
+#ifdef __hpux
#define DLN_DEFINED
{
shl_t lib = NULL;
@@ -1308,16 +1315,19 @@ dln_load(file)
{
void (*init_fct)();
- init_fct = (void(*)())load(file, 1, 0);
+ init_fct = (void(*)())load((char*)file, 1, 0);
if (init_fct == NULL) {
aix_loaderror(file);
}
+ if (loadbind(0, (void*)dln_load, (void*)init_fct) == -1) {
+ aix_loaderror(file);
+ }
(*init_fct)();
return;
}
#endif /* _AIX */
-#ifdef NeXT
+#if defined(NeXT) || defined(__APPLE__)
#define DLN_DEFINED
/*----------------------------------------------------
By SHIROYAMA Takayuki Psi@fortune.nest.or.jp
@@ -1327,7 +1337,8 @@ dln_load(file)
Mi hisho@tasihara.nest.or.jp,
and... Miss ARAI Akino(^^;)
----------------------------------------------------*/
-#if NS_TARGET_MAJOR < 4 /* NeXTSTEP rld functions */
+#if defined(NeXT) && (NS_TARGET_MAJOR < 4)/* NeXTSTEP rld functions */
+
{
unsigned long init_address;
char *object_files[2] = {NULL, NULL};
@@ -1351,19 +1362,19 @@ dln_load(file)
init_fct = (void(*)())init_address;
(*init_fct)();
- return ;
+ return;
}
#else/* OPENSTEP dyld functions */
{
- int dyld_result ;
- NSObjectFileImage obj_file ; /* handle, but not use it */
+ int dyld_result;
+ NSObjectFileImage obj_file; /* handle, but not use it */
/* "file" is module file name .
"buf" is initial function name with "_" . */
void (*init_fct)();
- dyld_result = NSCreateObjectFileImageFromFile( file, &obj_file );
+ dyld_result = NSCreateObjectFileImageFromFile(file, &obj_file);
if (dyld_result != NSObjectFileImageSuccess) {
rb_loaderror("Failed to load %.200s", file);
@@ -1373,15 +1384,15 @@ dln_load(file)
/* lookup the initial function */
/*NSIsSymbolNameDefined require function name without "_" */
- if( NSIsSymbolNameDefined( buf + 1 ) ) {
+ if(NSIsSymbolNameDefined(buf + 1)) {
rb_loaderror("Failed to lookup Init function %.200s",file);
}
/* NSLookupAndBindSymbol require function name with "_" !! */
- init_fct = NSAddressOfSymbol( NSLookupAndBindSymbol( buf ) );
+ init_fct = NSAddressOfSymbol(NSLookupAndBindSymbol(buf));
(*init_fct)();
- return ;
+ return;
}
#endif /* rld or dyld */
#endif
@@ -1406,14 +1417,14 @@ dln_load(file)
/* strcat(init_fct_symname, "__Fv"); */ /* parameter nothing. */
/* "__Fv" dont need! The Be Book Bug ? */
err_stat = get_image_symbol(img_id, buf,
- B_SYMBOL_TYPE_TEXT, &init_fct);
+ B_SYMBOL_TYPE_TEXT, (void **)&init_fct);
if (err_stat != B_NO_ERROR) {
char real_name[1024];
strcpy(real_name, buf);
strcat(real_name, "__Fv");
err_stat = get_image_symbol(img_id, real_name,
- B_SYMBOL_TYPE_TEXT, &init_fct);
+ B_SYMBOL_TYPE_TEXT, (void **)&init_fct);
}
if ((B_BAD_IMAGE_ID == err_stat) || (B_BAD_INDEX == err_stat)) {
@@ -1453,8 +1464,8 @@ dln_load(file)
c2pstr(fullpath);
(void)FSMakeFSSpec(0, 0, fullpath, &libspec);
err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething);
- if ( err ) {
- rb_loaderror("Unresolved Alias - %s", file);
+ if (err) {
+ rb_loaderror("Unresolved Alias - %s", file);
}
/* Load the fragment (or return the connID if it is already loaded */
@@ -1462,16 +1473,16 @@ dln_load(file)
err = GetDiskFragment(&libspec, 0, 0, fragname,
kLoadCFrag, &connID, &mainAddr,
errMessage);
- if ( err ) {
- p2cstr(errMessage);
- rb_loaderror("%s - %s",errMessage , file);
+ if (err) {
+ p2cstr(errMessage);
+ rb_loaderror("%s - %s",errMessage , file);
}
/* Locate the address of the correct init function */
c2pstr(buf);
err = FindSymbol(connID, buf, &symAddr, &class);
- if ( err ) {
- rb_loaderror("Unresolved symbols - %s" , file);
+ if (err) {
+ rb_loaderror("Unresolved symbols - %s" , file);
}
init_fct = (void (*)())symAddr;
@@ -1496,8 +1507,8 @@ static char *dln_find_1();
char *
dln_find_exe(fname, path)
- char *fname;
- char *path;
+ const char *fname;
+ const char *path;
{
if (!path) {
#if defined(__human68k__)
@@ -1519,18 +1530,24 @@ dln_find_exe(fname, path)
char *
dln_find_file(fname, path)
- char *fname;
- char *path;
+ const char *fname;
+ const char *path;
{
+#ifndef __MACOS__
if (!path) path = ".";
return dln_find_1(fname, path, 0);
+#else
+ if (!path) path = ".";
+ return _macruby_path_conv_posix_to_macos(dln_find_1(fname, path, 0));
+#endif
}
#if defined(__CYGWIN32__)
-char *
-conv_to_posix_path(win32, posix)
+const char *
+conv_to_posix_path(win32, posix, len)
char *win32;
char *posix;
+ int len;
{
char *first = win32;
char *p = win32;
@@ -1545,7 +1562,10 @@ conv_to_posix_path(win32, posix)
first = p + 1;
*p = ';';
}
- cygwin32_conv_to_posix_path(first, posix);
+ if (len < strlen(first))
+ fprintf(stderr, "PATH length too long: %s\n", first);
+ else
+ cygwin32_conv_to_posix_path(first, posix);
return dst;
}
#endif
@@ -1561,26 +1581,23 @@ dln_find_1(fname, path, exe_flag)
register char *dp;
register char *ep;
register char *bp;
+#ifndef __MACOS__
struct stat st;
-
-#if defined(__CYGWIN32__)
- char rubypath[MAXPATHLEN];
- conv_to_posix_path(path, rubypath);
- path = rubypath;
+#else
+ const char* mac_fullpath;
#endif
-#ifndef __MACOS__
+
if (fname[0] == '/') return fname;
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
return fname;
if (exe_flag && strchr(fname, '/')) return fname;
-#if defined(MSDOS) || defined(NT) || defined(__human68k__)
+#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
if (fname[0] == '\\') return fname;
if (strlen(fname) > 2 && fname[1] == ':') return fname;
if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
return fname;
if (exe_flag && strchr(fname, '\\')) return fname;
#endif
-#endif /* __MACOS__ */
for (dp = path;; dp = ++ep) {
register int l;
@@ -1588,7 +1605,7 @@ dln_find_1(fname, path, exe_flag)
int fspace;
/* extract a component */
- ep = strchr(dp, RUBY_PATH_SEP[0]);
+ ep = strchr(dp, PATH_SEP[0]);
if (ep == NULL)
ep = dp+strlen(dp);
@@ -1606,7 +1623,7 @@ dln_find_1(fname, path, exe_flag)
*/
if (*dp == '~' && (l == 1 ||
-#if defined(MSDOS) || defined(NT) || defined(__human68k__)
+#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
dp[1] == '\\' ||
#endif
dp[1] == '/')) {
@@ -1632,11 +1649,7 @@ dln_find_1(fname, path, exe_flag)
/* add a "/" between directory and filename */
if (ep[-1] != '/')
-#ifdef __MACOS__
- *bp++ = ':';
-#else
*bp++ = '/';
-#endif
}
/* now append the file name */
@@ -1651,12 +1664,20 @@ dln_find_1(fname, path, exe_flag)
}
memcpy(bp, fname, i + 1);
+#ifndef __MACOS__
if (stat(fbuf, &st) == 0) {
if (exe_flag == 0) return fbuf;
/* looking for executable */
if (eaccess(fbuf, X_OK) == 0) return fbuf;
}
-#if defined(MSDOS) || defined(NT) || defined(__human68k__)
+#else
+ if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name(fbuf)) {
+ if (exe_flag == 0) return mac_fullpath;
+ /* looking for executable */
+ if (eaccess(mac_fullpath, X_OK) == 0) return mac_fullpath;
+ }
+#endif
+#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
if (exe_flag) {
static const char *extension[] = {
#if defined(MSDOS)
@@ -1664,8 +1685,12 @@ dln_find_1(fname, path, exe_flag)
#if defined(DJGPP)
".btm", ".sh", ".ksh", ".pl", ".sed",
#endif
+#elif defined(__EMX__) || defined(NT)
+ ".exe", ".com", ".cmd", ".bat",
+/* end of __EMX__ or NT*/
#else
".r", ".R", ".x", ".X", ".bat", ".BAT",
+/* __human68k__ */
#endif
(char *) NULL
};
@@ -1679,11 +1704,16 @@ dln_find_1(fname, path, exe_flag)
continue;
}
strcpy(bp + i, extension[j]);
+#ifndef __MACOS__
if (stat(fbuf, &st) == 0)
return fbuf;
+#else
+ if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name(fbuf))
+ return mac_fullpath;
+#endif
}
}
-#endif /* MSDOS or NT or __human68k__ */
+#endif /* MSDOS or NT or __human68k__ or __EMX__ */
/* if not, and no other alternatives, life is bleak */
if (*ep == '\0') {
return NULL;
diff --git a/dln.h b/dln.h
index 7af1f63a9db..6e4f6062124 100644
--- a/dln.h
+++ b/dln.h
@@ -3,7 +3,6 @@
dln.h -
$Author$
- $Revision$
$Date$
created at: Wed Jan 19 16:53:09 JST 1994
@@ -14,17 +13,18 @@
#ifndef _
#ifndef __STDC__
# define _(args) ()
+# define const
#else
# define _(args) args
#endif
#endif
-char *dln_find_exe _((char*,char*));
-char *dln_find_file _((char*,char*));
+char *dln_find_exe _((const char*,const char*));
+char *dln_find_file _((const char*,const char*));
#ifdef USE_DLN_A_OUT
extern char *dln_argv0;
#endif
-void dln_load _((char*));
+void dln_load _((const char*));
#endif
diff --git a/enum.c b/enum.c
index 2b4b9040188..dc7e2112a40 100644
--- a/enum.c
+++ b/enum.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Oct 1 15:15:19 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -56,6 +56,7 @@ enum_grep(obj, pat)
arg[0] = pat; arg[1] = tmp = rb_ary_new();
rb_iterate(rb_each, obj, grep_i, (VALUE)arg);
+ if (RARRAY(tmp)->len == 0) return Qnil;
return tmp;
}
}
@@ -122,6 +123,28 @@ enum_find_all(obj)
}
static VALUE
+reject_i(i, tmp)
+ VALUE i, tmp;
+{
+ if (!RTEST(rb_yield(i))) {
+ rb_ary_push(tmp, i);
+ }
+ return Qnil;
+}
+
+static VALUE
+enum_reject(obj)
+ VALUE obj;
+{
+ VALUE tmp;
+
+ tmp = rb_ary_new();
+ rb_iterate(rb_each, obj, reject_i, tmp);
+
+ return tmp;
+}
+
+static VALUE
collect_i(i, tmp)
VALUE i, tmp;
{
@@ -373,7 +396,10 @@ Init_Enumerable()
rb_define_method(rb_mEnumerable,"sort", enum_sort, 0);
rb_define_method(rb_mEnumerable,"grep", enum_grep, 1);
rb_define_method(rb_mEnumerable,"find", enum_find, -1);
+ rb_define_method(rb_mEnumerable,"detect", enum_find, -1);
rb_define_method(rb_mEnumerable,"find_all", enum_find_all, 0);
+ 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,"min", enum_min, 0);
rb_define_method(rb_mEnumerable,"max", enum_max, 0);
diff --git a/env.h b/env.h
index 79fdfc2befd..6c38d4cbb19 100644
--- a/env.h
+++ b/env.h
@@ -3,7 +3,6 @@
env.h -
$Author$
- $Revision$
$Date$
created at: Mon Jul 11 11:53:03 JST 1994
@@ -19,6 +18,7 @@ extern struct FRAME {
VALUE last_class;
VALUE cbase;
struct FRAME *prev;
+ struct FRAME *tmp;
char *file;
int line;
int iter;
@@ -37,7 +37,7 @@ extern struct SCOPE {
#define SCOPE_MALLOC 1
#define SCOPE_NOSTACK 2
-extern int rb_in_eval;
+extern int ruby_in_eval;
extern VALUE ruby_class;
diff --git a/error.c b/error.c
index 44ca067472f..300c09fed00 100644
--- a/error.c
+++ b/error.c
@@ -6,7 +6,7 @@
$Date$
created at: Mon Aug 9 16:11:34 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -45,10 +45,10 @@ err_snprintf(buf, len, fmt, args)
}
}
-static void err_append _((char*));
+static void err_append _((const char*));
static void
err_print(fmt, args)
- char *fmt;
+ const char *fmt;
va_list args;
{
char buf[BUFSIZ];
@@ -59,10 +59,10 @@ err_print(fmt, args)
void
#ifdef HAVE_STDARG_PROTOTYPES
-rb_compile_error(char *fmt, ...)
+rb_compile_error(const char *fmt, ...)
#else
rb_compile_error(fmt, va_alist)
- char *fmt;
+ const char *fmt;
va_dcl
#endif
{
@@ -76,10 +76,10 @@ rb_compile_error(fmt, va_alist)
void
#ifdef HAVE_STDARG_PROTOTYPES
-rb_compile_error_append(char *fmt, ...)
+rb_compile_error_append(const char *fmt, ...)
#else
rb_compile_error_append(fmt, va_alist)
- char *fmt;
+ const char *fmt;
va_dcl
#endif
{
@@ -94,10 +94,10 @@ rb_compile_error_append(fmt, va_alist)
void
#ifdef HAVE_STDARG_PROTOTYPES
-rb_warn(char *fmt, ...)
+rb_warn(const char *fmt, ...)
#else
rb_warn(fmt, va_alist)
- char *fmt;
+ const char *fmt;
va_dcl
#endif
{
@@ -114,17 +114,17 @@ rb_warn(fmt, va_alist)
/* rb_warning() reports only in verbose mode */
void
#ifdef HAVE_STDARG_PROTOTYPES
-rb_warning(char *fmt, ...)
+rb_warning(const char *fmt, ...)
#else
rb_warning(fmt, va_alist)
- char *fmt;
+ const char *fmt;
va_dcl
#endif
{
char buf[BUFSIZ];
va_list args;
- if (!RTEST(rb_verbose)) return;
+ if (!RTEST(ruby_verbose)) return;
snprintf(buf, BUFSIZ, "warning: %s", fmt);
@@ -135,10 +135,10 @@ rb_warning(fmt, va_alist)
void
#ifdef HAVE_STDARG_PROTOTYPES
-rb_bug(char *fmt, ...)
+rb_bug(const char *fmt, ...)
#else
rb_bug(fmt, va_alist)
- char *fmt;
+ const char *fmt;
va_dcl
#endif
{
@@ -146,7 +146,7 @@ rb_bug(fmt, va_alist)
va_list args;
snprintf(buf, BUFSIZ, "[BUG] %s", fmt);
- rb_in_eval = 0;
+ ruby_in_eval = 0;
va_init_list(args, fmt);
err_print(buf, args);
@@ -156,7 +156,7 @@ rb_bug(fmt, va_alist)
static struct types {
int type;
- char *name;
+ const char *name;
} builtin_types[] = {
T_NIL, "nil",
T_OBJECT, "Object",
@@ -220,7 +220,10 @@ rb_check_type(x, t)
#include <errno.h>
VALUE rb_eException;
-VALUE rb_eSystemExit, rb_eInterrupt, rb_eFatal;
+VALUE rb_eSystemExit;
+VALUE rb_eInterrupt;
+VALUE rb_eSignal;
+VALUE rb_eFatal;
VALUE rb_eStandardError;
VALUE rb_eRuntimeError;
VALUE rb_eSyntaxError;
@@ -238,8 +241,8 @@ VALUE rb_mErrno;
VALUE
rb_exc_new(etype, ptr, len)
VALUE etype;
- char *ptr;
- int len;
+ const char *ptr;
+ long len;
{
VALUE exc = rb_obj_alloc(etype);
@@ -250,7 +253,7 @@ rb_exc_new(etype, ptr, len)
VALUE
rb_exc_new2(etype, s)
VALUE etype;
- char *s;
+ const char *s;
{
return rb_exc_new(etype, s, strlen(s));
}
@@ -283,20 +286,21 @@ exc_initialize(argc, argv, exc)
}
static VALUE
-exc_new(argc, argv, self)
+exc_exception(argc, argv, self)
int argc;
VALUE *argv;
VALUE self;
{
VALUE etype, exc;
+ if (argc == 0) return self;
if (argc == 1 && self == argv[0]) return self;
etype = CLASS_OF(self);
while (FL_TEST(etype, FL_SINGLETON)) {
etype = RCLASS(etype)->super;
}
exc = rb_obj_alloc(etype);
- rb_obj_call_init(exc);
+ rb_obj_call_init(exc, argc, argv);
return exc;
}
@@ -337,7 +341,10 @@ static VALUE
exc_backtrace(exc)
VALUE exc;
{
- return rb_iv_get(exc, "bt");
+ ID bt = rb_intern("bt");
+
+ if (!rb_ivar_defined(exc, bt)) return Qnil;
+ return rb_ivar_get(exc, bt);
}
static VALUE
@@ -370,54 +377,15 @@ exc_set_backtrace(exc, bt)
return rb_iv_set(exc, "bt", check_backtrace(bt));
}
-static VALUE
-exception(argc, argv)
- int argc;
- VALUE *argv;
-{
- VALUE v = Qnil;
- VALUE etype = rb_eStandardError;
- int i;
- ID id;
-
- if (argc == 0) {
- rb_raise(rb_eArgError, "wrong # of arguments");
- }
- rb_warn("Exception() is now obsolete");
- if (TYPE(argv[argc-1]) == T_CLASS) {
- etype = argv[argc-1];
- argc--;
- if (!rb_funcall(etype, '<', 1, rb_eException)) {
- rb_raise(rb_eTypeError, "exception should be subclass of Exception");
- }
- }
- for (i=0; i<argc; i++) { /* argument check */
- id = rb_to_id(argv[i]);
- if (!rb_id2name(id)) {
- rb_raise(rb_eArgError, "argument needs to be symbol or string");
- }
- if (!rb_is_const_id(id)) {
- rb_raise(rb_eArgError, "identifier `%s' needs to be constant",
- rb_id2name(id));
- }
- }
- for (i=0; i<argc; i++) {
- v = rb_define_class_under(ruby_class,
- rb_id2name(rb_to_id(argv[i])),
- rb_eStandardError);
- }
- return v;
-}
-
#ifdef __BEOS__
typedef struct {
VALUE *list;
- size_t n;
+ int n;
} syserr_list_entry;
typedef struct {
int ix;
- size_t n;
+ int n;
} syserr_index_entry;
static VALUE syserr_list_b_general[16+1];
@@ -471,7 +439,7 @@ extern int sys_nerr;
static VALUE
set_syserr(i, name)
int i;
- char *name;
+ const char *name;
{
#ifdef __BEOS__
VALUE *list;
@@ -533,7 +501,8 @@ void
Init_Exception()
{
rb_eException = rb_define_class("Exception", rb_cObject);
- rb_define_method(rb_eException, "new", exc_new, -1);
+ rb_define_singleton_method(rb_eException, "exception", rb_class_new_instance, -1);
+ rb_define_method(rb_eException, "exception", exc_exception, -1);
rb_define_method(rb_eException, "initialize", exc_initialize, -1);
rb_define_method(rb_eException, "to_s", exc_to_s, 0);
rb_define_method(rb_eException, "to_str", exc_to_s, 0);
@@ -543,8 +512,9 @@ Init_Exception()
rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1);
rb_eSystemExit = rb_define_class("SystemExit", rb_eException);
- rb_eFatal = rb_define_class("fatal", rb_eException);
+ rb_eFatal = rb_define_class("fatal", rb_eException);
rb_eInterrupt = rb_define_class("Interrupt", rb_eException);
+ rb_eSignal = rb_define_class("SignalException", rb_eException);
rb_eStandardError = rb_define_class("StandardError", rb_eException);
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eStandardError);
@@ -559,17 +529,15 @@ Init_Exception()
rb_eNotImpError = rb_define_class("NotImplementError", rb_eException);
init_syserr();
-
- rb_define_global_function("Exception", exception, -1);
}
void
#ifdef HAVE_STDARG_PROTOTYPES
-rb_raise(VALUE exc, char *fmt, ...)
+rb_raise(VALUE exc, const char *fmt, ...)
#else
rb_raise(exc, fmt, va_alist)
VALUE exc;
- char *fmt;
+ const char *fmt;
va_dcl
#endif
{
@@ -584,10 +552,10 @@ rb_raise(exc, fmt, va_alist)
void
#ifdef HAVE_STDARG_PROTOTYPES
-rb_loaderror(char *fmt, ...)
+rb_loaderror(const char *fmt, ...)
#else
rb_loaderror(fmt, va_alist)
- char *fmt;
+ const char *fmt;
va_dcl
#endif
{
@@ -610,10 +578,10 @@ rb_notimplement()
void
#ifdef HAVE_STDARG_PROTOTYPES
-rb_fatal(char *fmt, ...)
+rb_fatal(const char *fmt, ...)
#else
rb_fatal(fmt, va_alist)
- char *fmt;
+ const char *fmt;
va_dcl
#endif
{
@@ -624,13 +592,13 @@ rb_fatal(fmt, va_alist)
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
- rb_in_eval = 0;
+ ruby_in_eval = 0;
rb_exc_fatal(rb_exc_new2(rb_eFatal, buf));
}
void
rb_sys_fail(mesg)
- char *mesg;
+ const char *mesg;
{
#ifndef NT
char *strerror();
@@ -1079,20 +1047,20 @@ init_syserr()
static void
err_append(s)
- char *s;
+ const char *s;
{
- extern VALUE rb_errinfo;
+ extern VALUE ruby_errinfo;
- if (rb_in_eval) {
- if (NIL_P(rb_errinfo)) {
- rb_errinfo = rb_exc_new2(rb_eSyntaxError, s);
+ if (ruby_in_eval) {
+ if (NIL_P(ruby_errinfo)) {
+ ruby_errinfo = rb_exc_new2(rb_eSyntaxError, s);
}
else {
- VALUE str = rb_str_to_str(rb_errinfo);
+ VALUE str = rb_str_to_str(ruby_errinfo);
rb_str_cat(str, "\n", 1);
rb_str_cat(str, s, strlen(s));
- rb_errinfo = rb_exc_new3(rb_eSyntaxError, str);
+ ruby_errinfo = rb_exc_new3(rb_eSyntaxError, str);
}
}
else {
diff --git a/eval.c b/eval.c
index a7da313fbe1..4f8f9f7c9ed 100644
--- a/eval.c
+++ b/eval.c
@@ -6,7 +6,7 @@
$Date$
created at: Thu Jun 10 14:22:17 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -21,7 +21,7 @@
#include "dln.h"
#ifndef HAVE_STRING_H
-char *strrchr _((char*,char));
+char *strrchr _((const char*,const char));
#endif
#ifdef HAVE_UNISTD_H
@@ -38,6 +38,10 @@ char *strrchr _((char*,char));
#include <compat.h>
#endif
+#ifdef __MACOS__
+#include "macruby_private.h"
+#endif
+
#ifndef setjmp
#ifdef HAVE__SETJMP
#define setjmp(env) _setjmp(env)
@@ -64,6 +68,19 @@ static int scope_vmode;
#define SCOPE_SET(f) do {scope_vmode=(f);} while(0)
#define SCOPE_TEST(f) (scope_vmode&(f))
+static void print_undef _((VALUE, ID)) NORETURN;
+static void
+print_undef(klass, id)
+ VALUE klass;
+ ID id;
+{
+ rb_raise(rb_eNameError, "undefined method `%s' for %s `%s'",
+ rb_id2name(id),
+ (TYPE(klass) == T_MODULE)?"module":"class",
+ rb_class2name(klass));
+}
+
+
#define CACHE_SIZE 0x800
#define CACHE_MASK 0x7ff
#define EXPR1(c,m) ((((c)>>3)^(m))&CACHE_MASK)
@@ -198,14 +215,13 @@ rb_alias(klass, name, def)
}
}
if (!orig || !orig->nd_body) {
- rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
- rb_id2name(def), rb_class2name(klass));
+ print_undef(klass, def);
}
body = orig->nd_body;
if (nd_type(body) == NODE_FBODY) { /* was alias */
- body = body->nd_head;
def = body->nd_mid;
origin = body->nd_orig;
+ body = body->nd_head;
}
st_insert(RCLASS(klass)->m_tbl, name,
@@ -232,7 +248,7 @@ remove_method(klass, mid)
void
rb_remove_method(klass, name)
VALUE klass;
- char *name;
+ const char *name;
{
remove_method(klass, rb_intern(name));
}
@@ -240,7 +256,7 @@ rb_remove_method(klass, name)
void
rb_disable_super(klass, name)
VALUE klass;
- char *name;
+ const char *name;
{
VALUE origin;
NODE *body;
@@ -248,8 +264,7 @@ rb_disable_super(klass, name)
body = search_method(klass, mid, &origin);
if (!body || !body->nd_body) {
- rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
- rb_id2name(mid), rb_class2name(klass));
+ print_undef(klass, mid);
}
if (origin == klass) {
body->nd_noex |= NOEX_UNDEF;
@@ -263,7 +278,7 @@ rb_disable_super(klass, name)
void
rb_enable_super(klass, name)
VALUE klass;
- char *name;
+ const char *name;
{
VALUE origin;
NODE *body;
@@ -271,8 +286,7 @@ rb_enable_super(klass, name)
body = search_method(klass, mid, &origin);
if (!body || !body->nd_body || origin != klass) {
- rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
- rb_id2name(mid), rb_class2name(klass));
+ print_undef(klass, mid);
}
body->nd_noex &= ~NOEX_UNDEF;
}
@@ -294,8 +308,7 @@ rb_export_method(klass, name, noex)
body = search_method(rb_cObject, name, &origin);
}
if (!body) {
- rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
- rb_id2name(name), rb_class2name(klass));
+ print_undef(klass, name);
}
if (body->nd_noex != noex) {
if (klass == origin) {
@@ -317,7 +330,7 @@ rb_method_boundp(klass, id, ex)
int noex;
if (rb_get_method_body(&klass, &id, &noex)) {
- if (ex && noex & NOEX_PRIVATE)
+ if (ex && (noex & NOEX_PRIVATE))
return Qfalse;
return Qtrue;
}
@@ -330,7 +343,7 @@ rb_attr(klass, id, read, write, ex)
ID id;
int read, write, ex;
{
- char *name;
+ const char *name;
char *buf;
ID attriv;
int noex;
@@ -366,8 +379,8 @@ rb_attr(klass, id, read, write, ex)
}
}
-static ID init, eqq, each, aref, aset, match;
-VALUE rb_errinfo = Qnil;
+static ID init, eqq, each, aref, aset, match, missing;
+VALUE ruby_errinfo = Qnil;
extern NODE *ruby_eval_tree_begin;
extern NODE *ruby_eval_tree;
extern int ruby_nerrs;
@@ -385,11 +398,13 @@ static struct SCOPE *top_scope;
#define PUSH_FRAME() { \
struct FRAME _frame; \
_frame.prev = ruby_frame; \
+ _frame.tmp = 0; \
_frame.file = ruby_sourcefile; \
_frame.line = ruby_sourceline; \
_frame.iter = ruby_iter->iter; \
_frame.cbase = ruby_frame->cbase; \
_frame.argc = 0; \
+ _frame.argv = 0; \
ruby_frame = &_frame; \
#define POP_FRAME() \
@@ -407,14 +422,16 @@ struct BLOCK {
struct tag *tag;
int iter;
int vmode;
+ int flags;
struct RVarmap *d_vars;
-#ifdef USE_THREAD
VALUE orig_thread;
-#endif
struct BLOCK *prev;
};
+
+#define BLOCK_D_SCOPE 1
+#define BLOCK_DYNAMIC 2
+
static struct BLOCK *ruby_block;
-static struct BLOCK *ruby_calling_block;
#define PUSH_BLOCK(v,b) { \
struct BLOCK _block; \
@@ -427,10 +444,11 @@ static struct BLOCK *ruby_calling_block;
_block.frame.file = ruby_sourcefile;\
_block.frame.line = ruby_sourceline;\
_block.scope = ruby_scope; \
- _block.d_vars = ruby_dyna_vars; \
_block.prev = ruby_block; \
_block.iter = ruby_iter->iter; \
_block.vmode = scope_vmode; \
+ _block.flags = BLOCK_D_SCOPE; \
+ _block.d_vars = ruby_dyna_vars; \
ruby_block = &_block;
#define POP_BLOCK() \
@@ -439,37 +457,34 @@ static struct BLOCK *ruby_calling_block;
#define PUSH_BLOCK2(b) { \
struct BLOCK * volatile _old; \
- struct BLOCK * volatile _old_call; \
_old = ruby_block; \
- _old_call = ruby_calling_block; \
- ruby_calling_block = b; \
ruby_block = b;
#define POP_BLOCK2() \
- ruby_calling_block = _old_call; \
ruby_block = _old; \
}
struct RVarmap *ruby_dyna_vars;
#define PUSH_VARS() { \
- struct RVarmap * volatile _oldvmap; \
- _oldvmap = ruby_dyna_vars; \
+ struct RVarmap * volatile _old; \
+ _old = ruby_dyna_vars; \
ruby_dyna_vars = 0;
#define POP_VARS() \
- ruby_dyna_vars = _oldvmap; \
+ ruby_dyna_vars = _old; \
}
static struct RVarmap*
-new_dvar(id, value)
+new_dvar(id, value, prev)
ID id;
VALUE value;
+ struct RVarmap *prev;
{
NEWOBJ(vars, struct RVarmap);
OBJSETUP(vars, 0, T_VARMAP);
vars->id = id;
vars->val = value;
- vars->next = ruby_dyna_vars;
+ vars->next = prev;
return vars;
}
@@ -507,17 +522,19 @@ rb_dvar_push(id, value)
ID id;
VALUE value;
{
- ruby_dyna_vars = new_dvar(id, value);
+ ruby_dyna_vars = new_dvar(id, value, ruby_dyna_vars);
}
-void
-rb_dvar_asgn(id, value)
+static void
+dvar_asgn(id, value, push)
ID id;
VALUE value;
+ int push;
{
struct RVarmap *vars = ruby_dyna_vars;
while (vars) {
+ if (push && vars->id == 0) break;
if (vars->id == id) {
vars->val = value;
return;
@@ -525,7 +542,14 @@ rb_dvar_asgn(id, value)
vars = vars->next;
}
rb_dvar_push(id, value);
- return;
+}
+
+void
+rb_dvar_asgn(id, value)
+ ID id;
+ VALUE value;
+{
+ dvar_asgn(id, value, 0);
}
static void
@@ -533,9 +557,16 @@ dvar_asgn_push(id, value)
ID id;
VALUE value;
{
- rb_dvar_asgn(id, value);
- if (ruby_calling_block) {
- ruby_calling_block->d_vars = ruby_dyna_vars;
+ struct RVarmap* vars = 0;
+
+ if (ruby_dyna_vars && ruby_dyna_vars->id == 0) {
+ vars = ruby_dyna_vars;
+ ruby_dyna_vars = ruby_dyna_vars->next;
+ }
+ dvar_asgn(id, value, 1);
+ if (vars) {
+ vars->next = ruby_dyna_vars;
+ ruby_dyna_vars = vars;
}
}
@@ -565,6 +596,7 @@ struct tag {
struct iter *iter;
ID tag;
VALUE retval;
+ struct SCOPE *scope;
int dst;
struct tag *prev;
};
@@ -577,6 +609,7 @@ static struct tag *prot_tag;
_tag.iter = ruby_iter; \
_tag.prev = prot_tag; \
_tag.retval = Qnil; \
+ _tag.scope = ruby_scope; \
_tag.tag = ptag; \
_tag.dst = 0; \
prot_tag = &_tag;
@@ -612,8 +645,8 @@ static struct tag *prot_tag;
VALUE ruby_class;
static VALUE ruby_wrapper; /* security wrapper */
-#define PUSH_CLASS() { \
- VALUE _class = ruby_class; \
+#define PUSH_CLASS() { \
+ VALUE _class = ruby_class; \
#define POP_CLASS() ruby_class = _class; }
@@ -630,39 +663,35 @@ static VALUE ruby_wrapper; /* security wrapper */
scope_vmode = SCOPE_PUBLIC;
#define SCOPE_DONT_RECYCLE FL_USER2
-
-static void scope_dup(struct SCOPE *);
-
-#define POP_SCOPE() \
- if (ruby_scope->flag == SCOPE_ALLOCA) {\
- if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE)) {\
- scope_dup(ruby_scope);\
- FL_SET(_old, SCOPE_DONT_RECYCLE);\
- }\
- else {\
- ruby_scope->local_vars = 0;\
- ruby_scope->local_tbl = 0;\
+#define POP_SCOPE() \
+ if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE)) {\
+ FL_SET(_old, SCOPE_DONT_RECYCLE);\
+ } \
+ else { \
+ if (ruby_scope->flag == SCOPE_ALLOCA) {\
+ ruby_scope->local_vars = 0; \
+ ruby_scope->local_tbl = 0; \
if (ruby_scope != top_scope)\
rb_gc_force_recycle((VALUE)ruby_scope);\
- }\
- }\
- else {\
- ruby_scope->flag |= SCOPE_NOSTACK;\
- }\
- ruby_scope = _old;\
- scope_vmode = _vmode;\
+ } \
+ else { \
+ ruby_scope->flag |= SCOPE_NOSTACK;\
+ } \
+ } \
+ ruby_scope = _old; \
+ scope_vmode = _vmode; \
}
static VALUE rb_eval _((VALUE,NODE*));
static VALUE eval _((VALUE,VALUE,VALUE,char*,int));
-static NODE *compile _((VALUE,char*));
-static VALUE rb_yield_0 _((VALUE, VALUE, VALUE));
+static NODE *compile _((VALUE, char*, int));
+static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int));
static VALUE rb_call _((VALUE,VALUE,ID,int,VALUE*,int));
static VALUE module_setup _((VALUE,NODE*));
-static VALUE massign _((VALUE,NODE*,VALUE));
-static void assign _((VALUE,NODE*,VALUE));
+static VALUE massign _((VALUE,NODE*,VALUE,int));
+static void assign _((VALUE,NODE*,VALUE,int));
static int safe_level = 0;
/* safe-level:
@@ -770,12 +799,19 @@ error_print()
{
VALUE errat;
VALUE eclass;
- VALUE einfo;
- volatile int safe = safe_level;
+ char *einfo;
+ int elen;
- if (NIL_P(rb_errinfo)) return;
+ if (NIL_P(ruby_errinfo)) return;
- errat = get_backtrace(rb_errinfo);
+ PUSH_TAG(PROT_NONE);
+ if (EXEC_TAG() == 0) {
+ errat = get_backtrace(ruby_errinfo);
+ }
+ else {
+ errat = Qnil;
+ }
+ POP_TAG();
if (!NIL_P(errat)) {
VALUE mesg = RARRAY(errat)->ptr[0];
@@ -785,38 +821,46 @@ error_print()
}
}
- eclass = CLASS_OF(rb_errinfo);
- einfo = rb_obj_as_string(rb_errinfo);
- if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
+ eclass = CLASS_OF(ruby_errinfo);
+ PUSH_TAG(PROT_NONE);
+ if (EXEC_TAG() == 0) {
+ einfo = str2cstr(rb_obj_as_string(ruby_errinfo), &elen);
+ }
+ else {
+ einfo = "";
+ elen = 0;
+ }
+ POP_TAG();
+ if (eclass == rb_eRuntimeError && elen == 0) {
fprintf(stderr, ": unhandled exception\n");
}
else {
VALUE epath;
epath = rb_class_path(eclass);
- if (RSTRING(einfo)->len == 0) {
+ if (elen == 0) {
fprintf(stderr, ": ");
fwrite(RSTRING(epath)->ptr, 1, RSTRING(epath)->len, stderr);
putc('\n', stderr);
}
else {
char *tail = 0;
- int len = RSTRING(einfo)->len;
+ int len = elen;
if (RSTRING(epath)->ptr[0] == '#') epath = 0;
- if (tail = strchr(RSTRING(einfo)->ptr, '\n')) {
- len = tail - RSTRING(einfo)->ptr;
+ if (tail = strchr(einfo, '\n')) {
+ len = tail - einfo;
tail++; /* skip newline */
}
fprintf(stderr, ": ");
- fwrite(RSTRING(einfo)->ptr, 1, len, stderr);
+ fwrite(einfo, 1, len, stderr);
if (epath) {
fprintf(stderr, " (");
fwrite(RSTRING(epath)->ptr, 1, RSTRING(epath)->len, stderr);
fprintf(stderr, ")\n");
}
if (tail) {
- fwrite(tail, 1, RSTRING(einfo)->len-len-1, stderr);
+ fwrite(tail, 1, elen-len-1, stderr);
putc('\n', stderr);
}
}
@@ -836,13 +880,12 @@ error_print()
fprintf(stderr, "\tfrom %s\n", RSTRING(ep->ptr[i])->ptr);
}
if (i == TRACE_HEAD && ep->len > TRACE_MAX) {
- fprintf(stderr, "\t ... %d levels...\n",
+ fprintf(stderr, "\t ... %ld levels...\n",
ep->len - TRACE_HEAD - TRACE_TAIL);
i = ep->len - TRACE_TAIL;
}
}
}
- safe_level = safe;
}
#if !defined(NT) && !defined(__MACOS__)
@@ -851,17 +894,22 @@ extern char **environ;
char **rb_origenviron;
void rb_call_inits _((void));
-void Init_stack _((void));
+void Init_stack _((void*));
void Init_heap _((void));
void Init_ext _((void));
void
ruby_init()
{
+ static int initialized = 0;
static struct FRAME frame;
static struct iter iter;
int state;
+ if (initialized)
+ return;
+ initialized = 1;
+
ruby_frame = top_frame = &frame;
ruby_iter = &iter;
@@ -871,6 +919,7 @@ ruby_init()
rb_origenviron = environ;
#endif
+ Init_stack(0);
Init_heap();
PUSH_SCOPE();
ruby_scope->local_vars = 0;
@@ -879,13 +928,16 @@ ruby_init()
/* default visibility is private at toplevel */
SCOPE_SET(SCOPE_PRIVATE);
- PUSH_TAG(PROT_NONE)
+ PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
rb_call_inits();
ruby_class = rb_cObject;
ruby_frame->self = ruby_top_self;
ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,rb_cObject,0,0);
rb_define_global_const("TOPLEVEL_BINDING", rb_f_binding(ruby_top_self));
+#ifdef __MACOS__
+ _macruby_init();
+#endif
ruby_prog_init();
}
POP_TAG();
@@ -905,13 +957,8 @@ ruby_options(argc, argv)
PUSH_TAG(PROT_NONE)
if ((state = EXEC_TAG()) == 0) {
- NODE *save;
-
ruby_process_options(argc, argv);
ext_init = 1; /* Init_ext() called in ruby_process_options */
- save = ruby_eval_tree;
- ruby_require_modules();
- ruby_eval_tree = save;
}
POP_TAG();
if (state) {
@@ -925,49 +972,54 @@ static VALUE
eval_node(self)
VALUE self;
{
- VALUE result = Qnil;
- NODE *tree;
+ NODE *beg_tree, *tree;
- if (ruby_eval_tree_begin) {
- tree = ruby_eval_tree_begin;
+ beg_tree = ruby_eval_tree_begin;
+ tree = ruby_eval_tree;
+ if (beg_tree) {
ruby_eval_tree_begin = 0;
- rb_eval(self, tree);
+ rb_eval(self, beg_tree);
}
- if (!ruby_eval_tree) return Qnil;
-
- tree = ruby_eval_tree;
+ if (!tree) return Qnil;
ruby_eval_tree = 0;
- result = rb_eval(self, tree);
- return result;
+ return rb_eval(self, tree);
}
-int rb_in_eval;
+int ruby_in_eval;
-#ifdef USE_THREAD
static void rb_thread_cleanup _((void));
static void rb_thread_wait_other_threads _((void));
-#endif
static int exit_status;
-static void exec_end_proc _((void));
+static void
+call_required_libraries()
+{
+ NODE *save;
+
+ ruby_sourcefile = 0;
+ if (!ext_init) Init_ext();
+ save = ruby_eval_tree;
+ ruby_require_libraries();
+ ruby_eval_tree = save;
+}
void
ruby_run()
{
int state;
static int ex;
+ volatile NODE *tmp;
if (ruby_nerrs > 0) exit(ruby_nerrs);
- Init_stack();
-
+ Init_stack(&tmp);
PUSH_TAG(PROT_NONE);
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
- if (!ext_init) Init_ext();
+ call_required_libraries();
eval_node(ruby_top_self);
}
POP_ITER();
@@ -978,10 +1030,8 @@ ruby_run()
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
rb_trap_exit();
-#ifdef USE_THREAD
rb_thread_cleanup();
rb_thread_wait_other_threads();
-#endif
}
else {
ex = state;
@@ -1021,30 +1071,32 @@ ruby_run()
break;
case TAG_RAISE:
case TAG_FATAL:
- if (rb_obj_is_kind_of(rb_errinfo, rb_eSystemExit)) {
- exit(exit_status);
+ if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
+ ex = exit_status;
+ }
+ else {
+ error_print();
+ ex = 1;
}
- error_print();
- ex = 1;
break;
default:
rb_bug("Unknown longjmp status %d", ex);
break;
}
- exec_end_proc();
+ rb_exec_end_proc();
rb_gc_call_finalizer_at_exit();
exit(ex);
}
static void
compile_error(at)
- char *at;
+ const char *at;
{
VALUE str;
char *mesg;
int len;
- mesg = str2cstr(rb_errinfo, &len);
+ mesg = str2cstr(ruby_errinfo, &len);
ruby_nerrs = 0;
str = rb_str_new2("compile error");
if (at) {
@@ -1058,7 +1110,7 @@ compile_error(at)
VALUE
rb_eval_string(str)
- char *str;
+ const char *str;
{
VALUE v;
char *oldsrc = ruby_sourcefile;
@@ -1072,7 +1124,7 @@ rb_eval_string(str)
VALUE
rb_eval_string_protect(str, state)
- char *str;
+ const char *str;
int *state;
{
VALUE result; /* OK */
@@ -1094,6 +1146,33 @@ rb_eval_string_protect(str, state)
}
VALUE
+rb_eval_string_wrap(str, state)
+ const char *str;
+ int *state;
+{
+ int status;
+ VALUE self = ruby_top_self;
+ VALUE val;
+
+ PUSH_CLASS();
+ ruby_class = ruby_wrapper = rb_module_new();
+ ruby_top_self = rb_obj_clone(ruby_top_self);
+ rb_extend_object(self, ruby_class);
+
+ val = rb_eval_string_protect(str, &status);
+ ruby_top_self = self;
+
+ POP_CLASS();
+ if (state) {
+ *state = status;
+ if (status) {
+ JUMP_TAG(status);
+ }
+ }
+ return val;
+}
+
+VALUE
rb_eval_cmd(cmd, arg)
VALUE cmd, arg;
{
@@ -1121,6 +1200,8 @@ rb_eval_cmd(cmd, arg)
val = eval(ruby_top_self, cmd, Qnil, 0, 0);
}
+ if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE))
+ FL_SET(saved_scope, SCOPE_DONT_RECYCLE);
ruby_scope = saved_scope;
safe_level = safe;
POP_TAG();
@@ -1151,7 +1232,7 @@ rb_eval_cmd(cmd, arg)
return val;
}
-VALUE
+static VALUE
rb_trap_eval(cmd, sig)
VALUE cmd;
int sig;
@@ -1304,11 +1385,11 @@ rb_mod_alias_method(mod, newname, oldname)
}
#ifdef C_ALLOCA
-# define TMP_PROTECT NODE * volatile __protect_tmp=0
-# define TMP_ALLOC(n) \
- (__protect_tmp = rb_node_newnode(NODE_ALLOCA, \
- ALLOC_N(VALUE,n),__protect_tmp,n), \
- (void*)__protect_tmp->nd_head)
+# define TMP_PROTECT NODE * volatile tmp__protect_tmp=0
+# define TMP_ALLOC(n) \
+ (tmp__protect_tmp = rb_node_newnode(NODE_ALLOCA, \
+ ALLOC_N(VALUE,n),tmp__protect_tmp,n), \
+ (void*)tmp__protect_tmp->nd_head)
#else
# define TMP_PROTECT typedef int foobazzz
# define TMP_ALLOC(n) ALLOCA_N(VALUE,n)
@@ -1411,7 +1492,7 @@ is_defined(self, node, buf)
case NODE_ZSUPER:
if (ruby_frame->last_func == 0) return 0;
else if (rb_method_boundp(RCLASS(ruby_frame->last_class)->super,
- ruby_frame->last_func, 1)) {
+ ruby_frame->last_func, 0)) {
if (nd_type(node) == NODE_SUPER) {
return arg_defined(self, node->nd_args, buf, "super");
}
@@ -1602,9 +1683,7 @@ call_trace_func(event, file, line, self, id, klass)
trace = trace_func;
trace_func = 0;
-#ifdef USE_THREAD
rb_thread_critical++;
-#endif
prev = ruby_frame;
PUSH_FRAME();
@@ -1632,9 +1711,7 @@ call_trace_func(event, file, line, self, id, klass)
POP_TAG();
POP_FRAME();
-#ifdef USE_THREAD
rb_thread_critical--;
-#endif
if (!trace_func) trace_func = trace;
ruby_sourceline = line_save;
ruby_sourcefile = file_save;
@@ -1651,10 +1728,6 @@ rb_eval(self, node)
{
int state;
volatile VALUE result = Qnil;
-#ifdef NOBLOCK_RECUR
- NODE * volatile next = 0;
- NODE * volatile nstack = 0;
-#endif
#define RETURN(v) { result = (v); goto finish; }
@@ -1663,24 +1736,13 @@ rb_eval(self, node)
switch (nd_type(node)) {
case NODE_BLOCK:
-#ifndef NOBLOCK_RECUR
- if (!node->nd_next) {
- node = node->nd_head;
- goto again;
- }
- while (node) {
- result = rb_eval(self, node->nd_head);
+ while (node->nd_next) {
+ rb_eval(self, node->nd_head);
node = node->nd_next;
}
- break;
-#else
- if (next) {
- nstack = rb_node_newnode(NODE_CREF,next,0,nstack);
- }
- next = node->nd_next;
node = node->nd_head;
goto again;
-#endif
+
case NODE_POSTEXE:
rb_f_END();
nd_set_type(node, NODE_NIL); /* exec just once */
@@ -1738,11 +1800,7 @@ rb_eval(self, node)
case NODE_IF:
ruby_sourceline = nd_line(node);
-#ifdef NOBLOCK_RECUR
- if (RTEST(result)){
-#else
if (RTEST(rb_eval(self, node->nd_cond))) {
-#endif
node = node->nd_body;
}
else {
@@ -1754,11 +1812,7 @@ rb_eval(self, node)
{
VALUE val;
-#ifdef NOBLOCK_RECUR
- val = result;
-#else
val = rb_eval(self, node->nd_head);
-#endif
node = node->nd_body;
while (node) {
NODE *tag;
@@ -1883,6 +1937,7 @@ rb_eval(self, node)
char *file = ruby_sourcefile;
int line = ruby_sourceline;
+ _block.flags &= ~BLOCK_D_SCOPE;
recv = rb_eval(self, node->nd_iter);
PUSH_ITER(ITER_PRE);
ruby_sourcefile = file;
@@ -1953,13 +2008,13 @@ rb_eval(self, node)
else {
result = Qnil;
}
- result = rb_yield_0(result, 0, 0);
+ result = rb_yield_0(result, 0, 0, Qfalse);
break;
case NODE_RESCUE:
retry_entry:
{
- volatile VALUE e_info = rb_errinfo;
+ volatile VALUE e_info = ruby_errinfo;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
@@ -1978,7 +2033,7 @@ rb_eval(self, node)
}
POP_TAG();
if (state == 0) {
- rb_errinfo = e_info;
+ ruby_errinfo = e_info;
}
else if (state == TAG_RETRY) {
state = 0;
@@ -2030,11 +2085,9 @@ rb_eval(self, node)
case NODE_DOT2:
case NODE_DOT3:
- result = rb_range_new(rb_eval(self, node->nd_beg), rb_eval(self, node->nd_end));
-#if 0
- break;
-#else
- result = rb_range_new(rb_eval(self, node->nd_beg), rb_eval(self, node->nd_end));
+ result = rb_range_new(rb_eval(self, node->nd_beg),
+ rb_eval(self, node->nd_end),
+ nd_type(node) == NODE_DOT3);
if (node->nd_state) break;
if (nd_type(node->nd_beg) == NODE_LIT && FIXNUM_P(node->nd_beg->nd_lit) &&
nd_type(node->nd_end) == NODE_LIT && FIXNUM_P(node->nd_end->nd_lit))
@@ -2045,7 +2098,6 @@ rb_eval(self, node)
else {
node->nd_state = 1;
}
-#endif
break;
case NODE_FLIP2: /* like AWK */
@@ -2106,13 +2158,7 @@ rb_eval(self, node)
TMP_PROTECT;
BEGIN_CALLARGS;
-#ifdef NOBLOCK_RECUR_incomplete
- printf("mid %s recv: ", rb_id2name(node->nd_mid));
- rb_p(result);
- recv = result;
-#else
recv = rb_eval(self, node->nd_recv);
-#endif
SETUP_ARGS(node->nd_args);
END_CALLARGS;
@@ -2167,7 +2213,11 @@ rb_eval(self, node)
case NODE_SCOPE:
{
- VALUE save = ruby_frame->cbase;
+ struct FRAME frame;
+
+ frame = *ruby_frame;
+ frame.tmp = ruby_frame;
+ ruby_frame = &frame;
PUSH_SCOPE();
PUSH_TAG(PROT_NONE);
@@ -2188,7 +2238,7 @@ rb_eval(self, node)
}
POP_TAG();
POP_SCOPE();
- ruby_frame->cbase = save;
+ ruby_frame = frame.tmp;
if (state) JUMP_TAG(state);
}
break;
@@ -2204,15 +2254,16 @@ rb_eval(self, node)
rval = node->nd_args->nd_head;
SETUP_ARGS(node->nd_args->nd_next);
val = rb_funcall2(recv, aref, argc-1, argv);
- if (node->nd_mid == 0) { /* OR */
- if (RTEST(val)) break;
+ switch (node->nd_mid) {
+ case 0: /* OR */
+ if (RTEST(val)) RETURN(val);
val = rb_eval(self, rval);
- }
- else if (node->nd_mid == 1) { /* AND */
- if (!RTEST(val)) break;
+ break;
+ case 1: /* AND */
+ if (!RTEST(val)) RETURN(val);
val = rb_eval(self, rval);
- }
- else {
+ break;
+ default:
val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval));
}
argv[argc-1] = val;
@@ -2228,15 +2279,16 @@ rb_eval(self, node)
recv = rb_eval(self, node->nd_recv);
val = rb_funcall(recv, id, 0);
- if (node->nd_next->nd_mid == 0) { /* OR */
- if (RTEST(val)) break;
+ switch (node->nd_next->nd_mid) {
+ case 0: /* OR */
+ if (RTEST(val)) RETURN(val);
val = rb_eval(self, node->nd_value);
- }
- else if (node->nd_next->nd_mid == 1) { /* AND */
- if (!RTEST(val)) break;
+ break;
+ case 1: /* AND */
+ if (!RTEST(val)) RETURN(val);
val = rb_eval(self, node->nd_value);
- }
- else {
+ break;
+ default:
val = rb_funcall(val, node->nd_next->nd_mid, 1,
rb_eval(self, node->nd_value));
}
@@ -2261,7 +2313,7 @@ rb_eval(self, node)
break;
case NODE_MASGN:
- result = massign(self, node, rb_eval(self, node->nd_value));
+ result = massign(self, node, rb_eval(self, node->nd_value),0);
break;
case NODE_LASGN:
@@ -2297,9 +2349,9 @@ rb_eval(self, node)
}
result = rb_eval(self, node->nd_value);
/* check for static scope constants */
- if (RTEST(rb_verbose) &&
+ if (RTEST(ruby_verbose) &&
ev_const_defined((NODE*)ruby_frame->cbase, node->nd_vid)) {
- if (RTEST(rb_verbose)) {
+ if (RTEST(ruby_verbose)) {
rb_warning("already initialized constant %s",
rb_id2name(node->nd_vid));
}
@@ -2445,10 +2497,13 @@ rb_eval(self, node)
str2 = list->nd_head->nd_lit;
break;
case NODE_EVSTR:
- rb_in_eval++;
- list->nd_head = compile(list->nd_head->nd_lit,0);
+ ruby_sourceline = nd_line(node);
+ ruby_in_eval++;
+ list->nd_head = compile(list->nd_head->nd_lit,
+ ruby_sourcefile,
+ ruby_sourceline);
ruby_eval_tree = 0;
- rb_in_eval--;
+ ruby_in_eval--;
if (ruby_nerrs > 0) {
compile_error("string expansion");
}
@@ -2494,7 +2549,7 @@ rb_eval(self, node)
case NODE_ATTRSET:
if (ruby_frame->argc != 1)
- rb_raise(rb_eArgError, "Wrong # of arguments(%d for 1)",
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",
ruby_frame->argc);
result = rb_ivar_set(self, node->nd_vid, ruby_frame->argv[0]);
break;
@@ -2514,10 +2569,10 @@ rb_eval(self, node)
body = search_method(ruby_class, node->nd_mid, &origin);
if (body) {
if (origin == ruby_class) {
- if (safe_level >= 3) {
+ if (safe_level >= 4) {
rb_raise(rb_eSecurityError, "re-defining method prohibited");
}
- if (RTEST(rb_verbose)) {
+ if (RTEST(ruby_verbose)) {
rb_warning("discarding old %s", rb_id2name(node->nd_mid));
}
}
@@ -2562,18 +2617,11 @@ rb_eval(self, node)
VALUE klass;
NODE *body = 0;
- if (FIXNUM_P(recv)) {
- rb_raise(rb_eTypeError, "Can't define method \"%s\" for Fixnum",
- rb_id2name(node->nd_mid));
- }
- if (NIL_P(recv)) {
- rb_raise(rb_eTypeError, "Can't define method \"%s\" for nil",
- rb_id2name(node->nd_mid));
- }
if (rb_special_const_p(recv)) {
rb_raise(rb_eTypeError,
- "Can't define method \"%s\" for special constants",
- rb_id2name(node->nd_mid));
+ "can't define method \"%s\" for %s",
+ rb_id2name(node->nd_mid),
+ rb_class2name(CLASS_OF(recv)));
}
if (rb_safe_level() >= 4 && !FL_TEST(recv, FL_TAINT)) {
@@ -2581,10 +2629,10 @@ rb_eval(self, node)
}
klass = rb_singleton_class(recv);
if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &body)) {
- if (safe_level >= 3) {
+ if (safe_level >= 4) {
rb_raise(rb_eSecurityError, "re-defining method prohibited");
}
- if (RTEST(rb_verbose)) {
+ if (RTEST(ruby_verbose)) {
rb_warning("redefine %s", rb_id2name(node->nd_mid));
}
}
@@ -2622,6 +2670,9 @@ rb_eval(self, node)
s0 = "";
}
}
+ else if (TYPE(klass) == T_MODULE) {
+ s0 = " module";
+ }
rb_raise(rb_eNameError, "undefined method `%s' for%s `%s'",
rb_id2name(node->nd_mid),s0,rb_class2name(klass));
}
@@ -2686,7 +2737,7 @@ rb_eval(self, node)
rb_id2name(node->nd_cname));
}
}
- if (safe_level >= 3) {
+ if (safe_level >= 4) {
rb_raise(rb_eSecurityError, "extending class prohibited");
}
rb_clear_cache();
@@ -2696,7 +2747,6 @@ rb_eval(self, node)
klass = rb_define_class_id(node->nd_cname, super);
rb_const_set(ruby_class, node->nd_cname, klass);
rb_set_class_path(klass,ruby_class,rb_id2name(node->nd_cname));
- rb_obj_call_init(klass);
}
if (ruby_wrapper) {
rb_extend_object(klass, ruby_wrapper);
@@ -2728,7 +2778,7 @@ rb_eval(self, node)
rb_raise(rb_eTypeError, "%s is not a module",
rb_id2name(node->nd_cname));
}
- if (safe_level >= 3) {
+ if (safe_level >= 4) {
rb_raise(rb_eSecurityError, "extending module prohibited");
}
}
@@ -2736,7 +2786,6 @@ rb_eval(self, node)
module = rb_define_module_id(node->nd_cname);
rb_const_set(ruby_class, node->nd_cname, module);
rb_set_class_path(module,ruby_class,rb_id2name(node->nd_cname));
- rb_obj_call_init(module);
}
if (ruby_wrapper) {
rb_extend_object(module, ruby_wrapper);
@@ -2752,14 +2801,9 @@ rb_eval(self, node)
VALUE klass;
klass = rb_eval(self, node->nd_recv);
- if (FIXNUM_P(klass)) {
- rb_raise(rb_eTypeError, "No virtual class for Fixnums");
- }
- if (NIL_P(klass)) {
- rb_raise(rb_eTypeError, "No virtual class for nil");
- }
if (rb_special_const_p(klass)) {
- rb_raise(rb_eTypeError, "No virtual class for special constants");
+ rb_raise(rb_eTypeError, "no virtual class for %s",
+ rb_class2name(CLASS_OF(klass)));
}
if (FL_TEST(CLASS_OF(klass), FL_SINGLETON)) {
rb_clear_cache();
@@ -2780,7 +2824,7 @@ rb_eval(self, node)
char *desc = is_defined(self, node->nd_head, buf);
if (desc) result = rb_str_new2(desc);
- else result = Qfalse;
+ else result = Qnil;
}
break;
@@ -2799,18 +2843,6 @@ rb_eval(self, node)
}
finish:
CHECK_INTS;
-#ifdef NOBLOCK_RECUR
- if (next) {
- node = next;
- next = 0;
- goto again;
- }
- if (nstack) {
- node = nstack->nd_head;
- nstack = nstack->nd_next;
- goto again;
- }
-#endif
return result;
}
@@ -2820,12 +2852,16 @@ module_setup(module, node)
NODE * volatile node;
{
int state;
- VALUE save = ruby_frame->cbase;
+ struct FRAME frame;
VALUE result; /* OK */
char *file = ruby_sourcefile;
int line = ruby_sourceline;
TMP_PROTECT;
+ frame = *ruby_frame;
+ frame.tmp = ruby_frame;
+ ruby_frame = &frame;
+
/* fill c-ref */
node->nd_clss = module;
node = node->nd_body;
@@ -2833,6 +2869,7 @@ module_setup(module, node)
PUSH_CLASS();
ruby_class = module;
PUSH_SCOPE();
+ PUSH_VARS();
if (node->nd_rval) ruby_frame->cbase = node->nd_rval;
if (node->nd_tbl) {
@@ -2856,10 +2893,11 @@ module_setup(module, node)
result = rb_eval(ruby_class, node->nd_next);
}
POP_TAG();
+ POP_VARS();
POP_SCOPE();
POP_CLASS();
- ruby_frame->cbase = save;
+ ruby_frame = frame.tmp;
if (trace_func) {
call_trace_func("end", file, line, 0, ruby_frame->last_func, 0);
}
@@ -2914,6 +2952,8 @@ rb_exit(status)
exit_status = status;
rb_exc_raise(rb_exc_new(rb_eSystemExit, 0, 0));
}
+ rb_exec_end_proc();
+ rb_gc_call_finalizer_at_exit();
exit(status);
}
@@ -2924,22 +2964,23 @@ rb_f_exit(argc, argv, obj)
VALUE obj;
{
VALUE status;
+ int istatus;
rb_secure(4);
if (rb_scan_args(argc, argv, "01", &status) == 1) {
- status = NUM2INT(status);
+ istatus = NUM2INT(status);
}
else {
- status = 0;
+ istatus = 0;
}
- rb_exit(status);
+ rb_exit(istatus);
return Qnil; /* not reached */
}
static void
rb_abort()
{
- if (rb_errinfo) {
+ if (ruby_errinfo) {
error_print();
}
rb_exit(1);
@@ -2969,7 +3010,7 @@ rb_longjmp(tag, mesg)
{
VALUE at;
- if (NIL_P(mesg)) mesg = rb_errinfo;
+ if (NIL_P(mesg)) mesg = ruby_errinfo;
if (NIL_P(mesg)) {
mesg = rb_exc_new(rb_eRuntimeError, 0, 0);
}
@@ -2982,13 +3023,13 @@ rb_longjmp(tag, mesg)
}
}
if (!NIL_P(mesg)) {
- rb_errinfo = mesg;
+ ruby_errinfo = mesg;
}
- if (RTEST(rb_debug) && !NIL_P(rb_errinfo)
- && !rb_obj_is_kind_of(rb_errinfo, rb_eSystemExit)) {
+ if (RTEST(ruby_debug) && !NIL_P(ruby_errinfo)
+ && !rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
fprintf(stderr, "Exception `%s' at %s:%d\n",
- rb_class2name(CLASS_OF(rb_errinfo)),
+ rb_class2name(CLASS_OF(ruby_errinfo)),
ruby_sourcefile, ruby_sourceline);
}
@@ -3028,32 +3069,33 @@ rb_f_raise(argc, argv)
int argc;
VALUE *argv;
{
- VALUE arg1, arg2, arg3;
VALUE mesg;
- int n;
mesg = Qnil;
- switch (n = rb_scan_args(argc, argv, "03", &arg1, &arg2, &arg3)) {
+ switch (argc) {
+ case 0:
+ mesg = Qnil;
+ break;
case 1:
- mesg = arg1;
+ if (NIL_P(argv[0])) break;
+ if (TYPE(argv[0]) == T_STRING) {
+ mesg = rb_exc_new3(rb_eRuntimeError, argv[0]);
+ break;
+ }
+ mesg = rb_funcall(argv[0], rb_intern("exception"), 0, 0);
break;
case 3:
case 2:
- mesg = arg2;
+ mesg = rb_funcall(argv[0], rb_intern("exception"), 1, argv[1]);
+ break;
+ default:
+ rb_raise(rb_eArgError, "wrong # of arguments");
break;
}
-
if (!NIL_P(mesg)) {
- if (n == 1 && TYPE(mesg) == T_STRING) {
- mesg = rb_exc_new3(rb_eRuntimeError, mesg);
- }
- else {
- mesg = rb_funcall(arg1, rb_intern("new"), 1, mesg);
- }
- if (!rb_obj_is_kind_of(mesg, rb_eException)) {
+ if (!rb_obj_is_kind_of(mesg, rb_eException))
rb_raise(rb_eTypeError, "exception object expected");
- }
- set_backtrace(mesg, arg3);
+ set_backtrace(mesg, (argc>2)?argv[2]:Qnil);
}
PUSH_FRAME(); /* fake frame */
@@ -3086,8 +3128,9 @@ rb_f_iterator_p()
}
static VALUE
-rb_yield_0(val, self, klass)
+rb_yield_0(val, self, klass, acheck)
VALUE val, self, klass; /* OK */
+ int acheck;
{
NODE *node;
volatile VALUE result = Qnil;
@@ -3110,15 +3153,27 @@ rb_yield_0(val, self, klass)
old_scope = ruby_scope;
ruby_scope = block->scope;
ruby_block = block->prev;
- ruby_dyna_vars = block->d_vars;
+ if (block->flags & BLOCK_D_SCOPE) {
+ /* put place holder for dynamic (in-block) local variables */
+ ruby_dyna_vars = new_dvar(0, 0, block->d_vars);
+ }
+ else {
+ /* FOR does not introduce new scope */
+ ruby_dyna_vars = block->d_vars;
+ }
ruby_class = klass?klass:block->klass;
if (!self) self = block->self;
node = block->body;
if (block->var) {
- if (nd_type(block->var) == NODE_MASGN)
- massign(self, block->var, val);
- else
- assign(self, block->var, val);
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ if (nd_type(block->var) == NODE_MASGN)
+ massign(self, block->var, val, acheck);
+ else
+ assign(self, block->var, val, acheck);
+ }
+ POP_TAG();
+ if (state) goto pop_state;
}
PUSH_ITER(block->iter);
PUSH_TAG(PROT_NONE);
@@ -3154,6 +3209,7 @@ rb_yield_0(val, self, klass)
}
}
POP_TAG();
+ pop_state:
POP_ITER();
POP_CLASS();
POP_VARS();
@@ -3170,23 +3226,24 @@ VALUE
rb_yield(val)
VALUE val;
{
- return rb_yield_0(val, 0, 0);
+ return rb_yield_0(val, 0, 0, Qfalse);
}
static VALUE
rb_f_loop()
{
- for (;;) { rb_yield_0(Qnil, 0, 0); }
+ for (;;) { rb_yield_0(Qnil, 0, 0, Qfalse); }
}
static VALUE
-massign(self, node, val)
+massign(self, node, val, check)
VALUE self;
NODE *node;
VALUE val;
+ int check;
{
NODE *list;
- int i, len;
+ int i = 0, len;
list = node->nd_head;
@@ -3196,33 +3253,49 @@ massign(self, node, val)
}
len = RARRAY(val)->len;
for (i=0; list && i<len; i++) {
- assign(self, list->nd_head, RARRAY(val)->ptr[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 (!list && i<len) {
- assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i));
+ 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));
+ assign(self, node->nd_args, rb_ary_new2(0), check);
}
}
+ else if (check && i<len) goto arg_error;
}
- else if (node->nd_args) {
- assign(self, node->nd_args, Qnil);
+ else if (node->nd_args && node->nd_args != (NODE*)-1) {
+ assign(self, node->nd_args, Qnil, check);
}
+
+ if (check && list) goto arg_error;
while (list) {
- assign(self, list->nd_head, Qnil);
+ i++;
+ assign(self, list->nd_head, Qnil, check);
list = list->nd_next;
}
return val;
+
+ arg_error:
+ while (list) {
+ i++;
+ list = list->nd_next;
+ }
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for %d)", len, i);
}
static void
-assign(self, lhs, val)
+assign(self, lhs, val, check)
VALUE self;
NODE *lhs;
VALUE val;
+ int check;
{
switch (nd_type(lhs)) {
case NODE_GASGN:
@@ -3252,14 +3325,14 @@ assign(self, lhs, val)
break;
case NODE_MASGN:
- massign(self, lhs, val);
+ massign(self, lhs, val, check);
break;
case NODE_CALL:
{
VALUE recv;
recv = rb_eval(self, lhs->nd_recv);
- if (!lhs->nd_args->nd_head) {
+ if (!lhs->nd_args) {
/* attr set */
rb_call(CLASS_OF(recv), recv, lhs->nd_mid, 1, &val, 0);
}
@@ -3268,7 +3341,7 @@ assign(self, lhs, val)
VALUE args;
args = rb_eval(self, lhs->nd_args);
- RARRAY(args)->ptr[RARRAY(args)->len-1] = val;
+ rb_ary_push(args, val);
rb_call(CLASS_OF(recv), recv, lhs->nd_mid,
RARRAY(args)->len, RARRAY(args)->ptr, 0);
}
@@ -3339,7 +3412,7 @@ handle_rescue(self, node)
TMP_PROTECT;
if (!node->nd_args) {
- return rb_obj_is_kind_of(rb_errinfo, rb_eStandardError);
+ return rb_obj_is_kind_of(ruby_errinfo, rb_eStandardError);
}
BEGIN_CALLARGS;
@@ -3350,7 +3423,7 @@ handle_rescue(self, node)
if (!rb_obj_is_kind_of(argv[0], rb_cModule)) {
rb_raise(rb_eTypeError, "class or module required for rescue clause");
}
- if (rb_obj_is_kind_of(rb_errinfo, argv[0])) return 1;
+ if (rb_obj_is_kind_of(ruby_errinfo, argv[0])) return 1;
argv++;
}
return 0;
@@ -3363,18 +3436,18 @@ rb_rescue(b_proc, data1, r_proc, data2)
{
int state;
volatile VALUE result;
- volatile VALUE e_info = rb_errinfo;
+ volatile VALUE e_info = ruby_errinfo;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
retry_entry:
result = (*b_proc)(data1);
}
- else if (state == TAG_RAISE && rb_obj_is_kind_of(rb_errinfo, rb_eStandardError)) {
+ else if (state == TAG_RAISE && rb_obj_is_kind_of(ruby_errinfo, rb_eStandardError)) {
if (r_proc) {
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- result = (*r_proc)(data2, rb_errinfo);
+ result = (*r_proc)(data2, ruby_errinfo);
}
POP_TAG();
if (state == TAG_RETRY) {
@@ -3387,7 +3460,7 @@ rb_rescue(b_proc, data1, r_proc, data2)
state = 0;
}
if (state == 0) {
- rb_errinfo = e_info;
+ ruby_errinfo = e_info;
}
}
POP_TAG();
@@ -3443,6 +3516,26 @@ rb_ensure(b_proc, data1, e_proc, data2)
return result;
}
+VALUE
+rb_with_disable_interrupt(proc, data)
+ VALUE (*proc)();
+ VALUE data;
+{
+ VALUE result; /* OK */
+ int status;
+
+ DEFER_INTS;
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ result = (*proc)(data);
+ }
+ POP_TAG();
+ ALLOW_INTS;
+ if (status) JUMP_TAG(status);
+
+ return result;
+}
+
static int last_call_status;
#define CSTAT_PRIV 1
@@ -3456,8 +3549,9 @@ rb_f_missing(argc, argv, obj)
VALUE obj;
{
ID id;
- VALUE desc = 0;
+ volatile VALUE d = 0;
char *format = 0;
+ char *desc = "";
char *file = ruby_sourcefile;
int line = ruby_sourceline;
@@ -3469,41 +3563,39 @@ rb_f_missing(argc, argv, obj)
format = "undefined method `%s' for nil";
break;
case T_TRUE:
- format = "undefined method `%s' for Qtrue";
+ format = "undefined method `%s' for true";
break;
case T_FALSE:
- format = "undefined method `%s' for Qfalse";
+ format = "undefined method `%s' for false";
break;
case T_OBJECT:
- desc = rb_any_to_s(obj);
+ d = rb_any_to_s(obj);
break;
default:
- desc = rb_inspect(obj);
+ d = rb_inspect(obj);
break;
}
- if (desc) {
+ if (d) {
if (last_call_status & CSTAT_PRIV) {
- format = "private method `%s' called for %s";
+ format = "private method `%s' called for %s%s%s";
}
if (last_call_status & CSTAT_PROT) {
- format = "protected method `%s' called for %s";
- }
- else if (rb_iterator_p()) {
- format = "undefined iterator `%s' for %s";
+ format = "protected method `%s' called for %s%s%s";
}
else if (last_call_status & CSTAT_VCALL) {
- char *mname = rb_id2name(id);
+ const char *mname = rb_id2name(id);
if (('a' <= mname[0] && mname[0] <= 'z') || mname[0] == '_') {
- format = "undefined local variable or method `%s' for %s";
+ format = "undefined local variable or method `%s' for %s%s%s";
}
}
if (!format) {
- format = "undefined method `%s' for %s";
+ format = "undefined method `%s' for %s%s%s";
}
- if (RSTRING(desc)->len > 65) {
- desc = rb_any_to_s(obj);
+ if (RSTRING(d)->len > 65) {
+ d = rb_any_to_s(obj);
}
+ desc = RSTRING(d)->ptr;
}
ruby_sourcefile = file;
@@ -3511,9 +3603,9 @@ rb_f_missing(argc, argv, obj)
PUSH_FRAME(); /* fake frame */
*ruby_frame = *_frame.prev->prev;
- rb_raise(rb_eNameError, format,
- rb_id2name(id),
- desc?(char*)RSTRING(desc)->ptr:"");
+ rb_raise(rb_eNameError, format, rb_id2name(id),
+ desc, desc[0]=='#'?"":":",
+ desc[0]=='#'?"":rb_class2name(CLASS_OF(obj)));
POP_FRAME();
return Qnil; /* not reached */
@@ -3535,7 +3627,7 @@ rb_undefined(obj, id, argc, argv, call_status)
last_call_status = call_status;
- return rb_funcall2(obj, rb_intern("method_missing"), argc+1, nargv);
+ return rb_funcall2(obj, missing, argc+1, nargv);
}
#ifdef DJGPP
@@ -3570,7 +3662,7 @@ call_cfunc(func, recv, len, argc, argv)
VALUE *argv;
{
if (len >= 0 && argc != len) {
- rb_raise(rb_eArgError, "Wrong # of arguments(%d for %d)",
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)",
argc, len);
}
@@ -3681,7 +3773,6 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
rb_raise(rb_eSysStackError, "stack level too deep");
}
}
-
PUSH_ITER(itr);
PUSH_FRAME();
@@ -3775,21 +3866,23 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
i = node->nd_cnt;
if (i > argc) {
- rb_raise(rb_eArgError, "Wrong # of arguments(%d for %d)",
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)",
argc, i);
}
if (node->nd_rest == -1) {
- int opt = argc - i;
+ int opt = i;
NODE *optnode = node->nd_opt;
while (optnode) {
- opt--;
+ opt++;
optnode = optnode->nd_next;
}
- if (opt > 0) {
- rb_raise(rb_eArgError, "Wrong # of arguments(%d for %d)",
- argc, argc-opt);
+ if (opt < argc) {
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)",
+ argc, opt);
}
+ ruby_frame->argc = opt;
+ ruby_frame->argv = local_vars+2;
}
if (local_vars) {
@@ -3802,7 +3895,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
NODE *opt = node->nd_opt;
while (opt && argc) {
- assign(recv, opt->nd_head, *argv);
+ assign(recv, opt->nd_head, *argv, 1);
argv++; argc--;
opt = opt->nd_next;
}
@@ -3896,13 +3989,20 @@ rb_call(klass, recv, mid, argc, argv, scope)
return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
}
- /* receiver specified form for private method */
- if ((noex & NOEX_PRIVATE) && scope == 0)
- return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV);
+ if (mid != missing) {
+ /* receiver specified form for private method */
+ if ((noex & NOEX_PRIVATE) && scope == 0)
+ return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV);
- /* self must be kind of a specified form for private method */
- if ((noex & NOEX_PROTECTED) && !rb_obj_is_kind_of(ruby_frame->self, klass))
- return rb_undefined(recv, mid, argc, argv, CSTAT_PROT);
+ /* self must be kind of a specified form for private method */
+ if ((noex & NOEX_PROTECTED)) {
+ VALUE defined_class = klass;
+ while (TYPE(defined_class) == T_ICLASS)
+ defined_class = RBASIC(defined_class)->klass;
+ if (!rb_obj_is_kind_of(ruby_frame->self, defined_class))
+ return rb_undefined(recv, mid, argc, argv, CSTAT_PROT);
+ }
+ }
return rb_call0(klass, recv, id, argc, argv, body, noex & NOEX_UNDEF);
}
@@ -3991,6 +4091,16 @@ rb_funcall2(recv, mid, argc, argv)
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
}
+VALUE
+rb_funcall3(recv, mid, argc, argv)
+ VALUE recv;
+ ID mid;
+ int argc;
+ VALUE *argv;
+{
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0);
+}
+
static VALUE
backtrace(lev)
int lev;
@@ -3998,9 +4108,7 @@ backtrace(lev)
struct FRAME *frame = ruby_frame;
char buf[BUFSIZ];
VALUE ary;
- int slev = safe_level;
- safe_level = 0;
ary = rb_ary_new();
if (lev < 0) {
if (frame->last_func) {
@@ -4016,7 +4124,10 @@ backtrace(lev)
else {
while (lev-- > 0) {
frame = frame->prev;
- if (!frame) return Qnil;
+ if (!frame) {
+ ary = Qnil;
+ break;
+ }
}
}
while (frame && frame->file) {
@@ -4031,7 +4142,7 @@ backtrace(lev)
rb_ary_push(ary, rb_str_new2(buf));
frame = frame->prev;
}
- safe_level = slev;
+
return ary;
}
@@ -4081,15 +4192,15 @@ rb_frame_last_func()
}
static NODE*
-compile(src, place)
+compile(src, file, line)
VALUE src;
- char *place;
+ char *file;
+ int line;
{
NODE *node;
Check_Type(src, T_STRING);
- if (place == 0) place = ruby_sourcefile;
- node = rb_compile_string(place, src);
+ node = rb_compile_string(file, src, line);
if (ruby_nerrs == 0) return node;
return 0;
@@ -4105,7 +4216,6 @@ eval(self, src, scope, file, line)
volatile VALUE result = Qnil;
struct SCOPE * volatile old_scope;
struct BLOCK * volatile old_block;
- struct BLOCK * volatile old_call_block;
struct RVarmap * volatile old_d_vars;
int volatile old_vmode;
struct FRAME frame;
@@ -4128,12 +4238,10 @@ eval(self, src, scope, file, line)
/* PUSH BLOCK from data */
frame = data->frame;
- frame.prev = ruby_frame;
+ frame.tmp = ruby_frame; /* gc protection */
ruby_frame = &(frame);
old_scope = ruby_scope;
ruby_scope = data->scope;
- old_call_block = ruby_calling_block;
- ruby_calling_block = data;
old_block = ruby_block;
ruby_block = data->prev;
old_d_vars = ruby_dyna_vars;
@@ -4152,15 +4260,13 @@ eval(self, src, scope, file, line)
PUSH_CLASS();
ruby_class = ((NODE*)ruby_frame->cbase)->nd_clss;
- rb_in_eval++;
+ ruby_in_eval++;
if (TYPE(ruby_class) == T_ICLASS) {
ruby_class = RBASIC(ruby_class)->klass;
}
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- ruby_sourcefile = file;
- ruby_sourceline = line;
- compile(src, file);
+ compile(src, file, line);
if (ruby_nerrs > 0) {
compile_error(0);
}
@@ -4168,15 +4274,13 @@ eval(self, src, scope, file, line)
}
POP_TAG();
POP_CLASS();
- rb_in_eval--;
+ ruby_in_eval--;
if (!NIL_P(scope)) {
- ruby_frame = ruby_frame->prev;
+ ruby_frame = frame.tmp;
if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE))
FL_SET(old_scope, SCOPE_DONT_RECYCLE);
ruby_scope = old_scope;
ruby_block = old_block;
- ruby_calling_block = old_call_block;
- data->d_vars = ruby_dyna_vars;
ruby_dyna_vars = old_d_vars;
data->vmode = scope_vmode; /* write back visibility mode */
scope_vmode = old_vmode;
@@ -4191,20 +4295,20 @@ eval(self, src, scope, file, line)
VALUE err;
VALUE errat;
- errat = get_backtrace(rb_errinfo);
+ errat = get_backtrace(ruby_errinfo);
if (strcmp(file, "(eval)") == 0) {
if (ruby_sourceline > 1) {
err = RARRAY(errat)->ptr[0];
rb_str_cat(err, ": ", 2);
- rb_str_concat(err, rb_errinfo);
+ rb_str_concat(err, ruby_errinfo);
}
else {
- err = rb_str_dup(rb_errinfo);
+ err = rb_str_dup(ruby_errinfo);
}
errat = Qnil;
- rb_exc_raise(rb_exc_new3(CLASS_OF(rb_errinfo), err));
+ rb_exc_raise(rb_exc_new3(CLASS_OF(ruby_errinfo), err));
}
- rb_exc_raise(rb_errinfo);
+ rb_exc_raise(ruby_errinfo);
}
JUMP_TAG(state);
}
@@ -4220,7 +4324,7 @@ rb_f_eval(argc, argv, self)
{
VALUE src, scope, vfile, vline;
char *file = "(eval)";
- int line = 0;
+ int line = 1;
rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline);
if (argc >= 3) {
@@ -4235,6 +4339,7 @@ rb_f_eval(argc, argv, self)
return eval(self, src, scope, file, line);
}
+/* function to call func under the specified class/module context */
static VALUE
exec_under(func, under, args)
VALUE (*func)();
@@ -4276,10 +4381,11 @@ eval_under_i(args)
return eval(args[0], args[1], Qnil, (char*)args[2], (int)args[3]);
}
+/* string eval under the class/module context */
static VALUE
eval_under(under, self, src, file, line)
VALUE under, self, src;
- char *file;
+ const char *file;
int line;
{
VALUE args[4];
@@ -4296,50 +4402,70 @@ static VALUE
yield_under_i(self)
VALUE self;
{
- return rb_yield_0(self, self, ruby_class);
+ if (ruby_block->flags & BLOCK_DYNAMIC) {
+ struct BLOCK * volatile old_block = ruby_block;
+ struct BLOCK block;
+ volatile VALUE cbase = ruby_block->frame.cbase;
+ /* cbase should be pointed from volatile local variable */
+ /* to be protected from GC. */
+ VALUE result;
+ int state;
+
+ block = *ruby_block;
+ /* copy the block to avoid modifying global data. */
+ block.frame.cbase = ruby_frame->cbase;
+ ruby_block = &block;
+
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ result = rb_yield_0(self, self, ruby_class, Qfalse);
+ }
+ POP_TAG();
+ ruby_block = old_block;
+ if (state) JUMP_TAG(state);
+
+ return result;
+ }
+ /* static block, no need to restore */
+ ruby_block->frame.cbase = ruby_frame->cbase;
+ return rb_yield_0(self, self, ruby_class, Qfalse);
}
+/* block eval under the class/module context */
static VALUE
yield_under(under, self)
VALUE under, self;
{
- rb_secure(4);
+ if (rb_safe_level() >= 4 && !FL_TEST(self, FL_TAINT))
+ rb_raise(rb_eSecurityError, "Insecure: can't eval");
return exec_under(yield_under_i, under, self);
}
-VALUE
-rb_obj_instance_eval(argc, argv, self)
+static VALUE
+specific_eval(argc, argv, klass, self)
int argc;
VALUE *argv;
- VALUE self;
+ VALUE klass, self;
{
char *file = 0;
- int line = 0;
- VALUE klass;
+ int line = 1;
+ int iter = rb_iterator_p();
- if (argc == 0) {
- if (!rb_iterator_p()) {
- rb_raise(rb_eArgError, "block not supplied");
- }
- }
- else if (argc < 4) {
+ if (argc > 0) {
Check_SafeStr(argv[0]);
+ if (argc > 3) {
+ rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}",
+ rb_id2name(ruby_frame->last_func),
+ rb_id2name(ruby_frame->last_func));
+ }
if (argc > 1) file = STR2CSTR(argv[1]);
if (argc > 2) line = NUM2INT(argv[2]);
}
- else {
- rb_raise(rb_eArgError, "Wrong # of arguments: %s(src) or %s{..}",
- rb_id2name(ruby_frame->last_func),
- rb_id2name(ruby_frame->last_func));
+ else if (!iter) {
+ rb_raise(rb_eArgError, "block not supplied");
}
- if (rb_special_const_p(self)) {
- klass = Qnil;
- }
- else {
- klass = rb_singleton_class(self);
- }
- if (argc == 0) {
+ if (iter) {
return yield_under(klass, self);
}
else {
@@ -4347,53 +4473,57 @@ rb_obj_instance_eval(argc, argv, self)
}
}
-static VALUE
-rb_mod_module_eval(argc, argv, mod)
+VALUE
+rb_obj_instance_eval(argc, argv, self)
int argc;
VALUE *argv;
- VALUE mod;
+ VALUE self;
{
- char *file = 0;
- int line = 0;
+ VALUE klass;
- if (argc == 0) {
- if (!rb_iterator_p()) {
- rb_raise(rb_eArgError, "block not supplied");
- }
- }
- else if (argc < 4) {
- Check_SafeStr(argv[0]);
- if (argc > 1) file = STR2CSTR(argv[1]);
- if (argc > 2) line = NUM2INT(argv[2]);
+ if (rb_special_const_p(self)) {
+ klass = Qnil;
}
else {
- rb_raise(rb_eArgError, "Wrong # of arguments: %s(src) or %s{..}",
- rb_id2name(ruby_frame->last_func),
- rb_id2name(ruby_frame->last_func));
+ klass = rb_singleton_class(self);
}
- if (argc == 0) {
- return yield_under(mod, mod);
- }
- else {
- return eval_under(mod, mod, argv[0], file, line);
- }
+ return specific_eval(argc, argv, klass, self);
+}
+
+static VALUE
+rb_mod_module_eval(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
+{
+ return specific_eval(argc, argv, mod, mod);
}
VALUE rb_load_path;
static int
is_absolute_path(path)
- char *path;
+ const char *path;
{
if (path[0] == '/') return 1;
-# if defined(MSDOS) || defined(NT) || defined(__human68k__)
+# if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
if (path[0] == '\\') return 1;
if (strlen(path) > 2 && path[1] == ':') return 1;
# endif
return 0;
}
+#ifdef __MACOS__
+static int
+is_macos_native_path(path)
+ const char *path;
+{
+ if (strchr(path, ':')) return 1;
+ return 0;
+}
+#endif
+
static char*
find_file(file)
char *file;
@@ -4402,6 +4532,16 @@ find_file(file)
volatile VALUE vpath;
char *path;
+#ifdef __MACOS__
+ if (is_macos_native_path(file)) {
+ FILE *f = fopen(file, "r");
+
+ if (f == NULL) return 0;
+ fclose(f);
+ return file;
+ }
+#endif
+
if (is_absolute_path(file)) {
FILE *f = fopen(file, "r");
@@ -4410,14 +4550,25 @@ find_file(file)
return file;
}
+ if (file[0] == '~') {
+ VALUE argv[1];
+ argv[0] = rb_str_new2(file);
+ file = STR2CSTR(rb_file_s_expand_path(1, argv));
+ }
+
if (rb_load_path) {
int i;
Check_Type(rb_load_path, T_ARRAY);
+ vpath = rb_ary_new();
for (i=0;i<RARRAY(rb_load_path)->len;i++) {
- Check_SafeStr(RARRAY(rb_load_path)->ptr[i]);
+ VALUE str = RARRAY(rb_load_path)->ptr[i];
+ Check_SafeStr(str);
+ if (RSTRING(str)->len > 0) {
+ rb_ary_push(vpath, str);
+ }
}
- vpath = rb_ary_join(rb_load_path, rb_str_new2(RUBY_PATH_SEP));
+ vpath = rb_ary_join(vpath, rb_str_new2(PATH_SEP));
path = STR2CSTR(vpath);
if (safe_level >= 2 && !rb_path_check(path)) {
rb_raise(rb_eSecurityError, "loading from unsefe path %s", path);
@@ -4447,18 +4598,12 @@ rb_load(fname, wrap)
else {
Check_SafeStr(fname);
}
-#ifndef __MACOS__
- if (RSTRING(fname)->ptr[0] == '~') {
- fname = rb_file_s_expand_path(1, &fname);
- }
-#endif
file = find_file(RSTRING(fname)->ptr);
if (!file) {
rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
}
PUSH_VARS();
- PUSH_TAG(PROT_NONE);
PUSH_CLASS();
if (!wrap) {
rb_secure(4); /* should alter global state */
@@ -4481,19 +4626,20 @@ rb_load(fname, wrap)
VALUE *vars = TMP_ALLOC(len);
*vars++ = 0;
MEMCPY(tbl, top_scope->local_tbl, ID, len);
- MEMCPY(vars, top_scope->local_vars, ID, len-1);
+ MEMCPY(vars, top_scope->local_vars, VALUE, len-1);
ruby_scope->local_tbl = tbl; /* copy toplevel scope */
ruby_scope->local_vars = vars; /* will not alter toplevel variables */
}
/* default visibility is private at loading toplevel */
SCOPE_SET(SCOPE_PRIVATE);
+ PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
last_func = ruby_frame->last_func;
if (state == 0) {
- rb_in_eval++;
+ ruby_in_eval++;
rb_load_file(file);
- rb_in_eval--;
+ ruby_in_eval--;
if (ruby_nerrs == 0) {
eval_node(self);
}
@@ -4503,14 +4649,15 @@ rb_load(fname, wrap)
if (ruby_scope->local_tbl) /* toplevel was empty */
free(ruby_scope->local_tbl);
}
+ POP_TAG();
POP_SCOPE();
POP_FRAME();
POP_CLASS();
- POP_TAG();
POP_VARS();
ruby_wrapper = 0;
if (ruby_nerrs > 0) {
- rb_exc_raise(rb_errinfo);
+ ruby_nerrs = 0;
+ rb_exc_raise(ruby_errinfo);
}
if (state) JUMP_TAG(state);
}
@@ -4547,7 +4694,7 @@ static VALUE rb_features;
static int
rb_provided(feature)
- char *feature;
+ const char *feature;
{
VALUE *p, *pend;
char *f;
@@ -4568,14 +4715,12 @@ rb_provided(feature)
return Qfalse;
}
-#ifdef USE_THREAD
-static int rb_thread_loading _((char*));
-static void rb_thread_loading_done _((void));
-#endif
+static int rb_thread_loading _((const char*));
+static void rb_thread_loading_done _((const char*));
void
rb_provide(feature)
- char *feature;
+ const char *feature;
{
char *buf, *ext;
@@ -4598,6 +4743,7 @@ rb_f_require(obj, fname)
{
char *ext, *file, *feature, *buf; /* OK */
volatile VALUE load;
+ int state;
rb_secure(4);
Check_SafeStr(fname);
@@ -4609,7 +4755,7 @@ rb_f_require(obj, fname)
if (strcmp(".rb", ext) == 0) {
feature = file = RSTRING(fname)->ptr;
file = find_file(file);
- if (file) goto rb_load;
+ if (file) goto load_rb;
}
else if (strcmp(".so", ext) == 0 || strcmp(".o", ext) == 0) {
file = feature = RSTRING(fname)->ptr;
@@ -4621,12 +4767,12 @@ rb_f_require(obj, fname)
file = feature = buf;
}
file = find_file(file);
- if (file) goto dyna_load;
+ if (file) goto load_dyna;
}
else if (strcmp(DLEXT, ext) == 0) {
feature = RSTRING(fname)->ptr;
file = find_file(feature);
- if (file) goto dyna_load;
+ if (file) goto load_dyna;
}
}
buf = ALLOCA_N(char, strlen(RSTRING(fname)->ptr) + 5);
@@ -4636,59 +4782,56 @@ rb_f_require(obj, fname)
if (file) {
fname = rb_str_new2(file);
feature = buf;
- goto rb_load;
+ goto load_rb;
}
strcpy(buf, RSTRING(fname)->ptr);
strcat(buf, DLEXT);
file = find_file(buf);
if (file) {
feature = buf;
- goto dyna_load;
+ goto load_dyna;
}
rb_raise(rb_eLoadError, "No such file to load -- %s",
RSTRING(fname)->ptr);
- dyna_load:
-#ifdef USE_THREAD
+ load_dyna:
if (rb_thread_loading(feature)) return Qfalse;
- else {
- int state;
- PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
-#endif
- load = rb_str_new2(file);
- file = RSTRING(load)->ptr;
- dln_load(file);
- rb_provide(feature);
-#ifdef USE_THREAD
- }
- POP_TAG();
- rb_thread_loading_done();
- if (state) JUMP_TAG(state);
+
+ rb_provide(feature);
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ load = rb_str_new2(file);
+ file = RSTRING(load)->ptr;
+ dln_load(file);
}
-#endif
+ POP_TAG();
+ rb_thread_loading_done(feature);
+ if (state) JUMP_TAG(state);
+
return Qtrue;
- rb_load:
-#ifdef USE_THREAD
+ load_rb:
if (rb_thread_loading(feature)) return Qfalse;
- else {
- int state;
- PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
-#endif
- rb_load(fname, 0);
- rb_provide(feature);
-#ifdef USE_THREAD
- }
- POP_TAG();
- rb_thread_loading_done();
- if (state) JUMP_TAG(state);
+ rb_provide(feature);
+
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ rb_load(fname, 0);
}
-#endif
+ POP_TAG();
+ rb_thread_loading_done(feature);
+ if (state) JUMP_TAG(state);
+
return Qtrue;
}
+VALUE
+rb_require(fname)
+ const char *fname;
+{
+ return rb_f_require(Qnil, rb_str_new2(fname));
+}
+
static void
set_method_visibility(self, argc, argv, ex)
VALUE self;
@@ -4804,8 +4947,7 @@ rb_mod_modfunc(argc, argv, module)
id = rb_to_id(argv[i]);
body = search_method(module, id, 0);
if (body == 0 || body->nd_body == 0) {
- rb_raise(rb_eNameError, "undefined method `%s' for module `%s'",
- rb_id2name(id), rb_class2name(module));
+ rb_bug("undefined method `%s'; can't happen", rb_id2name(id));
}
rb_clear_cache_by_id(id);
rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
@@ -4846,11 +4988,13 @@ rb_mod_include(argc, argv, module)
}
void
-rb_obj_call_init(obj)
+rb_obj_call_init(obj, argc, argv)
VALUE obj;
+ int argc;
+ VALUE *argv;
{
PUSH_ITER(rb_iterator_p()?ITER_PRE:ITER_NOT);
- rb_funcall2(obj, init, ruby_frame->argc, ruby_frame->argv);
+ rb_funcall2(obj, init, argc, argv);
POP_ITER();
}
@@ -4866,7 +5010,7 @@ rb_class_new_instance(argc, argv, klass)
rb_raise(rb_eTypeError, "can't create instance of virtual class");
}
obj = rb_obj_alloc(klass);
- rb_obj_call_init(obj);
+ rb_obj_call_init(obj, argc, argv);
return obj;
}
@@ -4919,7 +5063,7 @@ errinfo_setter(val, id, var)
ID id;
VALUE *var;
{
- if (!rb_obj_is_kind_of(val, rb_eException)) {
+ if (!NIL_P(val) && !rb_obj_is_kind_of(val, rb_eException)) {
rb_raise(rb_eTypeError, "assigning non-exception to $!");
}
*var = val;
@@ -4929,7 +5073,7 @@ static VALUE
errat_getter(id)
ID id;
{
- return get_backtrace(rb_errinfo);
+ return get_backtrace(ruby_errinfo);
}
static void
@@ -4938,10 +5082,10 @@ errat_setter(val, id, var)
ID id;
VALUE *var;
{
- if (NIL_P(rb_errinfo)) {
+ if (NIL_P(ruby_errinfo)) {
rb_raise(rb_eArgError, "$! not set");
}
- set_backtrace(rb_errinfo, val);
+ set_backtrace(ruby_errinfo, val);
}
VALUE rb_f_global_variables();
@@ -5026,15 +5170,20 @@ rb_f_at_exit()
return proc;
}
-static void
-exec_end_proc()
+void
+rb_exec_end_proc()
{
struct end_proc_data *link = end_proc_data;
+ struct end_proc_data *tmp;
+ int status;
while (link) {
- (*link->func)(link->data);
- link = link->next;
+ rb_protect((VALUE(*)())link->func, link->data, &status);
+ tmp = link->next;
+ free(link);
+ link = tmp;
}
+ end_proc_data = 0;
}
void
@@ -5047,6 +5196,7 @@ Init_eval()
aref = rb_intern("[]");
aset = rb_intern("[]=");
match = rb_intern("=~");
+ missing = rb_intern("method_missing");
rb_global_variable((VALUE*)&top_scope);
rb_global_variable((VALUE*)&ruby_eval_tree_begin);
@@ -5055,7 +5205,7 @@ Init_eval()
rb_global_variable((VALUE*)&ruby_dyna_vars);
rb_define_virtual_variable("$@", errat_getter, errat_setter);
- rb_define_hooked_variable("$!", &rb_errinfo, 0, errinfo_setter);
+ rb_define_hooked_variable("$!", &ruby_errinfo, 0, errinfo_setter);
rb_define_global_function("eval", rb_f_eval, -1);
rb_define_global_function("iterator?", rb_f_iterator_p, 0);
@@ -5178,10 +5328,20 @@ static void
blk_free(data)
struct BLOCK *data;
{
- struct BLOCK *tmp;
+ struct FRAME *frame;
+ void *tmp;
+ frame = data->frame.prev;
+ while (frame) {
+ if (frame->argc > 0)
+ free(frame->argv);
+ tmp = frame;
+ frame = frame->prev;
+ free(tmp);
+ }
while (data) {
- free(data->frame.argv);
+ if (data->frame.argc > 0)
+ free(data->frame.argv);
tmp = data;
data = data->prev;
free(tmp);
@@ -5197,13 +5357,37 @@ blk_copy_prev(block)
while (block->prev) {
tmp = ALLOC_N(struct BLOCK, 1);
MEMCPY(tmp, block->prev, struct BLOCK, 1);
- tmp->frame.argv = ALLOC_N(VALUE, tmp->frame.argc);
- MEMCPY(tmp->frame.argv, block->frame.argv, VALUE, tmp->frame.argc);
+ if (tmp->frame.argc > 0) {
+ tmp->frame.argv = ALLOC_N(VALUE, tmp->frame.argc);
+ MEMCPY(tmp->frame.argv, block->frame.argv, VALUE, tmp->frame.argc);
+ }
+ scope_dup(tmp->scope);
block->prev = tmp;
block = tmp;
}
}
+static void
+frame_dup(frame)
+ struct FRAME *frame;
+{
+ VALUE *argv;
+ struct FRAME *tmp;
+
+ for (;;) {
+ if (frame->argc > 0) {
+ argv = ALLOC_N(VALUE, frame->argc);
+ MEMCPY(argv, frame->argv, VALUE, frame->argc);
+ frame->argv = argv;
+ }
+ frame->tmp = 0; /* should not preserve tmp */
+ if (!frame->prev) break;
+ tmp = ALLOC(struct FRAME);
+ *tmp = *frame->prev;
+ frame->prev = tmp;
+ frame = tmp;
+ }
+}
static VALUE
bind_clone(self)
@@ -5213,10 +5397,10 @@ bind_clone(self)
VALUE bind;
Data_Get_Struct(self, struct BLOCK, orig);
- bind = Data_Make_Struct(self,struct BLOCK,blk_mark,blk_free,data);
+ bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
+ CLONESETUP(bind,self);
MEMCPY(data, orig, struct BLOCK, 1);
- data->frame.argv = ALLOC_N(VALUE, orig->frame.argc);
- MEMCPY(data->frame.argv, orig->frame.argv, VALUE, orig->frame.argc);
+ frame_dup(&data->frame);
if (data->iter) {
blk_copy_prev(data);
@@ -5239,15 +5423,12 @@ rb_f_binding(self)
bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
*data = *ruby_block;
-#ifdef USE_THREAD
data->orig_thread = rb_thread_current();
-#endif
data->iter = rb_f_iterator_p();
+ frame_dup(&data->frame);
if (ruby_frame->prev) {
data->frame.last_func = ruby_frame->prev->last_func;
}
- data->frame.argv = ALLOC_N(VALUE, data->frame.argc);
- MEMCPY(data->frame.argv, ruby_block->frame.argv, VALUE, data->frame.argc);
if (data->iter) {
blk_copy_prev(data);
@@ -5319,22 +5500,19 @@ proc_s_new(klass)
proc = Data_Make_Struct(klass, struct BLOCK, blk_mark, blk_free, data);
*data = *ruby_block;
-#ifdef USE_THREAD
data->orig_thread = rb_thread_current();
-#endif
data->iter = data->prev?Qtrue:Qfalse;
- data->frame.argv = ALLOC_N(VALUE, data->frame.argc);
- MEMCPY(data->frame.argv, ruby_block->frame.argv, VALUE, data->frame.argc);
+ frame_dup(&data->frame);
if (data->iter) {
blk_copy_prev(data);
}
else {
data->prev = 0;
}
+ data->flags |= BLOCK_DYNAMIC;
scope_dup(data->scope);
proc_save_safe_level(proc);
- rb_obj_call_init(proc);
return proc;
}
@@ -5353,11 +5531,9 @@ blk_orphan(data)
(data->scope->flag & SCOPE_NOSTACK)) {
return 1;
}
-#ifdef USE_THREAD
if (data->orig_thread != rb_thread_current()) {
return 1;
}
-#endif
return 0;
}
@@ -5372,6 +5548,15 @@ proc_call(proc, args)
volatile int orphan;
volatile int safe = safe_level;
+ Data_Get_Struct(proc, struct BLOCK, data);
+ orphan = blk_orphan(data);
+
+ /* PUSH BLOCK from data */
+ old_block = ruby_block;
+ ruby_block = data;
+ PUSH_ITER(ITER_CUR);
+ ruby_frame->iter = ITER_CUR;
+
if (TYPE(args) == T_ARRAY) {
switch (RARRAY(args)->len) {
case 0:
@@ -5383,15 +5568,6 @@ proc_call(proc, args)
}
}
- Data_Get_Struct(proc, struct BLOCK, data);
- orphan = blk_orphan(data);
-
- /* PUSH BLOCK from data */
- old_block = ruby_block;
- ruby_block = data;
- PUSH_ITER(ITER_CUR);
- ruby_frame->iter = ITER_CUR;
-
if (orphan) {/* orphan procedure */
if (rb_iterator_p()) {
ruby_block->frame.iter = ITER_CUR;
@@ -5405,7 +5581,7 @@ proc_call(proc, args)
state = EXEC_TAG();
if (state == 0) {
proc_set_safe_level(proc);
- result = rb_yield_0(args, 0, 0);
+ result = rb_yield_0(args, 0, 0, Qtrue);
}
POP_TAG();
@@ -5436,6 +5612,31 @@ proc_call(proc, args)
}
static VALUE
+proc_arity(proc)
+ VALUE proc;
+{
+ struct BLOCK *data;
+ NODE *list;
+ int n;
+
+ Data_Get_Struct(proc, struct BLOCK, data);
+ if (data->var == 0) return FIX2INT(-1);
+ switch (nd_type(data->var)) {
+ default:
+ return INT2FIX(-2);
+ case NODE_MASGN:
+ list = data->var->nd_head;
+ n = 0;
+ while (list) {
+ n++;
+ list = list->nd_next;
+ }
+ if (data->var->nd_args) return INT2FIX(-n-1);
+ return INT2FIX(n);
+ }
+}
+
+static VALUE
block_pass(self, node)
VALUE self;
NODE *node;
@@ -5587,12 +5788,44 @@ method_call(argc, argv, method)
}
static VALUE
+method_arity(method)
+ VALUE method;
+{
+ struct METHOD *data;
+ NODE *body;
+ int n;
+
+ Data_Get_Struct(method, struct METHOD, data);
+
+ body = data->body;
+ switch (nd_type(body)) {
+ case NODE_CFUNC:
+ if (body->nd_argc < 0) return INT2FIX(-1);
+ return INT2FIX(body->nd_argc);
+ case NODE_ZSUPER:
+ return INT2FIX(-1);
+ case NODE_ATTRSET:
+ return INT2FIX(1);
+ case NODE_IVAR:
+ return INT2FIX(0);
+ default:
+ body = body->nd_next; /* skip NODE_SCOPE */
+ if (nd_type(body) == NODE_BLOCK)
+ body = body->nd_head;
+ if (!body) return INT2FIX(0);
+ n = body->nd_cnt;
+ if (body->nd_rest) n = -n-1;
+ return INT2FIX(n);
+ }
+}
+
+static VALUE
method_inspect(method)
VALUE method;
{
struct METHOD *data;
VALUE str;
- char *s;
+ const char *s;
Data_Get_Struct(method, struct METHOD, data);
str = rb_str_new2("#<");
@@ -5651,6 +5884,7 @@ Init_Proc()
rb_define_singleton_method(rb_cProc, "new", proc_s_new, 0);
rb_define_method(rb_cProc, "call", proc_call, -2);
+ rb_define_method(rb_cProc, "arity", proc_arity, 0);
rb_define_method(rb_cProc, "[]", proc_call, -2);
rb_define_global_function("proc", rb_f_lambda, 0);
rb_define_global_function("lambda", rb_f_lambda, 0);
@@ -5663,14 +5897,13 @@ Init_Proc()
rb_undef_method(CLASS_OF(rb_cMethod), "new");
rb_define_method(rb_cMethod, "call", method_call, -1);
rb_define_method(rb_cMethod, "[]", method_call, -1);
+ rb_define_method(rb_cMethod, "arity", method_arity, 0);
rb_define_method(rb_cMethod, "inspect", method_inspect, 0);
rb_define_method(rb_cMethod, "to_s", method_inspect, 0);
rb_define_method(rb_cMethod, "to_proc", method_proc, 0);
rb_define_method(rb_mKernel, "method", rb_obj_method, 1);
}
-#ifdef USE_THREAD
-
static VALUE rb_eThreadError;
int rb_thread_pending = 0;
@@ -5728,19 +5961,18 @@ struct thread {
struct SCOPE *scope;
struct RVarmap *dyna_vars;
struct BLOCK *block;
- struct BLOCK *cblock;
struct iter *iter;
struct tag *tag;
VALUE klass;
VALUE wrapper;
VALUE trace;
- int misc; /* misc. states (vmode/rb_trap_immediate) */
+ int flags; /* misc. states (vmode/rb_trap_immediate/raised) */
char *file;
int line;
- VALUE rb_errinfo;
+ VALUE errinfo;
VALUE last_status;
VALUE last_line;
VALUE last_match;
@@ -5760,10 +5992,12 @@ struct thread {
VALUE thread;
};
-static thread_t curr_thread;
-static int num_waiting_on_fd;
-static int num_waiting_on_timer;
-static int num_waiting_on_join;
+#define THREAD_RAISED 0x200
+
+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;
#define FOREACH_THREAD_FROM(f,x) x = f; do { x = x->next;
#define END_FOREACH_FROM(f,x) } while (x != f)
@@ -5801,9 +6035,10 @@ thread_mark(th)
rb_gc_mark(th->scope);
rb_gc_mark(th->dyna_vars);
- rb_gc_mark(th->rb_errinfo);
+ rb_gc_mark(th->errinfo);
rb_gc_mark(th->last_line);
rb_gc_mark(th->last_match);
+ rb_mark_tbl(th->locals);
/* mark data in copied stack */
if (th->status == THREAD_KILLED) return;
@@ -5817,20 +6052,24 @@ thread_mark(th)
frame = th->frame;
while (frame && frame != top_frame) {
frame = ADJ(frame);
- if (frame->argv && !STACK(frame->argv)) {
- rb_gc_mark_frame(frame);
+ rb_gc_mark_frame(frame);
+ if (frame->tmp) {
+ struct FRAME *tmp = ADJ(frame->tmp);
+
+ while (tmp && tmp != top_frame) {
+ tmp = ADJ(tmp);
+ rb_gc_mark_frame(tmp);
+ tmp = tmp->prev;
+ }
}
frame = frame->prev;
}
block = th->block;
while (block) {
block = ADJ(block);
- if (block->frame.argv && !STACK(block->frame.argv)) {
- rb_gc_mark_frame(&block->frame);
- }
+ rb_gc_mark_frame(&block->frame);
block = block->prev;
}
- rb_mark_tbl(th->locals);
}
void
@@ -5889,11 +6128,10 @@ rb_thread_save_context(th)
th->wrapper = ruby_wrapper;
th->dyna_vars = ruby_dyna_vars;
th->block = ruby_block;
- th->cblock = ruby_calling_block;
- th->misc = scope_vmode | (rb_trap_immediate<<8);
+ th->flags = scope_vmode | (rb_trap_immediate<<8);
th->iter = ruby_iter;
th->tag = prot_tag;
- th->rb_errinfo = rb_errinfo;
+ th->errinfo = ruby_errinfo;
th->last_status = rb_last_status;
th->last_line = rb_lastline_get();
th->last_match = rb_backref_get();
@@ -5902,8 +6140,6 @@ rb_thread_save_context(th)
th->trace = trace_func;
th->file = ruby_sourcefile;
th->line = ruby_sourceline;
-
- th->locals = 0;
}
static void rb_thread_restore_context _((thread_t,int));
@@ -5925,6 +6161,14 @@ static char *th_raise_file;
static int th_raise_line;
static VALUE th_cmd;
static int th_sig;
+static char *th_signm;
+
+#define RESTORE_NORMAL 0
+#define RESTORE_FATAL 1
+#define RESTORE_INTERRUPT 2
+#define RESTORE_TRAP 3
+#define RESTORE_RAISE 4
+#define RESTORE_SIGNAL 5
static void
rb_thread_restore_context(th, exit)
@@ -5952,12 +6196,11 @@ rb_thread_restore_context(th, exit)
ruby_wrapper = th->wrapper;
ruby_dyna_vars = th->dyna_vars;
ruby_block = th->block;
- ruby_calling_block = th->cblock;
- scope_vmode = th->misc&SCOPE_MASK;
- rb_trap_immediate = th->misc>>8;
+ scope_vmode = th->flags&SCOPE_MASK;
+ rb_trap_immediate = (th->flags&0x100)?1:0;
ruby_iter = th->iter;
prot_tag = th->tag;
- rb_errinfo = th->rb_errinfo;
+ ruby_errinfo = th->errinfo;
rb_last_status = th->last_status;
safe_level = th->safe;
@@ -5974,26 +6217,31 @@ rb_thread_restore_context(th, exit)
rb_backref_set(tmp->last_match);
switch (ex) {
- case 1:
+ case RESTORE_FATAL:
JUMP_TAG(TAG_FATAL);
break;
- case 2:
+ case RESTORE_INTERRUPT:
rb_interrupt();
break;
- case 3:
+ case RESTORE_TRAP:
rb_trap_eval(th_cmd, th_sig);
errno = EINTR;
break;
- case 4:
+ case RESTORE_SIGNAL:
+ rb_raise(rb_eSignal, "SIG%s", th_signm);
+ break;
+
+ case RESTORE_RAISE:
ruby_frame->last_func = 0;
ruby_sourcefile = th_raise_file;
ruby_sourceline = th_raise_line;
rb_f_raise(th_raise_argc, th_raise_argv);
break;
+ case RESTORE_NORMAL:
default:
longjmp(tmp->context, 1);
}
@@ -6033,15 +6281,46 @@ rb_thread_dead(th)
return th->status == THREAD_KILLED;
}
+void
+rb_thread_fd_close(fd)
+ int fd;
+{
+ thread_t th;
+
+ FOREACH_THREAD(th) {
+ if ((th->wait_for & WAIT_FD) && th->fd == fd) {
+ th_raise_argc = 1;
+ th_raise_argv[0] = rb_exc_new2(rb_eIOError, "stream closed");
+ th_raise_file = ruby_sourcefile;
+ th_raise_line = ruby_sourceline;
+ curr_thread = th;
+ rb_thread_ready(th);
+ rb_thread_restore_context(curr_thread, RESTORE_RAISE);
+ }
+ }
+ END_FOREACH(th);
+}
+
static void
rb_thread_deadlock()
{
+#if 1
curr_thread = main_thread;
th_raise_argc = 1;
th_raise_argv[0] = rb_exc_new2(rb_eFatal, "Thread: deadlock");
th_raise_file = ruby_sourcefile;
th_raise_line = ruby_sourceline;
+ rb_thread_restore_context(main_thread, RESTORE_RAISE);
+#else
+ static int invoked = 0;
+
+ if (invoked) return;
+ invoked = 1;
+ rb_prohibit_interrupt = 1;
+ ruby_errinfo = rb_exc_new2(rb_eFatal, "Thread: deadlock");
+ set_backtrace(ruby_errinfo, make_backtrace());
rb_abort();
+#endif
}
void
@@ -6053,7 +6332,9 @@ rb_thread_schedule()
select_err:
rb_thread_pending = 0;
- if (curr_thread == curr_thread->next) return;
+ if (curr_thread == curr_thread->next
+ && curr_thread->status == THREAD_RUNNABLE)
+ return;
next = 0;
curr = curr_thread; /* starting thread */
@@ -6143,7 +6424,14 @@ rb_thread_schedule()
n = select(max+1, &readfds, 0, 0, delay_ptr);
if (n < 0) {
if (rb_trap_pending) rb_trap_exec();
- goto select_err;
+ switch (errno) {
+ case EBADF:
+ case ENOMEM:
+ n = 0;
+ break;
+ default:
+ goto select_err;
+ }
}
if (n > 0) {
/* Some descriptors are ready.
@@ -6172,13 +6460,18 @@ rb_thread_schedule()
curr_thread->file = ruby_sourcefile;
curr_thread->line = ruby_sourceline;
FOREACH_THREAD_FROM(curr, th) {
- fprintf(stderr, "%s:%d:deadlock 0x%x: %d:%d %s\n",
+ fprintf(stderr, "%s:%d:deadlock 0x%lx: %d:%d %s\n",
th->file, th->line, th->thread, th->status,
th->wait_for, th==main_thread?"(main)":"");
+ if (th->status == THREAD_STOPPED) {
+ next = th;
+ }
}
END_FOREACH_FROM(curr, th);
/* raise fatal error to main thread */
rb_thread_deadlock();
+ rb_thread_ready(next);
+ next->status = THREAD_TO_KILL;
}
if (next->status == THREAD_RUNNABLE && next == curr_thread) {
return;
@@ -6195,9 +6488,9 @@ rb_thread_schedule()
curr_thread = next;
if (next->status == THREAD_TO_KILL) {
/* execute ensure-clause if any */
- rb_thread_restore_context(next, 1);
+ rb_thread_restore_context(next, RESTORE_FATAL);
}
- rb_thread_restore_context(next, 0);
+ rb_thread_restore_context(next, RESTORE_NORMAL);
}
void
@@ -6213,20 +6506,20 @@ rb_thread_wait_fd(fd)
rb_thread_schedule();
}
-void
+int
rb_thread_fd_writable(fd)
int fd;
{
struct timeval zero;
fd_set fds;
- if (curr_thread == curr_thread->next) return;
+ if (curr_thread == curr_thread->next) return 1;
zero.tv_sec = zero.tv_usec = 0;
for (;;) {
FD_ZERO(&fds);
FD_SET(fd, &fds);
- if (select(fd+1, 0, &fds, 0, &zero) == 1) break;
+ if (select(fd+1, 0, &fds, 0, &zero) == 1) return 0;
rb_thread_schedule();
}
}
@@ -6373,14 +6666,28 @@ rb_thread_join(thread)
{
thread_t th = rb_thread_check(thread);
- if (rb_thread_dead(th)) return thread;
- if ((th->wait_for & WAIT_JOIN) && th->join == curr_thread)
- rb_raise(rb_eThreadError, "Thread#join: deadlock");
- curr_thread->status = THREAD_STOPPED;
- curr_thread->join = th;
- num_waiting_on_join++;
- curr_thread->wait_for |= WAIT_JOIN;
- rb_thread_schedule();
+ if (!rb_thread_dead(th)) {
+ if (th == curr_thread)
+ rb_raise(rb_eThreadError, "recursive join");
+ if ((th->wait_for & WAIT_JOIN) && th->join == curr_thread)
+ rb_raise(rb_eThreadError, "Thread#join: deadlock - mutual join");
+ curr_thread->status = THREAD_STOPPED;
+ curr_thread->join = th;
+ num_waiting_on_join++;
+ curr_thread->wait_for |= WAIT_JOIN;
+ rb_thread_schedule();
+ }
+
+ if (!NIL_P(th->errinfo) && (th->flags & THREAD_RAISED)) {
+ VALUE oldbt = get_backtrace(th->errinfo);
+ VALUE errat = make_backtrace();
+
+ if (TYPE(oldbt) == T_ARRAY && RARRAY(oldbt)->len > 0) {
+ rb_ary_unshift(errat, rb_ary_entry(oldbt, 0));
+ }
+ set_backtrace(th->errinfo, errat);
+ rb_exc_raise(th->errinfo);
+ }
return thread;
}
@@ -6406,7 +6713,7 @@ rb_thread_main()
return main_thread->thread;
}
-static VALUE
+VALUE
rb_thread_wakeup(thread)
VALUE thread;
{
@@ -6419,7 +6726,7 @@ rb_thread_wakeup(thread)
return thread;
}
-static VALUE
+VALUE
rb_thread_run(thread)
VALUE thread;
{
@@ -6465,14 +6772,14 @@ rb_thread_pass()
return Qnil;
}
-static VALUE
+VALUE
rb_thread_stop()
{
rb_thread_critical = 0;
- curr_thread->status = THREAD_STOPPED;
if (curr_thread == curr_thread->next) {
rb_raise(rb_eThreadError, "stopping only thread");
}
+ curr_thread->status = THREAD_STOPPED;
rb_thread_schedule();
return Qnil;
@@ -6510,19 +6817,19 @@ rb_thread_sleep_forever()
rb_thread_schedule();
}
-static int rb_thread_abort;
+static int thread_abort;
static VALUE
rb_thread_s_abort_exc()
{
- return rb_thread_abort?Qtrue:Qfalse;
+ return thread_abort?Qtrue:Qfalse;
}
static VALUE
rb_thread_s_abort_exc_set(self, val)
VALUE self, val;
{
- rb_thread_abort = RTEST(val);
+ thread_abort = RTEST(val);
return val;
}
@@ -6545,41 +6852,44 @@ rb_thread_abort_exc_set(thread, val)
return val;
}
+#define THREAD_ALLOC(th) do {\
+ th = ALLOC(struct thread);\
+\
+ th->status = 0;\
+ th->result = 0;\
+ th->errinfo = Qnil;\
+\
+ th->stk_ptr = 0;\
+ th->stk_len = 0;\
+ th->stk_max = 0;\
+ th->wait_for = 0;\
+ th->fd = 0;\
+ th->delay = 0.0;\
+ th->join = 0;\
+\
+ th->frame = 0;\
+ th->scope = 0;\
+ th->klass = 0;\
+ th->wrapper = 0;\
+ th->dyna_vars = 0;\
+ th->block = 0;\
+ th->iter = 0;\
+ th->tag = 0;\
+ th->errinfo = 0;\
+ th->last_status = 0;\
+ th->last_line = 0;\
+ th->last_match = 0;\
+ th->abort = 0;\
+ th->locals = 0;\
+} while(0)
+
static thread_t
rb_thread_alloc(klass)
VALUE klass;
{
thread_t th;
- th = ALLOC(struct thread);
- th->status = THREAD_RUNNABLE;
-
- th->status = 0;
- th->result = 0;
- th->rb_errinfo = Qnil;
-
- th->stk_ptr = 0;
- th->stk_len = 0;
- th->stk_max = 0;
- th->wait_for = 0;
- th->fd = 0;
- th->delay = 0.0;
- th->join = 0;
-
- th->frame = 0;
- th->scope = 0;
- th->klass = 0;
- th->wrapper = 0;
- th->dyna_vars = 0;
- th->block = 0;
- th->iter = 0;
- th->tag = 0;
- th->rb_errinfo = 0;
- th->last_status = 0;
- th->last_line = 0;
- th->last_match = 0;
- th->abort = 0;
-
+ THREAD_ALLOC(th);
th->thread = Data_Wrap_Struct(klass, thread_mark, thread_free, th);
if (curr_thread) {
@@ -6654,6 +6964,7 @@ rb_thread_create_0(fn, arg, klass)
VALUE klass;
{
thread_t th = rb_thread_alloc(klass);
+ volatile VALUE thread = th->thread;
enum thread_status status;
int state;
@@ -6673,7 +6984,7 @@ rb_thread_create_0(fn, arg, klass)
FL_SET(ruby_scope, SCOPE_SHARED);
rb_thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
- return th->thread;
+ return thread;
}
PUSH_TAG(PROT_THREAD);
@@ -6687,24 +6998,25 @@ rb_thread_create_0(fn, arg, klass)
POP_TAG();
status = th->status;
rb_thread_remove();
- if (state && status != THREAD_TO_KILL && !NIL_P(rb_errinfo)) {
+ if (state && status != THREAD_TO_KILL && !NIL_P(ruby_errinfo)) {
+ th->flags |= THREAD_RAISED;
if (state == TAG_FATAL) {
/* fatal error within this thread, need to stop whole script */
- main_thread->rb_errinfo = rb_errinfo;
+ main_thread->errinfo = ruby_errinfo;
rb_thread_cleanup();
}
- else if (rb_obj_is_kind_of(rb_errinfo, rb_eSystemExit)) {
+ else if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
/* delegate exception to main_thread */
- rb_thread_raise(1, &rb_errinfo, main_thread->thread);
+ rb_thread_raise(1, &ruby_errinfo, main_thread->thread);
}
- else if (rb_thread_abort || curr_thread->abort || RTEST(rb_debug)) {
+ else if (thread_abort || th->abort || RTEST(ruby_debug)) {
VALUE err = rb_exc_new(rb_eSystemExit, 0, 0);
error_print();
/* exit on main_thread */
rb_thread_raise(1, &err, main_thread->thread);
}
else {
- curr_thread->rb_errinfo = rb_errinfo;
+ th->errinfo = ruby_errinfo;
}
}
rb_thread_schedule();
@@ -6731,7 +7043,7 @@ rb_thread_yield(arg, th)
thread_t th;
{
scope_dup(ruby_block->scope);
- return rb_yield_0(th->thread, 0, 0);
+ return rb_yield_0(th->thread, 0, 0, Qfalse);
}
static VALUE
@@ -6751,14 +7063,6 @@ rb_thread_value(thread)
thread_t th = rb_thread_check(thread);
rb_thread_join(thread);
- if (!NIL_P(th->rb_errinfo)) {
- VALUE oldbt = get_backtrace(th->rb_errinfo);
- VALUE errat = make_backtrace();
-
- rb_ary_unshift(errat, rb_ary_entry(oldbt, 0));
- set_backtrace(th->rb_errinfo, errat);
- rb_exc_raise(th->rb_errinfo);
- }
return th->result;
}
@@ -6770,7 +7074,8 @@ rb_thread_status(thread)
thread_t th = rb_thread_check(thread);
if (rb_thread_dead(th)) {
- if (NIL_P(th->rb_errinfo)) return Qfalse;
+ if (NIL_P(th->errinfo) && (th->flags & THREAD_RAISED))
+ return Qfalse;
return Qnil;
}
@@ -6808,8 +7113,8 @@ rb_thread_cleanup()
FOREACH_THREAD(th) {
if (th != curr_thread && th->status != THREAD_KILLED) {
+ rb_thread_ready(th);
th->status = THREAD_TO_KILL;
- th->wait_for = 0;
}
}
END_FOREACH(th);
@@ -6844,7 +7149,27 @@ rb_thread_interrupt()
return;
}
curr_thread = main_thread;
- rb_thread_restore_context(curr_thread, 2);
+ rb_thread_restore_context(curr_thread, RESTORE_INTERRUPT);
+}
+
+void
+rb_thread_signal_raise(sig)
+ char *sig;
+{
+ if (sig == 0) return; /* should not happen */
+ rb_thread_critical = 0;
+ if (curr_thread == main_thread) {
+ rb_thread_ready(curr_thread);
+ rb_raise(rb_eSignal, "SIG%s", sig);
+ }
+ rb_thread_ready(main_thread);
+ rb_thread_save_context(curr_thread);
+ if (setjmp(curr_thread->context)) {
+ return;
+ }
+ th_signm = sig;
+ curr_thread = main_thread;
+ rb_thread_restore_context(curr_thread, RESTORE_SIGNAL);
}
void
@@ -6866,7 +7191,7 @@ rb_thread_trap_eval(cmd, sig)
th_cmd = cmd;
th_sig = sig;
curr_thread = main_thread;
- rb_thread_restore_context(curr_thread, 3);
+ rb_thread_restore_context(curr_thread, RESTORE_TRAP);
}
static VALUE
@@ -6895,36 +7220,33 @@ rb_thread_raise(argc, argv, thread)
th_raise_argc = argc;
th_raise_file = ruby_sourcefile;
th_raise_line = ruby_sourceline;
- rb_thread_restore_context(curr_thread, 4);
+ rb_thread_restore_context(curr_thread, RESTORE_RAISE);
return Qnil; /* not reached */
}
-static thread_t loading_thread;
-static int loading_nest;
+static st_table *loading_tbl;
static int
rb_thread_loading(feature)
- char *feature;
+ const char *feature;
{
- if (curr_thread != curr_thread->next && loading_thread) {
- while (loading_thread != curr_thread) {
- rb_thread_schedule();
- CHECK_INTS;
- }
- if (rb_provided(feature)) return Qtrue; /* no need to load */
+ if (!rb_provided(feature)) return Qfalse; /* need to load */
+ if (!loading_tbl) {
+ loading_tbl = st_init_strtable();
}
-
- loading_thread = curr_thread;
- loading_nest++;
-
- return Qfalse;
+ while (st_lookup(loading_tbl, feature, 0)) {
+ CHECK_INTS;
+ rb_thread_schedule();
+ }
+ return Qtrue;
}
static void
-rb_thread_loading_done()
+rb_thread_loading_done(feature)
+ const char *feature;
{
- if (--loading_nest == 0) {
- loading_thread = 0;
+ if (loading_tbl) {
+ st_delete(loading_tbl, feature, 0);
}
}
@@ -6957,13 +7279,11 @@ rb_thread_local_aset(thread, id, val)
ID id;
VALUE val;
{
- thread_t th;
-
+ thread_t th = rb_thread_check(thread);
if (safe_level >= 4 && !FL_TEST(thread, FL_TAINT))
rb_raise(rb_eSecurityError, "Insecure: can't modify thread values");
- th = rb_thread_check(thread);
if (!th->locals) {
th->locals = st_init_numtable();
}
@@ -7002,39 +7322,17 @@ rb_callcc(self)
VALUE self;
{
volatile VALUE cont;
- thread_t th = ALLOC(struct thread);
-
- th->status = THREAD_RUNNABLE;
-
- th->status = 0;
- th->result = 0;
- th->rb_errinfo = Qnil;
-
- th->stk_ptr = 0;
- th->stk_len = 0;
- th->stk_max = 0;
- th->wait_for = 0;
- th->fd = 0;
- th->delay = 0.0;
- th->join = 0;
-
- th->frame = 0;
- th->scope = 0;
- th->klass = 0;
- th->dyna_vars = 0;
- th->block = 0;
- th->iter = 0;
- th->tag = 0;
- th->rb_errinfo = 0;
- th->last_status = 0;
- th->last_line = 0;
- th->last_match = 0;
- th->abort = 0;
+ thread_t th;
+ struct tag *tag;
+ THREAD_ALLOC(th);
th->thread = cont = Data_Wrap_Struct(rb_cContinuation, thread_mark,
thread_free, th);
FL_SET(ruby_scope, SCOPE_DONT_RECYCLE);
+ for (tag=prot_tag; tag; tag=tag->prev) {
+ scope_dup(tag->scope);
+ }
rb_thread_save_context(th);
if (setjmp(th->context)) {
return th->result;
@@ -7063,7 +7361,7 @@ rb_continuation_call(argc, argv, cont)
th->result = rb_ary_new4(argc, argv);
break;
}
- rb_thread_restore_context(th, 0);
+ rb_thread_restore_context(th, RESTORE_NORMAL);
return Qnil;
}
@@ -7114,9 +7412,8 @@ Init_Thread()
rb_cContinuation = rb_define_class("Continuation", rb_cObject);
rb_undef_method(CLASS_OF(rb_cContinuation), "new");
rb_define_method(rb_cContinuation, "call", rb_continuation_call, -1);
- rb_define_method(rb_mKernel, "callcc", rb_callcc, 0);
+ rb_define_global_function("callcc", rb_callcc, 0);
}
-#endif
static VALUE
rb_f_catch(dmy, tag)
@@ -7129,7 +7426,7 @@ rb_f_catch(dmy, tag)
t = rb_to_id(tag);
PUSH_TAG(t);
if ((state = EXEC_TAG()) == 0) {
- val = rb_yield_0(tag, 0, 0);
+ val = rb_yield_0(tag, 0, 0, Qfalse);
}
else if (state == TAG_THROW && t == prot_tag->dst) {
val = prot_tag->retval;
@@ -7150,7 +7447,7 @@ catch_i(tag)
VALUE
rb_catch(tag, proc, data)
- char *tag;
+ const char *tag;
VALUE (*proc)();
VALUE data;
{
@@ -7174,13 +7471,11 @@ rb_f_throw(argc, argv)
tt->dst = t;
break;
}
-#ifdef USE_THREAD
if (tt->tag == PROT_THREAD) {
rb_raise(rb_eThreadError, "uncaught throw `%s' in thread 0x%x",
rb_id2name(t),
curr_thread);
}
-#endif
tt = tt->prev;
}
if (!tt) {
@@ -7194,7 +7489,7 @@ rb_f_throw(argc, argv)
void
rb_throw(tag, val)
- char *tag;
+ const char *tag;
VALUE val;
{
VALUE argv[2];
@@ -7208,7 +7503,6 @@ rb_throw(tag, val)
static void
return_check()
{
-#ifdef USE_THREAD
struct tag *tt = prot_tag;
while (tt) {
@@ -7221,6 +7515,5 @@ return_check()
}
tt = tt->prev;
}
-#endif
}
diff --git a/file.c b/file.c
index 11a8dedf145..9ac2db6b356 100644
--- a/file.c
+++ b/file.c
@@ -6,7 +6,7 @@
$Date$
created at: Mon Nov 15 12:24:34 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -28,6 +28,7 @@
# define MAXPATHLEN 1024
#endif
+#include <time.h>
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#else
@@ -39,6 +40,8 @@ struct timeval {
#endif /* NT */
#endif
+VALUE rb_time_new _((time_t, time_t));
+
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
@@ -48,7 +51,7 @@ struct timeval {
#endif
#ifndef HAVE_STRING_H
-char *strrchr _((char*,char));
+char *strrchr _((const char*,const char));
#endif
#include <sys/types.h>
@@ -58,107 +61,17 @@ char *strrchr _((char*,char));
#include "macruby_missing.h"
extern int fileno(FILE *stream);
extern int utimes();
+ char* strdup(char*);
#endif
+#ifdef __EMX__
+#define lstat stat
+#endif
+
VALUE rb_cFile;
VALUE rb_mFileTest;
static VALUE sStat;
-VALUE
-rb_file_open(fname, mode)
- char *fname, *mode;
-{
- OpenFile *fptr;
- NEWOBJ(port, struct RFile);
- OBJSETUP(port, rb_cFile, T_FILE);
- MakeOpenFile(port, fptr);
-
- fptr->mode = rb_io_mode_flags(mode);
- fptr->f = rb_fopen(fname, mode);
- fptr->path = strdup(fname);
- rb_obj_call_init((VALUE)port);
-
- return (VALUE)port;
-}
-
-static VALUE
-rb_file_s_open(argc, argv, klass)
- int argc;
- VALUE *argv;
- VALUE klass;
-{
- VALUE fname, vmode, file;
- char *mode;
-
- rb_scan_args(argc, argv, "11", &fname, &vmode);
- Check_SafeStr(fname);
- if (!NIL_P(vmode)) {
- mode = STR2CSTR(vmode);
- }
- else {
- mode = "r";
- }
- file = rb_file_open(RSTRING(fname)->ptr, mode);
-
- RBASIC(file)->klass = klass;
- rb_obj_call_init(file);
- if (rb_iterator_p()) {
- return rb_ensure(rb_yield, file, rb_io_close, file);
- }
-
- return file;
-}
-
-static VALUE
-rb_file_reopen(argc, argv, file)
- int argc;
- VALUE *argv;
- VALUE file;
-{
- VALUE fname, nmode;
- char *mode;
- OpenFile *fptr;
-
- rb_secure(4);
- if (rb_scan_args(argc, argv, "11", &fname, &nmode) == 1) {
- if (TYPE(fname) == T_FILE) { /* fname must be IO */
- return rb_io_reopen(file, fname);
- }
- }
-
- Check_SafeStr(fname);
- if (!NIL_P(nmode)) {
- mode = STR2CSTR(nmode);
- }
- else {
- mode = "r";
- }
-
- GetOpenFile(file, fptr);
- if (fptr->path) free(fptr->path);
- fptr->path = strdup(RSTRING(fname)->ptr);
- fptr->mode = rb_io_mode_flags(mode);
- if (!fptr->f) {
- fptr->f = rb_fopen(RSTRING(fname)->ptr, mode);
- if (fptr->f2) {
- fclose(fptr->f2);
- fptr->f2 = NULL;
- }
- return file;
- }
-
- if (freopen(RSTRING(fname)->ptr, mode, fptr->f) == NULL) {
- rb_sys_fail(fptr->path);
- }
- if (fptr->f2) {
- if (freopen(RSTRING(fname)->ptr, "w", fptr->f2) == NULL) {
- rb_sys_fail(fptr->path);
- }
- }
-
- return file;
-}
-
static int
apply2files(func, vargs, arg)
int (*func)();
@@ -247,6 +160,9 @@ rb_stat(file, st)
return fstat(fileno(fptr->f), st);
}
Check_SafeStr(file);
+#if defined DJGPP
+ if (RSTRING(file)->len == 0) return -1;
+#endif
return stat(RSTRING(file)->ptr, st);
}
@@ -281,7 +197,7 @@ static VALUE
rb_file_s_lstat(obj, fname)
VALUE obj, fname;
{
-#if !defined(MSDOS) && !defined(NT)
+#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__)
struct stat st;
Check_SafeStr(fname);
@@ -299,7 +215,7 @@ static VALUE
rb_file_lstat(obj)
VALUE obj;
{
-#if !defined(MSDOS) && !defined(NT)
+#if !defined(MSDOS) && !defined(NT)
OpenFile *fptr;
struct stat st;
@@ -347,7 +263,7 @@ group_member(gid)
int
eaccess(path, mode)
- char *path;
+ const char *path;
int mode;
{
#ifndef NT
@@ -608,8 +524,8 @@ test_s(obj, fname)
{
struct stat st;
- if (rb_stat(fname, &st) < 0) return Qfalse;
- if (st.st_size == 0) return Qfalse;
+ if (rb_stat(fname, &st) < 0) return Qnil;
+ if (st.st_size == 0) return Qnil;
return rb_int2inum(st.st_size);
}
@@ -651,7 +567,7 @@ test_grpowned(obj, fname)
#if defined(S_ISUID) || defined(S_ISGID) || defined(S_ISVTX)
static VALUE
check3rdbyte(file, mode)
- char *file;
+ const char *file;
int mode;
{
struct stat st;
@@ -693,7 +609,7 @@ test_sticky(obj, fname)
#ifdef S_ISVTX
return check3rdbyte(STR2CSTR(fname), S_ISVTX);
#else
- return Qfalse;
+ return Qnil;
#endif
}
@@ -836,7 +752,7 @@ rb_file_ctime(obj)
static void
chmod_internal(path, mode)
- char *path;
+ const char *path;
int mode;
{
if (chmod(path, mode) == -1)
@@ -870,7 +786,7 @@ rb_file_chmod(obj, vmode)
mode = NUM2INT(vmode);
GetOpenFile(obj, fptr);
-#if defined(DJGPP) || defined(NT) || defined(USE_CWGUSI) || defined(__BEOS__)
+#if defined(DJGPP) || defined(NT) || defined(USE_CWGUSI) || defined(__BEOS__) || defined(__EMX__)
if (chmod(fptr->path, mode) == -1)
rb_sys_fail(fptr->path);
#else
@@ -887,7 +803,7 @@ struct chown_args {
static void
chown_internal(path, args)
- char *path;
+ const char *path;
struct chown_args *args;
{
if (chown(path, args->owner, args->group) < 0)
@@ -929,7 +845,7 @@ rb_file_chown(obj, owner, group)
rb_secure(4);
GetOpenFile(obj, fptr);
-#if defined(DJGPP) || defined(__CYGWIN32__) || defined(NT) || defined(USE_CWGUSI)
+#if defined(DJGPP) || defined(__CYGWIN32__) || defined(NT) || defined(USE_CWGUSI) || defined(__EMX__)
if (chown(fptr->path, NUM2INT(owner), NUM2INT(group)) == -1)
rb_sys_fail(fptr->path);
#else
@@ -993,7 +909,7 @@ struct utimbuf {
static void
utime_internal(path, utp)
- char *path;
+ const char *path;
struct utimbuf *utp;
{
if (utime(path, utp) < 0)
@@ -1043,7 +959,7 @@ static VALUE
rb_file_s_symlink(obj, from, to)
VALUE obj, from, to;
{
-#if !defined(MSDOS) && !defined(NT)
+#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__)
Check_SafeStr(from);
Check_SafeStr(to);
@@ -1060,7 +976,7 @@ static VALUE
rb_file_s_readlink(obj, path)
VALUE obj, path;
{
-#if !defined(MSDOS) && !defined(NT)
+#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__)
char buf[MAXPATHLEN];
int cc;
@@ -1078,7 +994,7 @@ rb_file_s_readlink(obj, path)
static void
unlink_internal(path)
- char *path;
+ const char *path;
{
if (unlink(path) < 0)
rb_sys_fail(path);
@@ -1132,6 +1048,12 @@ rb_file_s_umask(argc, argv)
#endif /* USE_CWGUSI */
}
+#if defined DOSISH
+#define isdirsep(x) ((x) == '/' || (x) == '\\')
+#else
+#define isdirsep(x) ((x) == '/')
+#endif
+
VALUE
rb_file_s_expand_path(argc, argv)
int argc;
@@ -1146,11 +1068,7 @@ rb_file_s_expand_path(argc, argv)
s = STR2CSTR(fname);
p = buf;
if (s[0] == '~') {
- if (s[1] == '/' ||
-#if defined(MSDOS) || defined(NT) || defined(__human68k__)
- s[1] == '\\' ||
-#endif
- s[1] == '\0') {
+ if (isdirsep(s[1]) || s[1] == '\0') {
char *dir = getenv("HOME");
if (!dir) {
@@ -1165,7 +1083,7 @@ rb_file_s_expand_path(argc, argv)
struct passwd *pwPtr;
s++;
#endif
- while (*s && *s != '/') {
+ while (*s && !isdirsep(*s)) {
*p++ = *s++;
}
*p = '\0';
@@ -1181,6 +1099,14 @@ rb_file_s_expand_path(argc, argv)
#endif
}
}
+#if defined DOSISH
+ /* skip drive letter */
+ else if (isalpha(s[0]) && s[1] == ':' && isdirsep(s[2])) {
+ while (*s && !isdirsep(*s)) {
+ *p++ = *s++;
+ }
+ }
+#endif
else if (s[0] != '/') {
if (argc == 2) {
dname = rb_file_s_expand_path(1, &dname);
@@ -1204,10 +1130,10 @@ rb_file_s_expand_path(argc, argv)
if (*(s+1)) {
switch (*++s) {
case '.':
- if (*(s+1) == '\0' || *(s+1) == '/') {
+ if (*(s+1) == '\0' || isdirsep(*(s+1))) {
/* We must go back to the parent */
- if (*p == '/' && p > buf) p--;
- while (p > buf && *p != '/') p--;
+ if (isdirsep(*p) && p > buf) p--;
+ while (p > buf && !isdirsep(*p)) p--;
}
else {
*++p = '.';
@@ -1215,7 +1141,10 @@ rb_file_s_expand_path(argc, argv)
}
break;
case '/':
- if (*p != '/') *++p = '/';
+#if defined DOSISH
+ case '\\':
+#endif
+ if (!isdirsep(*p)) *++p = '/';
break;
default:
*++p = '.'; *++p = *s; break;
@@ -1223,14 +1152,17 @@ rb_file_s_expand_path(argc, argv)
}
break;
case '/':
- if (*p != '/') *++p = '/'; break;
+#if defined DOSISH
+ case '\\':
+#endif
+ if (!isdirsep(*p)) *++p = '/'; break;
default:
*++p = *s;
}
}
/* Place a \0 at end. If path ends with a "/", delete it */
- if (p == buf || *p != '/') p++;
+ if (p == buf || !isdirsep(*p)) p++;
*p = '\0';
return rb_tainted_str_new2(buf);
@@ -1238,7 +1170,7 @@ rb_file_s_expand_path(argc, argv)
static int
rmext(p, e)
- char *p, *e;
+ const char *p, *e;
{
int l1, l2;
@@ -1394,10 +1326,11 @@ rb_file_truncate(obj, len)
# define LOCK_UN 8
# endif
-#if defined(USE_THREAD) && defined(EWOULDBLOCK)
+#if defined(EWOULDBLOCK)
static int
-rb_thread_flock(fd, op)
+rb_thread_flock(fd, op, fptr)
int fd, op;
+ OpenFile *fptr;
{
if (rb_thread_alone() || (op & LOCK_NB)) {
return flock(fd, op);
@@ -1408,6 +1341,7 @@ rb_thread_flock(fd, op)
case EINTR: /* can be happen? */
case EWOULDBLOCK:
rb_thread_schedule(); /* busy wait */
+ rb_io_check_closed(fptr);
break;
default:
return -1;
@@ -1415,7 +1349,7 @@ rb_thread_flock(fd, op)
}
return 0;
}
-#define flock rb_thread_flock
+#define flock(fd, op) rb_thread_flock(fd, op, fptr)
#endif
static VALUE
@@ -1452,7 +1386,7 @@ test_check(n, argc, argv)
int i;
n+=1;
- if (n < argc) rb_raise(rb_eArgError, "Wrong # of arguments(%d for %d)", argc, n);
+ if (n < argc) rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)", argc, n);
for (i=1; i<n; i++) {
switch (TYPE(argv[i])) {
case T_STRING:
@@ -1476,7 +1410,7 @@ rb_f_test(argc, argv)
{
int cmd;
- if (argc == 0) rb_raise(rb_eArgError, "Wrong # of arguments");
+ if (argc == 0) rb_raise(rb_eArgError, "wrong # of arguments");
cmd = NUM2CHR(argv[0]);
if (cmd == 0) return Qfalse;
if (strchr("bcdefgGkloOprRsSuwWxXz", cmd)) {
@@ -1596,15 +1530,24 @@ rb_f_test(argc, argv)
}
}
/* unknown command */
- rb_raise(rb_eArgError, "unknow command ?%c", cmd);
+ rb_raise(rb_eArgError, "unknown command ?%c", cmd);
return Qnil; /* not reached */
}
+static VALUE rb_mConst;
+
void
-Init_File()
+rb_file_const(name, value)
+ const char *name;
+ VALUE value;
{
- VALUE rb_mConst;
+ rb_define_const(rb_cFile, name, value);
+ rb_define_const(rb_mConst, name, value);
+}
+void
+Init_File()
+{
rb_mFileTest = rb_define_module("FileTest");
rb_define_module_function(rb_mFileTest, "directory?", test_d, 1);
@@ -1637,9 +1580,6 @@ Init_File()
rb_cFile = rb_define_class("File", rb_cIO);
rb_extend_object(rb_cFile, CLASS_OF(rb_mFileTest));
- rb_define_singleton_method(rb_cFile, "new", rb_file_s_open, -1);
- rb_define_singleton_method(rb_cFile, "open", rb_file_s_open, -1);
-
rb_define_singleton_method(rb_cFile, "stat", rb_file_s_stat, 1);
rb_define_singleton_method(rb_cFile, "lstat", rb_file_s_lstat, 1);
rb_define_singleton_method(rb_cFile, "ftype", rb_file_s_ftype, 1);
@@ -1668,10 +1608,16 @@ Init_File()
separator = rb_str_new2("/");
rb_define_const(rb_cFile, "Separator", separator);
+ rb_define_const(rb_cFile, "SEPARATOR", separator);
rb_define_singleton_method(rb_cFile, "split", rb_file_s_split, 1);
rb_define_singleton_method(rb_cFile, "join", rb_file_s_join, -2);
- rb_define_method(rb_cFile, "reopen", rb_file_reopen, -1);
+#ifdef DOSISH
+ rb_define_const(rb_cFile, "ALT_SEPARATOR", rb_str_new2("\\"));
+#else
+ rb_define_const(rb_cFile, "ALT_SEPARATOR", Qnil);
+#endif
+ rb_define_const(rb_cFile, "PATH_SEPARATOR", rb_str_new2(PATH_SEP));
rb_define_method(rb_cIO, "stat", rb_io_stat, 0); /* this is IO's method */
rb_define_method(rb_cFile, "lstat", rb_file_lstat, 0);
@@ -1687,15 +1633,10 @@ Init_File()
rb_define_method(rb_cFile, "flock", rb_file_flock, 1);
rb_mConst = rb_define_module_under(rb_cFile, "Constants");
- rb_define_const(rb_cFile, "LOCK_SH", INT2FIX(LOCK_SH));
- rb_define_const(rb_cFile, "LOCK_EX", INT2FIX(LOCK_EX));
- rb_define_const(rb_cFile, "LOCK_UN", INT2FIX(LOCK_UN));
- rb_define_const(rb_cFile, "LOCK_NB", INT2FIX(LOCK_NB));
-
- rb_define_const(rb_mConst, "LOCK_SH", INT2FIX(LOCK_SH));
- rb_define_const(rb_mConst, "LOCK_EX", INT2FIX(LOCK_EX));
- rb_define_const(rb_mConst, "LOCK_UN", INT2FIX(LOCK_UN));
- rb_define_const(rb_mConst, "LOCK_NB", INT2FIX(LOCK_NB));
+ rb_file_const("LOCK_SH", INT2FIX(LOCK_SH));
+ rb_file_const("LOCK_EX", INT2FIX(LOCK_EX));
+ rb_file_const("LOCK_UN", INT2FIX(LOCK_UN));
+ rb_file_const("LOCK_NB", INT2FIX(LOCK_NB));
rb_define_method(rb_cFile, "path", rb_file_path, 0);
diff --git a/fnmatch.c b/fnmatch.c
deleted file mode 100644
index f031749c3dc..00000000000
--- a/fnmatch.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#include "config.h"
-#include <errno.h>
-#include "fnmatch.h"
-
-#ifdef USE_CWGUSI
-#include <sys/errno.h>
-#endif
-
-#if !defined (__GNU_LIBRARY__) && !defined (STDC_HEADERS)
-# if !defined (errno)
-extern int errno;
-# endif /* !errno */
-#endif
-
-/* Match STRING against the filename pattern PATTERN, returning zero if
- it matches, FNM_NOMATCH if not. */
-int
-fnmatch (pattern, string, flags)
- char *pattern;
- char *string;
- int flags;
-{
- register char *p = pattern, *n = string;
- register char c;
-
- if ((flags & ~__FNM_FLAGS) != 0)
- {
- errno = EINVAL;
- return (-1);
- }
-
- while ((c = *p++) != '\0')
- {
- switch (c)
- {
- case '?':
- if (*n == '\0')
- return (FNM_NOMATCH);
- else if ((flags & FNM_PATHNAME) && *n == '/')
- /* If we are matching a pathname, `?' can never match a `/'. */
- return (FNM_NOMATCH);
- else if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
- /* `?' cannot match a `.' if it is the first character of the
- string or if it is the first character following a slash and
- we are matching a pathname. */
- return (FNM_NOMATCH);
- break;
-
- case '\\':
- if (!(flags & FNM_NOESCAPE))
- {
- c = *p++;
- if (c == '\0')
- return (FNM_NOMATCH);
- }
- if (*n != c)
- return (FNM_NOMATCH);
- break;
-
- case '*':
- if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
- /* `*' cannot match a `.' if it is the first character of the
- string or if it is the first character following a slash and
- we are matching a pathname. */
- return (FNM_NOMATCH);
-
- /* Collapse multiple consecutive, `*' and `?', but make sure that
- one character of the string is consumed for each `?'. */
- for (c = *p++; c == '?' || c == '*'; c = *p++)
- {
- if ((flags & FNM_PATHNAME) && *n == '/')
- /* A slash does not match a wildcard under FNM_PATHNAME. */
- return (FNM_NOMATCH);
- else if (c == '?')
- {
- if (*n == '\0')
- return (FNM_NOMATCH);
- /* One character of the string is consumed in matching
- this ? wildcard, so *??? won't match if there are
- fewer than three characters. */
- n++;
- }
- }
-
- if (c == '\0')
- return (0);
-
- /* General case, use recursion. */
- {
- char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
- for (--p; *n != '\0'; ++n)
- /* Only call fnmatch if the first character indicates a
- possible match. */
- if ((c == '[' || *n == c1) &&
- fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
- return (0);
- return (FNM_NOMATCH);
- }
-
- case '[':
- {
- /* Nonzero if the sense of the character class is inverted. */
- register int not;
-
- if (*n == '\0')
- return (FNM_NOMATCH);
-
- /* A character class cannot match a `.' if it is the first
- character of the string or if it is the first character
- following a slash and we are matching a pathname. */
- if ((flags & FNM_PERIOD) && *n == '.' &&
- (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
- return (FNM_NOMATCH);
-
- /* POSIX.2 2.8.3.1.2 says: `An expression containing a `[' that
- is not preceded by a backslash and is not part of a bracket
- expression produces undefined results.' This implementation
- treats the `[' as just a character to be matched if there is
- not a closing `]'. This code will have to be changed when
- POSIX.2 character classes are implemented. */
- {
- register char *np;
-
- for (np = p; np && *np && *np != ']'; np++)
- ;
-
- if (np && !*np)
- {
- if (*n != '[')
- return (FNM_NOMATCH);
- break;
- }
- }
-
- not = (*p == '!' || *p == '^');
- if (not)
- ++p;
-
- c = *p++;
- for (;;)
- {
- register char cstart, cend;
-
- /* Initialize cstart and cend in case `-' is the last
- character of the pattern. */
- cstart = cend = c;
-
- if (!(flags & FNM_NOESCAPE) && c == '\\')
- {
- if (*p == '\0')
- return FNM_NOMATCH;
- cstart = cend = *p++;
- }
-
- if (c == '\0')
- /* [ (unterminated) loses. */
- return (FNM_NOMATCH);
-
- c = *p++;
-
- if ((flags & FNM_PATHNAME) && c == '/')
- /* [/] can never match. */
- return (FNM_NOMATCH);
-
- /* This introduces a range, unless the `-' is the last
- character of the class. Find the end of the range
- and move past it. */
- if (c == '-' && *p != ']')
- {
- cend = *p++;
- if (!(flags & FNM_NOESCAPE) && cend == '\\')
- cend = *p++;
- if (cend == '\0')
- return (FNM_NOMATCH);
-
- c = *p++;
- }
-
- if (*n >= cstart && *n <= cend)
- goto matched;
-
- if (c == ']')
- break;
- }
- if (!not)
- return (FNM_NOMATCH);
- break;
-
- matched:
- /* Skip the rest of the [...] that already matched. */
- while (c != ']')
- {
- if (c == '\0')
- /* [... (unterminated) loses. */
- return (FNM_NOMATCH);
-
- c = *p++;
- if (!(flags & FNM_NOESCAPE) && c == '\\')
- {
- if (*p == '\0')
- return FNM_NOMATCH;
- /* XXX 1003.2d11 is unclear if this is right. */
- ++p;
- }
- }
- if (not)
- return (FNM_NOMATCH);
- }
- break;
-
- default:
- if (c != *n)
- return (FNM_NOMATCH);
- }
-
- ++n;
- }
-
- if (*n == '\0')
- return (0);
-
- return (FNM_NOMATCH);
-}
diff --git a/fnmatch.h b/fnmatch.h
deleted file mode 100644
index 62c8c8fa021..00000000000
--- a/fnmatch.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#ifndef _FNMATCH_H
-
-#define _FNMATCH_H 1
-
-/* Bits set in the FLAGS argument to `fnmatch'. */
-#define FNM_PATHNAME (1 << 0)/* No wildcard can ever match `/'. */
-#define FNM_NOESCAPE (1 << 1)/* Backslashes don't quote special chars. */
-#define FNM_PERIOD (1 << 2)/* Leading `.' is matched only explicitly. */
-#define __FNM_FLAGS (FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD)
-
-/* Value returned by `fnmatch' if STRING does not match PATTERN. */
-#define FNM_NOMATCH 1
-
-/* Match STRING against the filename pattern PATTERN,
- returning zero if it matches, FNM_NOMATCH if not. */
-extern int fnmatch();
-
-#endif /* fnmatch.h */
diff --git a/gc.c b/gc.c
index 31ed11196ac..7e2a4f70824 100644
--- a/gc.c
+++ b/gc.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Oct 5 09:44:46 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -42,14 +42,18 @@ static void run_final();
#if defined(MSDOS) || defined(__human68k__)
#define GC_MALLOC_LIMIT 100000
#else
-#define GC_MALLOC_LIMIT 200000
+#define GC_MALLOC_LIMIT 400000
#endif
#endif
-#define GC_NEWOBJ_LIMIT 1000
+#define GC_NEWOBJ_LIMIT 10000
static unsigned long malloc_memories = 0;
static unsigned long alloc_objects = 0;
+static int malloc_called = 0;
+static int free_called = 0;
+
+#ifndef xmalloc
void *
xmalloc(size)
size_t size;
@@ -64,6 +68,7 @@ xmalloc(size)
if (malloc_memories > GC_MALLOC_LIMIT && alloc_objects > GC_NEWOBJ_LIMIT) {
rb_gc();
}
+ malloc_called++;
mem = malloc(size);
if (!mem) {
rb_gc();
@@ -111,6 +116,15 @@ xrealloc(ptr, size)
return mem;
}
+static void
+xfree(x)
+ void *x;
+{
+ free_called++;
+ free(x);
+}
+#endif
+
/* The way of garbage collecting which allows use of the cstack is due to */
/* Scheme In One Defun, but in C this time.
@@ -284,7 +298,7 @@ rb_data_object_alloc(klass, datap, dmark, dfree)
}
extern st_table *rb_class_tbl;
-VALUE *rb_gc_stack_start;
+VALUE *rb_gc_stack_start = 0;
#if defined(__GNUC__) && __GNUC__ >= 2
__inline__
@@ -334,7 +348,7 @@ rb_gc_mark_locations(start, end)
start = end;
end = tmp;
}
- n = end - start;
+ n = end - start + 1;
mark_locations_array(start,n);
}
@@ -389,10 +403,10 @@ rb_gc_mark(ptr)
register RVALUE *obj = RANY(ptr);
Top:
- if (FIXNUM_P(obj)) return; /* fixnum not marked */
+ if (FIXNUM_P(obj)) return; /* fixnum not marked */
if (rb_special_const_p((VALUE)obj)) return; /* special const not marked */
- if (obj->as.basic.flags == 0) return; /* free cell */
- if (obj->as.basic.flags & FL_MARK) return; /* already marked */
+ if (obj->as.basic.flags == 0) return; /* free cell */
+ if (obj->as.basic.flags & FL_MARK) return; /* already marked */
obj->as.basic.flags |= FL_MARK;
@@ -445,7 +459,6 @@ rb_gc_mark(ptr)
case NODE_OR:
case NODE_CASE:
case NODE_SCLASS:
- case NODE_ARGS:
case NODE_DOT2:
case NODE_DOT3:
case NODE_FLIP2:
@@ -479,6 +492,7 @@ rb_gc_mark(ptr)
case NODE_RETURN:
case NODE_YIELD:
case NODE_COLON2:
+ case NODE_ARGS:
obj = RANY(obj->as.node.u1.node);
goto Top;
@@ -598,7 +612,8 @@ rb_gc_mark(ptr)
break;
case T_SCOPE:
- if (obj->as.scope.local_vars) {
+ if (obj->as.scope.local_vars &&
+ obj->as.scope.flag != SCOPE_ALLOCA) {
int n = obj->as.scope.local_tbl[0]+1;
VALUE *vars = &obj->as.scope.local_vars[-1];
@@ -660,7 +675,7 @@ gc_sweep()
if (p->as.basic.flags) {
obj_free((VALUE)p);
}
- if (need_call_final && FL_TEST(p, FL_FINALIZE)) {
+ if (need_call_final && FL_TEST(p, FL_FINALIZE)) {
p->as.free.flag = FL_MARK; /* remain marked */
p->as.free.next = final_list;
final_list = p;
@@ -769,10 +784,10 @@ obj_free(obj)
}
break;
case T_MATCH:
- if (RANY(obj)->as.match.regs)
+ if (RANY(obj)->as.match.regs) {
re_free_registers(RANY(obj)->as.match.regs);
- if (RANY(obj)->as.match.regs)
free(RANY(obj)->as.match.regs);
+ }
break;
case T_FILE:
if (RANY(obj)->as.file.fptr) {
@@ -807,7 +822,8 @@ obj_free(obj)
return; /* no need to free iv_tbl */
case T_SCOPE:
- if (RANY(obj)->as.scope.local_vars) {
+ if (RANY(obj)->as.scope.local_vars &&
+ RANY(obj)->as.scope.flag != SCOPE_ALLOCA) {
VALUE *vars = RANY(obj)->as.scope.local_vars-1;
if (vars[0] == 0)
free(RANY(obj)->as.scope.local_tbl);
@@ -890,7 +906,16 @@ rb_gc()
/* mark frame stack */
for (frame = ruby_frame; frame; frame = frame->prev) {
- rb_gc_mark_frame(frame);
+ rb_gc_mark_frame(frame);
+ }
+ for (frame = ruby_frame; frame; frame = frame->prev) {
+ if (frame->tmp) {
+ struct FRAME *tmp = frame->tmp;
+ while (tmp) {
+ rb_gc_mark_frame(tmp);
+ tmp = tmp->prev;
+ }
+ }
}
rb_gc_mark(ruby_class);
rb_gc_mark(ruby_scope);
@@ -909,10 +934,7 @@ rb_gc()
rb_gc_mark_locations((VALUE*)((char*)rb_gc_stack_start + 2),
(VALUE*)((char*)&stack_end + 2));
#endif
-
-#ifdef USE_THREAD
rb_gc_mark_threads();
-#endif
/* mark protected global variables */
for (list = Global_List; list; list = list->next) {
@@ -937,22 +959,26 @@ gc_start()
}
void
-Init_stack()
+Init_stack(addr)
+ VALUE *addr;
{
#ifdef __human68k__
extern void *_SEND;
- gc_stack_start = _SEND;
+ rb_gc_stack_start = _SEND;
#else
VALUE start;
- rb_gc_stack_start = &start;
+ if (!addr) addr = &start;
+ rb_gc_stack_start = addr;
#endif
}
void
Init_heap()
{
- Init_stack();
+ if (!rb_gc_stack_start) {
+ Init_stack(0);
+ }
add_heap();
}
@@ -1073,15 +1099,26 @@ call_final(os, obj)
return obj;
}
+static VALUE
+run_single_final(args)
+ VALUE *args;
+{
+ rb_eval_cmd(args[0], args[1]);
+ return Qnil;
+}
+
static void
run_final(obj)
VALUE obj;
{
- int i;
+ int i, status;
+ VALUE args[2];
obj = rb_obj_id(obj); /* make obj into id */
+ args[1] = rb_ary_new3(1, obj);
for (i=0; i<RARRAY(finalizers)->len; i++) {
- rb_eval_cmd(RARRAY(finalizers)->ptr[i], rb_ary_new3(1, obj));
+ args[0] = RARRAY(finalizers)->ptr[i];
+ rb_protect(run_single_final, (VALUE)args, &status);
}
}
@@ -1105,9 +1142,12 @@ rb_gc_call_finalizer_at_exit()
p = heaps[i]; pend = p + HEAP_SLOTS;
while (p < pend) {
if (BUILTIN_TYPE(p) == T_DATA &&
- DATA_PTR(p) &&
- RANY(p)->as.data.dfree)
+ DATA_PTR(p) && RANY(p)->as.data.dfree) {
(*RANY(p)->as.data.dfree)(DATA_PTR(p));
+ }
+ else if (BUILTIN_TYPE(p) == T_FILE) {
+ rb_io_fptr_finalize(RANY(p)->as.file.fptr);
+ }
p++;
}
}
diff --git a/glob.c b/glob.c
deleted file mode 100644
index 09a47e0aa4a..00000000000
--- a/glob.c
+++ /dev/null
@@ -1,591 +0,0 @@
-/* File-name wildcard pattern matching for GNU.
- Copyright (C) 1985, 1988, 1989 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* To whomever it may concern: I have never seen the code which most
- Unix programs use to perform this function. I wrote this from scratch
- based on specifications for the pattern matching. --RMS. */
-
-#include "config.h"
-
-#if !defined (__GNUC__) && !defined (HAVE_ALLOCA_H) && defined (_AIX)
- #pragma alloca
-#endif /* _AIX && RISC6000 && !__GNUC__ */
-
-#if defined (HAVE_ALLOCA_H)
-# include <alloca.h>
-#endif
-
-#if defined (HAVE_UNISTD_H)
-# include <unistd.h>
-#endif
-
-#if defined (HAVE_STDLIB_H)
-# include <stdlib.h>
-#else
-# if defined (SHELL)
-# include "ansi_stdlib.h"
-# endif /* SHELL */
-#endif
-
-#include <sys/types.h>
-
-#if defined (HAVE_DIRENT_H)
-# include <dirent.h>
-# define D_NAMLEN(d) strlen ((d)->d_name)
-#elif HAVE_DIRECT_H
-# include <direct.h>
-# define D_NAMLEN(d) strlen ((d)->d_name)
-#else /* !HAVE_DIRENT_H */
-# define D_NAMLEN(d) ((d)->d_namlen)
-# if defined (HAVE_SYS_NDIR_H)
-# include <sys/ndir.h>
-# endif
-# if defined (HAVE_SYS_DIR_H)
-# include <sys/dir.h>
-# endif /* HAVE_SYS_DIR_H */
-# if defined (HAVE_NDIR_H)
-# include <ndir.h>
-# endif
-# if !defined (dirent)
-# define dirent direct
-# endif
-#endif /* !HAVE_DIRENT_H */
-
-#if defined (_POSIX_SOURCE) || defined(DJGPP) || defined(USE_CWGUSI)
-/* Posix does not require that the d_ino field be present, and some
- systems do not provide it. */
-# define REAL_DIR_ENTRY(dp) 1
-#elif defined (__BORLANDC__)
-# define REAL_DIR_ENTRY(dp) 1
-#else
-# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
-#endif /* _POSIX_SOURCE */
-
-#if defined (HAVE_STRING_H)
-# include <string.h>
-#else /* !HAVE_STRING_H */
-# include <strings.h>
-#endif /* !HAVE_STRING_H */
-
-#if !defined (HAVE_BCOPY) && !defined (bcopy)
-# define bcopy(s, d, n) ((void) memcpy ((d), (s), (n)))
-#endif /* !HAVE_BCOPY */
-
-/* If the opendir () on your system lets you open non-directory files,
- then we consider that not robust. */
-#if defined (OPENDIR_NOT_ROBUST)
-# if defined (SHELL)
-# include "posixstat.h"
-# else /* !SHELL */
-# include <sys/stat.h>
-# endif /* !SHELL */
-#endif /* OPENDIR_NOT_ROBUST */
-
-#include "fnmatch.h"
-
-extern void *xmalloc (), *xrealloc ();
-#if !defined (HAVE_STDLIB_H)
-extern void free ();
-#endif /* !HAVE_STDLIB_H */
-
-#if !defined (NULL)
-# if defined (__STDC__)
-# define NULL ((void *) 0)
-# else
-# define NULL 0x0
-# endif /* __STDC__ */
-#endif /* !NULL */
-
-#if defined (SHELL)
-extern void throw_to_top_level ();
-
-extern int interrupt_state;
-#endif /* SHELL */
-
-#if defined(NT) && defined(_MSC_VER)
-#include "missing/dir.h"
-#endif
-
-/* Global variable which controls whether or not * matches .*.
- Non-zero means don't match .*. */
-int noglob_dot_filenames = 1;
-
-/* Global variable to return to signify an error in globbing. */
-char *glob_error_return;
-
-/* Return nonzero if PATTERN has any special globbing chars in it. */
-int
-glob_pattern_p (pattern)
- char *pattern;
-{
- register char *p = pattern;
- register char c;
- int open = 0;
-
- while ((c = *p++) != '\0')
- switch (c)
- {
- case '?':
- case '*':
- return (1);
-
- case '[': /* Only accept an open brace if there is a close */
- open++; /* brace to match it. Bracket expressions must be */
- continue; /* complete, according to Posix.2 */
- case ']':
- if (open)
- return (1);
- continue;
-
- case '\\':
- if (*p++ == '\0')
- return (0);
- }
-
- return (0);
-}
-
-/* Remove backslashes quoting characters in PATHNAME by modifying PATHNAME. */
-static void
-dequote_pathname (pathname)
- char *pathname;
-{
- register int i, j;
-
- for (i = j = 0; pathname && pathname[i]; )
- {
- if (pathname[i] == '\\')
- i++;
-
- pathname[j++] = pathname[i++];
-
- if (!pathname[i - 1])
- break;
- }
- pathname[j] = '\0';
-}
-
-
-/* Return a vector of names of files in directory DIR
- whose names match glob pattern PAT.
- The names are not in any particular order.
- Wildcards at the beginning of PAT do not match an initial period.
-
- The vector is terminated by an element that is a null pointer.
-
- To free the space allocated, first free the vector's elements,
- then free the vector.
-
- Return 0 if cannot get enough memory to hold the pointer
- and the names.
-
- Return -1 if cannot access directory DIR.
- Look in errno for more information. */
-
-char **
-glob_vector (pat, dir)
- char *pat;
- char *dir;
-{
- struct globval
- {
- struct globval *next;
- char *name;
- };
-
- DIR *d;
- register struct dirent *dp;
- struct globval *lastlink;
- register struct globval *nextlink;
- register char *nextname;
- unsigned int count;
- int lose, skip;
- register char **name_vector;
- register unsigned int i;
-#if defined (OPENDIR_NOT_ROBUST)
- struct stat finfo;
-
- if (stat (dir, &finfo) < 0)
- return ((char **) &glob_error_return);
-
- if (!S_ISDIR (finfo.st_mode))
- return ((char **) &glob_error_return);
-#endif /* OPENDIR_NOT_ROBUST */
-
- d = opendir (dir);
- if (d == NULL)
- return ((char **) &glob_error_return);
-
- lastlink = 0;
- count = 0;
- lose = 0;
- skip = 0;
-
- /* If PAT is empty, skip the loop, but return one (empty) filename. */
- if (!pat || !*pat)
- {
- nextlink = (struct globval *)alloca (sizeof (struct globval));
- nextlink->next = lastlink;
- nextname = (char *) xmalloc (1);
- if (!nextname)
- lose = 1;
- else
- {
- lastlink = nextlink;
- nextlink->name = nextname;
- nextname[0] = '\0';
- count++;
- }
- skip = 1;
- }
-
- /* Scan the directory, finding all names that match.
- For each name that matches, allocate a struct globval
- on the stack and store the name in it.
- Chain those structs together; lastlink is the front of the chain. */
- while (!skip)
- {
- int flags; /* Flags passed to fnmatch (). */
-#if defined (SHELL)
- /* Make globbing interruptible in the bash shell. */
- if (interrupt_state)
- {
- closedir (d);
- lose = 1;
- goto lost;
- }
-#endif /* SHELL */
-
- dp = readdir (d);
- if (dp == NULL)
- break;
-
- /* If this directory entry is not to be used, try again. */
- if (!REAL_DIR_ENTRY (dp))
- continue;
-
- /* If a dot must be explicity matched, check to see if they do. */
- if (noglob_dot_filenames && dp->d_name[0] == '.' && pat[0] != '.' &&
- (pat[0] != '\\' || pat[1] != '.'))
- continue;
-
- flags = (noglob_dot_filenames ? FNM_PERIOD : 0) | FNM_PATHNAME;
-
- if (fnmatch (pat, dp->d_name, flags) != FNM_NOMATCH)
- {
- nextlink = (struct globval *) alloca (sizeof (struct globval));
- nextlink->next = lastlink;
- nextname = (char *) xmalloc (D_NAMLEN (dp) + 1);
- if (nextname == NULL)
- {
- lose = 1;
- break;
- }
- lastlink = nextlink;
- nextlink->name = nextname;
- bcopy (dp->d_name, nextname, D_NAMLEN (dp) + 1);
- ++count;
- }
- }
- (void) closedir (d);
-
- if (!lose)
- {
- name_vector = (char **) xmalloc ((count + 1) * sizeof (char *));
- lose |= name_vector == NULL;
- }
-
- /* Have we run out of memory? */
-#if defined (SHELL)
- lost:
-#endif
- if (lose)
- {
- /* Here free the strings we have got. */
- while (lastlink)
- {
- free (lastlink->name);
- lastlink = lastlink->next;
- }
-#if defined (SHELL)
- if (interrupt_state)
- throw_to_top_level ();
-#endif /* SHELL */
- return (NULL);
- }
-
- /* Copy the name pointers from the linked list into the vector. */
- for (i = 0; i < count; ++i)
- {
- name_vector[i] = lastlink->name;
- lastlink = lastlink->next;
- }
-
- name_vector[count] = NULL;
- return (name_vector);
-}
-
-/* Return a new array which is the concatenation of each string in ARRAY
- to DIR. This function expects you to pass in an allocated ARRAY, and
- it takes care of free()ing that array. Thus, you might think of this
- function as side-effecting ARRAY. */
-static char **
-glob_dir_to_array (dir, array)
- char *dir, **array;
-{
- register unsigned int i, l;
- int add_slash;
- char **result;
-
- l = strlen (dir);
- if (l == 0)
- return (array);
-
- add_slash = dir[l - 1] != '/';
-
- i = 0;
- while (array[i] != NULL)
- ++i;
-
- result = (char **) xmalloc ((i + 1) * sizeof (char *));
- if (result == NULL)
- return (NULL);
-
- for (i = 0; array[i] != NULL; i++)
- {
- result[i] = (char *) xmalloc (l + (add_slash ? 1 : 0)
- + strlen (array[i]) + 1);
- if (result[i] == NULL)
- return (NULL);
-#if 1
- strcpy (result[i], dir);
- if (add_slash)
- result[i][l] = '/';
- strcpy (result[i] + l + add_slash, array[i]);
-#else
- (void)sprintf (result[i], "%s%s%s", dir, add_slash ? "/" : "", array[i]);
-#endif
- }
- result[i] = NULL;
-
- /* Free the input array. */
- for (i = 0; array[i] != NULL; i++)
- free (array[i]);
- free ((char *) array);
-
- return (result);
-}
-
-/* Do globbing on PATHNAME. Return an array of pathnames that match,
- marking the end of the array with a null-pointer as an element.
- If no pathnames match, then the array is empty (first element is null).
- If there isn't enough memory, then return NULL.
- If a file system error occurs, return -1; `errno' has the error code. */
-char **
-glob_filename (pathname)
- char *pathname;
-{
-#ifndef strrchr
- char *strrchr();
-#endif
-
- char **result;
- unsigned int result_size;
- char *directory_name, *filename;
- unsigned int directory_len;
-
- result = (char **) xmalloc (sizeof (char *));
- result_size = 1;
- if (result == NULL)
- return (NULL);
-
- result[0] = NULL;
-
- /* Find the filename. */
- filename = strrchr (pathname, '/');
- if (filename == NULL)
- {
- filename = pathname;
- directory_name = "";
- directory_len = 0;
- }
- else
- {
- directory_len = (filename - pathname) + 1;
- directory_name = (char *) alloca (directory_len + 1);
-
- bcopy (pathname, directory_name, directory_len);
- directory_name[directory_len] = '\0';
- ++filename;
- }
-
- /* If directory_name contains globbing characters, then we
- have to expand the previous levels. Just recurse. */
- if (glob_pattern_p (directory_name))
- {
- char **directories;
- register unsigned int i;
-
- if (directory_name[directory_len - 1] == '/')
- directory_name[directory_len - 1] = '\0';
-
- directories = glob_filename (directory_name);
-
- if (directories == NULL)
- goto memory_error;
- else if (directories == (char **)&glob_error_return)
- {
- free ((char *) result);
- return ((char **) &glob_error_return);
- }
- else if (*directories == NULL)
- {
- free ((char *) directories);
- free ((char *) result);
- return ((char **) &glob_error_return);
- }
-
- /* We have successfully globbed the preceding directory name.
- For each name in DIRECTORIES, call glob_vector on it and
- FILENAME. Concatenate the results together. */
- for (i = 0; directories[i] != NULL; ++i)
- {
- char **temp_results;
-
- /* Scan directory even on a NULL pathname. That way, `*h/'
- returns only directories ending in `h', instead of all
- files ending in `h' with a `/' appended. */
- temp_results = glob_vector (filename, directories[i]);
-
- /* Handle error cases. */
- if (temp_results == NULL)
- goto memory_error;
- else if (temp_results == (char **)&glob_error_return)
- /* This filename is probably not a directory. Ignore it. */
- ;
- else
- {
- char **array;
- register unsigned int l;
-
- array = glob_dir_to_array (directories[i], temp_results);
- l = 0;
- while (array[l] != NULL)
- ++l;
-
- result =
- (char **)xrealloc(result, (result_size + l) * sizeof (char *));
-
- if (result == NULL)
- goto memory_error;
-
- for (l = 0; array[l] != NULL; ++l)
- result[result_size++ - 1] = array[l];
-
- result[result_size - 1] = NULL;
-
- /* Note that the elements of ARRAY are not freed. */
- free ((char *) array);
- }
- }
- /* Free the directories. */
- for (i = 0; directories[i]; i++)
- free (directories[i]);
-
- free ((char *) directories);
-
- return (result);
- }
-
- /* If there is only a directory name, return it. */
- if (*filename == '\0')
- {
- result = (char **) xrealloc ((char *) result, 2 * sizeof (char *));
- if (result == NULL)
- return (NULL);
- result[0] = (char *) xmalloc (directory_len + 1);
- if (result[0] == NULL)
- goto memory_error;
- bcopy (directory_name, result[0], directory_len + 1);
- result[1] = NULL;
- return (result);
- }
- else
- {
- char **temp_results;
-
- /* There are no unquoted globbing characters in DIRECTORY_NAME.
- Dequote it before we try to open the directory since there may
- be quoted globbing characters which should be treated verbatim. */
- if (directory_len > 0)
- dequote_pathname (directory_name);
-
- /* We allocated a small array called RESULT, which we won't be using.
- Free that memory now. */
- free (result);
-
- /* Just return what glob_vector () returns appended to the
- directory name. */
- temp_results =
- glob_vector (filename, (directory_len == 0 ? "." : directory_name));
-
- if (temp_results == NULL || temp_results == (char **)&glob_error_return)
- return (temp_results);
-
- return (glob_dir_to_array (directory_name, temp_results));
- }
-
- /* We get to memory_error if the program has run out of memory, or
- if this is the shell, and we have been interrupted. */
- memory_error:
- if (result != NULL)
- {
- register unsigned int i;
- for (i = 0; result[i] != NULL; ++i)
- free (result[i]);
- free ((char *) result);
- }
-#if defined (SHELL)
- if (interrupt_state)
- throw_to_top_level ();
-#endif /* SHELL */
- return (NULL);
-}
-
-#if defined (TEST)
-
-main (argc, argv)
- int argc;
- char **argv;
-{
- unsigned int i;
-
- for (i = 1; i < argc; ++i)
- {
- char **value = glob_filename (argv[i]);
- if (value == NULL)
- puts ("Out of memory.");
- else if (value == &glob_error_return)
- perror (argv[i]);
- else
- for (i = 0; value[i] != NULL; i++)
- puts (value[i]);
- }
-
- exit (0);
-}
-#endif /* TEST. */
diff --git a/hash.c b/hash.c
index 9141406410d..608f85d72f0 100644
--- a/hash.c
+++ b/hash.c
@@ -6,12 +6,13 @@
$Date$
created at: Mon Nov 22 18:51:18 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
#include "ruby.h"
#include "st.h"
+#include "util.h"
#include "rubysig.h"
#include <sys/types.h>
@@ -21,6 +22,10 @@
char *strchr _((char*,char));
#endif
+#ifdef USE_CWGUSI
+char* strdup(const char*);
+#endif
+
#define HASH_FREEZE FL_USER1
#define HASH_DELETED FL_USER2
@@ -30,7 +35,7 @@ rb_hash_modify(hash)
{
if (FL_TEST(hash, HASH_FREEZE))
rb_raise(rb_eTypeError, "can't modify frozen hash");
- if (rb_safe_level() >= 4 && !FL_TEST(hash, FL_TAINT))
+ if (!FL_TEST(hash, FL_TAINT) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify hash");
}
@@ -63,6 +68,13 @@ rb_hash(obj)
return rb_funcall(obj, hash, 0);
}
+static VALUE
+eql(args)
+ VALUE *args;
+{
+ return (VALUE)rb_eql(args[0], args[1]);
+}
+
static int
rb_any_cmp(a, b)
VALUE a, b;
@@ -73,11 +85,13 @@ rb_any_cmp(a, b)
else if (TYPE(a) == T_STRING) {
if (TYPE(b) == T_STRING) return rb_str_cmp(a, b);
}
+ else {
+ VALUE args[2];
- DEFER_INTS;
- a = !rb_eql(a, b);
- ENABLE_INTS;
- return a;
+ args[0] = a;
+ args[1] = b;
+ return !rb_with_disable_interrupt(eql, (VALUE)args);
+ }
}
static int
@@ -127,7 +141,7 @@ rb_hash_foreach_iter(key, value, arg)
st_table *tbl = RHASH(arg->hash)->tbl;
struct st_table_entry **bins = tbl->bins;
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
status = (*arg->func)(key, value, arg->arg);
if (RHASH(arg->hash)->tbl != tbl || RHASH(arg->hash)->tbl->bins != bins){
rb_raise(rb_eIndexError, "rehash occurred during iteration");
@@ -143,14 +157,6 @@ rb_hash_foreach_call(arg)
return Qnil;
}
-static int
-rb_hash_delete_nil(key, value)
- VALUE key, value;
-{
- if (value == Qnil) return ST_DELETE;
- return ST_CONTINUE;
-}
-
static VALUE
rb_hash_foreach_ensure(hash)
VALUE hash;
@@ -159,7 +165,7 @@ rb_hash_foreach_ensure(hash)
if (RHASH(hash)->iter_lev == 0) {
if (FL_TEST(hash, HASH_DELETED)) {
- st_foreach(RHASH(hash)->tbl, rb_hash_delete_nil, 0);
+ st_cleanup_safe(RHASH(hash)->tbl, Qnil);
FL_UNSET(hash, HASH_DELETED);
}
}
@@ -187,8 +193,7 @@ rb_hash_s_new(argc, argv, klass)
VALUE *argv;
VALUE klass;
{
- VALUE sz, ifnone;
- int size;
+ VALUE ifnone;
NEWOBJ(hash, struct RHash);
OBJSETUP(hash, klass, T_HASH);
@@ -197,15 +202,10 @@ rb_hash_s_new(argc, argv, klass)
hash->ifnone = Qnil;
hash->tbl = 0; /* avoid GC crashing */
- rb_scan_args(argc, argv, "02", &ifnone, &sz);
- if (NIL_P(sz)) {
- size = 0;
- }
- else size = NUM2INT(sz);
+ rb_scan_args(argc, argv, "01", &ifnone);
hash->ifnone = ifnone;
- hash->tbl = st_init_table_with_size(&objhash, size);
- rb_obj_call_init((VALUE)hash);
+ hash->tbl = st_init_table(&objhash);
return (VALUE)hash;
}
@@ -240,19 +240,22 @@ rb_hash_s_create(argc, argv, klass)
VALUE hash;
int i;
- if (argc == 1 && TYPE(argv[0]) == T_HASH) {
- if (klass == CLASS_OF(argv[0])) return argv[0];
- else {
+ if (argc == 1) {
+ if (TYPE(argv[0]) == T_HASH) {
NEWOBJ(hash, struct RHash);
OBJSETUP(hash, klass, T_HASH);
hash->iter_lev = 0;
hash->ifnone = Qnil;
hash->tbl = 0; /* avoid GC crashing */
- hash->tbl = (st_table*)st_copy(RHASH(argv[0])->tbl);
- rb_obj_call_init((VALUE)hash);
+ hash->tbl = st_copy(RHASH(argv[0])->tbl);
+
return (VALUE)hash;
}
+ else {
+ VALUE a = rb_Array(argv[0]);
+ return rb_hash_s_create(RARRAY(a)->len, RARRAY(a)->ptr, klass);
+ }
}
if (argc % 2 != 0) {
@@ -263,7 +266,6 @@ rb_hash_s_create(argc, argv, klass)
for (i=0; i<argc; i+=2) {
st_insert(RHASH(hash)->tbl, argv[i], argv[i+1]);
}
- rb_obj_call_init(hash);
return hash;
}
@@ -380,6 +382,32 @@ rb_hash_set_default(hash, ifnone)
return hash;
}
+static int
+index_i(key, value, args)
+ VALUE key, value;
+ VALUE *args;
+{
+ if (rb_equal(value, args[0])) {
+ args[1] = key;
+ return ST_STOP;
+ }
+ return ST_CONTINUE;
+}
+
+static VALUE
+rb_hash_index(hash, value)
+ VALUE hash, value;
+{
+ VALUE args[2];
+
+ args[0] = value;
+ args[1] = Qnil;
+
+ st_foreach(RHASH(hash)->tbl, index_i, args);
+
+ return args[1];
+}
+
static VALUE
rb_hash_indexes(argc, argv, hash)
int argc;
@@ -428,7 +456,7 @@ shift_i(key, value, var)
VALUE key, value;
struct shift_var *var;
{
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
if (var->stop) return ST_STOP;
var->stop = 1;
var->key = key;
@@ -454,8 +482,8 @@ static int
delete_if_i(key, value)
VALUE key, value;
{
- if (key == Qnil) return ST_CONTINUE;
- if (rb_yield(rb_assoc_new(key, value)))
+ if (value == Qnil) return ST_CONTINUE;
+ if (RTEST(rb_yield(rb_assoc_new(key, value))))
return ST_DELETE;
return ST_CONTINUE;
}
@@ -471,8 +499,8 @@ rb_hash_delete_if(hash)
}
static int
-clear_i(key, value)
- VALUE key, value;
+clear_i(key, value, dummy)
+ VALUE key, value, dummy;
{
return ST_DELETE;
}
@@ -482,7 +510,7 @@ rb_hash_clear(hash)
VALUE hash;
{
rb_hash_modify(hash);
- st_foreach(RHASH(hash)->tbl, clear_i);
+ st_foreach(RHASH(hash)->tbl, clear_i, 0);
return hash;
}
@@ -500,7 +528,7 @@ rb_hash_aset(hash, key, val)
st_insert(RHASH(hash)->tbl, key, val);
}
else {
- st_add_direct(RHASH(hash)->tbl, rb_str_dup_frozen(key), val);
+ st_add_direct(RHASH(hash)->tbl, rb_str_new4(key), val);
}
return val;
}
@@ -544,7 +572,7 @@ static int
each_value_i(key, value)
VALUE key, value;
{
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
rb_yield(value);
return ST_CONTINUE;
}
@@ -561,7 +589,7 @@ static int
each_key_i(key, value)
VALUE key, value;
{
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
rb_yield(key);
return ST_CONTINUE;
}
@@ -578,7 +606,7 @@ static int
each_pair_i(key, value)
VALUE key, value;
{
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
rb_yield(rb_assoc_new(key, value));
return ST_CONTINUE;
}
@@ -595,7 +623,7 @@ static int
to_a_i(key, value, ary)
VALUE key, value, ary;
{
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
rb_ary_push(ary, rb_assoc_new(key, value));
return ST_CONTINUE;
}
@@ -625,7 +653,7 @@ inspect_i(key, value, str)
{
VALUE str2;
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
if (RSTRING(str)->len > 1) {
rb_str_cat(str, ", ", 2);
}
@@ -687,7 +715,7 @@ static int
keys_i(key, value, ary)
VALUE key, value, ary;
{
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
rb_ary_push(ary, key);
return ST_CONTINUE;
}
@@ -708,7 +736,7 @@ static int
values_i(key, value, ary)
VALUE key, value, ary;
{
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
rb_ary_push(ary, value);
return ST_CONTINUE;
}
@@ -740,7 +768,7 @@ static int
rb_hash_search_value(key, value, data)
VALUE key, value, *data;
{
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
if (rb_equal(value, data[1])) {
data[0] = Qtrue;
return ST_STOP;
@@ -773,7 +801,7 @@ equal_i(key, val1, data)
{
VALUE val2;
- if (key == Qnil) return ST_CONTINUE;
+ if (val1 == Qnil) return ST_CONTINUE;
if (!st_lookup(data->tbl, key, &val2)) {
data->result = Qfalse;
return ST_STOP;
@@ -807,7 +835,7 @@ rb_hash_invert_i(key, value, hash)
VALUE key, value;
VALUE hash;
{
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
rb_hash_aset(hash, value, key);
return ST_CONTINUE;
}
@@ -827,7 +855,7 @@ rb_hash_update_i(key, value, hash)
VALUE key, value;
VALUE hash;
{
- if (key == Qnil) return ST_CONTINUE;
+ if (value == Qnil) return ST_CONTINUE;
rb_hash_aset(hash, key, value);
return ST_CONTINUE;
}
@@ -841,7 +869,6 @@ rb_hash_update(hash1, hash2)
return hash1;
}
-#ifndef __MACOS__ /* no environment variables on MacOS. */
static int path_tainted = -1;
#ifndef NT
@@ -853,24 +880,20 @@ static VALUE
env_delete(obj, name)
VALUE obj, name;
{
- int i, len;
- char *nam, *val = 0;
+ int len;
+ char *nam, *val;
rb_secure(4);
- nam = STR2CSTR(name);
- if (strcmp(nam, "PATH") == 0) path_tainted = 0;
- len = strlen(nam);
- for(i=0; environ[i]; i++) {
- if (strncmp(environ[i], nam, len) == 0 && environ[i][len] == '=') {
- val = environ[i]+len+1;
- break;
- }
- }
- while (environ[i]) {
- environ[i] = environ[i+1];
- i++;
+ nam = str2cstr(name, &len);
+ if (strlen(nam) != len) {
+ rb_raise(rb_eArgError, "bad environment variable name");
}
+ val = getenv(nam);
if (val) {
+ ruby_setenv(nam, 0);
+ if (strcmp(nam, "PATH") == 0 && !OBJ_TAINTED(name)) {
+ path_tainted = 0;
+ }
return rb_str_new2(val);
}
return Qnil;
@@ -894,7 +917,7 @@ rb_f_getenv(obj, name)
nam = str2cstr(name, &len);
if (strlen(nam) != len) {
- rb_raise(rb_eArgError, "Bad environment variable name");
+ rb_raise(rb_eArgError, "bad environment variable name");
}
env = getenv(nam);
if (env) {
@@ -930,7 +953,7 @@ rb_path_check(path)
char *path;
{
char *p, *pend;
- const char sep = RUBY_PATH_SEP[0];
+ const char sep = PATH_SEP_CHAR;
if (!path) return 1;
@@ -988,12 +1011,12 @@ char *nam;
return i;
}
-static void
-my_setenv(name, value)
- char *name;
- char *value;
+void
+ruby_setenv(name, value)
+ const char *name;
+ const char *value;
{
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN32__)
#ifdef USE_WIN32_RTL_ENV
register char *envstr;
STRLEN namlen = strlen(name);
@@ -1049,9 +1072,16 @@ my_setenv(name, value)
SetEnvironmentVariable(name,value);
#endif
+#elif defined __CYGWIN__
+#undef setenv
+#undef unsetenv
+ if (value)
+ setenv(name,value,1);
+ else
+ unsetenv(name);
#else /* WIN32 */
- register int i=envix(name); /* where does it go? */
+ int i=envix(name); /* where does it go? */
if (environ == origenviron) { /* need we copy environment? */
int j;
@@ -1066,6 +1096,7 @@ my_setenv(name, value)
environ = tmpenv; /* tell exec where it is now */
}
if (!value) {
+ free(environ[i]);
while (environ[i]) {
environ[i] = environ[i+1];
i++;
@@ -1095,6 +1126,13 @@ my_setenv(name, value)
#endif /* WIN32 */
}
+void
+ruby_unsetenv(name)
+ const char *name;
+{
+ ruby_setenv(name, 0);
+}
+
static VALUE
rb_f_setenv(obj, nm, val)
VALUE obj, nm, val;
@@ -1112,13 +1150,13 @@ rb_f_setenv(obj, nm, val)
}
name = str2cstr(nm, &nlen);
- value = STR2CSTR(val &vlen);
+ value = str2cstr(val, &vlen);
if (strlen(name) != nlen)
- rb_raise(rb_eArgError, "Bad environment name");
+ rb_raise(rb_eArgError, "bad environment variable name");
if (strlen(value) != vlen)
- rb_raise(rb_eArgError, "Bad environment value");
+ rb_raise(rb_eArgError, "bad environment variable value");
- my_setenv(name, value);
+ ruby_setenv(name, value);
if (strcmp(name, "PATH") == 0) {
if (OBJ_TAINTED(val)) {
/* already tainted, no check */
@@ -1303,10 +1341,8 @@ env_has_value(dmy, value)
VALUE dmy, value;
{
char **env;
- volatile VALUE ary;
if (TYPE(value) != T_STRING) return Qfalse;
- ary = rb_ary_new();
env = environ;
while (*env) {
char *s = strchr(*env, '=')+1;
@@ -1320,6 +1356,26 @@ env_has_value(dmy, value)
}
static VALUE
+env_index(dmy, value)
+ VALUE dmy, value;
+{
+ char **env;
+
+ if (TYPE(value) != T_STRING) return Qnil;
+ env = environ;
+ while (*env) {
+ char *s = strchr(*env, '=')+1;
+ if (s) {
+ if (strncmp(s, RSTRING(value)->ptr, strlen(s)) == 0) {
+ return rb_tainted_str_new(*env, s-*env);
+ }
+ }
+ env++;
+ }
+ return Qnil;
+}
+
+static VALUE
env_indexes(argc, argv)
int argc;
VALUE *argv;
@@ -1363,8 +1419,6 @@ env_to_hash(obj)
return hash;
}
-#endif /* ifndef __MACOS__ no environment variables on MacOS. */
-
void
Init_Hash()
{
@@ -1396,6 +1450,7 @@ Init_Hash()
rb_define_method(rb_cHash,"store", rb_hash_aset, 2);
rb_define_method(rb_cHash,"default", rb_hash_default, 0);
rb_define_method(rb_cHash,"default=", rb_hash_set_default, 1);
+ rb_define_method(rb_cHash,"index", rb_hash_index, 1);
rb_define_method(rb_cHash,"indexes", rb_hash_indexes, -1);
rb_define_method(rb_cHash,"indices", rb_hash_indexes, -1);
rb_define_method(rb_cHash,"length", rb_hash_length, 0);
@@ -1414,12 +1469,14 @@ Init_Hash()
rb_define_method(rb_cHash,"shift", rb_hash_shift, 0);
rb_define_method(rb_cHash,"delete", rb_hash_delete, 1);
rb_define_method(rb_cHash,"delete_if", rb_hash_delete_if, 0);
+ rb_define_method(rb_cHash,"reject!", rb_hash_delete_if, 0);
rb_define_method(rb_cHash,"clear", rb_hash_clear, 0);
rb_define_method(rb_cHash,"invert", rb_hash_invert, 0);
rb_define_method(rb_cHash,"update", rb_hash_update, 1);
rb_define_method(rb_cHash,"replace", rb_hash_replace, 1);
rb_define_method(rb_cHash,"include?", rb_hash_has_key, 1);
+ rb_define_method(rb_cHash,"member?", rb_hash_has_key, 1);
rb_define_method(rb_cHash,"has_key?", rb_hash_has_key, 1);
rb_define_method(rb_cHash,"has_value?", rb_hash_has_value, 1);
rb_define_method(rb_cHash,"key?", rb_hash_has_key, 1);
@@ -1438,9 +1495,11 @@ Init_Hash()
rb_define_singleton_method(envtbl,"each_value", env_each_value, 0);
rb_define_singleton_method(envtbl,"delete", env_delete_method, 1);
rb_define_singleton_method(envtbl,"delete_if", env_delete_if, 0);
+ rb_define_singleton_method(envtbl,"reject!", env_delete_if, 0);
rb_define_singleton_method(envtbl,"to_s", env_to_s, 0);
rb_define_singleton_method(envtbl,"rehash", env_none, 0);
rb_define_singleton_method(envtbl,"to_a", env_to_a, 0);
+ rb_define_singleton_method(envtbl,"index", env_index, 1);
rb_define_singleton_method(envtbl,"indexes", env_indexes, -1);
rb_define_singleton_method(envtbl,"indices", env_indexes, -1);
rb_define_singleton_method(envtbl,"length", env_size, 0);
@@ -1448,6 +1507,7 @@ Init_Hash()
rb_define_singleton_method(envtbl,"keys", env_keys, 0);
rb_define_singleton_method(envtbl,"values", env_values, 0);
rb_define_singleton_method(envtbl,"include?", env_has_key, 1);
+ rb_define_singleton_method(envtbl,"member?", env_has_key, 1);
rb_define_singleton_method(envtbl,"has_key?", env_has_key, 1);
rb_define_singleton_method(envtbl,"has_value?", env_has_value, 1);
rb_define_singleton_method(envtbl,"key?", env_has_key, 1);
diff --git a/inits.c b/inits.c
index 3708edc03a5..fdc49f0f4b6 100644
--- a/inits.c
+++ b/inits.c
@@ -6,7 +6,7 @@
$Date$
created at: Tue Dec 28 16:01:58 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -31,6 +31,7 @@ void Init_marshal _((void));
void Init_Numeric _((void));
void Init_Object _((void));
void Init_pack _((void));
+void Init_Precision _((void));
void Init_sym _((void));
void Init_process _((void));
void Init_Random _((void));
@@ -51,12 +52,11 @@ rb_call_inits()
Init_Object();
Init_Comparable();
Init_Enumerable();
+ Init_Precision();
Init_eval();
Init_String();
Init_Exception();
-#ifdef USE_THREAD
Init_Thread();
-#endif
Init_Numeric();
Init_Bignum();
Init_Array();
diff --git a/install-sh b/install-sh
index 89fc9b098b8..e69de29bb2d 100644
--- a/install-sh
+++ b/install-sh
@@ -1,238 +0,0 @@
-#! /bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-tranformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
diff --git a/instruby.rb b/instruby.rb
index d489e0f838a..52c7c2397f0 100644
--- a/instruby.rb
+++ b/instruby.rb
@@ -7,51 +7,85 @@ destdir = ARGV[0] || ''
$:.unshift CONFIG["srcdir"]+"/lib"
require "ftools"
+require "find"
-binsuffix = CONFIG["binsuffix"]
+exeext = CONFIG["EXEEXT"]
if ENV["prefix"]
prefix = ENV["prefix"]
else
prefix = CONFIG["prefix"]
end
ruby_install_name = CONFIG["ruby_install_name"]
-bindir = CONFIG["bindir"]
-libdir = CONFIG["libdir"]
-pkglibdir = libdir + "/" + ruby_install_name
+bindir = destdir+CONFIG["bindir"]
+libdir = destdir+CONFIG["libdir"]
+#pkglibdir = libdir + "/" + ruby_install_name+"/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
+pkglibdir = libdir + "/ruby/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
archdir = pkglibdir + "/" + CONFIG["arch"]
-mandir = CONFIG["mandir"] + "/man1"
+mandir = destdir+CONFIG["mandir"] + "/man1"
wdir = Dir.getwd
-File.makedirs "#{destdir}#{bindir}", true
-File.install "ruby#{binsuffix}",
- "#{destdir}#{bindir}/#{ruby_install_name}#{binsuffix}", 0755, true
+File.makedirs bindir, true
+File.install ruby_install_name+exeext,
+ "#{bindir}/#{ruby_install_name}#{exeext}", 0755, true
for dll in Dir['*.dll']
- File.install dll, "#{destdir}#{bindir}/#{dll}", 0755, true
+ File.install dll, "#{bindir}/#{dll}", 0755, true
end
-File.makedirs "#{destdir}#{libdir}", true
-for lib in ["libruby.so", "libruby.so.LIB"]
+File.makedirs libdir, true
+for lib in ["libruby.so.LIB", CONFIG["LIBRUBY_SO"]]
if File.exist? lib
- File.install lib, "#{destdir}#{libdir}", 0644, true
+ File.install lib, libdir, 0555, true
end
end
-File.makedirs "#{destdir}#{pkglibdir}", true
-File.makedirs "#{destdir}#{archdir}", true
+Dir.chdir libdir
+if File.exist? CONFIG["LIBRUBY_SO"]
+ for link in CONFIG["LIBRUBY_ALIASES"].split
+ if File.exist? link
+ File.delete link
+ end
+ File.symlink CONFIG["LIBRUBY_SO"], link
+ print "link #{CONFIG['LIBRUBY_SO']} -> #{link}\n"
+ end
+end
+Dir.chdir wdir
+File.makedirs pkglibdir, true
+File.makedirs archdir, true
+File.makedirs pkglibdir+"/site_ruby", true
+File.makedirs pkglibdir+"/site_ruby/"+CONFIG["arch"], true
+
+if RUBY_PLATFORM =~ /cygwin/ and File.exist? "import.h"
+ File.install "import.h", archdir, 0644, true
+end
+
+if RUBY_PLATFORM =~ /-aix/
+ File.install "ruby.imp", archdir, 0644, true
+end
+
Dir.chdir "ext"
-system "../miniruby#{binsuffix} extmk.rb install #{destdir}"
+system "../miniruby#{exeext} extmk.rb install #{destdir}"
Dir.chdir CONFIG["srcdir"]
-for f in Dir["lib/*.rb"]
- File.install f, "#{destdir}#{pkglibdir}", 0644, true
+
+Find.find("lib") do |f|
+ next unless /\.rb$/ =~ f
+ dir = pkglibdir+"/"+File.dirname(f[4..-1])
+ File.makedirs dir, true unless File.directory? dir
+ File.install f, dir, 0644, true
end
-File.makedirs(archdir,true)
for f in Dir["*.h"]
- File.install f, "#{destdir}#{archdir}", 0644, true
+ File.install f, archdir, 0644, true
+end
+if RUBY_PLATFORM =~ /mswin32/
+ File.makedirs archdir + "/win32", true
+ File.install "win32/win32.h", archdir + "/win32", 0644, true
+ if File.exist? wdir+'/rubymw.lib'
+ File.install wdir+'/rubymw.lib', archdir, 0644, true
+ end
end
-File.install "libruby.a", "#{destdir}#{archdir}", 0644, true
+File.install wdir+'/'+CONFIG['LIBRUBY_A'], archdir, 0644, true
-File.makedirs "#{destdir}#{mandir}", true
-File.install "ruby.1", "#{destdir}#{mandir}", 0644, true
+File.makedirs mandir, true
+File.install "ruby.1", mandir, 0644, true
Dir.chdir wdir
-File.install "config.h", "#{destdir}#{archdir}", 0644, true
-File.install "rbconfig.rb", "#{destdir}#{archdir}", 0644, true
+File.install "config.h", archdir, 0644, true
+File.install "rbconfig.rb", archdir, 0644, true
# vi:set sw=2:
diff --git a/intern.h b/intern.h
index 8b88751469c..4bfefa2fd11 100644
--- a/intern.h
+++ b/intern.h
@@ -6,18 +6,18 @@
void rb_mem_clear _((register VALUE*, register size_t));
VALUE rb_assoc_new _((VALUE, VALUE));
VALUE rb_ary_new _((void));
-VALUE rb_ary_new2 _((size_t));
-VALUE rb_ary_new3 __((size_t,...));
-VALUE rb_ary_new4 _((size_t, VALUE *));
+VALUE rb_ary_new2 _((long));
+VALUE rb_ary_new3 __((long,...));
+VALUE rb_ary_new4 _((long, VALUE *));
VALUE rb_ary_freeze _((VALUE));
VALUE rb_ary_aref _((int, VALUE*, VALUE));
-void rb_ary_store _((VALUE, size_t, VALUE));
+void rb_ary_store _((VALUE, long, VALUE));
VALUE rb_ary_to_s _((VALUE));
VALUE rb_ary_push _((VALUE, VALUE));
VALUE rb_ary_pop _((VALUE));
VALUE rb_ary_shift _((VALUE));
VALUE rb_ary_unshift _((VALUE, VALUE));
-VALUE rb_ary_entry _((VALUE, size_t));
+VALUE rb_ary_entry _((VALUE, long));
VALUE rb_ary_each _((VALUE));
VALUE rb_ary_join _((VALUE, VALUE));
VALUE rb_ary_print_on _((VALUE, VALUE));
@@ -41,7 +41,7 @@ VALUE rb_uint2big _((unsigned long));
VALUE rb_int2big _((long));
VALUE rb_uint2inum _((unsigned long));
VALUE rb_int2inum _((long));
-VALUE rb_str2inum _((char*, int));
+VALUE rb_str2inum _((const char*, int));
VALUE rb_big2str _((VALUE, int));
long rb_big2long _((VALUE));
#define rb_big2int(x) rb_big2long(x)
@@ -73,28 +73,28 @@ VALUE rb_class_protected_instance_methods _((int, VALUE*, VALUE));
VALUE rb_class_private_instance_methods _((int, VALUE*, VALUE));
VALUE rb_obj_singleton_methods _((VALUE));
void rb_define_method_id _((VALUE, ID, VALUE (*)(), int));
-void rb_undef_method _((VALUE, char*));
-void rb_define_protected_method _((VALUE, char*, VALUE (*)(), int));
-void rb_define_private_method _((VALUE, char*, VALUE (*)(), int));
-void rb_define_singleton_method _((VALUE,char*,VALUE(*)(),int));
-void rb_define_private_method _((VALUE,char*,VALUE(*)(),int));
+void rb_undef_method _((VALUE, const char*));
+void rb_define_protected_method _((VALUE, const char*, VALUE (*)(), int));
+void rb_define_private_method _((VALUE, const char*, VALUE (*)(), int));
+void rb_define_singleton_method _((VALUE,const char*,VALUE(*)(),int));
+void rb_define_private_method _((VALUE,const char*,VALUE(*)(),int));
VALUE rb_singleton_class _((VALUE));
/* enum.c */
VALUE rb_enum_length _((VALUE));
/* error.c */
extern int ruby_nerrs;
-VALUE rb_exc_new _((VALUE, char*, int));
-VALUE rb_exc_new2 _((VALUE, char*));
+VALUE rb_exc_new _((VALUE, const char*, long));
+VALUE rb_exc_new2 _((VALUE, const char*));
VALUE rb_exc_new3 _((VALUE, VALUE));
-void rb_loaderror __((char*, ...)) NORETURN;
-void rb_compile_error __((char*, ...));
-void rb_compile_error_append __((char*, ...));
+void rb_loaderror __((const char*, ...)) NORETURN;
+void rb_compile_error __((const char*, ...));
+void rb_compile_error_append __((const char*, ...));
/* eval.c */
void rb_exc_raise _((VALUE)) NORETURN;
void rb_exc_fatal _((VALUE)) NORETURN;
-void rb_remove_method _((VALUE, char*));
-void rb_disable_super _((VALUE, char*));
-void rb_enable_super _((VALUE, char*));
+void rb_remove_method _((VALUE, const char*));
+void rb_disable_super _((VALUE, const char*));
+void rb_enable_super _((VALUE, const char*));
void rb_clear_cache _((void));
void rb_alias _((VALUE, ID, ID));
void rb_attr _((VALUE,ID,int,int,int));
@@ -104,37 +104,41 @@ VALUE rb_dvar_ref _((ID));
void rb_dvar_asgn _((ID, VALUE));
void rb_dvar_push _((ID, VALUE));
VALUE rb_eval_cmd _((VALUE, VALUE));
-VALUE rb_trap_eval _((VALUE, int));
int rb_respond_to _((VALUE, ID));
void rb_interrupt _((void));
VALUE rb_apply _((VALUE, ID, VALUE));
-VALUE rb_funcall2 _((VALUE, ID, int, VALUE*));
void rb_backtrace _((void));
ID rb_frame_last_func _((void));
VALUE rb_obj_instance_eval _((int, VALUE*, VALUE));
void rb_load _((VALUE, int));
void rb_load_protect _((VALUE, int, int*));
void rb_jump_tag _((int)) NORETURN;
-void rb_provide _((char*));
+void rb_provide _((const char*));
VALUE rb_f_require _((VALUE, VALUE));
-void rb_obj_call_init _((VALUE));
+void rb_obj_call_init _((VALUE, int, VALUE*));
VALUE rb_class_new_instance _((int, VALUE*, VALUE));
VALUE rb_f_lambda _((void));
VALUE rb_protect _((VALUE (*)(), VALUE, int*));
void rb_set_end_proc _((void (*)(), VALUE));
+void rb_exec_end_proc _((void));
void rb_gc_mark_threads _((void));
void rb_thread_start_timer _((void));
void rb_thread_stop_timer _((void));
void rb_thread_schedule _((void));
void rb_thread_wait_fd _((int));
-void rb_thread_fd_writable _((int));
+int rb_thread_fd_writable _((int));
+void rb_thread_fd_close _((int));
int rb_thread_alone _((void));
void rb_thread_sleep _((int));
void rb_thread_sleep_forever _((void));
+VALUE rb_thread_stop _((void));
+VALUE rb_thread_wakeup _((VALUE));
+VALUE rb_thread_run _((VALUE));
VALUE rb_thread_create _((VALUE (*)(), void*));
int rb_thread_scope_shared_p _((void));
void rb_thread_interrupt _((void));
void rb_thread_trap_eval _((VALUE, int));
+void rb_thread_signal_raise _((char*));
int rb_thread_select();
void rb_thread_wait_for();
VALUE rb_thread_current _((void));
@@ -142,9 +146,9 @@ VALUE rb_thread_main _((void));
VALUE rb_thread_local_aref _((VALUE, ID));
VALUE rb_thread_local_aset _((VALUE, ID, VALUE));
/* file.c */
-VALUE rb_file_open _((char*, char*));
-int eaccess _((char*, int));
+int eaccess _((const char*, int));
VALUE rb_file_s_expand_path _((int, VALUE *));
+void rb_file_const _((const char*, VALUE));
/* gc.c */
void rb_global_variable _((VALUE*));
void rb_gc_mark_locations _((VALUE*, VALUE*));
@@ -176,8 +180,7 @@ VALUE rb_io_ungetc _((VALUE, VALUE));
VALUE rb_io_close _((VALUE));
VALUE rb_io_eof _((VALUE));
VALUE rb_io_binmode _((VALUE));
-int rb_io_mode_flags _((char*));
-VALUE rb_io_reopen _((VALUE, VALUE));
+VALUE rb_file_open _((const char*, const char*));
VALUE rb_gets _((void));
void rb_str_setter _((VALUE, ID, VALUE*));
/* numeric.c */
@@ -199,7 +202,7 @@ VALUE rb_obj_taint _((VALUE));
VALUE rb_obj_tainted _((VALUE));
VALUE rb_obj_untaint _((VALUE));
VALUE rb_obj_id _((VALUE));
-VALUE rb_convert_type _((VALUE,int,char*,char*));
+VALUE rb_convert_type _((VALUE,int,const char*,const char*));
VALUE rb_Integer _((VALUE));
VALUE rb_Float _((VALUE));
VALUE rb_String _((VALUE));
@@ -218,11 +221,11 @@ void rb_backref_set _((VALUE));
VALUE rb_lastline_get _((void));
void rb_lastline_set _((VALUE));
/* process.c */
-int rb_proc_exec _((char*));
+int rb_proc_exec _((const char*));
void rb_syswait _((int));
/* range.c */
-VALUE rb_range_new _((VALUE, VALUE));
-VALUE rb_range_beg_end _((VALUE, int*, int*));
+VALUE rb_range_new _((VALUE, VALUE, int));
+VALUE rb_range_beg_len _((VALUE, long*, long*, long, int));
/* re.c */
VALUE rb_reg_nth_defined _((int, VALUE));
VALUE rb_reg_nth_match _((int, VALUE));
@@ -230,20 +233,23 @@ VALUE rb_reg_last_match _((VALUE));
VALUE rb_reg_match_pre _((VALUE));
VALUE rb_reg_match_post _((VALUE));
VALUE rb_reg_match_last _((VALUE));
-VALUE rb_reg_new _((char*, size_t, int));
+VALUE rb_reg_new _((const char*, long, int));
VALUE rb_reg_match _((VALUE, VALUE));
VALUE rb_reg_match2 _((VALUE));
int rb_reg_options _((VALUE));
-char*rb_get_kcode _((void));
-void rb_set_kcode _((char*));
+const char* rb_get_kcode _((void));
+void rb_set_kcode _((const char*));
int rb_ignorecase_p _((void));
+void rb_match_busy _((VALUE, int));
/* ruby.c */
+EXTERN VALUE rb_argv;
+EXTERN VALUE rb_argv0;
void rb_load_file _((char*));
void ruby_script _((char*));
void ruby_prog_init _((void));
void ruby_set_argv _((int, char**));
void ruby_process_options _((int, char**));
-void ruby_require_modules _((void));
+void ruby_require_libraries _((void));
void ruby_load_script _((void));
/* signal.c */
VALUE rb_f_kill _((int, VALUE*));
@@ -257,52 +263,52 @@ void rb_trap_exec _((void));
/* sprintf.c */
VALUE rb_f_sprintf _((int, VALUE*));
/* string.c */
-VALUE rb_str_new _((char*, size_t));
-VALUE rb_str_new2 _((char*));
+VALUE rb_str_new _((const char*, long));
+VALUE rb_str_new2 _((const char*));
VALUE rb_str_new3 _((VALUE));
VALUE rb_str_new4 _((VALUE));
-VALUE rb_tainted_str_new _((char*, size_t));
-VALUE rb_tainted_str_new2 _((char*));
+VALUE rb_tainted_str_new _((const char*, long));
+VALUE rb_tainted_str_new2 _((const char*));
VALUE rb_obj_as_string _((VALUE));
VALUE rb_str_to_str _((VALUE));
VALUE rb_str_dup _((VALUE));
VALUE rb_str_plus _((VALUE, VALUE));
VALUE rb_str_times _((VALUE, VALUE));
-VALUE rb_str_substr _((VALUE, size_t, size_t));
+VALUE rb_str_substr _((VALUE, long, long));
void rb_str_modify _((VALUE));
VALUE rb_str_freeze _((VALUE));
-VALUE rb_str_dup_frozen _((VALUE));
-VALUE rb_str_resize _((VALUE, size_t));
-VALUE rb_str_cat _((VALUE, char*, size_t));
+VALUE rb_str_resize _((VALUE, long));
+VALUE rb_str_cat _((VALUE, const char*, long));
VALUE rb_str_concat _((VALUE, VALUE));
int rb_str_hash _((VALUE));
int rb_str_cmp _((VALUE, VALUE));
-VALUE rb_str_upto _((VALUE, VALUE));
+VALUE rb_str_upto _((VALUE, VALUE, int));
VALUE rb_str_inspect _((VALUE));
-VALUE rb_str_split _((VALUE, char*));
+VALUE rb_str_split _((VALUE, const char*));
/* struct.c */
VALUE rb_struct_new __((VALUE, ...));
-VALUE rb_struct_define __((char*, ...));
+VALUE rb_struct_define __((const char*, ...));
VALUE rb_struct_alloc _((VALUE, VALUE));
VALUE rb_struct_aref _((VALUE, VALUE));
VALUE rb_struct_aset _((VALUE, VALUE, VALUE));
VALUE rb_struct_getmember _((VALUE, ID));
/* time.c */
-VALUE rb_time_new _((int, int));
+VALUE rb_time_new();
/* variable.c */
VALUE rb_mod_name _((VALUE));
VALUE rb_class_path _((VALUE));
-void rb_set_class_path _((VALUE, VALUE, char*));
-VALUE rb_path2class _((char*));
+void rb_set_class_path _((VALUE, VALUE, const char*));
+VALUE rb_path2class _((const char*));
void rb_name_class _((VALUE, ID));
-void rb_autoload _((char*, char*));
+void rb_autoload _((const char*, const char*));
VALUE rb_f_autoload _((VALUE, VALUE, VALUE));
void rb_gc_mark_global_tbl _((void));
VALUE rb_f_trace_var _((int, VALUE*));
VALUE rb_f_untrace_var _((int, VALUE*));
-VALUE rb_gvar_set2 _((char*, VALUE));
+VALUE rb_gvar_set2 _((const char*, VALUE));
VALUE rb_f_global_variables _((void));
void rb_alias_variable _((ID, ID));
+void rb_clone_generic_ivar _((VALUE,VALUE));
void rb_mark_generic_ivar _((VALUE));
void rb_mark_generic_ivar_tbl _((void));
void rb_free_generic_ivar _((VALUE));
diff --git a/io.c b/io.c
index 5573e76a648..fb1e0d894ba 100644
--- a/io.c
+++ b/io.c
@@ -6,13 +6,14 @@
$Date$
created at: Fri Oct 15 18:08:59 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
#include "ruby.h"
#include "rubyio.h"
#include "rubysig.h"
+#include "env.h"
#include <ctype.h>
#include <errno.h>
@@ -20,8 +21,10 @@
#if !defined(DJGPP) && !defined(NT) && !defined(__human68k__)
#include <sys/ioctl.h>
#endif
-#if defined(HAVE_FCNTL)
+#if defined(HAVE_FCNTL_H) || defined(NT)
#include <fcntl.h>
+#elif defined(HAVE_SYS_FCNTL_H)
+#include <sys/fcntl.h>
#endif
#ifdef HAVE_SYS_TIME_H
@@ -40,7 +43,8 @@ struct timeval {
#include <sys/stat.h>
-#ifdef HAVE_SYS_PARAM_H
+/* EMX has sys/parm.h, but.. */
+#if defined(HAVE_SYS_PARAM_H) && !defined(__EMX__)
# include <sys/param.h>
#else
# define NOFILE 64
@@ -55,9 +59,17 @@ struct timeval {
#include <unix.mac.h>
#include <compat.h>
#endif
+
+#ifndef strdup
+char *strdup();
+#endif
+
extern void Init_File _((void));
#ifdef __BEOS__
+# ifdef _X86_
+# define NOFILE (OPEN_MAX)
+# endif
#include <net/socket.h>
#endif
@@ -68,6 +80,7 @@ VALUE rb_eEOFError;
VALUE rb_eIOError;
VALUE rb_stdin, rb_stdout, rb_stderr, rb_defout;
+static VALUE orig_stdin, orig_stdout, orig_stderr;
VALUE rb_fs;
VALUE rb_output_fs;
@@ -81,9 +94,9 @@ static ID id_write;
extern char *ruby_inplace_mode;
-struct timeval rb_time_timeval _((VALUE));
+struct timeval rb_time_interval _((VALUE));
-static VALUE filename, file;
+static VALUE filename, current_file;
static int gets_lineno;
static int init_p = 0, next_p = 0;
static VALUE lineno;
@@ -99,20 +112,19 @@ static VALUE lineno;
#elif defined(__BEOS__)
# define ReadDataPending(fp) (fp->_state._eof == 0)
#elif defined(USE_CWGUSI)
-# define ReadDataPending(fp) (fp->state.eof == 0)
+# define READ_DATA_PENDING(fp) (fp->state.eof == 0)
#else
/* requires systems own version of the ReadDataPending() */
extern int ReadDataPending();
# define READ_DATA_PENDING(fp) ReadDataPending(fp)
#endif
-#ifndef USE_THREAD
-# define READ_CHECK(fp) 0
-#else
-# define READ_CHECK(fp) do {\
- if (!READ_DATA_PENDING(fp)) rb_thread_wait_fd(fileno(fp));\
+#define READ_CHECK(fp) do {\
+ if (!READ_DATA_PENDING(fp)) {\
+ rb_thread_wait_fd(fileno(fp));\
+ rb_io_check_closed(fptr);\
+ }\
} while(0)
-#endif
void
rb_eof_error()
@@ -124,6 +136,9 @@ void
rb_io_check_closed(fptr)
OpenFile *fptr;
{
+ if (!fptr) {
+ rb_raise(rb_eIOError, "uninitialized stream");
+ }
if (fptr->f == NULL && fptr->f2 == NULL)
rb_raise(rb_eIOError, "closed stream");
}
@@ -146,9 +161,18 @@ rb_io_check_writable(fptr)
}
}
+void
+rb_read_check(fp)
+ FILE *fp;
+{
+ if (!READ_DATA_PENDING(fp)) {
+ rb_thread_wait_fd(fileno(fp));
+ }
+}
+
/* writing functions */
-VALUE
-rb_io_write(io, str)
+static VALUE
+io_write(io, str)
VALUE io, str;
{
OpenFile *fptr;
@@ -182,7 +206,7 @@ rb_io_write(io, str)
rb_sys_fail(fptr->path);
#else
n = fwrite(RSTRING(str)->ptr, 1, RSTRING(str)->len, f);
- if (n == 0 || ferror(f)) {
+ if (ferror(f)) {
rb_sys_fail(fptr->path);
}
#endif
@@ -193,6 +217,13 @@ rb_io_write(io, str)
return INT2FIX(n);
}
+VALUE
+rb_io_write(io, str)
+ VALUE io, str;
+{
+ return rb_funcall(io, id_write, 1, str);
+}
+
static VALUE
rb_io_addstr(io, str)
VALUE io, str;
@@ -226,7 +257,7 @@ rb_io_tell(io)
GetOpenFile(io, fptr);
pos = ftell(fptr->f);
- if (ferror(fptr->f) != 0) rb_sys_fail(fptr->path);
+ if (ferror(fptr->f)) rb_sys_fail(fptr->path);
return rb_int2inum(pos);
}
@@ -290,11 +321,8 @@ rb_io_eof(io)
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
- if (READ_DATA_PENDING(fptr->f)) return Qfalse;
-#if 0
if (feof(fptr->f)) return Qtrue;
- return Qfalse;
-#else
+ if (READ_DATA_PENDING(fptr->f)) return Qfalse;
READ_CHECK(fptr->f);
TRAP_BEG;
ch = getc(fptr->f);
@@ -305,7 +333,6 @@ rb_io_eof(io)
return Qfalse;
}
return Qtrue;
-#endif
}
static VALUE
@@ -375,13 +402,17 @@ read_all(port)
GetOpenFile(port, fptr);
rb_io_check_readable(fptr);
+ if (feof(fptr->f)) return Qnil;
if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode)
#ifdef __BEOS__
&& (st.st_dev > 3)
#endif
)
{
- if (st.st_size == 0) return rb_str_new(0, 0);
+ if (st.st_size == 0) {
+ getc(fptr->f); /* force EOF */
+ return rb_str_new(0, 0);
+ }
else {
long pos = ftell(fptr->f);
if (st.st_size > pos && pos >= 0) {
@@ -395,9 +426,9 @@ read_all(port)
TRAP_BEG;
n = fread(RSTRING(str)->ptr+bytes, 1, siz-bytes, fptr->f);
TRAP_END;
- if (n <= 0) {
- if (ferror(fptr->f)) rb_sys_fail(fptr->path);
- return rb_str_new(0,0);
+ if (n == 0) {
+ if (feof(fptr->f)) return Qnil;
+ rb_sys_fail(fptr->path);
}
bytes += n;
if (bytes < siz) break;
@@ -412,7 +443,7 @@ read_all(port)
}
static VALUE
-rb_io_read(argc, argv, io)
+io_read(argc, argv, io)
int argc;
VALUE *argv;
VALUE io;
@@ -430,15 +461,16 @@ rb_io_read(argc, argv, io)
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
+ if (feof(fptr->f)) return Qnil;
str = rb_str_new(0, len);
READ_CHECK(fptr->f);
TRAP_BEG;
n = fread(RSTRING(str)->ptr, 1, len, fptr->f);
TRAP_END;
- if (n <= 0) {
- if (ferror(fptr->f)) rb_sys_fail(fptr->path);
- return Qnil;
+ if (n == 0) {
+ if (feof(fptr->f)) return Qnil;
+ rb_sys_fail(fptr->path);
}
RSTRING(str)->len = n;
RSTRING(str)->ptr[n] = '\0';
@@ -522,7 +554,7 @@ rb_io_gets_internal(argc, argv, io)
c = getc(f);
TRAP_END;
if (c == EOF) {
- if (errno == EINTR) continue;
+ if (ferror(f) && errno == EINTR) continue;
break;
}
if ((*bp++ = c) == newline) break;
@@ -611,7 +643,7 @@ rb_io_gets(io)
c = getc(f);
TRAP_END;
if (c == EOF) {
- if (errno == EINTR) continue;
+ if (ferror(f) && errno == EINTR) continue;
break;
}
if ((*bp++ = c) == '\n') break;
@@ -691,6 +723,21 @@ lineno_setter(val, id, var)
}
static VALUE
+argf_set_lineno(argf, val)
+ VALUE argf, val;
+{
+ gets_lineno = NUM2INT(val);
+ lineno = INT2FIX(gets_lineno);
+ return Qnil;
+}
+
+static VALUE
+argf_lineno()
+{
+ return lineno;
+}
+
+static VALUE
rb_io_readline(argc, argv, io)
int argc;
VALUE *argv;
@@ -730,7 +777,7 @@ rb_io_each_line(argc, argv, io)
while (!NIL_P(str = rb_io_gets_internal(argc, argv, io))) {
rb_yield(str);
}
- return Qnil;
+ return io;
}
static VALUE
@@ -753,7 +800,7 @@ rb_io_each_byte(io)
if (c == EOF) break;
rb_yield(INT2FIX(c & 0xff));
}
- if (ferror(f) != 0) rb_sys_fail(fptr->path);
+ if (ferror(f)) rb_sys_fail(fptr->path);
return Qnil;
}
@@ -775,12 +822,28 @@ rb_io_getc(io)
TRAP_END;
if (c == EOF) {
- if (ferror(f) != 0) rb_sys_fail(fptr->path);
+ if (ferror(f)) rb_sys_fail(fptr->path);
return Qnil;
}
return INT2FIX(c & 0xff);
}
+int
+rb_getc(f)
+ FILE *f;
+{
+ int c;
+
+ if (!READ_DATA_PENDING(f)) {
+ rb_thread_wait_fd(fileno(f));
+ }
+ TRAP_BEG;
+ c = getc(f);
+ TRAP_END;
+
+ return c;
+}
+
static VALUE
rb_io_readchar(io)
VALUE io;
@@ -830,18 +893,17 @@ fptr_finalize(fptr)
if (fptr->f2 != NULL) {
fclose(fptr->f2);
}
- if (fptr->pid) {
- rb_syswait(fptr->pid);
- fptr->pid = 0;
- }
}
static void
rb_io_fptr_close(fptr)
OpenFile *fptr;
{
+ int fd;
+
if (fptr->f == NULL && fptr->f2 == NULL) return;
+ fd = fileno(fptr->f);
if (fptr->finalize) {
(*fptr->finalize)(fptr);
}
@@ -849,6 +911,7 @@ rb_io_fptr_close(fptr)
fptr_finalize(fptr);
}
fptr->f = fptr->f2 = NULL;
+ rb_thread_fd_close(fd);
}
void
@@ -870,6 +933,10 @@ rb_io_close(io)
GetOpenFile(io, fptr);
rb_io_fptr_close(fptr);
+ if (fptr->pid) {
+ rb_syswait(fptr->pid);
+ fptr->pid = 0;
+ }
return Qnil;
}
@@ -898,6 +965,7 @@ rb_io_close_read(io)
VALUE io;
{
OpenFile *fptr;
+ int n;
rb_secure(4);
GetOpenFile(io, fptr);
@@ -907,10 +975,11 @@ rb_io_close_read(io)
if (fptr->f2 == 0) {
return rb_io_close(io);
}
- fclose(fptr->f);
+ n = fclose(fptr->f);
fptr->mode &= ~FMODE_READABLE;
fptr->f = fptr->f2;
fptr->f2 = 0;
+ if (n != 0) rb_sys_fail(fptr->path);
return Qnil;
}
@@ -920,6 +989,7 @@ rb_io_close_write(io)
VALUE io;
{
OpenFile *fptr;
+ int n;
rb_secure(4);
GetOpenFile(io, fptr);
@@ -929,9 +999,10 @@ rb_io_close_write(io)
if (fptr->f2 == 0) {
return rb_io_close(io);
}
- fclose(fptr->f2);
+ n = fclose(fptr->f2);
fptr->f2 = 0;
fptr->mode &= ~FMODE_WRITABLE;
+ if (n != 0) rb_sys_fail(fptr->path);
return Qnil;
}
@@ -952,9 +1023,9 @@ rb_io_syswrite(io, str)
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);
-#ifdef USE_THREAD
- rb_thread_fd_writable(fileno(f));
-#endif
+ if (!rb_thread_fd_writable(fileno(f))) {
+ rb_io_check_closed(fptr);
+ }
n = write(fileno(f), RSTRING(str)->ptr, RSTRING(str)->len);
if (n == -1) rb_sys_fail(fptr->path);
@@ -976,15 +1047,15 @@ rb_io_sysread(io, len)
str = rb_str_new(0, ilen);
-#ifdef USE_THREAD
rb_thread_wait_fd(fileno(fptr->f));
-#endif
TRAP_BEG;
n = read(fileno(fptr->f), RSTRING(str)->ptr, RSTRING(str)->len);
TRAP_END;
if (n == -1) rb_sys_fail(fptr->path);
- if (n == 0) rb_eof_error();
+ if (n == 0 && ilen > 0) {
+ rb_eof_error();
+ }
RSTRING(str)->len = n;
RSTRING(str)->ptr[n] = '\0';
@@ -997,7 +1068,8 @@ VALUE
rb_io_binmode(io)
VALUE io;
{
-#if defined(NT) || defined(DJGPP) || defined(__CYGWIN32__) || defined(__human68k__) || defined(USE_CWGUSI)
+#if defined(NT) || defined(DJGPP) || defined(__CYGWIN32__)\
+ || defined(__human68k__) || defined(USE_CWGUSI) || defined(__EMX__)
OpenFile *fptr;
GetOpenFile(io, fptr);
@@ -1014,9 +1086,9 @@ rb_io_binmode(io)
rb_sys_fail(fptr->path);
# else /* USE_CWGUSI */
if (fptr->f)
- fptr->f->mode.binrb_ary_io = 1;
+ fptr->f->mode.binary_io = 1;
if (fptr->f2)
- fptr->f2->mode.binrb_ary_io = 1;
+ fptr->f2->mode.binary_io = 1;
# endif /* USE_CWGUSI */
#endif
@@ -1027,7 +1099,7 @@ rb_io_binmode(io)
int
rb_io_mode_flags(mode)
- char *mode;
+ const char *mode;
{
int flags = 0;
@@ -1042,7 +1114,8 @@ rb_io_mode_flags(mode)
flags |= FMODE_WRITABLE;
break;
default:
- rb_raise(rb_eArgError, "illegal access mode");
+ error:
+ rb_raise(rb_eArgError, "illegal access mode %s", mode);
}
if (mode[1] == 'b') {
@@ -1052,48 +1125,193 @@ rb_io_mode_flags(mode)
if (mode[1] == '+') {
flags |= FMODE_READWRITE;
+ if (mode[2] != 0) goto error;
+ }
+ else if (mode[1] != 0) goto error;
+
+ return flags;
+}
+
+static int
+rb_io_mode_flags2(mode)
+ int mode;
+{
+ int flags;
+
+ switch (mode & (O_RDONLY|O_WRONLY|O_RDWR)) {
+ case O_RDONLY:
+ flags = FMODE_READABLE;
+ break;
+ case O_WRONLY:
+ flags = FMODE_WRITABLE;
+ break;
+ case O_RDWR:
+ flags = FMODE_WRITABLE|FMODE_READABLE;
+ break;
}
+#ifdef O_BINARY
+ if (mode & O_BINARY) {
+ flags |= FMODE_BINMODE;
+ }
+#endif
+
return flags;
}
+static char*
+rb_io_flags_mode(flags)
+ int flags;
+{
+ static char mode[4];
+ char *p = mode;
+
+ switch (flags & (O_RDONLY|O_WRONLY|O_RDWR)) {
+ case O_RDONLY:
+ *p++ = 'r';
+ break;
+ case O_WRONLY:
+ *p++ = 'w';
+ break;
+ case O_RDWR:
+ *p++ = 'w';
+ *p++ = '+';
+ break;
+ }
+ *p++ = '\0';
+#ifdef O_BINARY
+ if (flags & O_BINARY) {
+ if (mode[1] == '+') {
+ mode[1] = 'b'; mode[2] = '+'; mode[3] = '\0';
+ }
+ else {
+ mode[1] = 'b'; mode[2] = '\0';
+ }
+ }
+#endif
+ return mode;
+}
+
+static int
+rb_open(fname, flag, mode)
+ char *fname;
+ int flag;
+ unsigned int mode;
+{
+ int fd;
+
+ fd = open(fname, flag, mode);
+ if (fd < 0) {
+ if (errno == EMFILE || errno == ENFILE) {
+ rb_gc();
+ fd = open(fname, flag, mode);
+ }
+ if (fd < 0) {
+ rb_sys_fail(fname);
+ }
+ }
+ return fd;
+}
+
FILE *
rb_fopen(fname, mode)
- char *fname;
- char *mode;
+ const char *fname;
+ const char *mode;
{
- FILE *f;
+ FILE *file;
- f = fopen(fname, mode);
- if (f == NULL) {
+ file = fopen(fname, mode);
+ if (file == NULL) {
if (errno == EMFILE || errno == ENFILE) {
rb_gc();
- f = fopen(fname, mode);
+ file = fopen(fname, mode);
}
- if (f == NULL) {
+ if (file == NULL) {
rb_sys_fail(fname);
}
}
- return f;
+ return file;
}
FILE *
rb_fdopen(fd, mode)
int fd;
- char *mode;
+ const char *mode;
{
- FILE *f;
+ FILE *file;
- f = fdopen(fd, mode);
- if (f == NULL) {
- if (errno == EMFILE) {
- f = fdopen(fd, mode);
+ file = fdopen(fd, mode);
+ if (file == NULL) {
+ if (errno == EMFILE || errno == ENFILE) {
+ rb_gc();
+ file = fdopen(fd, mode);
}
- if (f == NULL) {
+ if (file == NULL) {
rb_sys_fail(0);
}
}
- return f;
+ return file;
+}
+
+static VALUE
+rb_file_open_internal(klass, fname, mode)
+ VALUE klass;
+ const char *fname, *mode;
+{
+ OpenFile *fptr;
+ NEWOBJ(port, struct RFile);
+ OBJSETUP(port, klass, T_FILE);
+ MakeOpenFile(port, fptr);
+
+ fptr->mode = rb_io_mode_flags(mode);
+ fptr->f = rb_fopen(fname, mode);
+ fptr->path = strdup(fname);
+
+ return (VALUE)port;
+}
+
+VALUE
+rb_file_open(fname, mode)
+ const char *fname, *mode;
+{
+ return rb_file_open_internal(rb_cFile, fname, mode);
+}
+
+VALUE
+rb_file_sysopen_internal(klass, fname, flags, mode)
+ VALUE klass;
+ char *fname;
+ int flags, mode;
+{
+#ifdef USE_CWGUSI
+ if (mode != 0666) {
+ rb_warn("can't specify file mode on this platform");
+ }
+ return rb_file_open_internal(klass, fname, rb_io_flags_mode(flags));
+#else
+ OpenFile *fptr;
+ int fd;
+ char *m;
+ NEWOBJ(port, struct RFile);
+ OBJSETUP(port, klass, T_FILE);
+ MakeOpenFile(port, fptr);
+
+ fd = rb_open(fname, flags, mode);
+ m = rb_io_flags_mode(flags);
+ fptr->mode = rb_io_mode_flags2(flags);
+ fptr->f = rb_fdopen(fd, m);
+ fptr->path = strdup(fname);
+
+ return (VALUE)port;
+#endif
+}
+
+VALUE
+rb_file_sysopen(fname, flags, mode)
+ const char *fname;
+ int flags, mode;
+{
+ return rb_file_sysopen_internal(rb_cFile, fname, flags, mode);
}
#if defined (NT) || defined(DJGPP) || defined(__CYGWIN32__) || defined(__human68k__)
@@ -1205,7 +1423,6 @@ pipe_open(pname, mode)
fptr->f2 = f;
rb_io_unbuffered(fptr);
}
- rb_obj_call_init((VALUE)port);
return (VALUE)port;
}
#else
@@ -1242,8 +1459,6 @@ pipe_open(pname, mode)
}
if (doexec) {
- extern char *ruby_sourcefile;
- extern int ruby_sourceline;
int fd;
for (fd = 3; fd < NOFILE; fd++)
@@ -1257,11 +1472,7 @@ pipe_open(pname, mode)
case -1: /* fork failed */
if (errno == EAGAIN) {
-#ifdef USE_THREAD
rb_thread_sleep(1);
-#else
- sleep(1);
-#endif
goto retry;
}
close(pr[0]); close(pw[1]);
@@ -1293,7 +1504,6 @@ pipe_open(pname, mode)
fptr->finalize = pipe_finalize;
pipe_add_fptr(fptr);
#endif
- rb_obj_call_init((VALUE)port);
return (VALUE)port;
}
}
@@ -1311,7 +1521,7 @@ rb_io_s_popen(argc, argv, self)
VALUE self;
{
char *mode;
- VALUE pname, pmode;
+ VALUE pname, pmode, port;
if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) {
mode = "r";
@@ -1325,19 +1535,45 @@ rb_io_s_popen(argc, argv, self)
rb_raise(rb_eArgError, "illegal access mode");
}
Check_SafeStr(pname);
- return pipe_open(RSTRING(pname)->ptr, mode);
+ port = pipe_open(RSTRING(pname)->ptr, mode);
+ if (NIL_P(port)) return Qnil;
+ return port;
}
static VALUE
-rb_io_open(fname, mode)
- char *fname, *mode;
+rb_file_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
- if (fname[0] == '|') {
- return pipe_open(fname+1, mode);
+ VALUE fname, vmode, file, perm;
+ char *path, *mode;
+
+ rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
+ Check_SafeStr(fname);
+ path = RSTRING(fname)->ptr;
+
+ if (FIXNUM_P(vmode)) {
+ int flags = FIX2INT(vmode);
+ int fmode = NIL_P(perm) ? 0666 : FIX2INT(perm);
+
+ file = rb_file_sysopen_internal(klass, path, flags, fmode);
}
else {
- return rb_file_open(fname, mode);
+ if (!NIL_P(vmode)) {
+ mode = STR2CSTR(vmode);
+ }
+ else {
+ mode = "r";
+ }
+ file = rb_file_open_internal(klass, RSTRING(fname)->ptr, mode);
+ }
+
+ if (rb_iterator_p()) {
+ return rb_ensure(rb_yield, file, rb_io_close, file);
}
+
+ return file;
}
static VALUE
@@ -1346,24 +1582,32 @@ rb_f_open(argc, argv)
VALUE *argv;
{
char *mode;
- VALUE pname, pmode;
+ VALUE pname, pmode, perm;
VALUE port;
- rb_scan_args(argc, argv, "11", &pname, &pmode);
+ rb_scan_args(argc, argv, "12", &pname, &pmode, &perm);
Check_SafeStr(pname);
+ if (RSTRING(pname)->ptr[0] != '|') /* open file */
+ return rb_file_s_open(argc, argv, rb_cFile);
+
+ /* open pipe */
if (NIL_P(pmode)) {
mode = "r";
}
+ else if (FIXNUM_P(pmode)) {
+ mode = rb_io_flags_mode(FIX2INT(pmode));
+ }
else {
int len;
mode = STR2CSTR(pmode);
len = strlen(mode);
if (len == 0 || len > 3)
- rb_raise(rb_eArgError, "illegal access mode");
+ rb_raise(rb_eArgError, "illegal access mode %s", mode);
}
- port = rb_io_open(RSTRING(pname)->ptr, mode);
+ port = pipe_open(RSTRING(pname)->ptr+1, mode);
+ if (NIL_P(port)) return Qnil;
if (rb_iterator_p()) {
return rb_ensure(rb_yield, port, rb_io_close, port);
}
@@ -1372,6 +1616,18 @@ rb_f_open(argc, argv)
}
static VALUE
+rb_io_open(fname, mode)
+ char *fname, *mode;
+{
+ if (fname[0] == '|') {
+ return pipe_open(fname+1, mode);
+ }
+ else {
+ return rb_file_open(fname, mode);
+ }
+}
+
+static VALUE
rb_io_get_io(io)
VALUE io;
{
@@ -1393,7 +1649,7 @@ rb_io_mode_string(fptr)
}
}
-VALUE
+static VALUE
rb_io_reopen(io, nfile)
VALUE io, nfile;
{
@@ -1406,12 +1662,14 @@ rb_io_reopen(io, nfile)
nfile = rb_io_get_io(nfile);
GetOpenFile(nfile, orig);
+ if (fptr == orig) return io;
if (orig->f2) {
fflush(orig->f2);
}
else if (orig->mode & FMODE_WRITABLE) {
fflush(orig->f);
}
+ rb_thread_fd_close(fileno(fptr->f));
/* copy OpenFile structure */
fptr->mode = orig->mode;
@@ -1458,6 +1716,56 @@ rb_io_reopen(io, nfile)
}
static VALUE
+rb_file_reopen(argc, argv, file)
+ int argc;
+ VALUE *argv;
+ VALUE file;
+{
+ VALUE fname, nmode;
+ char *mode;
+ OpenFile *fptr;
+
+ rb_secure(4);
+ if (rb_scan_args(argc, argv, "11", &fname, &nmode) == 1) {
+ if (TYPE(fname) == T_FILE) { /* fname must be IO */
+ return rb_io_reopen(file, fname);
+ }
+ }
+
+ Check_SafeStr(fname);
+ if (!NIL_P(nmode)) {
+ mode = STR2CSTR(nmode);
+ }
+ else {
+ mode = "r";
+ }
+
+ GetOpenFile(file, fptr);
+ if (fptr->path) free(fptr->path);
+ fptr->path = strdup(RSTRING(fname)->ptr);
+ fptr->mode = rb_io_mode_flags(mode);
+ if (!fptr->f) {
+ fptr->f = rb_fopen(RSTRING(fname)->ptr, mode);
+ if (fptr->f2) {
+ fclose(fptr->f2);
+ fptr->f2 = NULL;
+ }
+ return file;
+ }
+
+ if (freopen(RSTRING(fname)->ptr, mode, fptr->f) == NULL) {
+ rb_sys_fail(fptr->path);
+ }
+ if (fptr->f2) {
+ if (freopen(RSTRING(fname)->ptr, "w", fptr->f2) == NULL) {
+ rb_sys_fail(fptr->path);
+ }
+ }
+
+ return file;
+}
+
+static VALUE
rb_io_clone(io)
VALUE io;
{
@@ -1466,7 +1774,7 @@ rb_io_clone(io)
char *mode;
NEWOBJ(obj, struct RFile);
- OBJSETUP(obj, CLASS_OF(io), T_FILE);
+ CLONESETUP(obj, io);
GetOpenFile(io, orig);
MakeOpenFile(obj, fptr);
@@ -1601,7 +1909,7 @@ rb_io_putc(io, ch)
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);
- if (fputc(c, f) == EOF || ferror(f))
+ if (fputc(c, f) == EOF)
rb_sys_fail(fptr->path);
if (fptr->mode & FMODE_SYNC)
fflush(f);
@@ -1725,38 +2033,135 @@ rb_io_defset(val, id)
VALUE val;
ID id;
{
- if (TYPE(val) == T_STRING) {
- val = rb_io_open(RSTRING(val)->ptr, "w");
- }
if (!rb_respond_to(val, id_write)) {
- rb_raise(rb_eTypeError, "$< must have write method, %s given",
+ rb_raise(rb_eTypeError, "$> must have write method, %s given",
rb_class2name(CLASS_OF(val)));
}
rb_defout = val;
}
+static int
+rb_dup(orig)
+ int orig;
+{
+ int fd;
+
+ fd = dup(orig);
+ if (fd < 0) {
+ if (errno == EMFILE || errno == ENFILE) {
+ rb_gc();
+ fd = dup(orig);
+ }
+ if (fd < 0) {
+ rb_sys_fail(0);
+ }
+ }
+ return fd;
+}
+
static void
-rb_io_stdio_set(val, id, var)
+set_stdin(val, id, var)
VALUE val;
ID id;
VALUE *var;
{
OpenFile *fptr;
int fd;
+ char *mode;
+ if (val == *var) return;
if (TYPE(val) != T_FILE) {
- rb_raise(rb_eTypeError, "%s must be IO object", rb_id2name(id));
+ *var = val;
+ return;
}
+ if (TYPE(*var) != T_FILE) {
+ *var = orig_stdin;
+ }
+
+ GetOpenFile(val, fptr);
+ rb_io_check_readable(fptr);
+
GetOpenFile(*var, fptr);
- fd = fileno(fptr->f);
+ mode = rb_io_mode_string(fptr);
+ fd = rb_dup(fileno(fptr->f));
+ if (fileno(fptr->f) > 2) {
+ fclose(fptr->f);
+ }
+ fptr->f = rb_fdopen(fd, mode);
+
GetOpenFile(val, fptr);
- if (fd == 0) {
- rb_io_check_readable(fptr);
+ dup2(fileno(fptr->f), 0);
+ fclose(fptr->f);
+ fptr->f = stdin;
+
+ *var = val;
+}
+
+static void
+set_outfile(val, var, orig, stdf)
+ VALUE val;
+ VALUE *var;
+ VALUE orig;
+ FILE *stdf;
+{
+ OpenFile *fptr;
+ FILE *f;
+ int fd;
+ char *mode;
+
+ if (val == *var) return;
+
+ if (TYPE(*var) == T_FILE) {
+ rb_io_flush(*var);
}
- else {
- rb_io_check_writable(fptr);
+ if (TYPE(val) != T_FILE) {
+ *var = val;
+ return;
+ }
+ if (TYPE(*var) != T_FILE) {
+ *var = orig;
+ }
+
+ GetOpenFile(val, fptr);
+ rb_io_check_writable(fptr);
+
+ GetOpenFile(*var, fptr);
+ mode = rb_io_mode_string(fptr);
+ f = GetWriteFile(fptr);
+ fd = rb_dup(fileno(f));
+ if (fileno(f) > 2) {
+ fclose(fptr->f);
}
- rb_io_reopen(*var, val);
+ f = rb_fdopen(fd, mode);
+ if (fptr->f2) fptr->f2 = f;
+ else fptr->f = f;
+
+ GetOpenFile(val, fptr);
+ f = GetWriteFile(fptr);
+ dup2(fileno(f), fileno(stdf));
+ fclose(f);
+ if (fptr->f2) fptr->f2 = stdf;
+ else fptr->f = stdf;
+
+ *var = val;
+}
+
+static void
+set_stdout(val, id, var)
+ VALUE val;
+ ID id;
+ VALUE *var;
+{
+ set_outfile(val, var, orig_stdout, stdout);
+}
+
+static void
+set_stderr(val, id, var)
+ VALUE val;
+ ID id;
+ VALUE *var;
+{
+ set_outfile(val, var, orig_stderr, stderr);
}
static VALUE
@@ -1772,7 +2177,6 @@ prep_stdio(f, mode, klass)
MakeOpenFile(io, fp);
fp->f = f;
fp->mode = mode;
- rb_obj_call_init((VALUE)io);
return (VALUE)io;
}
@@ -1793,6 +2197,28 @@ rb_io_s_new(argc, argv, klass)
return prep_stdio(rb_fdopen(NUM2INT(fnum), m), rb_io_mode_flags(m), klass);
}
+static int binmode = 0;
+
+static VALUE
+argf_forward()
+{
+ return rb_funcall3(current_file, ruby_frame->last_func,
+ ruby_frame->argc, ruby_frame->argv);
+}
+
+static VALUE
+argf_binmode()
+{
+ if (TYPE(current_file) != T_FILE) {
+ argf_forward();
+ }
+ else {
+ rb_io_binmode(current_file);
+ }
+ binmode = 1;
+ return argf;
+}
+
static int
next_argv()
{
@@ -1805,7 +2231,7 @@ next_argv()
}
else {
next_p = -1;
- file = rb_stdin;
+ current_file = rb_stdin;
}
init_p = 1;
gets_lineno = 0;
@@ -1816,9 +2242,9 @@ next_argv()
next_p = 0;
if (RARRAY(rb_argv)->len > 0) {
filename = rb_ary_shift(rb_argv);
- fn = RSTRING(filename)->ptr;
- if (RSTRING(filename)->len == 1 && fn[0] == '-') {
- file = rb_stdin;
+ fn = STR2CSTR(filename);
+ if (strlen(fn) == 1 && fn[0] == '-') {
+ current_file = rb_stdin;
if (ruby_inplace_mode) {
rb_defout = rb_stdout;
}
@@ -1843,7 +2269,7 @@ next_argv()
rb_str_cat(str, ruby_inplace_mode,
strlen(ruby_inplace_mode));
#endif
-#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN32__) || defined(NT) || defined(__human68k__)
+#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN32__) || defined(NT) || defined(__human68k__) || defined(__EMX__)
(void)fclose(fr);
(void)unlink(RSTRING(str)->ptr);
(void)rename(fn, RSTRING(str)->ptr);
@@ -1870,8 +2296,7 @@ next_argv()
#endif
}
fw = rb_fopen(fn, "w");
-#if !defined(MSDOS) && !defined(__CYGWIN32__) && !(NT) && !defined(__human68k__)\
- && !defined(USE_CWGUSI) && !defined(__BEOS__)
+#if !defined(MSDOS) && !defined(__CYGWIN32__) && !(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__) && !defined(__EMX__)
fstat(fileno(fw), &st2);
fchmod(fileno(fw), st.st_mode);
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
@@ -1880,8 +2305,9 @@ next_argv()
#endif
rb_defout = prep_stdio(fw, FMODE_WRITABLE, rb_cFile);
}
- file = prep_stdio(fr, FMODE_READABLE, rb_cFile);
+ current_file = prep_stdio(fr, FMODE_READABLE, rb_cFile);
}
+ if (binmode) rb_io_binmode(current_file);
}
else {
init_p = 0;
@@ -1891,6 +2317,16 @@ next_argv()
return Qtrue;
}
+static void
+any_close(file)
+ VALUE file;
+{
+ if (TYPE(file) == T_FILE)
+ rb_io_close(file);
+ else
+ rb_funcall3(file, rb_intern("close"), 0, 0);
+}
+
static VALUE
rb_f_gets_internal(argc, argv)
int argc;
@@ -1900,9 +2336,17 @@ rb_f_gets_internal(argc, argv)
retry:
if (!next_argv()) return Qnil;
- line = rb_io_gets_internal(argc, argv, file);
+ if (TYPE(current_file) != T_FILE) {
+ line = rb_funcall3(current_file, rb_intern("gets"), argc, argv);
+ }
+ if (argc == 0 && rb_rs == rb_default_rs) {
+ line = rb_io_gets(current_file);
+ }
+ else {
+ line = rb_io_gets_internal(argc, argv, current_file);
+ }
if (NIL_P(line) && next_p != -1) {
- rb_io_close(file);
+ any_close(current_file);
next_p = 1;
goto retry;
}
@@ -1919,7 +2363,7 @@ rb_f_gets(argc, argv)
{
VALUE line = rb_f_gets_internal(argc, argv);
- if (!NIL_P(line)) rb_lastline_set(line);
+ rb_lastline_set(line);
return line;
}
@@ -1928,16 +2372,20 @@ rb_gets()
{
VALUE line;
+ if (rb_rs != rb_default_rs) {
+ return rb_f_gets(0, 0);
+ }
+
retry:
if (!next_argv()) return Qnil;
- line = rb_io_gets(file);
+ line = rb_io_gets(current_file);
if (NIL_P(line) && next_p != -1) {
- rb_io_close(file);
+ any_close(current_file);
next_p = 1;
goto retry;
}
+ rb_lastline_set(line);
if (!NIL_P(line)) {
- rb_lastline_set(line);
gets_lineno++;
lineno = INT2FIX(gets_lineno);
}
@@ -1960,76 +2408,13 @@ rb_f_readline(argc, argv)
}
static VALUE
-rb_f_tell()
-{
- return rb_io_tell(file);
-}
-
-static VALUE
-rb_f_seek(self, offset, ptrname)