summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-24 04:31:29 (GMT)
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-24 04:31:29 (GMT)
commit831aa6cd961ce56ef248d3a078db4f75c5d2bf6b (patch)
treecb461ab9246a2c8e13d373a8c2d2e6378e4db9cc
parent62e648e148b3cb9f96dcce808c55c02b7ccb4486 (diff)
This commit was manufactured by cvs2svn to create tag
'v1_3_1_990224'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_3_1_990224@406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--.cvsignore17
-rw-r--r--ChangeLog378
-rw-r--r--MANIFEST10
-rw-r--r--Makefile.in42
-rw-r--r--README6
-rw-r--r--README.EXT301
-rw-r--r--README.EXT.jp19
-rw-r--r--README.jp13
-rw-r--r--ToDo13
-rw-r--r--array.c152
-rw-r--r--bignum.c69
-rw-r--r--class.c18
-rw-r--r--compar.c2
-rw-r--r--config.dj36
-rw-r--r--config.sub4
-rw-r--r--configure955
-rw-r--r--configure.in248
-rw-r--r--defines.h4
-rw-r--r--dir.c2
-rw-r--r--dln.c37
-rw-r--r--enum.c28
-rw-r--r--env.h2
-rw-r--r--error.c35
-rw-r--r--eval.c527
-rw-r--r--ext/Win32API/Win32API.c38
-rw-r--r--ext/curses/curses.c4
-rw-r--r--ext/curses/extconf.rb2
-rw-r--r--ext/etc/MANIFEST3
-rw-r--r--ext/extmk.rb.in30
-rw-r--r--ext/gtk/MANIFEST18
-rw-r--r--ext/gtk/extconf.rb6
-rw-r--r--ext/gtk/gtk.c5904
-rw-r--r--ext/gtk/test.rb96
-rw-r--r--ext/gtk/test.xpm92
-rw-r--r--ext/gtk/test0.rb13
-rw-r--r--ext/gtk/test1.rb41
-rw-r--r--ext/gtk/test2.rb89
-rw-r--r--ext/gtk/test3.rb16
-rw-r--r--ext/gtk/test4.rb77
-rw-r--r--ext/gtk/test5.rb63
-rw-r--r--ext/gtk/test6.rb49
-rw-r--r--ext/gtk/test7.rb49
-rw-r--r--ext/gtk/test8.rb49
-rw-r--r--ext/gtk/test9.rb98
-rw-r--r--ext/gtk/testa.rb78
-rw-r--r--ext/gtk/testb.rb78
-rw-r--r--ext/gtk/testc.rb64
-rw-r--r--ext/marshal/MANIFEST5
-rw-r--r--ext/marshal/depend2
-rw-r--r--ext/marshal/extconf.rb1
-rw-r--r--ext/marshal/marshal.c850
-rw-r--r--ext/marshal/marshal.doc48
-rw-r--r--ext/md5/MANIFEST3
-rw-r--r--ext/nkf/MANIFEST7
-rw-r--r--ext/nkf/extconf.rb2
-rw-r--r--ext/nkf/lib/kconv.rb58
-rw-r--r--ext/nkf/nkf.c207
-rw-r--r--ext/nkf/orig/nkf.c1897
-rw-r--r--ext/nkf/test.rb318
-rw-r--r--ext/socket/socket.c11
-rw-r--r--ext/tcltklib/tcltklib.c6
-rw-r--r--ext/tk/lib/tk.rb4
-rw-r--r--ext/tk/lib/tkscrollbox.rb6
-rw-r--r--ext/tkutil/MANIFEST3
-rw-r--r--ext/tkutil/depend1
-rw-r--r--ext/tkutil/tkutil.c46
-rw-r--r--file.c138
-rw-r--r--fnmatch.c243
-rw-r--r--fnmatch.h36
-rw-r--r--gc.c22
-rw-r--r--hash.c87
-rw-r--r--inits.c4
-rw-r--r--instruby.rb53
-rw-r--r--intern.h34
-rw-r--r--io.c492
-rw-r--r--io.h58
-rw-r--r--lib/README23
-rw-r--r--lib/cgi-lib.rb125
-rw-r--r--lib/complex.rb18
-rw-r--r--lib/date2.rb24
-rw-r--r--lib/e2mmap.rb269
-rw-r--r--lib/e2mmap1_0.rb71
-rw-r--r--lib/ftools.rb4
-rw-r--r--lib/matrix.rb67
-rw-r--r--lib/mkmf.rb4
-rw-r--r--lib/mutex_m.rb9
-rw-r--r--lib/parsedate.rb21
-rw-r--r--lib/profile.rb2
-rw-r--r--lib/sync.rb14
-rw-r--r--lib/telnet.rb273
-rw-r--r--lib/tempfile.rb3
-rw-r--r--lib/tk.rb1254
-rw-r--r--lib/tkcanvas.rb326
-rw-r--r--lib/tkclass.rb38
-rw-r--r--lib/tkcore.rb528
-rw-r--r--lib/tkdialog.rb62
-rw-r--r--lib/tkentry.rb67
-rw-r--r--lib/tkscrollbox.rb27
-rw-r--r--lib/tktext.rb164
-rw-r--r--lib/tkthcore.rb550
-rw-r--r--lib/weakref.rb7
-rw-r--r--main.c7
-rw-r--r--marshal.c23
-rw-r--r--math.c2
-rw-r--r--misc/ruby-mode.el14
-rw-r--r--missing/fnmatch.c192
-rw-r--r--missing/fnmatch.h57
-rw-r--r--missing/nt.c2194
-rw-r--r--missing/nt.h362
-rw-r--r--missing/setenv.c149
-rw-r--r--missing/strftime.c28
-rw-r--r--missing/strtod.c266
-rw-r--r--missing/vsnprintf.c47
-rw-r--r--node.h2
-rw-r--r--numeric.c115
-rw-r--r--object.c6
-rw-r--r--pack.c349
-rw-r--r--parse.c1478
-rw-r--r--parse.y129
-rw-r--r--process.c40
-rw-r--r--random.c2
-rw-r--r--range.c2
-rw-r--r--re.c50
-rw-r--r--re.h2
-rw-r--r--regex.c4482
-rw-r--r--regex.h29
-rw-r--r--ruby.16
-rw-r--r--ruby.c106
-rw-r--r--ruby.h32
-rw-r--r--rubyio.h2
-rw-r--r--rubytest.rb6
-rw-r--r--sample/biorhythm.rb10
-rw-r--r--sample/cal.rb7
-rw-r--r--sample/io.rb44
-rw-r--r--sample/list.rb16
-rw-r--r--sample/mine.rb36
-rw-r--r--sample/rbc.rb8
-rw-r--r--sample/rcs.rb10
-rw-r--r--sample/rename.rb6
-rw-r--r--sample/ruby-mode.el649
-rw-r--r--sample/rubydb2x.el104
-rw-r--r--sample/rubydb3x.el104
-rw-r--r--sample/test.rb36
-rw-r--r--sample/tkbiff.rb149
-rw-r--r--sample/tkbrowse.rb69
-rw-r--r--sample/tkdialog.rb62
-rw-r--r--sample/tkfrom.rb126
-rw-r--r--sample/tkhello.rb10
-rw-r--r--sample/tkline.rb46
-rw-r--r--sample/tktimer.rb50
-rw-r--r--sample/uumerge.rb4
-rw-r--r--sig.h53
-rw-r--r--signal.c2
-rw-r--r--sprintf.c15
-rw-r--r--st.c483
-rw-r--r--st.h46
-rw-r--r--string.c209
-rw-r--r--struct.c74
-rw-r--r--time.c328
-rw-r--r--util.c9
-rw-r--r--util.h6
-rw-r--r--variable.c36
-rw-r--r--version.c4
-rw-r--r--version.h2
-rw-r--r--win32/Makefile2
-rw-r--r--win32/config.h34
-rw-r--r--win32/ruby.def6
-rw-r--r--win32/win32.c2
-rw-r--r--win32/win32.h33
169 files changed, 13110 insertions, 18426 deletions
diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index c1bdd08..0000000
--- a/.cvsignore
+++ /dev/null
@@ -1,17 +0,0 @@
-parse.c
-newver.rb
-ruby
-miniruby
-README.fat-patch
-config.cache
-config.h
-config.log
-config.status
-Makefile
-ppack
-archive
-*.orig
-*.rej
-*.bak
-*.sav
-*~
diff --git a/ChangeLog b/ChangeLog
index 6a317e2..31c0ea3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,381 @@
+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.
diff --git a/MANIFEST b/MANIFEST
index 5c697d6..e32c4fc 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,5 @@
COPYING
+COPYING.LIB
ChangeLog
MANIFEST
Makefile.in
@@ -28,8 +29,6 @@ env.h
error.c
eval.c
file.c
-fnmatch.c
-fnmatch.h
gc.c
glob.c
hash.c
@@ -50,6 +49,7 @@ object.c
pack.c
parse.c
parse.y
+prec.c
process.c
random.c
range.c
@@ -142,7 +142,12 @@ 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
@@ -152,6 +157,7 @@ missing/strdup.c
missing/strerror.c
missing/strftime.c
missing/strstr.c
+missing/strtod.c
missing/strtol.c
missing/strtoul.c
missing/vsnprintf.c
diff --git a/Makefile.in b/Makefile.in
index 628b0e0..f399fca 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -21,11 +21,19 @@ LDSHARED = @LDSHARED@
DLDFLAGS = @DLDFLAGS@
SOLIBS = @SOLIBS@
+RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
binsuffix = @binsuffix@
+PROGRAM=$(RUBY_INSTALL_NAME)$(binsuffix)
#### 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@
@@ -43,7 +51,6 @@ OBJS = array.o \
error.o \
eval.o \
file.o \
- fnmatch.o \
gc.o \
glob.o \
hash.o \
@@ -56,6 +63,7 @@ OBJS = array.o \
pack.o \
parse.o \
process.o \
+ prec.o \
random.o \
range.o \
re.o \
@@ -75,35 +83,36 @@ OBJS = array.o \
all: miniruby$(binsuffix) rbconfig.rb
@./miniruby$(binsuffix) -Xext extmk.rb @EXTSTATIC@
-miniruby$(binsuffix): libruby.a $(MAINOBJ) dmyext.o
+miniruby$(binsuffix): config.status $(LIBRUBY_A) $(MAINOBJ) dmyext.o
@rm -f $@
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.o libruby.a $(LIBS) -o $@
+ $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.o $(LIBRUBY_A) $(LIBS) -o $@
-ruby$(binsuffix): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS)
+$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS)
@rm -f $@
$(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
-libruby.a: $(OBJS) dmyext.o
+$(LIBRUBY_A): $(OBJS) dmyext.o
@AR@ rcu $@ $(OBJS) dmyext.o
@-@RANLIB@ $@ 2> /dev/null || true
-libruby.so: $(OBJS) dmyext.o
+$(LIBRUBY_SO): $(OBJS) dmyext.o
$(LDSHARED) $(DLDFLAGS) $(SOLIBS) $(OBJS) dmyext.o -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)
-clean:; @rm -f $(OBJS) $(LIBRUBY) $(MAINOBJ) rbconfig.rb
+clean:; @rm -f $(OBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES) $(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
+ @-./miniruby$(binsuffix) -Xext extmk.rb clean 2> /dev/null || true
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 $(PROGRAM) miniruby$(binsuffix)
realclean: distclean
@rm -f lex.c
@@ -111,7 +120,7 @@ realclean: distclean
test: miniruby$(binsuffix)
@./miniruby$(binsuffix) $(srcdir)/rubytest.rb
-rbconfig.rb: config.status miniruby$(binsuffix)
+rbconfig.rb: miniruby$(binsuffix)
@./miniruby$(binsuffix) $(srcdir)/mkconfig.rb rbconfig.rb
config.status: $(srcdir)/configure
@@ -142,6 +151,9 @@ dup2.o: @srcdir@/missing/dup2.c
flock.o: @srcdir@/missing/flock.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/flock.c
+fnmatch.o: @srcdir@/missing/fnmatch.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/fnmatch.c
+
memcmp.o: @srcdir@/missing/memcmp.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/memcmp.c
@@ -172,6 +184,9 @@ strftime.o: @srcdir@/missing/strftime.c
strstr.o: @srcdir@/missing/strstr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strstr.c
+strtod.o: @srcdir@/missing/strtod.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtod.c
+
strtol.o: @srcdir@/missing/strtol.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/strtol.c
@@ -203,11 +218,12 @@ 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
+hash.o: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h util.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
+prec.o: prec.c ruby.h config.h defines.h intern.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
diff --git a/README b/README
index dd93c59..b4b429f 100644
--- a/README
+++ b/README
@@ -98,9 +98,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], glob.c, 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 f169e54..9a56bd9 100644
--- a/README.EXT
+++ b/README.EXT
@@ -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
@@ -197,16 +191,13 @@ interpreter. Useful functions are listed below (not all):
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 +318,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 +337,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 +352,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 +389,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
-ここまでの説明でとりあえず拡張ライブラリは作れるはずです.
-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
@@ -600,16 +571,14 @@ Rubyの配列で引数を受け取るものはindexesがあります.実装はこ
--
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,8 +589,9 @@ 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関数を使う
@@ -643,23 +613,21 @@ extconf.rbはモジュールのコンパイルに必要な条件のチェックなど
(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ファイルにファイル名を入れる
- % 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) make
@@ -676,9 +644,9 @@ so that you can inspect the module by the debugger.
(10) done, now you have the extension library
-後はこっそり使うなり,広く公開するなり,売るなり,ご自由にお
-使いください.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.
Appendix A. Rubyのソースコードの分類
@@ -737,7 +705,7 @@ class library
struct.c
time.c
-Appendix B. 拡張用関数リファレンス
+Appendix B. Ruby extension API reference
C言語からRubyの機能を利用するAPIは以下の通りである.
@@ -758,13 +726,13 @@ 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)
@@ -776,40 +744,41 @@ Cの任意のポインタをカプセル化したRubyオブジェクトを返す.こ
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,19 +840,20 @@ 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, ...)
@@ -899,87 +869,91 @@ argc,argv形式で与えられた引数を分解する.fmtは必須引数の数,
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 +973,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 +997,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
index 87175be..1d56f25 100644
--- a/README.EXT.jp
+++ b/README.EXT.jp
@@ -134,7 +134,7 @@ VALUEの実際の構造は
* FIXNUMの場合
- 1bit右シフトして,LSBを立てる.
+ 1bit左シフトして,LSBを立てる.
* その他のポインタの場合
@@ -265,10 +265,10 @@ Rubyで提供されている関数を使えばRubyインタプリタに新しい機能
ます.
これらの関数の argcという引数はCの関数へ渡される引数の数(と
-形式)を決めます.argcが正の時は関数に引き渡す引数の数を意味
-します.16個以上の引数は使えません(が,要りませんよね,そん
-なに).実際の関数には先頭の引数としてselfが与えられますので,
-指定した数より1多い引数を持つことになります.
+形式)を決めます.argcが0以上の時は関数に引き渡す引数の数を意
+味します.16個以上の引数は使えません(が,要りませんよね,そ
+んなに).実際の関数には先頭の引数としてselfが与えられますの
+で,指定した数より1多い引数を持つことになります.
argcが負の時は引数の数ではなく,形式を指定したことになります.
argcが-1の時は引数を配列に入れて渡されます.argcが-2の時は引
@@ -666,16 +666,13 @@ Rubyの配列で引数を受け取るものはindexesがあります.実装はこ
--
static VALUE
fdbm_indexes(obj, args)
- VALUE obj;
- struct RArray *args;
+ VALUE obj, args;
{
:
}
--
-第1引数はself,第2引数はRubyの配列です.ここではキャストを減
-らすため struct RArray* で受けていますが,VALUEでも同じこと
-です.
+第1引数はself,第2引数はRubyの配列です.
** 注意事項
@@ -723,7 +720,7 @@ Makefileが依存関係をチェックしてくれます.
(7) MANIFESTファイルにファイル名を入れる
- % ls > MANIFEST
+ % find * -type f -print > MANIFEST
% vi MANIFEST
*.o, *~など不必要なファイル以外はMANIFESTに追加しておきます.
diff --git a/README.jp b/README.jp
index d137a43..5e3b230 100644
--- a/README.jp
+++ b/README.jp
@@ -142,22 +142,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], glob.c および.
+ /missingディレクトリ下のファイル群が該当します.それぞ
+ れの配布条件などに付いては各ファイルを参照してください.
5. Rubyへの入力となるスクリプトおよび,Rubyからの出力の権
利はRubyの作者ではなく,それぞれの入出力を生成した人に
- 属します.また,Rubyに組み込むための拡張モジュールにつ
+ 属します.また,Rubyに組み込むための拡張ライブラリにつ
いても同様です.
6. Rubyは無保証です.作者はRubyをサポートする意志はありま
diff --git a/ToDo b/ToDo
index 3bc7887..8f46ad6 100644
--- a/ToDo
+++ b/ToDo
@@ -1,8 +1,11 @@
Language Spec.
* package or access control for global variables
-* named arguments like foo(nation:="german").
+* named arguments like foo(nation:="german" or nation: "german").
+* method to retrieve argument information (need new C API)
* multiple return values, yield values. maybe imcompatible
+* cascading method invocation.
+* def Class#method .. end
Hacking Interpreter
@@ -12,7 +15,13 @@ Hacking Interpreter
* remove rb_eval() recursions
* syntax tree -> bytecode ???
* scrambled script, or script filter
-* regular expression bug /(?:\s+\d+){2}/ URGENT!!
+
+Standard Libraries
+
+* String#scanf(?)
+* Object#fmt(?)
+* Integer[num], Float[num] (String[str]??)
+* Stream or Port, abstract superclass of IO.
Extension Libraries
diff --git a/array.c b/array.c
index 8f6c0c2..8b25b9c 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;
+ int len;
{
NEWOBJ(ary, struct RArray);
OBJSETUP(ary, rb_cArray, T_ARRAY);
@@ -107,16 +107,16 @@ rb_ary_new()
VALUE
#ifdef HAVE_STDARG_PROTOTYPES
-rb_ary_new3(size_t n, ...)
+rb_ary_new3(int n, ...)
#else
rb_ary_new3(n, va_alist)
- size_t n;
+ int n;
va_dcl
#endif
{
va_list ar;
VALUE ary;
- size_t i;
+ int i;
if (n < 0) {
rb_raise(rb_eIndexError, "negative number of items(%d)", n);
@@ -135,7 +135,7 @@ rb_ary_new3(n, va_alist)
VALUE
rb_ary_new4(n, elts)
- size_t n;
+ int n;
VALUE *elts;
{
VALUE ary;
@@ -169,7 +169,7 @@ rb_ary_s_new(argc, argv, klass)
VALUE *argv;
VALUE klass;
{
- size_t len = 0;
+ int len = 0;
VALUE size, val;
NEWOBJ(ary, struct RArray);
OBJSETUP(ary, klass, T_ARRAY);
@@ -180,7 +180,7 @@ rb_ary_s_new(argc, argv, klass)
ary->capa = ARY_DEFAULT_SIZE;
}
else {
- size_t capa = NUM2UINT(size);
+ int capa = NUM2INT(size);
if (capa < 0) {
rb_raise(rb_eArgError, "negative array size");
@@ -224,7 +224,7 @@ rb_ary_s_create(argc, argv, klass)
void
rb_ary_store(ary, idx, val)
VALUE ary;
- size_t idx;
+ int idx;
VALUE val;
{
rb_ary_modify(ary);
@@ -236,7 +236,11 @@ rb_ary_store(ary, idx, val)
}
if (idx >= RARRAY(ary)->capa) {
- RARRAY(ary)->capa = idx + ARY_DEFAULT_SIZE;
+ int 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 +314,11 @@ rb_ary_unshift(ary, item)
{
rb_ary_modify(ary);
if (RARRAY(ary)->len >= RARRAY(ary)->capa) {
- RARRAY(ary)->capa+=ARY_DEFAULT_SIZE;
+ int 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 +334,7 @@ rb_ary_unshift(ary, item)
VALUE
rb_ary_entry(ary, offset)
VALUE ary;
- size_t offset;
+ int offset;
{
if (RARRAY(ary)->len == 0) return Qnil;
@@ -343,12 +351,13 @@ rb_ary_entry(ary, offset)
static VALUE
rb_ary_subseq(ary, beg, len)
VALUE ary;
- size_t beg, len;
+ int beg, len;
{
VALUE ary2;
- if (len <= 0) {
- return rb_ary_new2(0);
+ if (len == 0) return rb_ary_new2(0);
+ if (len < 0) {
+ rb_raise(rb_eIndexError, "negative length %d", len);
}
if (beg < 0) {
len += beg;
@@ -371,11 +380,10 @@ rb_ary_subseq(ary, beg, len)
static VALUE
beg_len(range, begp, lenp, len)
VALUE range;
- size_t *begp, *lenp;
- size_t len;
+ int *begp, *lenp, len;
{
- size_t beg, end;
- size_t b, e;
+ int beg, end;
+ int b, e;
if (!rb_range_beg_end(range, &beg, &end)) return Qfalse;
b = beg; e = end;
@@ -386,17 +394,20 @@ beg_len(range, begp, lenp, len)
if (end < 0) {
end = len + end;
}
+ *begp = beg;
if (beg > end) {
+ if (e == -1) {
+ *lenp = 0;
+ return Qtrue;
+ }
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;
+ *lenp = end - beg + 1;
}
return Qtrue;
}
@@ -408,11 +419,11 @@ rb_ary_aref(argc, argv, ary)
VALUE ary;
{
VALUE arg1, arg2;
- size_t beg, len;
+ int beg, len;
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
- beg = NUM2UINT(arg1);
- len = NUM2UINT(arg2);
+ beg = NUM2INT(arg1);
+ len = NUM2INT(arg2);
if (beg < 0) {
beg = RARRAY(ary)->len + beg;
}
@@ -421,7 +432,7 @@ rb_ary_aref(argc, argv, ary)
/* special case - speeding up */
if (FIXNUM_P(arg1)) {
- return rb_ary_entry(ary, FIX2UINT(arg1));
+ return rb_ary_entry(ary, FIX2INT(arg1));
}
else if (TYPE(arg1) == T_BIGNUM) {
rb_raise(rb_eIndexError, "index too big");
@@ -430,7 +441,7 @@ rb_ary_aref(argc, argv, ary)
/* check if idx is Range */
return rb_ary_subseq(ary, beg, len);
}
- return rb_ary_entry(ary, NUM2UINT(arg1));
+ return rb_ary_entry(ary, NUM2INT(arg1));
}
static VALUE
@@ -438,7 +449,7 @@ rb_ary_index(ary, val)
VALUE ary;
VALUE val;
{
- size_t i;
+ int i;
for (i=0; i<RARRAY(ary)->len; i++) {
if (rb_equal(RARRAY(ary)->ptr[i], val))
@@ -452,7 +463,7 @@ rb_ary_rindex(ary, val)
VALUE ary;
VALUE val;
{
- size_t i = RARRAY(ary)->len;
+ int i = RARRAY(ary)->len;
while (i--) {
if (rb_equal(RARRAY(ary)->ptr[i], val))
@@ -468,11 +479,11 @@ rb_ary_indexes(argc, argv, ary)
VALUE ary;
{
VALUE new_ary;
- size_t i;
+ int 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_store(new_ary, i, rb_ary_entry(ary, NUM2INT(argv[i])));
}
return new_ary;
@@ -481,7 +492,7 @@ rb_ary_indexes(argc, argv, ary)
static void
rb_ary_replace(ary, beg, len, rpl)
VALUE ary, rpl;
- size_t beg, len;
+ int beg, len;
{
if (len < 0) {
rb_raise(rb_eIndexError, "negative length %d", len);
@@ -511,7 +522,7 @@ rb_ary_replace(ary, beg, len, rpl)
RARRAY(ary)->len = len;
}
else {
- size_t alen;
+ int alen;
if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
@@ -539,25 +550,30 @@ rb_ary_aset(argc, argv, ary)
VALUE ary;
{
VALUE arg1, arg2, arg3;
- size_t offset;
- size_t beg, len;
+ int offset, beg, len;
if (rb_scan_args(argc, argv, "21", &arg1, &arg2, &arg3) == 3) {
- beg = NUM2UINT(arg1);
- len = NUM2UINT(arg2);
+ beg = NUM2INT(arg1);
+ len = NUM2INT(arg2);
if (beg < 0) {
beg = RARRAY(ary)->len + beg;
}
+#ifdef INABA
+ if (len < 0) return Qnil;
+#endif
rb_ary_replace(ary, beg, len, arg3);
return arg3;
}
else if (FIXNUM_P(arg1)) {
- offset = FIX2UINT(arg1);
+ offset = FIX2INT(arg1);
goto fixnum;
}
else if (beg_len(arg1, &beg, &len, RARRAY(ary)->len)) {
/* check if idx is Range */
+#ifdef INABA
+ if (len < 0) return Qnil;
+#endif
rb_ary_replace(ary, beg, len, arg2);
return arg2;
}
@@ -565,7 +581,7 @@ rb_ary_aset(argc, argv, ary)
rb_raise(rb_eIndexError, "index too big");
}
- offset = NUM2UINT(arg1);
+ offset = NUM2INT(arg1);
fixnum:
rb_ary_store(ary, offset, arg2);
return arg2;
@@ -575,7 +591,7 @@ VALUE
rb_ary_each(ary)
VALUE ary;
{
- size_t i;
+ int i;
for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(RARRAY(ary)->ptr[i]);
@@ -587,7 +603,7 @@ static VALUE
rb_ary_each_index(ary)
VALUE ary;
{
- size_t i;
+ int i;
for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(INT2FIX(i));
@@ -599,7 +615,7 @@ static VALUE
rb_ary_reverse_each(ary)
VALUE ary;
{
- size_t len = RARRAY(ary)->len;
+ int len = RARRAY(ary)->len;
while (len--) {
rb_yield(RARRAY(ary)->ptr[len]);
@@ -663,7 +679,7 @@ VALUE
rb_ary_join(ary, sep)
VALUE ary, sep;
{
- size_t i;
+ int i;
VALUE result, tmp;
if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
@@ -815,7 +831,7 @@ rb_inspecting_p(obj)
inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
if (NIL_P(inspect_tbl)) return Qfalse;
#else
- if (!inspect_tbl) return Qnil;
+ if (!inspect_tbl) return Qfalse;
#endif
return rb_ary_includes(inspect_tbl, obj);
}
@@ -824,7 +840,7 @@ static VALUE
inspect_ary(ary)
VALUE ary;
{
- size_t i = 0;
+ int i = 0;
VALUE s, str;
str = rb_str_new2("[");
@@ -953,7 +969,7 @@ rb_ary_delete(ary, item)
VALUE ary;
VALUE item;
{
- size_t i1, i2;
+ int i1, i2;
rb_ary_modify(ary);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
@@ -981,11 +997,11 @@ rb_ary_delete_at(ary, at)
VALUE ary;
VALUE at;
{
- size_t i1, i2, pos;
+ int i1, i2, pos;
VALUE del = Qnil;
rb_ary_modify(ary);
- pos = NUM2UINT(at);
+ pos = NUM2INT(at);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
if (i1 == pos) {
del = RARRAY(ary)->ptr[i1];
@@ -1005,11 +1021,11 @@ static VALUE
rb_ary_delete_if(ary)
VALUE ary;
{
- size_t i1, i2;
+ int 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 +1040,7 @@ static VALUE
rb_ary_filter(ary)
VALUE ary;
{
- size_t i;
+ int i;
rb_ary_modify(ary);
for (i = 0; i < RARRAY(ary)->len; i++) {
@@ -1061,7 +1077,7 @@ rb_ary_fill(argc, argv, ary)
VALUE ary;
{
VALUE item, arg1, arg2;
- size_t beg, len, end;
+ int beg, end, len;
VALUE *p, *pend;
if (rb_scan_args(argc, argv, "12", &item, &arg1, &arg2) == 2 &&
@@ -1069,12 +1085,12 @@ rb_ary_fill(argc, argv, ary)
/* beg and len set already */
}
else {
- beg = NIL_P(arg1)?0:NUM2UINT(arg1);
+ beg = NIL_P(arg1)?0:NUM2INT(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:NUM2INT(arg2);
}
rb_ary_modify(ary);
end = beg + len;
@@ -1138,13 +1154,13 @@ rb_ary_times(ary, times)
VALUE times;
{
VALUE ary2;
- size_t i, len;
+ int i, len;
if (TYPE(times) == T_STRING) {
return rb_ary_join(ary, times);
}
- len = NUM2UINT(times);
+ len = NUM2INT(times);
if (len < 0) {
rb_raise(rb_eArgError, "negative argument");
}
@@ -1200,7 +1216,7 @@ static VALUE
rb_ary_equal(ary1, ary2)
VALUE ary1, ary2;
{
- size_t i;
+ int i;
if (TYPE(ary2) != T_ARRAY) return Qfalse;
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
@@ -1215,7 +1231,7 @@ static VALUE
rb_ary_eql(ary1, ary2)
VALUE ary1, ary2;
{
- size_t i;
+ int i;
if (TYPE(ary2) != T_ARRAY) return Qfalse;
if (RARRAY(ary1)->len != RARRAY(ary2)->len)
@@ -1231,8 +1247,7 @@ static VALUE
rb_ary_hash(ary)
VALUE ary;
{
- size_t i;
- int h;
+ int i, h;
h = RARRAY(ary)->len;
for (i=0; i<RARRAY(ary)->len; i++) {
@@ -1247,7 +1262,7 @@ rb_ary_includes(ary, item)
VALUE ary;
VALUE item;
{
- size_t i;
+ int i;
for (i=0; i<RARRAY(ary)->len; i++) {
if (rb_equal(RARRAY(ary)->ptr[i], item)) {
return Qtrue;
@@ -1261,7 +1276,7 @@ rb_ary_cmp(ary, ary2)
VALUE ary;
VALUE ary2;
{
- size_t i, len;
+ int i, len;
ary2 = to_ary(ary2);
len = RARRAY(ary)->len;
@@ -1285,7 +1300,7 @@ rb_ary_diff(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
- size_t i;
+ int i;
ary2 = to_ary(ary2);
ary3 = rb_ary_new();
@@ -1302,7 +1317,7 @@ rb_ary_and(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
- size_t i;
+ int i;
ary2 = to_ary(ary2);
ary3 = rb_ary_new();
@@ -1320,7 +1335,7 @@ rb_ary_or(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
- size_t i;
+ int i;
if (TYPE(ary2) != T_ARRAY) {
if (rb_ary_includes(ary1, ary2)) return ary1;
@@ -1414,7 +1429,7 @@ static VALUE
rb_ary_nitems(ary)
VALUE ary;
{
- size_t n = 0;
+ int n = 0;
VALUE *p, *pend;
p = RARRAY(ary)->ptr;
@@ -1430,7 +1445,7 @@ static VALUE
rb_ary_flatten_bang(ary)
VALUE ary;
{
- size_t i;
+ int i;
int mod = 0;
rb_ary_modify(ary);
@@ -1504,6 +1519,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 770e86a..8ba36bb 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;
+ int len;
char sign;
{
NEWOBJ(big, struct RBignum);
@@ -79,7 +79,7 @@ static VALUE
bignorm(x)
VALUE x;
{
- size_t len = RBIGNUM(x)->len;
+ int len = RBIGNUM(x)->len;
USHORT *ds = BDIGITS(x);
while (len-- && !ds[len]) ;
@@ -170,7 +170,7 @@ rb_str2inum(str, base)
{
char sign = 1, c;
unsigned long num;
- size_t len, blen = 1;
+ int len, blen = 1;
int 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,10 +208,13 @@ 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);
}
@@ -352,7 +359,7 @@ rb_big2ulong(x)
VALUE x;
{
unsigned long num;
- size_t len = RBIGNUM(x)->len;
+ int len = RBIGNUM(x)->len;
USHORT *ds;
if (len > sizeof(long)/sizeof(USHORT))
@@ -396,7 +403,14 @@ rb_dbl2big(d)
VALUE z;
double u = (d < 0)?-d:d;
- while (0 != (long)u) {
+ if (isinf(d)) {
+ rb_raise(rb_eFloatDomainError, d < 0 ? "-Inifinity" : "Inifinity");
+ }
+ 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;
+ int 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;
+ int 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;
+ int 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;
+ int 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;
+ int 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;
+ int 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 nx = RBIGNUM(x)->len, ny = RBIGNUM(y)->len;
int i, j;
VALUE yy, z;
USHORT *xds, *yds, *zds, *tds;
- size_t t2;
+ unsigned long t2;
long num;
USHORT dd, q;
@@ -714,7 +728,7 @@ bigdivmod(x, y, div, mod, modulo)
if (div) *div = bignorm(z);
if (mod) {
if (!RBIGNUM(y)->sign) t2 = -(long)t2;
- *mod = INT2FIX(t2);
+ *mod = INT2NUM(t2);
}
return;
}
@@ -798,7 +812,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;
+ int len = ny;
zds = BDIGITS(*mod);
while (len-- && !zds[len]);
if (len > 0) {
@@ -936,6 +950,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 +968,7 @@ rb_big_and(x, y)
{
VALUE z;
USHORT *ds1, *ds2, *zds;
- size_t i, l1, l2;
+ int i, l1, l2;
char sign;
if (FIXNUM_P(y)) {
@@ -1112,11 +1127,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;
+ int len, i;
if (shift < 0) return rb_big_rshift(x, INT2FIX(-shift));
xds = BDIGITS(x);
@@ -1141,12 +1156,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;
+ int i = RBIGNUM(x)->len;
+ int j;
if (shift < 0) return rb_big_lshift(x, INT2FIX(-shift));
if (s1 > RBIGNUM(x)->len) {
@@ -1173,7 +1188,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 +1212,7 @@ static VALUE
rb_big_hash(x)
VALUE x;
{
- size_t i, len;
+ int i, len;
int key;
USHORT *digits;
@@ -1243,7 +1258,7 @@ rb_big_rand(max)
VALUE max;
{
struct RBignum *v;
- size_t len;
+ int len;
len = RBIGNUM(max)->len;
v = RBIGNUM(bignew(len,1));
diff --git a/class.c b/class.c
index 86ac8c5..93f8226 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
************************************************/
@@ -365,6 +365,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 +428,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)) {
@@ -596,10 +600,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 +616,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,10 +628,10 @@ 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') {
diff --git a/compar.c b/compar.c
index a6212a8..50e4fa3 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.dj b/config.dj
deleted file mode 100644
index 8ad3883..0000000
--- a/config.dj
+++ /dev/null
@@ -1,36 +0,0 @@
-#define THREAD 1
-#define HAVE_DIRENT_H 1
-#define HAVE_UNISTD_H 1
-#define HAVE_LIMITS_H 1
-#define HAVE_SYS_FILE_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_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_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 1 */
-/* #define HAVE_SETITIMER 1 */
-#define HAVE_GETGROUPS 1
-#define HAVE_SIGPROCMASK 1
-#define FILE_COUNT _cnt
-#define DLEXT ".so"
-#define RUBY_LIB ";/usr/local/lib/ruby;."
-#define RUBY_ARCHLIB "/usr/local/lib/ruby/i386-djgpp"
-#define RUBY_PLATFORM "i386-djgpp"
diff --git a/config.sub b/config.sub
index 858aba7..48d744c 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-* \
diff --git a/configure b/configure
index 31a40f0..2130847 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
@@ -343,7 +343,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 +532,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"
@@ -596,7 +603,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:607: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@@ -621,13 +628,13 @@ 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:638: checking target architecture" >&5
case "$host_os" in
rhapsody*)
@@ -692,7 +699,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:703: 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 +729,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:733: 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 +780,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:784: 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 +812,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:816: 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 +823,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
-#line 820 "configure"
+#line 827 "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:832: \"$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 +854,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:858: 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:863: 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 +868,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:872: \"$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 +887,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:891: 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 +919,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:923: 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 +934,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 938 "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:944: \"$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 +951,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 948 "configure"
+#line 955 "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:961: \"$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 +968,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 965 "configure"
+#line 972 "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:978: \"$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 +1000,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:1004: 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 1010 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -1017,7 +1024,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
-#line 1021 "configure"
+#line 1028 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -1043,7 +1050,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:1054: 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 +1083,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:1087: 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 +1116,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:1120: 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
@@ -1151,7 +1158,7 @@ test -n "$AR" || AR="ar"
# 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
+echo "configure:1162: 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 "(cached) $ac_c" 1>&6
@@ -1203,8 +1210,29 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
+echo "configure:1215: 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
+ 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
+fi
+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:1236: 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
@@ -1234,17 +1262,17 @@ fi
# 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:1266: 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 1271 "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:1276: \"$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 +1311,7 @@ fi
echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:1287: checking size of int" >&5
+echo "configure:1315: 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 +1319,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 1323 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -1302,7 +1330,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:1334: \"$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 +1349,47 @@ cat >> confdefs.h <<EOF
EOF
+echo $ac_n "checking size of short""... $ac_c" 1>&6
+echo "configure:1354: 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 1362 "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:1373: \"$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:1393: 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 +1397,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 1401 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -1341,7 +1408,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:1412: \"$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 +1428,7 @@ EOF
echo $ac_n "checking size of void*""... $ac_c" 1>&6
-echo "configure:1365: checking size of void*" >&5
+echo "configure:1432: 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 +1436,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 1440 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -1380,7 +1447,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:1451: \"$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 +1466,99 @@ cat >> confdefs.h <<EOF
EOF
+echo $ac_n "checking size of float""... $ac_c" 1>&6
+echo "configure:1471: 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 1479 "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:1490: \"$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:1510: 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 1518 "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:1529: \"$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:1550: 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 1555 "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:1562: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_have_prototypes=yes
else
@@ -1433,13 +1578,51 @@ EOF
fi
+echo $ac_n "checking token paste string""... $ac_c" 1>&6
+echo "configure:1583: 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 1588 "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:1595: \"$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:1621: 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 1626 "configure"
#include "confdefs.h"
#include <stdarg.h>
@@ -1456,7 +1639,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:1643: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_stdarg=yes
else
@@ -1477,19 +1660,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:1664: 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 1669 "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:1676: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_have_attr_noreturn=yes
else
@@ -1518,7 +1701,7 @@ beos*) ;;
*) 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:1705: 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 +1709,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lcrypt $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1530 "configure"
+#line 1713 "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 +1720,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:1724: \"$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 +1748,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:1752: 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 +1756,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1577 "configure"
+#line 1760 "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 +1767,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:1771: \"$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 +1795,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:1799: 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 +1803,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldld $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1624 "configure"
+#line 1807 "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 +1814,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:1818: \"$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 +1842,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:1846: 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 +1850,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lxpg4 $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1671 "configure"
+#line 1854 "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 +1861,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:1865: \"$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 +1894,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:1898: 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 1903 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_hdr>
@@ -1724,7 +1907,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:1911: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_header_dirent_$ac_safe=yes"
else
@@ -1749,7 +1932,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:1936: 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 +1940,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldir $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1761 "configure"
+#line 1944 "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 +1951,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:1955: \"$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 +1973,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:1977: 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 +1981,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lx $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1802 "configure"
+#line 1985 "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 +1992,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:1996: \"$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 +2015,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:2019: 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 2024 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -1845,7 +2028,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:2032: \"$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 +2045,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 2049 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -1880,7 +2063,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 2067 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -1901,7 +2084,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 1905 "configure"
+#line 2088 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1912,7 +2095,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:2099: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -1941,17 +2124,17 @@ for ac_hdr in stdlib.h unistd.h limits.h sys/file.h sys/ioctl.h pwd.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:2128: 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 2133 "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:2138: \"$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 +2162,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:2166: 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 2171 "configure"
#include "confdefs.h"
#include <sys/types.h>
EOF
@@ -2013,12 +2196,12 @@ EOF
fi
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:2017: checking for size_t" >&5
+echo "configure:2200: 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 2205 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -2046,12 +2229,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:2233: 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 2238 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -2059,7 +2242,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:2246: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_blksize=yes
else
@@ -2081,12 +2264,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:2268: 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 2273 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -2094,7 +2277,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:2281: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_blocks=yes
else
@@ -2118,12 +2301,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:2305: 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 2310 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -2131,7 +2314,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:2318: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_rdev=yes
else
@@ -2153,7 +2336,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:2340: 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 +2344,7 @@ else
ac_cv_type_getgroups=cross
else
cat > conftest.$ac_ext <<EOF
-#line 2165 "configure"
+#line 2348 "configure"
#include "confdefs.h"
/* Thanks to Mike Rendell for this test. */
@@ -2186,7 +2369,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:2373: \"$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 +2383,7 @@ fi
if test $ac_cv_type_getgroups = cross; then
cat > conftest.$ac_ext <<EOF
-#line 2204 "configure"
+#line 2387 "configure"
#include "confdefs.h"
#include <unistd.h>
EOF
@@ -2224,12 +2407,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:2411: 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 2416 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -2246,7 +2429,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:2433: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -2267,19 +2450,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:2454: 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 2459 "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:2466: \"$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 +2483,12 @@ EOF
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:2304: checking for alloca" >&5
+echo "configure:2487: 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 2492 "configure"
#include "confdefs.h"
#ifdef __GNUC__
@@ -2333,7 +2516,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:2520: \"$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 +2548,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:2552: 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 2557 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@@ -2395,12 +2578,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:2582: 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 2587 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2423,7 +2606,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:2610: \"$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 +2633,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:2637: 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 +2641,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
-#line 2462 "configure"
+#line 2645 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@@ -2477,7 +2660,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:2664: \"$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 +2682,12 @@ EOF
fi
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2503: checking for pid_t" >&5
+echo "configure:2686: 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 2691 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -2533,17 +2716,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:2720: 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 2725 "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:2730: \"$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 +2751,18 @@ else
fi
echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:2572: checking for working vfork" >&5
+echo "configure:2755: 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:2761: 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 2766 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vfork(); below. */
@@ -2602,7 +2785,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:2789: \"$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 +2807,7 @@ fi
ac_cv_func_vfork_works=$ac_cv_func_vfork
else
cat > conftest.$ac_ext <<EOF
-#line 2628 "configure"
+#line 2811 "configure"
#include "confdefs.h"
/* Thanks to Paul Eggert for this test. */
#include <stdio.h>
@@ -2719,7 +2902,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:2906: \"$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 +2925,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:2929: 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 +2933,7 @@ else
ac_cv_func_memcmp_clean=no
else
cat > conftest.$ac_ext <<EOF
-#line 2754 "configure"
+#line 2937 "configure"
#include "confdefs.h"
main()
@@ -2760,7 +2943,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:2947: \"$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
@@ -2778,15 +2961,16 @@ 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
+ 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:2969: 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 2974 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2809,7 +2993,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:2997: \"$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 +3022,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:3030: 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 3035 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2870,7 +3054,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:3058: \"$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
@@ -2896,12 +3080,12 @@ 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 "configure:3084: 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 3089 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <time.h>
@@ -2909,7 +3093,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:3097: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm=time.h
else
@@ -2930,12 +3114,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:3118: 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 3123 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_cv_struct_tm>
@@ -2943,7 +3127,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:3131: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm_zone=yes
else
@@ -2963,12 +3147,12 @@ EOF
else
echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:2967: checking for tzname" >&5
+echo "configure:3151: 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 3156 "configure"
#include "confdefs.h"
#include <time.h>
#ifndef tzname /* For SGI. */
@@ -2978,7 +3162,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:3166: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var_tzname=yes
else
@@ -3000,14 +3184,14 @@ EOF
fi
cat > conftest.$ac_ext <<EOF
-#line 3004 "configure"
+#line 3188 "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:3195: \"$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 +3211,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:3215: 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 3223 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -3057,7 +3241,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:3245: \"$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 +3255,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 +3264,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:3269: 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 3277 "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:3332: \"$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:3356: 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 3364 "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:3384: \"$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:3409: 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 3417 "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:3447: \"$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:3465: 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 3472 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -3176,11 +3479,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:3483: \"$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 3487 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -3191,7 +3494,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:3498: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
@@ -3211,7 +3514,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 3518 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
@@ -3224,7 +3527,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:3531: \"$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
@@ -3248,14 +3551,14 @@ 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:3555: 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 3562 "configure"
#include "confdefs.h"
#ifdef __CHAR_UNSIGNED__
yes
@@ -3277,7 +3580,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 3584 "configure"
#include "confdefs.h"
/* volatile prevents gcc2 from optimizing the test away on sparcs. */
#if !defined(__STDC__) || __STDC__ != 1
@@ -3287,7 +3590,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:3594: \"$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 +3615,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:3619: 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 3627 "configure"
#include "confdefs.h"
int
@@ -3332,7 +3635,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:3639: \"$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 +3649,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 +3663,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:3667: 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 3672 "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:3679: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="_cnt"
else
@@ -3382,14 +3685,14 @@ fi
rm -f conftest*
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3386 "configure"
+#line 3689 "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:3696: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="__cnt"
else
@@ -3400,14 +3703,14 @@ rm -f conftest*
fi
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3404 "configure"
+#line 3707 "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:3714: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="_r"
else
@@ -3418,14 +3721,14 @@ rm -f conftest*
fi
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3422 "configure"
+#line 3725 "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:3732: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="readCount"
else
@@ -3464,15 +3767,15 @@ 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:3771: 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 3779 "configure"
#include "confdefs.h"
/* Test for whether ELF binaries are produced */
@@ -3492,24 +3795,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:3799: \"$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,7 +3825,7 @@ 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:3829: checking whether OS depend dynamic link works" >&5
if test "$GCC" = yes; then
case "$host_os" in
nextstep*) ;;
@@ -3530,14 +3833,14 @@ echo "configure:3526: checking whether OS depend dynamic link works" >&5
rhapsody*) ;;
human*) ;;
cygwin*) CCDLFLAGS=-DDLLIMPORT;;
- *) CCDLFLAGS=-fpic;;
+ *) 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
@@ -3548,6 +3851,7 @@ echo "configure:3526: checking whether OS depend dynamic link works" >&5
LDFLAGS="-Wl,-E"
rb_cv_dlopen=yes;;
solaris*) LDSHARED='ld -G'
+ test "$GCC" = yes && `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null && LDFLAGS="-Wl,-E"
rb_cv_dlopen=yes;;
sunos*) LDSHARED='ld -assert nodefinitions'
rb_cv_dlopen=yes;;
@@ -3559,15 +3863,25 @@ echo "configure:3526: checking whether OS depend dynamic link works" >&5
rb_cv_dlopen=yes ;;
linux*) LDSHARED="gcc -shared"
rb_cv_dlopen=yes ;;
- freebsd3*) LDSHARED="ld -Bshareable"
- LDFLAGS="-rdynamic"
- rb_cv_dlopen=yes ;;
- freebsd*) LDSHARED="ld -Bshareable"
+ freebsd*) LDSHARED="gcc -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"
+ case "$host_cpu" in
+ alpha|mips)
+ LDFLAGS="-export-dynamic" ;;
+ *)
+ ;;
+ esac
rb_cv_dlopen=yes ;;
openbsd*) LDSHARED="ld -Bforcearchive -Bshareable"
- CCDLFLAGS=-fPIC
rb_cv_dlopen=yes ;;
nextstep*) LDSHARED='cc -r'
LDFLAGS="-u libsys_s"
@@ -3586,11 +3900,15 @@ echo "configure:3526: checking whether OS depend dynamic link works" >&5
human*) DLDFLAGS=''
LDSHARED=''
LDFLAGS='' ;;
- beos*) LDSHARED="ld -xms"
- case "$host_cpu" in
+ 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"
;;
@@ -3605,14 +3923,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:3929: 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 3934 "configure"
#include "confdefs.h"
#define USE_DLN_A_OUT
@@ -3622,7 +3940,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:3944: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_dln_a_out=yes
else
@@ -3634,7 +3952,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
@@ -3724,7 +4042,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:4046: 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 +4050,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsignal $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3736 "configure"
+#line 4054 "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 +4061,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:4065: \"$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 +4089,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:4093: 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 +4097,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lhmem $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3783 "configure"
+#line 4101 "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 +4108,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:4112: \"$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 +4138,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:4142: 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 4147 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3848,7 +4166,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:4170: \"$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 +4191,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:4195: 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 4203 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -3893,7 +4211,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:4215: \"$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 +4225,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 +4233,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:4237: 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 4245 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -3936,7 +4254,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:4258: \"$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 +4268,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
@@ -3985,18 +4303,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 +4327,30 @@ if test "$host_os" = "beos"; then
esac
fi
+LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
+LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
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*|linux*)
+ 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
+ ;;
+ hpux*)
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
+ LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl'
+ ;;
+ *)
+ ;;
+ esac
fi
case "$host_os" in
@@ -4029,6 +4372,9 @@ esac
+
+
+
ri_prefix=
test "$program_prefix" != NONE &&
ri_prefix=$program_prefix
@@ -4038,12 +4384,14 @@ test "$program_suffix" != NONE &&
ri_suffix=$program_suffix
RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
+#RUBY_LIB_PATH="${prefix}/lib/${RUBY_INSTALL_NAME}/${MAJOR}.${MINOR}"
+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
cat >> confdefs.h <<EOF
-#define RUBY_SITE_LIB "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby"
+#define RUBY_SITE_LIB "${RUBY_LIB_PATH}/site_ruby"
EOF
@@ -4051,42 +4399,29 @@ 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}"
-EOF
-
-
- cat >> confdefs.h <<EOF
-#define RUBY_SITE_THIN_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/" __ARCHITECTURE__ "-${host_os}"
-EOF
-
-
- cat >> confdefs.h <<EOF
-#define RUBY_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/${arch}"
+#define RUBY_THIN_ARCHLIB "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${host_os}"
EOF
- cat >> confdefs.h <<EOF
-#define RUBY_SITE_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby/${arch}"
-EOF
cat >> confdefs.h <<EOF
-#define RUBY_PLATFORM __ARCHITECTURE__ "-${host_os}"
+#define RUBY_SITE_THIN_ARCHLIB "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${host_os}"
EOF
else
arch="${host_cpu}-${host_os}"
- cat >> confdefs.h <<EOF
-#define RUBY_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/${arch}"
+fi
+cat >> confdefs.h <<EOF
+#define RUBY_ARCHLIB "${RUBY_LIB_PATH}/${arch}"
EOF
- cat >> confdefs.h <<EOF
-#define RUBY_SITE_ARCHLIB "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby/${arch}"
+cat >> confdefs.h <<EOF
+#define RUBY_SITE_ARCHLIB "${RUBY_LIB_PATH}/site_ruby/${arch}"
EOF
- cat >> confdefs.h <<EOF
+cat >> confdefs.h <<EOF
#define RUBY_PLATFORM "${arch}"
EOF
-fi
echo "creating config.h"
cat confdefs.h > config.h
@@ -4193,7 +4528,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 ;;
@@ -4236,6 +4571,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
@@ -4249,6 +4587,7 @@ 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%@LIBOBJS@%$LIBOBJS%g
s%@ALLOCA@%$ALLOCA%g
@@ -4261,6 +4600,10 @@ s%@STRIP@%$STRIP%g
s%@EXTSTATIC@%$EXTSTATIC%g
s%@binsuffix@%$binsuffix%g
s%@setup@%$setup%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
diff --git a/configure.in b/configure.in
index 0477ade..8894cd6 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
@@ -31,12 +38,12 @@ 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*)
@@ -85,27 +92,39 @@ AC_PROG_RANLIB
AC_SUBST(AR)
AC_CHECK_PROGS(AR, ar aal, ar)
AC_PROG_INSTALL
+AC_PROG_LN_S
AC_PROG_MAKE_SET
# 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 +138,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
@@ -171,12 +187,13 @@ 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)
+ 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)
if test "$ac_cv_func_strftime" = no; then
AC_STRUCT_TIMEZONE
AC_TRY_LINK([],
@@ -186,8 +203,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 +224,50 @@ 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_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 +278,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", )
@@ -296,8 +319,7 @@ AC_ARG_WITH(dln-a-out, [--with-dln-a-out use dln_a_out if possible], [
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 +337,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;;
@@ -346,14 +367,14 @@ if test "$with_dln_a_out" != yes; then
rhapsody*) ;;
human*) ;;
cygwin*) CCDLFLAGS=-DDLLIMPORT;;
- *) CCDLFLAGS=-fpic;;
+ *) 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
@@ -364,6 +385,7 @@ if test "$with_dln_a_out" != yes; then
LDFLAGS="-Wl,-E"
rb_cv_dlopen=yes;;
solaris*) LDSHARED='ld -G'
+ test "$GCC" = yes && `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null && LDFLAGS="-Wl,-E"
rb_cv_dlopen=yes;;
sunos*) LDSHARED='ld -assert nodefinitions'
rb_cv_dlopen=yes;;
@@ -375,15 +397,25 @@ if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=yes ;;
linux*) LDSHARED="gcc -shared"
rb_cv_dlopen=yes ;;
- freebsd3*) LDSHARED="ld -Bshareable"
- LDFLAGS="-rdynamic"
- rb_cv_dlopen=yes ;;
- freebsd*) LDSHARED="ld -Bshareable"
+ freebsd*) LDSHARED="gcc -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"
+ case "$host_cpu" in
+ alpha|mips)
+ LDFLAGS="-export-dynamic" ;;
+ *)
+ ;;
+ esac
rb_cv_dlopen=yes ;;
openbsd*) LDSHARED="ld -Bforcearchive -Bshareable"
- CCDLFLAGS=-fPIC
rb_cv_dlopen=yes ;;
nextstep*) LDSHARED='cc -r'
LDFLAGS="-u libsys_s"
@@ -402,11 +434,15 @@ if test "$with_dln_a_out" != yes; then
human*) DLDFLAGS=''
LDSHARED=''
LDFLAGS='' ;;
- beos*) LDSHARED="ld -xms"
- case "$host_cpu" in
+ 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"
;;
@@ -421,9 +457,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 +466,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)
@@ -498,8 +532,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 +546,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,8 +565,7 @@ 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
@@ -565,18 +597,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 +621,30 @@ if test "$host_os" = "beos"; then
esac
fi
+LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
+LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
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*|linux*)
+ 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
+ ;;
+ hpux*)
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
+ LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl'
+ ;;
+ *)
+ ;;
+ esac
fi
case "$host_os" in
@@ -604,7 +661,10 @@ case "$host_os" in
;;
esac
-
+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,28 +678,26 @@ 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_INSTALL_NAME}/${MAJOR}.${MINOR}"
+RUBY_LIB_PATH="${prefix}/lib/ruby/${MAJOR}.${MINOR}"
+AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
+AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_LIB_PATH}/site_ruby")
AC_SUBST(arch)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_LIB_PATH}/" __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_LIB_PATH}/site_ruby/${arch}")
+AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}")
echo "creating config.h"
cat confdefs.h > config.h
diff --git a/defines.h b/defines.h
index fb10d62..d9b744b 100644
--- a/defines.h
+++ b/defines.h
@@ -31,7 +31,7 @@
#endif /* NeXT */
#ifdef NT
-#include "missing/nt.h"
+#include "win32/win32.h"
#endif
#ifndef EXTERN
@@ -44,7 +44,7 @@
#define FLUSH_REGISTER_WINDOWS /* empty */
#endif
-#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__MACOS__)
+#if defined(MSDOS) || defined(NT) || defined(__human68k__)
#define RUBY_PATH_SEP ";"
#else
#define RUBY_PATH_SEP ":"
diff --git a/dir.c b/dir.c
index 51d7f9e..c77294c 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
************************************************/
diff --git a/dln.c b/dln.c
index 858291d..d8f6ec6 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
************************************************/
@@ -64,6 +64,7 @@ char *getenv();
# include <TextUtils.h>
# include <CodeFragments.h>
# include <Aliases.h>
+# include "macruby_private.h"
#endif
#ifdef __BEOS__
@@ -78,7 +79,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__)
# define FUNCNAME_PATTERN "_Init_%.200s"
# else
# define FUNCNAME_PATTERN "Init_%.200s"
@@ -1406,14 +1407,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)) {
@@ -1522,8 +1523,13 @@ dln_find_file(fname, path)
char *fname;
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__)
@@ -1561,14 +1567,17 @@ dln_find_1(fname, path, exe_flag)
register char *dp;
register char *ep;
register char *bp;
+#ifndef __MACOS__
struct stat st;
+#else
+ const char* mac_fullpath;
+#endif
#if defined(__CYGWIN32__)
char rubypath[MAXPATHLEN];
conv_to_posix_path(path, rubypath);
path = rubypath;
#endif
-#ifndef __MACOS__
if (fname[0] == '/') return fname;
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
return fname;
@@ -1580,7 +1589,6 @@ dln_find_1(fname, path, exe_flag)
return fname;
if (exe_flag && strchr(fname, '\\')) return fname;
#endif
-#endif /* __MACOS__ */
for (dp = path;; dp = ++ep) {
register int l;
@@ -1632,11 +1640,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,11 +1655,19 @@ 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;
}
+#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__)
if (exe_flag) {
static const char *extension[] = {
@@ -1679,8 +1691,13 @@ 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__ */
diff --git a/enum.c b/enum.c
index 2b4b904..dc7e211 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 79fdfc2..bdaac91 100644
--- a/env.h
+++ b/env.h
@@ -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 44ca067..98a77ce 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
************************************************/
@@ -124,7 +124,7 @@ rb_warning(fmt, va_alist)
char buf[BUFSIZ];
va_list args;
- if (!RTEST(rb_verbose)) return;
+ if (!RTEST(ruby_verbose)) return;
snprintf(buf, BUFSIZ, "warning: %s", fmt);
@@ -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);
@@ -283,13 +283,14 @@ 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)) {
@@ -337,7 +338,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
@@ -412,12 +416,12 @@ exception(argc, argv)
#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];
@@ -533,7 +537,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);
@@ -624,7 +629,7 @@ 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));
}
@@ -1081,18 +1086,18 @@ static void
err_append(s)
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 a7da313..d7a2314 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
************************************************/
@@ -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)
@@ -203,9 +207,9 @@ rb_alias(klass, name, 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,
@@ -367,7 +371,7 @@ rb_attr(klass, id, read, write, ex)
}
static ID init, eqq, each, aref, aset, match;
-VALUE rb_errinfo = Qnil;
+VALUE ruby_errinfo = Qnil;
extern NODE *ruby_eval_tree_begin;
extern NODE *ruby_eval_tree;
extern int ruby_nerrs;
@@ -629,22 +633,33 @@ static VALUE ruby_wrapper; /* security wrapper */
ruby_scope = _scope; \
scope_vmode = SCOPE_PUBLIC;
+#ifdef USE_THREAD
#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 {\
+ 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 /* not USE_THREAD */
+#define POP_SCOPE() \
+ 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;\
@@ -652,6 +667,7 @@ static void scope_dup(struct SCOPE *);
ruby_scope = _old;\
scope_vmode = _vmode;\
}
+#endif /* USE_THREAD */
static VALUE rb_eval _((VALUE,NODE*));
static VALUE eval _((VALUE,VALUE,VALUE,char*,int));
@@ -770,12 +786,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 +808,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, elen, 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);
}
}
@@ -842,7 +873,6 @@ error_print()
}
}
}
- safe_level = safe;
}
#if !defined(NT) && !defined(__MACOS__)
@@ -879,13 +909,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();
@@ -943,7 +976,7 @@ eval_node(self)
return result;
}
-int rb_in_eval;
+int ruby_in_eval;
#ifdef USE_THREAD
static void rb_thread_cleanup _((void));
@@ -1021,7 +1054,7 @@ ruby_run()
break;
case TAG_RAISE:
case TAG_FATAL:
- if (rb_obj_is_kind_of(rb_errinfo, rb_eSystemExit)) {
+ if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
exit(exit_status);
}
error_print();
@@ -1044,7 +1077,7 @@ compile_error(at)
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) {
@@ -1121,6 +1154,10 @@ rb_eval_cmd(cmd, arg)
val = eval(ruby_top_self, cmd, Qnil, 0, 0);
}
+#ifdef USE_THREAD
+ if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE))
+ FL_SET(saved_scope, SCOPE_DONT_RECYCLE);
+#endif
ruby_scope = saved_scope;
safe_level = safe;
POP_TAG();
@@ -1959,7 +1996,7 @@ rb_eval(self, node)
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 +2015,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;
@@ -2031,9 +2068,6 @@ 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));
if (node->nd_state) break;
if (nd_type(node->nd_beg) == NODE_LIT && FIXNUM_P(node->nd_beg->nd_lit) &&
@@ -2045,7 +2079,6 @@ rb_eval(self, node)
else {
node->nd_state = 1;
}
-#endif
break;
case NODE_FLIP2: /* like AWK */
@@ -2297,9 +2330,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 +2478,10 @@ rb_eval(self, node)
str2 = list->nd_head->nd_lit;
break;
case NODE_EVSTR:
- rb_in_eval++;
+ ruby_in_eval++;
list->nd_head = compile(list->nd_head->nd_lit,0);
ruby_eval_tree = 0;
- rb_in_eval--;
+ ruby_in_eval--;
if (ruby_nerrs > 0) {
compile_error("string expansion");
}
@@ -2514,10 +2547,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));
}
}
@@ -2581,10 +2614,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));
}
}
@@ -2686,7 +2719,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();
@@ -2728,7 +2761,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");
}
}
@@ -2939,7 +2972,7 @@ rb_f_exit(argc, argv, obj)
static void
rb_abort()
{
- if (rb_errinfo) {
+ if (ruby_errinfo) {
error_print();
}
rb_exit(1);
@@ -2969,7 +3002,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 +3015,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 +3061,34 @@ 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 */
@@ -3159,8 +3194,10 @@ rb_yield_0(val, self, klass)
POP_VARS();
ruby_block = block;
ruby_frame = ruby_frame->prev;
+#ifdef USE_THREAD
if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE))
FL_SET(old_scope, SCOPE_DONT_RECYCLE);
+#endif
ruby_scope = old_scope;
if (state) JUMP_TAG(state);
return result;
@@ -3339,7 +3376,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 +3387,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 +3400,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 +3424,7 @@ rb_rescue(b_proc, data1, r_proc, data2)
state = 0;
}
if (state == 0) {
- rb_errinfo = e_info;
+ ruby_errinfo = e_info;
}
}
POP_TAG();
@@ -3456,8 +3493,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,19 +3507,19 @@ 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";
}
@@ -3501,9 +3539,10 @@ rb_f_missing(argc, argv, obj)
if (!format) {
format = "undefined method `%s' for %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 +3550,7 @@ 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);
POP_FRAME();
return Qnil; /* not reached */
@@ -3681,7 +3718,6 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
rb_raise(rb_eSysStackError, "stack level too deep");
}
}
-
PUSH_ITER(itr);
PUSH_FRAME();
@@ -3998,9 +4034,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 +4050,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 +4068,7 @@ backtrace(lev)
rb_ary_push(ary, rb_str_new2(buf));
frame = frame->prev;
}
- safe_level = slev;
+
return ary;
}
@@ -4152,7 +4189,7 @@ 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;
}
@@ -4168,11 +4205,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;
+#ifdef USE_THREAD
if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE))
FL_SET(old_scope, SCOPE_DONT_RECYCLE);
+#endif
ruby_scope = old_scope;
ruby_block = old_block;
ruby_calling_block = old_call_block;
@@ -4191,20 +4230,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);
}
@@ -4303,7 +4342,8 @@ 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);
}
@@ -4394,6 +4434,16 @@ is_absolute_path(path)
return 0;
}
+#ifdef __MACOS__
+static int
+is_macos_native_path(path)
+ char *path;
+{
+ if (strchr(path, ':')) return 1;
+ return 0;
+}
+#endif
+
static char*
find_file(file)
char *file;
@@ -4402,6 +4452,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,6 +4470,12 @@ 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;
@@ -4447,11 +4513,6 @@ 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);
@@ -4491,9 +4552,9 @@ rb_load(fname, wrap)
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);
}
@@ -4510,7 +4571,7 @@ rb_load(fname, wrap)
POP_VARS();
ruby_wrapper = 0;
if (ruby_nerrs > 0) {
- rb_exc_raise(rb_errinfo);
+ rb_exc_raise(ruby_errinfo);
}
if (state) JUMP_TAG(state);
}
@@ -4609,7 +4670,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 +4682,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,19 +4697,19 @@ 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:
+ load_dyna:
#ifdef USE_THREAD
if (rb_thread_loading(feature)) return Qfalse;
else {
@@ -4669,7 +4730,7 @@ rb_f_require(obj, fname)
#endif
return Qtrue;
- rb_load:
+ load_rb:
#ifdef USE_THREAD
if (rb_thread_loading(feature)) return Qfalse;
else {
@@ -4689,6 +4750,20 @@ rb_f_require(obj, fname)
return Qtrue;
}
+static VALUE
+require_method(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ int i;
+
+ for (i=0; i<argc; i++) {
+ rb_f_require(self, argv[i]);
+ }
+ return Qnil;
+}
+
static void
set_method_visibility(self, argc, argv, ex)
VALUE self;
@@ -4854,6 +4929,17 @@ rb_obj_call_init(obj)
POP_ITER();
}
+void
+rb_obj_call_init2(obj, argc, argv)
+ VALUE obj;
+ int argc;
+ VALUE *argv;
+{
+ PUSH_ITER(rb_iterator_p()?ITER_PRE:ITER_NOT);
+ rb_funcall2(obj, init, argc, argv);
+ POP_ITER();
+}
+
VALUE
rb_class_new_instance(argc, argv, klass)
int argc;
@@ -4919,7 +5005,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 +5015,7 @@ static VALUE
errat_getter(id)
ID id;
{
- return get_backtrace(rb_errinfo);
+ return get_backtrace(ruby_errinfo);
}
static void
@@ -4938,10 +5024,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();
@@ -5055,7 +5141,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);
@@ -5131,7 +5217,7 @@ Init_load()
rb_define_readonly_variable("$\"", &rb_features);
rb_define_global_function("load", rb_f_load, -1);
- rb_define_global_function("require", rb_f_require, 1);
+ rb_define_global_function("require", require_method, -1);
rb_define_global_function("autoload", rb_f_autoload, 2);
rb_global_variable(&ruby_wrapper);
}
@@ -5740,7 +5826,7 @@ struct thread {
char *file;
int line;
- VALUE rb_errinfo;
+ VALUE errinfo;
VALUE last_status;
VALUE last_line;
VALUE last_match;
@@ -5801,9 +5887,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;
@@ -5830,7 +5917,6 @@ thread_mark(th)
}
block = block->prev;
}
- rb_mark_tbl(th->locals);
}
void
@@ -5893,7 +5979,7 @@ rb_thread_save_context(th)
th->misc = 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();
@@ -5926,6 +6012,12 @@ static int th_raise_line;
static VALUE th_cmd;
static int th_sig;
+#define RESTORE_NORMAL 0
+#define RESTORE_FATAL 1
+#define RESTORE_INTERRUPT 2
+#define RESTORE_TRAP 3
+#define RESTORE_RAISE 4
+
static void
rb_thread_restore_context(th, exit)
thread_t th;
@@ -5957,7 +6049,7 @@ rb_thread_restore_context(th, exit)
rb_trap_immediate = th->misc>>8;
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 +6066,27 @@ 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_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 +6126,45 @@ 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_restore_context(main_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
@@ -6143,7 +6266,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.
@@ -6175,10 +6305,15 @@ rb_thread_schedule()
fprintf(stderr, "%s:%d:deadlock 0x%x: %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 +6330,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 +6348,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();
}
}
@@ -6545,41 +6680,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 +6792,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 +6812,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 +6826,24 @@ 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)) {
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 (rb_thread_abort || curr_thread->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;
+ curr_thread->errinfo = ruby_errinfo;
}
}
rb_thread_schedule();
@@ -6751,13 +6890,13 @@ 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);
+ if (!NIL_P(th->errinfo)) {
+ VALUE oldbt = get_backtrace(th->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);
+ set_backtrace(th->errinfo, errat);
+ rb_exc_raise(th->errinfo);
}
return th->result;
@@ -6770,7 +6909,7 @@ 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)) return Qfalse;
return Qnil;
}
@@ -6844,7 +6983,7 @@ rb_thread_interrupt()
return;
}
curr_thread = main_thread;
- rb_thread_restore_context(curr_thread, 2);
+ rb_thread_restore_context(curr_thread, RESTORE_INTERRUPT);
}
void
@@ -6866,7 +7005,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,7 +7034,7 @@ 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 */
}
@@ -6957,13 +7096,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,35 +7139,9 @@ 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;
+ THREAD_ALLOC(th);
th->thread = cont = Data_Wrap_Struct(rb_cContinuation, thread_mark,
thread_free, th);
@@ -7063,7 +7174,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;
}
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c
index f4cb5c7..b57cf81 100644
--- a/ext/Win32API/Win32API.c
+++ b/ext/Win32API/Win32API.c
@@ -2,9 +2,11 @@
Win32API - Ruby Win32 API Import Facility
*/
+#ifndef _MSC_VER
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
+#endif
#define _T_VOID 0
#define _T_NUMBER 1
@@ -54,35 +56,35 @@ Win32API_initialize(self, dllname, proc, import, export)
if (!hdll) {
hdll = LoadLibrary(RSTRING(dllname)->ptr);
if (!hdll)
- Fail("LoadLibrary: %s\n", RSTRING(dllname)->ptr);
+ rb_raise(rb_eRuntimeError, "LoadLibrary: %s\n", RSTRING(dllname)->ptr);
Data_Wrap_Struct(self, 0, Win32API_FreeLibrary, hdll);
}
hproc = GetProcAddress(hdll, RSTRING(proc)->ptr);
if (!hproc) {
- str = str_new3(proc);
- str = str_cat(str, "A", 1);
+ str = rb_str_new3(proc);
+ str = rb_str_cat(str, "A", 1);
hproc = GetProcAddress(hdll, RSTRING(str)->ptr);
if (!hproc)
- Fail("GetProcAddress: %s or %s\n",
+ rb_raise(rb_eRuntimeError, "GetProcAddress: %s or %s\n",
RSTRING(proc)->ptr, RSTRING(str)->ptr);
}
rb_iv_set(self, "__dll__", INT2NUM((int)hdll));
rb_iv_set(self, "__dllname__", dllname);
rb_iv_set(self, "__proc__", INT2NUM((int)hproc));
- a_import = ary_new();
+ a_import = rb_ary_new();
ptr = RARRAY(import)->ptr;
for (i = 0, len = RARRAY(import)->len; i < len; i++) {
int c = *(char *)RSTRING(ptr[i])->ptr;
switch (c) {
case 'N': case 'n': case 'L': case 'l':
- ary_push(a_import, INT2FIX(_T_NUMBER));
+ rb_ary_push(a_import, INT2FIX(_T_NUMBER));
break;
case 'P': case 'p':
- ary_push(a_import, INT2FIX(_T_POINTER));
+ rb_ary_push(a_import, INT2FIX(_T_POINTER));
break;
case 'I': case 'i':
- ary_push(a_import, INT2FIX(_T_INTEGER));
+ rb_ary_push(a_import, INT2FIX(_T_INTEGER));
break;
}
}
@@ -146,18 +148,18 @@ Win32API_Call(argc, argv, obj)
texport = FIX2INT(obj_export);
if (items != nimport)
- Fail("Wrong number of parameters: expected %d, got %d.\n",
+ rb_raise(rb_eRuntimeError, "Wrong number of parameters: expected %d, got %d.\n",
nimport, items);
if (0 < nimport) {
for (i = nimport - 1; 0 <= i; i--) {
VALUE str;
- import_type = ary_entry(obj_import, i);
+ import_type = rb_ary_entry(obj_import, i);
timport = FIX2INT(import_type);
switch (timport) {
case _T_NUMBER:
case _T_INTEGER:
- lParam = NUM2INT(ary_entry(args, i));
+ lParam = NUM2INT(rb_ary_entry(args, i));
#if defined(_MSC_VER) || defined(__LCC__)
_asm {
mov eax, lParam
@@ -170,9 +172,9 @@ Win32API_Call(argc, argv, obj)
#endif
break;
case _T_POINTER:
- str = ary_entry(args, i);
+ str = rb_ary_entry(args, i);
Check_Type(str, T_STRING);
- str_modify(str);
+ rb_str_modify(str);
pParam = RSTRING(str)->ptr;
#if defined(_MSC_VER) || defined(__LCC__)
_asm {
@@ -197,7 +199,7 @@ Win32API_Call(argc, argv, obj)
break;
case _T_POINTER:
ApiFunctionPointer = (ApiPointer *) ApiFunction;
- Return = str_new2((char *)ApiFunctionPointer());
+ Return = rb_str_new2((char *)ApiFunctionPointer());
break;
case _T_INTEGER:
ApiFunctionInteger = (ApiInteger *) ApiFunction;
@@ -216,8 +218,14 @@ Win32API_Call(argc, argv, obj)
void
Init_Win32API()
{
- VALUE cWin32API = rb_define_class("Win32API", cObject);
+ VALUE cWin32API = rb_define_class("Win32API", rb_cObject);
rb_define_method(cWin32API, "initialize", Win32API_initialize, 4);
rb_define_method(cWin32API, "call", Win32API_Call, -1);
rb_define_alias(cWin32API, "Call", "call");
}
+
+void
+Init_win32api()
+{
+ Init_Win32API();
+}
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index f3d1bc0..89396a8 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -11,6 +11,9 @@
# ifdef HAVE_NCURSES_CURSES_H
# include <ncurses/curses.h>
# else
+#ifdef __hpux
+#include <curses_colr/curses.h>
+#else
# include <curses.h>
# if (defined(__bsdi__) || defined(__NetBSD__)) && !defined(_maxx)
# define _maxx maxx
@@ -26,6 +29,7 @@
# endif
# endif
#endif
+#endif
#include "ruby.h"
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index 442a942..8356241 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -8,6 +8,8 @@ if have_header("ncurses.h") and have_library("ncurses", "initscr")
make=TRUE
elsif have_header("ncurses/curses.h") and have_library("ncurses", "initscr")
make=TRUE
+elsif have_header("curses_colr/curses.h") and have_library("cur_colr", "initscr")
+ make=TRUE
else
$CFLAGS=nil
have_library("termcap", "tgetent")
diff --git a/ext/etc/MANIFEST b/ext/etc/MANIFEST
index a0f521b..79fb1ff 100644
--- a/ext/etc/MANIFEST
+++ b/ext/etc/MANIFEST
@@ -1,5 +1,6 @@
MANIFEST
etc.c
-etc.doc
+etc.txt
+etc.txt.jp
depend
extconf.rb
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index 058c144..ceadc4d 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -272,7 +272,7 @@ def create_makefile(target)
$DLDFLAGS = $DLDFLAGS + " -L" + $topdir
end
- $srcdir = $top_srcdir + "/ext/" + target
+ $srcdir = $top_srcdir + "/ext/" + $mdir
mfile = open("Makefile", "w")
mfile.printf "\
SHELL = /bin/sh
@@ -288,19 +288,19 @@ CC = @CC@
prefix = @prefix@
CFLAGS = %s -I#{$topdir} -I#{$top_srcdir} -I@includedir@ #{CFLAGS} #$CFLAGS %s
-DLDFLAGS = #$DLDFLAGS @LDFLAGS@ #$LDFLAGS
+DLDFLAGS = #$DLDFLAGS #$LDFLAGS
LDSHARED = @LDSHARED@
", if $static then "" else "@CCDLFLAGS@" end, $defs.join(" ")
mfile.printf "\
-program_transform_name = -e @program_transform_name@
-RUBY_INSTALL_NAME = `t='$(program_transform_name)'; echo ruby | sed $$t`
+RUBY_INSTALL_NAME = @RUBY_INSTALL_NAME@
prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
-pkglibdir = $(libdir)/$(RUBY_INSTALL_NAME)
+#pkglibdir = $(libdir)/$(RUBY_INSTALL_NAME)/@MAJOR@.@MINOR@
+pkglibdir = $(libdir)/ruby/@MAJOR@.@MINOR@
archdir = $(pkglibdir)/@arch@
@SET_MAKE@
@@ -448,7 +448,7 @@ def extmake(target)
elsif $clean
system "make clean"
else
- system "make all"
+ system "make all" or exit
end
end
if $static
@@ -513,13 +513,17 @@ end
exit if $install or $clean
$extinit = "" unless $extinit
+
+ruby = "@RUBY_INSTALL_NAME@@binsuffix@"
+miniruby = "miniruby@binsuffix@"
+
if $extlist.size > 0
for s,t in $extlist
f = format("%s/%s.a", s, t)
if File.exist?(f)
$extinit += format("\
\tInit_%s();\n\
-\trb_provide(\"%s.o\");\n\
+\trb_provide(\"%s.so\");\n\
", t, t)
$extobjs = "" unless $extobjs
$extobjs += "ext/"
@@ -545,8 +549,8 @@ if $extlist.size > 0
Dir.chdir ".."
- if older("ruby@binsuffix@", "#{$top_srcdir}/ext/@setup@") or older("ruby@binsuffix@", "miniruby@binsuffix@")
- `rm -f ruby@binsuffix@`
+ if older(ruby, "#{$top_srcdir}/ext/@setup@") or older(ruby, miniruby)
+ system("rm -f #{ruby}")
end
if $extobjs
@@ -557,12 +561,12 @@ if $extlist.size > 0
if PLATFORM =~ /m68k-human|beos/
$extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
end
- system format('make ruby@binsuffix@ EXTOBJS="%s" EXTLIBS="%s"', $extobjs, $extlibs)
+ system format('make #{ruby} EXTOBJS="%s" EXTLIBS="%s"', $extobjs, $extlibs)
else
Dir.chdir ".."
- if older("ruby@binsuffix@", "miniruby@binsuffix@")
- `rm -f ruby@binsuffix@`
- system("make ruby@binsuffix@")
+ if older(ruby, miniruby)
+ system("rm -f #{ruby}")
+ system("make #{ruby}")
end
end
diff --git a/ext/gtk/MANIFEST b/ext/gtk/MANIFEST
deleted file mode 100644
index 3e1962e..0000000
--- a/ext/gtk/MANIFEST
+++ /dev/null
@@ -1,18 +0,0 @@
-MANIFEST
-extconf.rb
-gtk.c
-test.rb
-test.xpm
-test0.rb
-test1.rb
-test2.rb
-test3.rb
-test4.rb
-test5.rb
-test6.rb
-test7.rb
-test8.rb
-test9.rb
-testa.rb
-testb.rb
-testc.rb
diff --git a/ext/gtk/extconf.rb b/ext/gtk/extconf.rb
deleted file mode 100644
index 621e073..0000000
--- a/ext/gtk/extconf.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require "mkmf"
-if have_library("glib", "g_print") and
- have_library("gdk", "gdk_init") and
- have_library("gtk", "gtk_init")
- create_makefile("gtk")
-end
diff --git a/ext/gtk/gtk.c b/ext/gtk/gtk.c
deleted file mode 100644
index 9114312..0000000
--- a/ext/gtk/gtk.c
+++ /dev/null
@@ -1,5904 +0,0 @@
-/************************************************
-
- gtk.c -
-
- $Author$
- $Date$
- created at: Wed Jan 7 23:55:11 JST 1998
-
-************************************************/
-
-#include "ruby.h"
-#include "sig.h"
-#include <gtk/gtk.h>
-#include <signal.h>
-
-extern VALUE rb_argv, rb_argv0;
-extern VALUE cData;
-
-static VALUE mGtk;
-
-static VALUE gObject;
-static VALUE gWidget;
-static VALUE gContainer;
-static VALUE gBin;
-static VALUE gAlignment;
-static VALUE gMisc;
-static VALUE gArrow;
-static VALUE gFrame;
-static VALUE gAspectFrame;
-static VALUE gData;
-static VALUE gAdjustment;
-static VALUE gBox;
-static VALUE gButton;
-static VALUE gTButton;
-static VALUE gCButton;
-static VALUE gRButton;
-static VALUE gBBox;
-static VALUE gCList;
-static VALUE gWindow;
-static VALUE gDialog;
-static VALUE gFileSel;
-static VALUE gVBox;
-static VALUE gColorSel;
-static VALUE gColorSelDialog;
-static VALUE gImage;
-static VALUE gDrawArea;
-static VALUE gEntry;
-static VALUE gEventBox;
-static VALUE gFixed;
-static VALUE gGamma;
-static VALUE gHBBox;
-static VALUE gVBBox;
-static VALUE gHBox;
-static VALUE gPaned;
-static VALUE gHPaned;
-static VALUE gVPaned;
-static VALUE gRuler;
-static VALUE gHRuler;
-static VALUE gVRuler;
-static VALUE gRange;
-static VALUE gScale;
-static VALUE gHScale;
-static VALUE gVScale;
-static VALUE gScrollbar;
-static VALUE gHScrollbar;
-static VALUE gVScrollbar;
-static VALUE gSeparator;
-static VALUE gHSeparator;
-static VALUE gVSeparator;
-static VALUE gInputDialog;
-static VALUE gLabel;
-static VALUE gList;
-static VALUE gItem;
-static VALUE gListItem;
-static VALUE gMenuShell;
-static VALUE gMenu;
-static VALUE gMenuBar;
-static VALUE gMenuItem;
-static VALUE gCMenuItem;
-static VALUE gRMenuItem;
-static VALUE gNotebook;
-static VALUE gOptionMenu;
-static VALUE gPixmap;
-static VALUE gPreview;
-static VALUE gProgressBar;
-static VALUE gScrolledWin;
-static VALUE gTable;
-static VALUE gText;
-static VALUE gToolbar;
-static VALUE gTooltips;
-static VALUE gTree;
-static VALUE gTreeItem;
-static VALUE gViewPort;
-
-static VALUE gAcceleratorTable;
-static VALUE gStyle;
-static VALUE gPreviewInfo;
-static VALUE gAllocation;
-static VALUE gRequisiton;
-
-static VALUE mGdk;
-
-static VALUE gdkFont;
-static VALUE gdkColor;
-static VALUE gdkColormap;
-static VALUE gdkPixmap;
-static VALUE gdkBitmap;
-static VALUE gdkWindow;
-static VALUE gdkImage;
-static VALUE gdkVisual;
-static VALUE gdkGC;
-static VALUE gdkRectangle;
-static VALUE gdkGCValues;
-static VALUE gdkRectangle;
-static VALUE gdkSegment;
-static VALUE gdkWindowAttr;
-static VALUE gdkCursor;
-static VALUE gdkAtom;
-static VALUE gdkColorContext;
-static VALUE gdkEvent;
-
-ID id_gtkdata, id_relatives, id_call;
-
-static void gobj_free();
-
-static char*
-get_cstring(str)
- VALUE str;
-{
- if (NIL_P(str)) return NULL;
- Check_Type(str, T_STRING);
- return RSTRING(str)->ptr;
-}
-
-static GtkObject*
-get_gobject(obj)
- VALUE obj;
-{
- struct RData *data;
- GtkObject *gtkp;
-
- if (NIL_P(obj)) return NULL;
-
- Check_Type(obj, T_OBJECT);
- data = RDATA(rb_ivar_get(obj, id_gtkdata));
- if (NIL_P(data) || data->dfree != gobj_free) {
- TypeError("not a Gtk object");
- }
- Data_Get_Struct(data, GtkObject, gtkp);
- if (!GTK_IS_OBJECT(gtkp)) {
- TypeError("not a GtkObject");
- }
-
- return gtkp;
-}
-
-static GtkWidget*
-get_widget(obj)
- VALUE obj;
-{
- GtkObject *data = get_gobject(obj);
-
- return GTK_WIDGET(data);
-}
-
-static VALUE
-get_value_from_gobject(obj)
- GtkObject *obj;
-{
- return (VALUE)gtk_object_get_user_data(obj);
-}
-
-static void
-clear_gobject(obj)
- VALUE obj;
-{
- rb_ivar_set(obj, id_relatives, Qnil);
-}
-
-static void
-add_relative(obj, relative)
- VALUE obj, relative;
-{
- VALUE ary = rb_ivar_get(obj, id_relatives);
-
- if (TYPE(ary) != T_ARRAY) {
- ary = ary_new();
- rb_ivar_set(obj, id_relatives, ary);
- }
- ary_push(ary, relative);
-}
-
-static VALUE gtk_object_list;
-
-static void
-gobj_free(obj)
- GtkObject *obj;
-{
- VALUE self = get_value_from_gobject(obj);
-
- if (GTK_OBJECT_NEED_DESTROY(obj)) {
- gtk_object_destroy(obj);
- }
- rb_ivar_set(self, id_relatives, Qnil);
-}
-
-static void
-delete_gobject(obj)
- GtkObject *obj;
-{
- ary_delete(gtk_object_list, get_value_from_gobject(obj));
-}
-
-static VALUE
-make_gobject(klass, gtkobj)
- VALUE klass;
- GtkObject *gtkobj;
-{
- VALUE obj = obj_alloc(klass);
- VALUE data;
-
- data = Data_Wrap_Struct(cData, 0, gobj_free, gtkobj);
- gtk_object_set_user_data(gtkobj, (gpointer)obj);
-
- rb_ivar_set(obj, id_gtkdata, data);
- gtk_signal_connect(gtkobj, "destroy", (GtkSignalFunc)delete_gobject, 0);
- ary_push(gtk_object_list, obj);
- return obj;
-}
-
-static VALUE
-make_widget(klass, widget)
- VALUE klass;
- GtkWidget *widget;
-{
- return make_gobject(klass, GTK_OBJECT(widget));
-}
-
-static void
-free_gstyle(style)
- GtkStyle *style;
-{
- gtk_style_unref(style);
-}
-
-static VALUE
-make_gstyle(style)
- GtkStyle *style;
-{
- gtk_style_ref(style);
- return Data_Wrap_Struct(gStyle, 0, free_gstyle, style);
-}
-
-static GtkStyle*
-get_gstyle(style)
- VALUE style;
-{
- GtkStyle *gstyle;
-
- if (NIL_P(style)) return NULL;
- if (!obj_is_instance_of(style, gStyle)) {
- TypeError("not a GtkStyle");
- }
- Data_Get_Struct(style, GtkStyle, gstyle);
-
- return gstyle;
-}
-
-static void
-free_gaccel(tbl)
- GtkAcceleratorTable *tbl;
-{
- gtk_accelerator_table_unref(tbl);
-}
-
-static VALUE
-make_gtkacceltbl(tbl)
- GtkAcceleratorTable *tbl;
-{
- gtk_accelerator_table_ref(tbl);
- return Data_Wrap_Struct(gAcceleratorTable, 0, free_gaccel, tbl);
-}
-
-static GtkAcceleratorTable*
-get_gtkacceltbl(value)
- VALUE value;
-{
- GtkAcceleratorTable *tbl;
-
- if (NIL_P(value)) return NULL;
-
- if (!obj_is_instance_of(value, gAcceleratorTable)) {
- TypeError("not an AcceleratorTable");
- }
- Data_Get_Struct(value, GtkAcceleratorTable, tbl);
-
- return tbl;
-}
-
-static VALUE
-make_gtkprevinfo(info)
- GtkPreviewInfo *info;
-{
- return Data_Wrap_Struct(gAcceleratorTable, 0, 0, info);
-}
-
-static GtkPreviewInfo*
-get_gtkprevinfo(value)
- VALUE value;
-{
- GtkPreviewInfo *info;
-
- if (NIL_P(value)) return NULL;
-
- if (!obj_is_instance_of(value, gPreviewInfo)) {
- TypeError("not a PreviewInfo");
- }
- Data_Get_Struct(value, GtkPreviewInfo, info);
-
- return info;
-}
-
-static void
-exec_callback(widget, data, nparams, params)
- GtkWidget *widget;
- VALUE data;
- int nparams;
- GtkType *params;
-{
- VALUE self = get_value_from_gobject(GTK_OBJECT(widget));
- VALUE proc = RARRAY(data)->ptr[0];
- VALUE event = RARRAY(data)->ptr[1];
- ID id = NUM2INT(event);
-
- if (NIL_P(proc) && rb_respond_to(self, id)) {
- rb_funcall(self, id, 3, self,
- INT2FIX(nparams), INT2NUM((INT)params));
- }
- else {
- rb_funcall(proc, id_call, 1, self);
- }
-}
-
-static void
-free_ttips(tips)
- GtkTooltips *tips;
-{
- gtk_tooltips_unref(tips);
-}
-
-static VALUE
-make_ttips(klass, tips)
- VALUE klass;
- GtkTooltips *tips;
-{
- gtk_tooltips_ref(tips);
- return Data_Wrap_Struct(klass, 0, free_ttips, tips);
-}
-
-static GtkTooltips*
-get_ttips(tips)
- VALUE tips;
-{
- GtkTooltips *gtips;
-
- if (NIL_P(tips)) return NULL;
-
- if (!obj_is_instance_of(tips, gTooltips)) {
- TypeError("not a GtkTooltips");
- }
- Data_Get_Struct(tips, GtkTooltips, gtips);
-
- return gtips;
-}
-
-static void
-free_gdkfont(font)
- GdkFont *font;
-{
- gdk_font_unref(font);
-}
-
-static VALUE
-make_gdkfont(font)
- GdkFont *font;
-{
- gdk_font_ref(font);
- return Data_Wrap_Struct(gdkFont, 0, free_gdkfont, font);
-}
-
-static GdkFont*
-get_gdkfont(font)
- VALUE font;
-{
- GdkFont *gfont;
-
- if (NIL_P(font)) return NULL;
-
- if (!obj_is_instance_of(font, gdkFont)) {
- TypeError("not a GdkFont");
- }
- Data_Get_Struct(font, GdkFont, gfont);
-
- return gfont;
-}
-
-static VALUE
-gdkfnt_equal(fn1, fn2)
- VALUE fn1, fn2;
-{
- if (gdk_font_equal(get_gdkfont(fn1), get_gdkfont(fn2)))
- return TRUE;
- return FALSE;
-}
-
-static void
-free_tobj(obj)
- gpointer obj;
-{
- free(obj);
-}
-
-static VALUE
-make_tobj(obj, klass, size)
- gpointer obj;
- VALUE klass;
- int size;
-{
- gpointer copy;
- VALUE data;
-
- copy = xmalloc(size);
- memcpy(copy, obj, size);
- data = Data_Wrap_Struct(klass, 0, free_tobj, copy);
-
- return data;
-}
-
-static gpointer
-get_tobj(obj, klass)
- VALUE obj, klass;
-{
- void *ptr;
-
- if (NIL_P(obj)) return NULL;
-
- if (!obj_is_instance_of(obj, klass)) {
- TypeError("not a %s", rb_class2name(klass));
- }
- Data_Get_Struct(obj, void, ptr);
-
- return ptr;
-}
-
-#define make_gdkcolor(c) make_tobj(c, gdkColor, sizeof(GdkColor))
-#define get_gdkcolor(c) ((GdkColor*)get_tobj(c, gdkColor))
-
-#define make_gdkrect(c) make_tobj(c, gdkRectangle, sizeof(GdkRectangle))
-#define get_gdkrect(c) ((GdkRectangle*)get_tobj(c, gdkRectangle))
-
-#define make_gdksegment(c) make_tobj(c, gdkSegment, sizeof(GdkSegment))
-#define get_gdksegment(c) ((GdkSegment*)get_tobj(c, gdkSegment))
-
-#define make_gdkwinattr(c) make_tobj(c, gdkWindowAttr, sizeof(GdkWindowAttr))
-#define get_gdkwinattr(c) ((GdkWindowAttr*)get_tobj(c, gdkWindowAttr))
-
-#define make_gdkwinattr(c) make_tobj(c, gdkWindowAttr, sizeof(GdkWindowAttr))
-#define get_gdkwinattr(c) ((GdkWindowAttr*)get_tobj(c, gdkWindowAttr))
-
-#define make_gallocation(c) make_tobj(c, gAllocation, sizeof(GtkAllocation))
-#define get_gallocation(c) ((GtkAllocation*)get_tobj(c, gAllocation))
-
-#define make_grequisiton(c) make_tobj(c, gRequisiton, sizeof(GtkRequisition))
-#define get_grequisiton(c) ((GtkRequisition*)get_tobj(c, gRequisiton))
-
-#define make_gdkrectangle(r) make_tobj(r, gdkRectangle, sizeof(GdkRectangle))
-#define get_gdkrectangle(r) ((GdkRectangle*)get_tobj(r, gdkRectangle))
-
-static void
-free_gdkcmap(cmap)
- GdkColormap *cmap;
-{
- gdk_colormap_unref(cmap);
-}
-
-static VALUE
-make_gdkcmap(cmap)
- GdkColormap *cmap;
-{
- gdk_colormap_ref(cmap);
- return Data_Wrap_Struct(gdkColormap, 0, free_gdkcmap, cmap);
-}
-
-static GdkColormap*
-get_gdkcmap(cmap)
- VALUE cmap;
-{
- GdkColormap *gcmap;
-
- if (NIL_P(cmap)) return NULL;
-
- if (!obj_is_kind_of(cmap, gdkColormap)) {
- TypeError("not a GdkColormap");
- }
- Data_Get_Struct(cmap, GdkColormap, gcmap);
-
- return gcmap;
-}
-
-static VALUE
-make_gdkvisual(visual)
- GdkVisual *visual;
-{
- return Data_Wrap_Struct(gdkVisual, 0, 0, visual);
-}
-
-static GdkVisual*
-get_gdkvisual(visual)
- VALUE visual;
-{
- GdkVisual *gvisual;
-
- if (NIL_P(visual)) return NULL;
-
- if (!obj_is_kind_of(visual, gdkVisual)) {
- TypeError("not a GdkVisual");
- }
- Data_Get_Struct(visual, GdkVisual, gvisual);
-
- return gvisual;
-}
-
-static void
-free_gdkwindow(window)
- GdkWindow *window;
-{
- gdk_window_unref(window);
-}
-
-static VALUE
-make_gdkwindow(window)
- GdkWindow *window;
-{
- gdk_window_ref(window);
- return Data_Wrap_Struct(gdkWindow, 0, free_gdkwindow, window);
-}
-
-static GdkWindow*
-get_gdkwindow(window)
- VALUE window;
-{
- GdkWindow *gwindow;
-
- if (NIL_P(window)) return NULL;
-
- if (!obj_is_kind_of(window, gdkWindow)) {
- TypeError("not a GdkWindow");
- }
- Data_Get_Struct(window, GdkWindow, gwindow);
-
- return gwindow;
-}
-
-static void
-free_gdkpixmap(pixmap)
- GdkPixmap *pixmap;
-{
- gdk_pixmap_unref(pixmap);
-}
-
-static VALUE
-make_gdkpixmap(klass, pixmap)
- VALUE klass;
- GdkPixmap *pixmap;
-{
- gdk_pixmap_ref(pixmap);
- return Data_Wrap_Struct(klass, 0, free_gdkpixmap, pixmap);
-}
-
-static GdkPixmap*
-get_gdkpixmap(pixmap)
- VALUE pixmap;
-{
- GdkPixmap *gpixmap;
-
- if (NIL_P(pixmap)) return NULL;
-
- if (!obj_is_kind_of(pixmap, gdkPixmap)) {
- TypeError("not a GdkPixmap");
- }
- Data_Get_Struct(pixmap, GdkPixmap, gpixmap);
-
- return gpixmap;
-}
-
-static VALUE
-gdkpmap_s_new(self, win, w, h, depth)
- VALUE self, win, w, h, depth;
-{
- GdkPixmap *new;
- GdkWindow *window = get_gdkwindow(win);
-
- new = gdk_pixmap_new(window, NUM2INT(w), NUM2INT(h), NUM2INT(depth));
- return make_gdkpixmap(self, new);
-}
-
-static VALUE
-gdkpmap_create_from_data(self, win, data, w, h, depth, fg, bg)
- VALUE self, win, data, w, h, depth, fg, bg;
-{
- GdkPixmap *new;
- GdkWindow *window = get_gdkwindow(win);
-
- Check_Type(data, T_STRING);
- new = gdk_pixmap_create_from_data(window,
- RSTRING(data)->ptr,
- NUM2INT(w), NUM2INT(h),
- NUM2INT(depth),
- get_gdkcolor(fg),
- get_gdkcolor(bg));
- return make_gdkpixmap(self, new);
-}
-
-static VALUE
-gdkpmap_create_from_xpm(self, win, tcolor, fname)
- VALUE self, win, tcolor, fname;
-{
- GdkPixmap *new;
- GdkBitmap *mask;
- GdkWindow *window = get_gdkwindow(win);
-
- Check_Type(fname, T_STRING);
- new = gdk_pixmap_create_from_xpm(window, &mask,
- get_gdkcolor(tcolor),
- RSTRING(fname)->ptr);
- if (!new) {
- ArgError("Pixmap not created from %s", RSTRING(fname)->ptr);
- }
- return assoc_new(make_gdkpixmap(self, new),
- make_gdkpixmap(gdkBitmap, mask));
-}
-
-static VALUE
-gdkpmap_create_from_xpm_d(self, win, tcolor, data)
- VALUE self, win, tcolor, data;
-{
- GdkPixmap *new;
- GdkBitmap *mask;
- GdkWindow *window = get_gdkwindow(win);
- int i;
- gchar **buf;
-
- Check_Type(data, T_ARRAY);
- buf = ALLOCA_N(char*, RARRAY(data)->len);
- for (i=0; i<RARRAY(data)->len; i++) {
- Check_Type(RARRAY(data)->ptr[i], T_STRING);
- buf[i] = RSTRING(RARRAY(data)->ptr[i])->ptr;
- }
-
- new = gdk_pixmap_create_from_xpm_d(window, &mask,
- get_gdkcolor(tcolor),
- buf);
-
- return assoc_new(make_gdkpixmap(self, new),
- make_gdkpixmap(gdkBitmap, mask));
-}
-
-static VALUE
-gdkbmap_s_new(self, win, w, h)
- VALUE self, win, w, h;
-{
- GdkPixmap *new;
- GdkWindow *window = get_gdkwindow(win);
-
- new = gdk_pixmap_new(window, NUM2INT(w), NUM2INT(h), 1);
- return make_gdkpixmap(self, new);
-}
-
-static VALUE
-gdkbmap_create_from_data(self, win, data, w, h)
- VALUE self, win, data, w, h;
-{
- GdkBitmap *new;
- GdkWindow *window = get_gdkwindow(win);
-
- Check_Type(data, T_STRING);
- new = gdk_bitmap_create_from_data(window,
- RSTRING(data)->ptr,
- NUM2INT(w), NUM2INT(h));
- return make_gdkpixmap(self, (GdkPixmap*)new);
-}
-
-static void
-free_gdkimage(image)
- GdkImage *image;
-{
- gdk_image_destroy(image);
-}
-
-static VALUE
-make_gdkimage(image)
- GdkImage *image;
-{
- return Data_Wrap_Struct(gdkImage, 0, free_gdkimage, image);
-}
-
-static GdkImage*
-get_gdkimage(image)
- VALUE image;
-{
- GdkImage *gimage;
-
- if (NIL_P(image)) return NULL;
-
- if (!obj_is_instance_of(image, gdkImage)) {
- TypeError("not a GdkImage");
- }
- Data_Get_Struct(image, GdkImage, gimage);
-
- return gimage;
-}
-
-static void
-free_gdkevent(event)
- GdkEvent *event;
-{
- gdk_event_free(event);
-}
-
-static VALUE
-make_gdkevent(event)
- GdkEvent *event;
-{
- event = gdk_event_copy(event);
- return Data_Wrap_Struct(gdkEvent, 0, free_gdkevent, event);
-}
-
-static GdkEvent*
-get_gdkevent(event)
- VALUE event;
-{
- GdkEvent *gevent;
-
- if (NIL_P(event)) return NULL;
-
- if (!obj_is_instance_of(event, gdkEvent)) {
- TypeError("not a GdkEvent");
- }
- Data_Get_Struct(event, GdkEvent, gevent);
-
- return gevent;
-}
-
-static VALUE
-glist2ary(list)
- GList *list;
-{
- VALUE ary = ary_new();
-
- while (list) {
- ary_push(ary, get_value_from_gobject(GTK_OBJECT(list->data)));
- list = list->next;
- }
-
- return ary;
-}
-
-static GList*
-ary2glist(ary)
- VALUE ary;
-{
- int i;
- GList *glist = NULL;
-
- Check_Type(ary, T_ARRAY);
- for (i=0; i<RARRAY(ary)->len; i++) {
- glist = g_list_prepend(glist,get_widget(RARRAY(ary)->ptr[i]));
- }
-
- return g_list_reverse(glist);
-}
-
-static GSList*
-ary2gslist(ary)
- VALUE ary;
-{
- int i;
- GSList *glist = NULL;
-
- if (NIL_P(ary)) return NULL;
- Check_Type(ary, T_ARRAY);
- for (i=0; i<RARRAY(ary)->len; i++) {
- glist = g_slist_append(glist,get_widget(RARRAY(ary)->ptr[i]));
- }
-
- return glist;
-}
-
-static VALUE
-gslist2ary(list)
- GSList *list;
-{
- VALUE ary = ary_new();
-
- while (list) {
- ary_push(ary, get_value_from_gobject(GTK_OBJECT(list->data)));
- list = list->next;
- }
-
- return ary;
-}
-
-static VALUE
-gobj_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- Fail("can't instantiate class %s", rb_class2name(self));
-}
-
-static VALUE
-gobj_smethod_added(self, id)
- VALUE self, id;
-{
- GtkObject *obj = get_gobject(self);
- char *name = rb_id2name(NUM2INT(id));
-
-
- if (gtk_signal_lookup(name, GTK_OBJECT_TYPE(obj))) {
- VALUE handler = assoc_new(Qnil, id);
-
- add_relative(self, handler);
- gtk_signal_connect_interp(obj, name,
- exec_callback, (gpointer)handler,
- NULL, 0);
- }
- return Qnil;
-}
-
-static VALUE
-gobj_destroy(self)
- VALUE self;
-{
- printf("a\n");
- gtk_object_destroy(get_gobject(self));
- printf("b\n");
- clear_gobject(self);
- return Qnil;
-}
-
-static VALUE
-gobj_set_flags(self, flags)
- VALUE self, flags;
-{
- GtkObject *object = get_gobject(self);
- GTK_OBJECT_SET_FLAGS(object, NUM2INT(flags));
- return self;
-}
-
-static VALUE
-gobj_unset_flags(self, flags)
- VALUE self, flags;
-{
- GtkObject *object = get_gobject(self);
- GTK_OBJECT_UNSET_FLAGS(object, NUM2INT(flags));
- return self;
-}
-
-static VALUE
-gobj_sig_connect(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE sig, handler;
- GtkWidget *widget = get_widget(self);
- ID id = 0;
- int n;
-
- rb_scan_args(argc, argv, "11", &sig, &handler);
- Check_Type(sig, T_STRING);
- if (NIL_P(handler) && iterator_p()) {
- handler = f_lambda();
- id = rb_intern(RSTRING(sig)->ptr);
- }
- handler = assoc_new(handler, INT2NUM(id));
- add_relative(self, handler);
- n = gtk_signal_connect_interp(GTK_OBJECT(widget), RSTRING(sig)->ptr,
- exec_callback, (gpointer)handler,
- NULL, 0);
-
- return INT2FIX(n);
-}
-
-static VALUE
-gobj_sig_connect_after(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE sig, handler;
- GtkWidget *widget = get_widget(self);
- ID id = 0;
- int n;
-
- rb_scan_args(argc, argv, "11", &sig, &handler);
- Check_Type(sig, T_STRING);
- if (NIL_P(handler) && iterator_p()) {
- handler = f_lambda();
- id = rb_intern(RSTRING(sig)->ptr);
- }
- add_relative(self, handler);
- n = gtk_signal_connect_interp(GTK_OBJECT(widget), RSTRING(sig)->ptr,
- exec_callback, (gpointer)handler,
- NULL, 1);
-
- return INT2FIX(n);
-}
-
-static VALUE
-cont_bwidth(self, width)
- VALUE self, width;
-{
- GtkWidget *widget = get_widget(self);
- gtk_container_border_width(GTK_CONTAINER(widget), NUM2INT(width));
- return self;
-}
-
-static VALUE
-cont_add(self, other)
- VALUE self, other;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_container_add(GTK_CONTAINER(widget), get_widget(other));
- return self;
-}
-
-static VALUE
-cont_disable_resize(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_container_disable_resize(GTK_CONTAINER(widget));
- return self;
-}
-
-static VALUE
-cont_enable_resize(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_container_enable_resize(GTK_CONTAINER(widget));
- return self;
-}
-
-static VALUE
-cont_block_resize(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_container_block_resize(GTK_CONTAINER(widget));
- return self;
-}
-
-static VALUE
-cont_unblock_resize(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_container_unblock_resize(GTK_CONTAINER(widget));
- return self;
-}
-
-static VALUE
-cont_need_resize(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_container_need_resize(GTK_CONTAINER(widget));
- return self;
-}
-
-static VALUE
-cont_foreach(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE callback;
- GtkWidget *widget = get_widget(self);
-
- rb_scan_args(argc, argv, "01", &callback);
- if (NIL_P(callback)) {
- callback = f_lambda();
- }
- gtk_container_foreach(GTK_CONTAINER(widget),
- exec_callback, (gpointer)callback);
- return self;
-}
-
-static void
-yield_callback(widget)
- GtkWidget *widget;
-{
- rb_yield(get_value_from_gobject(GTK_OBJECT(widget)));
-}
-
-static VALUE
-cont_each(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_container_foreach(GTK_CONTAINER(widget),
- yield_callback, 0);
- return self;
-}
-
-static VALUE
-cont_focus(self, direction)
- VALUE self, direction;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_container_focus(GTK_CONTAINER(widget),
- (GtkDirectionType)NUM2INT(direction));
- return self;
-}
-
-static void
-cont_children_callback(widget, data)
- GtkWidget *widget;
- gpointer data;
-{
- VALUE ary = (VALUE)data;
-
- ary_push(ary, get_value_from_gobject(GTK_OBJECT(widget)));
-}
-
-static VALUE
-cont_children(self, direction)
- VALUE self, direction;
-{
- GtkWidget *widget = get_widget(self);
- VALUE ary = ary_new();
-
- gtk_container_foreach(GTK_CONTAINER(widget),
- cont_children_callback,
- (gpointer)ary);
- return ary;
-}
-
-static VALUE
-align_s_new(self, xalign, yalign, xscale, yscale)
- VALUE self, xalign, yalign, xscale, yscale;
-{
- return make_widget(self, gtk_alignment_new(NUM2DBL(xalign),
- NUM2DBL(yalign),
- NUM2DBL(xscale),
- NUM2DBL(yscale)));
-}
-
-static VALUE
-align_set(self, xalign, yalign, xscale, yscale)
- VALUE self, xalign, yalign, xscale, yscale;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_alignment_set(GTK_ALIGNMENT(widget),
- NUM2DBL(xalign), NUM2DBL(yalign),
- NUM2DBL(xscale), NUM2DBL(yscale));
- return self;
-}
-
-static VALUE
-misc_set_align(self, xalign, yalign)
- VALUE self, xalign, yalign;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_misc_set_alignment(GTK_MISC(widget),
- NUM2DBL(xalign), NUM2DBL(yalign));
- return self;
-}
-
-static VALUE
-misc_set_padding(self, xpad, ypad)
- VALUE self, xpad, ypad;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_misc_set_padding(GTK_MISC(widget),
- NUM2DBL(xpad), NUM2DBL(ypad));
- return self;
-}
-
-static VALUE
-arrow_s_new(self, arrow_t, shadow_t)
- VALUE self, arrow_t, shadow_t;
-{
- return make_widget(self, gtk_arrow_new((GtkArrowType)NUM2INT(arrow_t),
- (GtkShadowType)NUM2INT(shadow_t)));
-}
-
-static VALUE
-arrow_set(self, arrow_t, shadow_t)
- VALUE self, arrow_t, shadow_t;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_arrow_set(GTK_ARROW(widget),
- (GtkArrowType)NUM2INT(arrow_t),
- (GtkShadowType)NUM2INT(shadow_t));
- return self;
-}
-
-static VALUE
-frame_s_new(self, label)
- VALUE self, label;
-{
- return make_widget(self, gtk_frame_new(get_cstring(label)));
-}
-
-static VALUE
-frame_set_label(self, label)
- VALUE self, label;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_frame_set_label(GTK_FRAME(widget), get_cstring(label));
- return self;
-}
-
-static VALUE
-frame_set_label_align(self, xalign, yalign)
- VALUE self, xalign, yalign;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_frame_set_label_align(GTK_FRAME(widget),
- NUM2DBL(xalign),
- NUM2DBL(yalign));
-
- return self;
-}
-
-static VALUE
-frame_set_shadow_type(self, type)
- VALUE self, type;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_frame_set_shadow_type(GTK_FRAME(widget),
- (GtkShadowType)NUM2INT(type));
- return self;
-}
-
-static VALUE
-aframe_s_new(self, label, xalign, yalign, ratio, obey_child)
- VALUE self, label, xalign, yalign, ratio, obey_child;
-{
- return make_widget(self, gtk_aspect_frame_new(get_cstring(label),
- NUM2DBL(xalign),
- NUM2DBL(yalign),
- NUM2DBL(ratio),
- RTEST(obey_child)));
-}
-
-static VALUE
-aframe_set(self, xalign, yalign, ratio, obey_child)
- VALUE self, xalign, yalign, ratio, obey_child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_aspect_frame_set(GTK_ASPECT_FRAME(widget),
- NUM2DBL(xalign), NUM2DBL(yalign),
- NUM2DBL(ratio), RTEST(obey_child));
- return self;
-}
-
-static VALUE
-adj_s_new(self, value, lower, upper, step_inc, page_inc, page_size)
- VALUE self, value, lower, upper, step_inc, page_inc, page_size;
-{
- return make_widget(self, gtk_adjustment_new(NUM2DBL(value),
- NUM2DBL(lower),
- NUM2DBL(upper),
- NUM2DBL(step_inc),
- NUM2DBL(page_inc),
- NUM2DBL(page_size)));
-}
-
-static VALUE
-widget_destroy(self)
- VALUE self;
-{
- gtk_widget_destroy(get_widget(self));
- clear_gobject(self);
-
- return Qnil;
-}
-
-static VALUE
-widget_show(self)
- VALUE self;
-{
- gtk_widget_show(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_show_all(self)
- VALUE self;
-{
- gtk_widget_show_all(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_hide(self)
- VALUE self;
-{
- gtk_widget_hide(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_hide_all(self)
- VALUE self;
-{
- gtk_widget_hide_all(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_map(self)
- VALUE self;
-{
- gtk_widget_map(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_unmap(self)
- VALUE self;
-{
- gtk_widget_unmap(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_realize(self)
- VALUE self;
-{
- gtk_widget_realize(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_unrealize(self)
- VALUE self;
-{
- gtk_widget_unrealize(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_queue_draw(self)
- VALUE self;
-{
- gtk_widget_queue_draw(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_queue_resize(self)
- VALUE self;
-{
- gtk_widget_queue_resize(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_draw(self, rect)
- VALUE self, rect;
-{
- gtk_widget_draw(get_widget(self), get_gdkrectangle(rect));
- return self;
-}
-
-static VALUE
-widget_draw_focus(self)
- VALUE self;
-{
- gtk_widget_draw_focus(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_draw_default(self)
- VALUE self;
-{
- gtk_widget_draw_default(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_draw_children(self)
- VALUE self;
-{
- gtk_widget_draw_children(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_size_request(self, req)
- VALUE self, req;
-{
- gtk_widget_size_request(get_widget(self), get_grequisiton(req));
- return self;
-}
-
-static VALUE
-widget_size_allocate(self, alloc)
- VALUE self, alloc;
-{
- gtk_widget_size_allocate(get_widget(self), get_gallocation(alloc));
- return self;
-}
-
-static VALUE
-widget_inst_accel(self, accel, sig, key, mod)
- VALUE self, accel, sig, key, mod;
-{
- gtk_widget_install_accelerator(get_widget(self),
- get_gtkacceltbl(accel),
- get_cstring(sig),
- NUM2INT(key),
- (guint8)NUM2INT(mod));
- return self;
-}
-
-static VALUE
-widget_rm_accel(self, accel, sig)
- VALUE self, accel, sig;
-{
- gtk_widget_remove_accelerator(get_widget(self),
- get_gtkacceltbl(accel),
- get_cstring(sig));
- return self;
-}
-
-static VALUE
-widget_event(self, event)
- VALUE self, event;
-{
- int n = gtk_widget_event(get_widget(self), get_gdkevent(event));
- return NUM2INT(n);
-}
-
-static VALUE
-widget_activate(self)
- VALUE self;
-{
- gtk_widget_activate(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_grab_focus(self)
- VALUE self;
-{
- gtk_widget_grab_focus(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_grab_default(self)
- VALUE self;
-{
- gtk_widget_grab_default(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_restore_state(self)
- VALUE self;
-{
- gtk_widget_restore_state(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_visible(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- if (GTK_WIDGET_VISIBLE(widget))
- return TRUE;
- return FALSE;
-}
-
-static VALUE
-widget_reparent(self, parent)
- VALUE self, parent;
-{
- gtk_widget_reparent(get_widget(self), get_widget(parent));
- return self;
-}
-
-static VALUE
-widget_popup(self, x, y)
- VALUE self, x, y;
-{
- gtk_widget_popup(get_widget(self), NUM2INT(x), NUM2INT(y));
- return self;
-}
-
-static VALUE
-widget_intersect(self, area, intersect)
- VALUE self, area, intersect;
-{
- int n = gtk_widget_intersect(get_widget(self),
- get_gdkrectangle(area),
- get_gdkrectangle(intersect));
- return NUM2INT(n);
-}
-
-static VALUE
-widget_basic(self)
- VALUE self;
-{
- int n = gtk_widget_basic(get_widget(self));
- return NUM2INT(n);
-}
-
-static VALUE
-widget_set_state(self, state)
- VALUE self, state;
-{
- gtk_widget_set_state(get_widget(self), (GtkStateType)NUM2INT(state));
- return self;
-}
-
-static VALUE
-widget_set_style(self, style)
- VALUE self, style;
-{
- gtk_widget_set_style(get_widget(self),
- get_gstyle(style));
- return self;
-}
-
-static VALUE
-widget_set_parent(self, parent)
- VALUE self, parent;
-{
- gtk_widget_set_parent(get_widget(self), get_widget(parent));
- return self;
-}
-
-static VALUE
-widget_set_name(self, name)
- VALUE self, name;
-{
- gtk_widget_set_name(get_widget(self), get_cstring(name));
- return self;
-}
-
-static VALUE
-widget_get_name(self)
- VALUE self;
-{
- char *name = gtk_widget_get_name(get_widget(self));
-
- return str_new2(name);
-}
-
-static VALUE
-widget_set_sensitive(self, sensitive)
- VALUE self, sensitive;
-{
- gtk_widget_set_sensitive(get_widget(self), RTEST(sensitive));
- return self;
-}
-
-static VALUE
-widget_set_uposition(self, x, y)
- VALUE self, x, y;
-{
- gtk_widget_set_uposition(get_widget(self), NUM2INT(x), NUM2INT(y));
- return self;
-}
-
-static VALUE
-widget_set_usize(self, w, h)
- VALUE self, w, h;
-{
- gtk_widget_set_usize(get_widget(self), NUM2INT(w), NUM2INT(h));
- return self;
-}
-
-static VALUE
-widget_set_events(self, events)
- VALUE self, events;
-{
- gtk_widget_set_events(get_widget(self), NUM2INT(events));
- return self;
-}
-
-static VALUE
-widget_set_eevents(self, mode)
- VALUE self, mode;
-{
- gtk_widget_set_extension_events(get_widget(self),
- (GdkExtensionMode)NUM2INT(mode));
- return self;
-}
-
-static VALUE
-widget_unparent(self)
- VALUE self;
-{
- gtk_widget_unparent(get_widget(self));
- return self;
-}
-
-static VALUE
-widget_window(self)
- VALUE self;
-{
- return make_gdkwindow(get_widget(self)->window);
-}
-
-static VALUE
-widget_get_toplevel(self)
- VALUE self;
-{
- return get_value_from_gobject(gtk_widget_get_toplevel(get_widget(self)));
-}
-
-static VALUE
-widget_get_ancestor(self, type)
- VALUE self, type;
-{
- GtkWidget *widget = get_widget(self);
-#if 0
- if (obj_is_kind_of(type, cClass)) {
- }
-#endif
- widget = gtk_widget_get_ancestor(widget, NUM2INT(type));
-
- return get_value_from_gobject(widget);
-}
-
-static VALUE
-widget_get_colormap(self)
- VALUE self;
-{
- GdkColormap *cmap = gtk_widget_get_colormap(get_widget(self));
-
- return make_gdkcmap(cmap);
-}
-
-static VALUE
-widget_get_visual(self)
- VALUE self;
-{
- GdkVisual *v = gtk_widget_get_visual(get_widget(self));
-
- return make_gdkvisual(v);
-}
-
-static VALUE
-widget_get_style(self)
- VALUE self;
-{
- GtkStyle *s = gtk_widget_get_style(get_widget(self));
-
- return make_gstyle(s);
-}
-
-static VALUE
-widget_get_pointer(self)
- VALUE self;
-{
- int x, y;
-
- gtk_widget_get_pointer(get_widget(self), &x, &y);
- return assoc_new(INT2FIX(x), INT2FIX(y));
-}
-
-static VALUE
-widget_is_ancestor(self, ancestor)
- VALUE self, ancestor;
-{
- if (gtk_widget_is_ancestor(get_widget(self), get_widget(ancestor))) {
- return TRUE;
- }
- return FALSE;
-}
-
-static VALUE
-widget_is_child(self, child)
- VALUE self, child;
-{
- if (gtk_widget_is_child(get_widget(self), get_widget(child))) {
- return TRUE;
- }
- return FALSE;
-}
-
-static VALUE
-widget_get_events(self)
- VALUE self;
-{
- int n = gtk_widget_get_events(get_widget(self));
- return NUM2INT(n);
-}
-
-static VALUE
-widget_get_eevents(self)
- VALUE self;
-{
- GdkExtensionMode m;
- m = gtk_widget_get_extension_events(get_widget(self));
- return NUM2INT((int)m);
-}
-
-static VALUE
-widget_push_cmap(self, cmap)
- VALUE self, cmap;
-{
- gtk_widget_push_colormap(get_gdkcmap(cmap));
- return Qnil;
-}
-
-static VALUE
-widget_push_visual(self, visual)
- VALUE self, visual;
-{
- gtk_widget_push_visual(get_gdkvisual(visual));
- return make_gdkcmap(visual);
-}
-
-static VALUE
-widget_push_style(self, style)
- VALUE self, style;
-{
- gtk_widget_push_style(get_gstyle(style));
- return Qnil;
-}
-
-static VALUE
-widget_pop_cmap(self, cmap)
- VALUE self, cmap;
-{
- gtk_widget_pop_colormap();
- return Qnil;
-}
-
-static VALUE
-widget_pop_visual(self, visual)
- VALUE self, visual;
-{
- gtk_widget_pop_visual();
- return Qnil;
-}
-
-static VALUE
-widget_pop_style(self, style)
- VALUE self, style;
-{
- gtk_widget_pop_style();
- return Qnil;
-}
-
-static VALUE
-widget_set_default_cmap(self, cmap)
- VALUE self, cmap;
-{
- gtk_widget_set_default_colormap(get_gdkcmap(cmap));
- return Qnil;
-}
-
-static VALUE
-widget_set_default_visual(self, visual)
- VALUE self, visual;
-{
- gtk_widget_set_default_visual(get_gdkvisual(visual));
- return make_gdkcmap(visual);
-}
-
-static VALUE
-widget_set_default_style(self, style)
- VALUE self, style;
-{
- gtk_widget_set_default_style(get_gstyle(style));
- return Qnil;
-}
-
-static VALUE
-widget_get_default_cmap(self)
- VALUE self;
-{
- GdkColormap *cmap = gtk_widget_get_default_colormap();
-
- return make_gdkcmap(cmap);
-}
-
-static VALUE
-widget_get_default_visual(self)
- VALUE self;
-{
- GdkVisual *v = gtk_widget_get_default_visual();
-
- return make_gdkvisual(v);
-}
-
-static VALUE
-widget_get_default_style(self)
- VALUE self;
-{
- GtkStyle *s = gtk_widget_get_default_style();
-
- return make_gstyle(s);
-}
-
-static VALUE
-widget_propagate_default_style(self)
- VALUE self;
-{
- gtk_widget_propagate_default_style();
- return Qnil;
-}
-
-static VALUE
-bbox_get_child_size_default(self)
- VALUE self;
-{
- int min_width, max_width;
-
- gtk_button_box_get_child_size_default(&min_width, &max_width);
-
- return assoc_new(INT2FIX(min_width), INT2FIX(max_width));
-}
-
-static VALUE
-bbox_get_child_ipadding_default(self)
- VALUE self;
-{
- int ipad_x, ipad_y;
-
- gtk_button_box_get_child_ipadding_default(&ipad_x, &ipad_y);
- return assoc_new(INT2FIX(ipad_x), INT2FIX(ipad_y));
-}
-
-static VALUE
-bbox_set_child_size_default(self, min_width, max_width)
- VALUE self, min_width, max_width;
-{
- gtk_button_box_set_child_size_default(NUM2INT(min_width),
- NUM2INT(max_width));
- return Qnil;
-}
-
-static VALUE
-bbox_set_child_ipadding_default(self, ipad_x, ipad_y)
- VALUE self, ipad_x, ipad_y;
-{
- gtk_button_box_set_child_ipadding_default(NUM2INT(ipad_x),
- NUM2INT(ipad_y));
- return Qnil;
-}
-
-static VALUE
-bbox_get_spacing(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- int n = gtk_button_box_get_spacing(GTK_BUTTON_BOX(widget));
-
- return INT2FIX(n);
-}
-
-static VALUE
-bbox_get_layout(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- int n = gtk_button_box_get_layout(GTK_BUTTON_BOX(widget));
-
- return INT2FIX(n);
-}
-
-static VALUE
-bbox_get_child_size(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- int min_width, max_width;
-
- gtk_button_box_get_child_size(GTK_BUTTON_BOX(widget),
- &min_width, &max_width);
- return assoc_new(INT2FIX(min_width), INT2FIX(max_width));
-}
-
-static VALUE
-bbox_get_child_ipadding(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- int ipad_x, ipad_y;
-
- gtk_button_box_get_child_ipadding(GTK_BUTTON_BOX(widget),
- &ipad_x, &ipad_y);
- return assoc_new(INT2FIX(ipad_x), INT2FIX(ipad_y));
-}
-
-static VALUE
-bbox_set_spacing(self, spacing)
- VALUE self, spacing;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_button_box_set_spacing(GTK_BUTTON_BOX(widget),
- NUM2INT(spacing));
- return self;
-}
-
-static VALUE
-bbox_set_layout(self, layout)
- VALUE self, layout;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_button_box_set_layout(GTK_BUTTON_BOX(widget),
- NUM2INT(layout));
- return self;
-}
-
-static VALUE
-bbox_set_child_size(self, min_width, max_width)
- VALUE self, min_width, max_width;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_button_box_set_child_size(GTK_BUTTON_BOX(widget),
- NUM2INT(min_width),
- NUM2INT(max_width));
- return self;
-}
-
-static VALUE
-bbox_set_child_ipadding(self, ipad_x, ipad_y)
- VALUE self, ipad_x, ipad_y;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_button_box_set_child_ipadding(GTK_BUTTON_BOX(widget),
- NUM2INT(ipad_x),
- NUM2INT(ipad_y));
- return self;
-}
-
-static VALUE
-clist_s_new(self, titles)
- VALUE self, titles;
-{
- char **buf;
- int i, len;
-
- Check_Type(titles, T_ARRAY);
- len = RARRAY(titles)->len;
- buf = ALLOCA_N(char*, len);
- for (i=0; i<len; i++) {
- Check_Type(RARRAY(titles)->ptr[i], T_STRING);
- buf[i] = RSTRING(RARRAY(titles)->ptr[i])->ptr;
- }
- return make_widget(self, gtk_clist_new(len, buf));
-}
-
-static VALUE
-clist_set_border(self, border)
- VALUE self, border;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_border(GTK_CLIST(widget), (GtkShadowType)NUM2INT(border));
- return self;
-}
-
-static VALUE
-clist_set_sel_mode(self, mode)
- VALUE self, mode;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_selection_mode(GTK_CLIST(widget),
- (GtkSelectionMode)NUM2INT(mode));
- return self;
-}
-
-static VALUE
-clist_set_policy(self, vpolicy, hpolicy)
- VALUE self, vpolicy, hpolicy;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_policy(GTK_CLIST(widget),
- (GtkPolicyType)NUM2INT(vpolicy),
- (GtkPolicyType)NUM2INT(hpolicy));
- return self;
-}
-
-static VALUE
-clist_freeze(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_freeze(GTK_CLIST(widget));
- return self;
-}
-
-static VALUE
-clist_thaw(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_thaw(GTK_CLIST(widget));
- return self;
-}
-
-static VALUE
-clist_set_col_title(self, col, title)
- VALUE self, col, title;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_column_title(GTK_CLIST(widget),
- NUM2INT(col),
- get_cstring(title));
- return self;
-}
-
-static VALUE
-clist_set_col_wigdet(self, col, win)
- VALUE self, col, win;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_column_widget(GTK_CLIST(widget),
- NUM2INT(col),
- get_widget(win));
- return self;
-}
-
-static VALUE
-clist_set_col_just(self, col, just)
- VALUE self, col, just;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_column_justification(GTK_CLIST(widget),
- NUM2INT(col),
- (GtkJustification)NUM2INT(just));
- return self;
-}
-
-static VALUE
-clist_set_col_width(self, col, width)
- VALUE self, col, width;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_column_width(GTK_CLIST(widget),
- NUM2INT(col), NUM2INT(width));
- return self;
-}
-
-static VALUE
-clist_set_row_height(self, height)
- VALUE self, height;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_row_height(GTK_CLIST(widget), NUM2INT(height));
- return self;
-}
-
-static VALUE
-clist_moveto(self, row, col, row_align, col_align)
- VALUE self, row, col, row_align, col_align;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_moveto(GTK_CLIST(widget),
- NUM2INT(row), NUM2INT(col),
- NUM2INT(row_align), NUM2INT(col_align));
- return self;
-}
-
-static VALUE
-clist_set_text(self, row, col, text)
- VALUE self, row, col, text;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_text(GTK_CLIST(widget),
- NUM2INT(row), NUM2INT(col),
- get_cstring(text));
- return self;
-}
-
-static VALUE
-clist_set_pixmap(self, row, col, pixmap, mask)
- VALUE self, row, col, pixmap, mask;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_pixmap(GTK_CLIST(widget),
- NUM2INT(row), NUM2INT(col),
- get_gdkpixmap(pixmap),
- (GdkBitmap*)get_gdkpixmap(mask));
- return self;
-}
-
-static VALUE
-clist_set_pixtext(self, row, col, text, spacing, pixmap, mask)
- VALUE self, row, col, text, spacing, pixmap, mask;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_pixtext(GTK_CLIST(widget),
- NUM2INT(row), NUM2INT(col),
- get_cstring(text),
- NUM2INT(spacing),
- get_gdkpixmap(pixmap),
- (GdkBitmap*)get_gdkpixmap(mask));
- return self;
-}
-
-static VALUE
-clist_set_foreground(self, row, color)
- VALUE self, row, color;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_foreground(GTK_CLIST(widget),
- NUM2INT(row), get_gdkcolor(color));
- return self;
-}
-
-static VALUE
-clist_set_background(self, row, color)
- VALUE self, row, color;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_background(GTK_CLIST(widget),
- NUM2INT(row), get_gdkcolor(color));
- return self;
-}
-
-static VALUE
-clist_set_shift(self, row, col, verticle, horizontal)
- VALUE self, row, col, verticle, horizontal;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_set_shift(GTK_CLIST(widget),
- NUM2INT(row), NUM2INT(col),
- NUM2INT(verticle), NUM2INT(horizontal));
- return self;
-}
-
-static VALUE
-clist_append(self, text)
- VALUE self, text;
-{
- GtkWidget *widget = get_widget(self);
- char **buf;
- int i, len;
-
- Check_Type(text, T_ARRAY);
- len = GTK_CLIST(widget)->columns;
- if (len > RARRAY(text)->len) {
- ArgError("text too short");
- }
- buf = ALLOCA_N(char*, len);
- for (i=0; i<len; i++) {
- Check_Type(RARRAY(text)->ptr[i], T_STRING);
- buf[i] = RSTRING(RARRAY(text)->ptr[i])->ptr;
- }
- i = gtk_clist_append(GTK_CLIST(widget), buf);
- return INT2FIX(i);
-}
-
-static VALUE
-clist_insert(self, row, text)
- VALUE self, row, text;
-{
- GtkWidget *widget = get_widget(self);
- char **buf;
- int i, len;
-
- Check_Type(text, T_ARRAY);
- len = GTK_CLIST(widget)->columns;
- if (len > RARRAY(text)->len) {
- ArgError("text too short");
- }
- buf = ALLOCA_N(char*, len);
- for (i=0; i<len; i++) {
- Check_Type(RARRAY(text)->ptr[i], T_STRING);
- buf[i] = RSTRING(RARRAY(text)->ptr[i])->ptr;
- }
- gtk_clist_insert(GTK_CLIST(widget), NUM2INT(row), buf);
- return self;
-}
-
-static VALUE
-clist_remove(self, row)
- VALUE self, row;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_remove(GTK_CLIST(widget), NUM2INT(row));
- return self;
-}
-
-static VALUE
-clist_set_row_data(self, row, data)
- VALUE self, row, data;
-{
- GtkWidget *widget = get_widget(self);
-
- add_relative(self, data);
- gtk_clist_set_row_data(GTK_CLIST(widget), NUM2INT(row), (gpointer)data);
- return self;
-}
-
-static VALUE
-clist_get_row_data(self, row)
- VALUE self, row;
-{
- GtkWidget *widget = get_widget(self);
-
- return (VALUE)gtk_clist_get_row_data(GTK_CLIST(widget), NUM2INT(row));
-}
-
-static VALUE
-clist_select_row(self, row, col)
- VALUE self, row, col;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_select_row(GTK_CLIST(widget), NUM2INT(row), NUM2INT(col));
- return self;
-}
-
-static VALUE
-clist_unselect_row(self, row, col)
- VALUE self, row, col;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_unselect_row(GTK_CLIST(widget), NUM2INT(row), NUM2INT(col));
- return self;
-}
-
-static VALUE
-clist_clear(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_clist_clear(GTK_CLIST(widget));
- return self;
-}
-
-static VALUE
-gwin_s_new(self, type)
- VALUE self, type;
-{
- return make_widget(self, gtk_window_new(NUM2INT(type)));
-}
-
-static VALUE
-gwin_set_policy(self, shrink, grow, auto_shrink)
- VALUE self, shrink, grow, auto_shrink;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_window_set_policy(GTK_WINDOW(widget),
- RTEST(shrink), RTEST(grow), RTEST(auto_shrink));
- return self;
-}
-
-static VALUE
-gwin_set_title(self, title)
- VALUE self, title;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_window_set_title(GTK_WINDOW(widget), get_cstring(title));
- return self;
-}
-
-static VALUE
-gwin_position(self, pos)
- VALUE self, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_window_position(GTK_WINDOW(widget),
- (GtkWindowPosition)NUM2INT(pos));
-
- return self;
-}
-
-static VALUE
-gwin_set_wmclass(self, wmclass1, wmclass2)
- VALUE self, wmclass1, wmclass2;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_window_set_wmclass(GTK_WINDOW(widget),
- get_cstring(wmclass1),
- get_cstring(wmclass2));
- return self;
-}
-
-static VALUE
-gwin_set_focus(self, win)
- VALUE self, win;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_window_set_focus(GTK_WINDOW(widget), get_widget(win));
- return self;
-}
-
-static VALUE
-gwin_set_default(self, win)
- VALUE self, win;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_window_set_default(GTK_WINDOW(widget), get_widget(win));
- return self;
-}
-
-static VALUE
-gwin_add_accel(self, accel)
- VALUE self, accel;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_window_add_accelerator_table(GTK_WINDOW(widget),
- get_gtkacceltbl(accel));
- return self;
-}
-
-static VALUE
-gwin_rm_accel(self, accel)
- VALUE self, accel;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_window_remove_accelerator_table(GTK_WINDOW(widget),
- get_gtkacceltbl(accel));
- return self;
-}
-
-static VALUE
-dialog_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_dialog_new());
-}
-
-static VALUE
-fsel_s_new(self, title)
- VALUE self, title;
-{
- return make_widget(self, gtk_file_selection_new(get_cstring(title)));
-}
-
-static VALUE
-fsel_set_fname(self, fname)
- VALUE self, fname;
-{
- GtkWidget *widget = get_widget(self);
-
- Check_Type(fname, T_STRING);
- gtk_file_selection_set_filename(GTK_FILE_SELECTION(widget),
- RSTRING(fname)->ptr);
-
- return self;
-}
-
-static VALUE
-fsel_get_fname(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- gchar *fname;
-
- fname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(widget));
-
- return str_new2(fname);
-}
-
-static VALUE
-fsel_ok_button(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- VALUE b = rb_iv_get(self, "ok_button");
-
- if (NIL_P(b)) {
- GtkWidget *w = GTK_FILE_SELECTION(widget)->ok_button;
- b = make_widget(gButton, w);
- rb_iv_set(self, "ok_button", b);
- }
-
- return b;
-}
-
-static VALUE
-fsel_cancel_button(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- VALUE b = rb_iv_get(self, "cancel_button");
-
- if (NIL_P(b)) {
- GtkWidget *w = GTK_FILE_SELECTION(widget)->cancel_button;
- b = make_widget(gButton, w);
- rb_iv_set(self, "cancel_button", b);
- }
-
- return b;
-}
-
-static VALUE
-fsel_help_button(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- VALUE b = rb_iv_get(self, "help_button");
-
- if (NIL_P(b)) {
- GtkWidget *w = GTK_FILE_SELECTION(widget)->help_button;
- b = make_widget(gButton, w);
- rb_iv_set(self, "help_button", b);
- }
-
- return b;
-}
-
-static VALUE
-label_s_new(self, label)
- VALUE self, label;
-{
- return make_widget(self, gtk_label_new(get_cstring(label)));
-}
-
-static VALUE
-list_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_list_new());
-}
-
-static VALUE
-list_set_sel_mode(self, mode)
- VALUE self, mode;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_list_set_selection_mode(GTK_LIST(widget),
- (GtkSelectionMode)NUM2INT(mode));
- return self;
-}
-
-static VALUE
-list_sel_mode(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- return INT2FIX(GTK_LIST(widget)->selection_mode);
-}
-
-static VALUE
-list_selection(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- return glist2ary(GTK_LIST(widget)->selection);
-}
-
-static VALUE
-list_insert_items(self, items, pos)
- VALUE self, items, pos;
-{
- GtkWidget *widget = get_widget(self);
- GList *glist;
-
- glist = ary2glist(items);
-
- gtk_list_insert_items(GTK_LIST(widget), glist, NUM2INT(pos));
- g_list_free(glist);
-
- return self;
-}
-
-static VALUE
-list_append_items(self, items)
- VALUE self, items;
-{
- GtkWidget *widget = get_widget(self);
- GList *glist;
-
- glist = ary2glist(items);
-
- gtk_list_append_items(GTK_LIST(widget), glist);
- g_list_free(glist);
-
- return self;
-}
-
-static VALUE
-list_prepend_items(self, items)
- VALUE self, items;
-{
- GtkWidget *widget = get_widget(self);
- GList *glist;
-
- glist = ary2glist(items);
- gtk_list_prepend_items(GTK_LIST(widget), glist);
- g_list_free(glist);
-
- return self;
-}
-
-static VALUE
-list_remove_items(self, items)
- VALUE self, items;
-{
- GtkWidget *widget = get_widget(self);
- GList *glist;
-
- glist = ary2glist(items);
- gtk_list_remove_items(GTK_LIST(widget), glist);
- g_list_free(glist);
-
- return self;
-}
-
-static VALUE
-list_clear_items(self, start, end)
- VALUE self, start, end;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_list_clear_items(GTK_LIST(widget), NUM2INT(start), NUM2INT(end));
- return self;
-}
-
-static VALUE
-list_select_item(self, pos)
- VALUE self, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_list_select_item(GTK_LIST(widget), NUM2INT(pos));
- return self;
-}
-
-static VALUE
-list_unselect_item(self, pos)
- VALUE self, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_list_unselect_item(GTK_LIST(widget), NUM2INT(pos));
- return self;
-}
-
-static VALUE
-list_select_child(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_list_select_child(GTK_LIST(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-list_unselect_child(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_list_unselect_child(GTK_LIST(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-list_child_position(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
- gint pos;
-
- pos = gtk_list_child_position(GTK_LIST(widget), get_widget(child));
- return INT2FIX(pos);
-}
-
-static VALUE
-item_select(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_item_select(GTK_ITEM(widget));
- return self;
-}
-
-static VALUE
-item_deselect(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_item_deselect(GTK_ITEM(widget));
- return self;
-}
-
-static VALUE
-item_toggle(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_item_toggle(GTK_ITEM(widget));
- return self;
-}
-
-static VALUE
-litem_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE label;
- GtkWidget *widget;
-
- if (rb_scan_args(argc, argv, "01", &label) == 1) {
- widget = gtk_list_item_new_with_label(get_cstring(label));
- }
- else {
- widget = gtk_list_item_new();
- }
-
- return make_widget(self, widget);
-}
-
-static VALUE
-mshell_append(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_shell_append(GTK_MENU_SHELL(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-mshell_prepend(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_shell_prepend(GTK_MENU_SHELL(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-mshell_insert(self, child, pos)
- VALUE self, child, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_shell_insert(GTK_MENU_SHELL(widget), get_widget(child),
- NUM2INT(pos));
- return self;
-}
-
-static VALUE
-mshell_deactivate(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_shell_deactivate(GTK_MENU_SHELL(widget));
- return self;
-}
-
-static VALUE
-menu_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_menu_new());
-}
-
-static VALUE
-menu_append(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_append(GTK_MENU(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-menu_prepend(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_prepend(GTK_MENU(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-menu_insert(self, child, pos)
- VALUE self, child, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_insert(GTK_MENU(widget), get_widget(child), NUM2INT(pos));
- return self;
-}
-
-static void
-menu_pos_func(menu, x, y, data)
- GtkMenu *menu;
- gint x, y;
- gpointer data;
-{
- VALUE m = get_value_from_gobject(GTK_OBJECT(menu));
-
- rb_funcall((VALUE)data, 3, m, INT2FIX(x), INT2FIX(y));
-}
-
-static VALUE
-menu_popup(self, pshell, pitem, func, button, activate_time)
- VALUE self, pshell, pitem, func, button, activate_time;
-{
- GtkWidget *widget = get_widget(self);
- GtkMenuPositionFunc pfunc = NULL;
- gpointer data = NULL;
-
- if (!NIL_P(func)) {
- pfunc = menu_pos_func;
- data = (gpointer)func;
- add_relative(self, func);
- }
- gtk_menu_popup(GTK_MENU(widget),
- get_widget(pshell), get_widget(pitem),
- pfunc,
- data,
- NUM2INT(button),
- NUM2INT(activate_time));
- return self;
-}
-
-static VALUE
-menu_popdown(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_popdown(GTK_MENU(widget));
- return self;
-}
-
-static VALUE
-menu_get_active(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- GtkWidget *mitem = gtk_menu_get_active(GTK_MENU(widget));
-
- return make_widget(gMenuItem, mitem);
-}
-
-static VALUE
-menu_set_active(self, active)
- VALUE self, active;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_set_active(GTK_MENU(widget), NUM2INT(active));
- return self;
-}
-
-static VALUE
-menu_set_acceltbl(self, table)
- VALUE self, table;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_set_accelerator_table(GTK_MENU(widget),
- get_gtkacceltbl(table));
- return self;
-}
-
-static VALUE
-mbar_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_menu_bar_new());
-}
-
-static VALUE
-mbar_append(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_bar_append(GTK_MENU_BAR(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-mbar_prepend(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_bar_prepend(GTK_MENU_BAR(widget), get_widget(child));
- return self;
-}
-static VALUE
-mbar_insert(self, child, pos)
- VALUE self, child, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_bar_insert(GTK_MENU_BAR(widget),
- get_widget(child), NUM2INT(pos));
- return self;
-}
-
-static VALUE
-mitem_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
-{
- VALUE label;
- GtkWidget *widget;
-
- if (rb_scan_args(argc, argv, "01", &label) == 1) {
- widget = gtk_menu_item_new_with_label(get_cstring(label));
- }
- else {
- widget = gtk_menu_item_new();
- }
-
- return make_widget(self, widget);
-}
-
-static VALUE
-mitem_set_submenu(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-mitem_set_placement(self, place)
- VALUE self, place;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_item_set_placement(GTK_MENU_ITEM(widget),
- (GtkSubmenuPlacement)NUM2INT(place));
- return self;
-}
-
-static VALUE
-mitem_accelerator_size(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_item_accelerator_size(GTK_MENU_ITEM(widget));
- return self;
-}
-
-static VALUE
-mitem_accelerator_text(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- char buf[1024]; /* enough? */
-
- gtk_menu_item_accelerator_text(GTK_MENU_ITEM(widget), buf);
- return str_new2(buf);
-}
-
-static VALUE
-mitem_configure(self, show_toggle, show_submenu)
- VALUE self, show_toggle, show_submenu;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_item_configure(GTK_MENU_ITEM(widget),
- NUM2INT(show_toggle),
- NUM2INT(show_submenu));
- return self;
-}
-
-static VALUE
-mitem_select(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_item_select(GTK_MENU_ITEM(widget));
- return self;
-}
-
-static VALUE
-mitem_deselect(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_item_deselect(GTK_MENU_ITEM(widget));
- return self;
-}
-
-static VALUE
-mitem_activate(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_item_activate(GTK_MENU_ITEM(widget));
- return self;
-}
-
-static VALUE
-mitem_right_justify(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_menu_item_right_justify(GTK_MENU_ITEM(widget));
- return self;
-}
-
-static VALUE
-cmitem_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
-{
- VALUE label;
- GtkWidget *widget;
-
- if (rb_scan_args(argc, argv, "01", &label) == 1) {
- widget = gtk_check_menu_item_new_with_label(get_cstring(label));
- }
- else {
- widget = gtk_check_menu_item_new();
- }
-
- return make_widget(self, widget);
-}
-
-static VALUE
-cmitem_set_state(self, state)
- VALUE self, state;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_check_menu_item_set_state(GTK_CHECK_MENU_ITEM(widget),
- NUM2INT(state));
- return self;
-}
-
-static VALUE
-cmitem_set_show_toggle(self, always)
- VALUE self, always;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(widget),
- (gboolean)RTEST(always));
- return self;
-}
-
-static VALUE
-cmitem_toggled(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_check_menu_item_toggled(GTK_CHECK_MENU_ITEM(widget));
- return self;
-}
-
-static VALUE
-rmitem_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
-{
- VALUE arg1, arg2;
- GtkWidget *widget;
- GSList *list = NULL;
- char *label = NULL;
-
- if (rb_scan_args(argc, argv, "02", &arg1, &arg2) == 1 &&
- TYPE(arg1) == T_STRING) {
- label = RSTRING(arg1)->ptr;
- }
- else {
- if (!NIL_P(arg2)) {
- Check_Type(arg2, T_STRING);
- label = RSTRING(arg2)->ptr;
- }
- if (obj_is_kind_of(arg1, gRMenuItem)) {
- GtkWidget *b = get_widget(arg1);
- list = GTK_RADIO_MENU_ITEM(b)->group;
- }
- else {
- list = ary2gslist(arg1);
- }
- }
- if (label) {
- widget = gtk_radio_menu_item_new_with_label(list, label);
- }
- else {
- widget = gtk_radio_menu_item_new(list);
- }
- return make_widget(self, widget);
-}
-
-static VALUE
-rmitem_group(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- return gslist2ary(gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(widget)));
-}
-
-static VALUE
-note_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_notebook_new());
-}
-
-static VALUE
-note_append_page(self, child, label)
- VALUE self, child, label;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_notebook_append_page(GTK_NOTEBOOK(widget),
- get_widget(child),
- get_widget(label));
- return self;
-}
-
-static VALUE
-note_prepend_page(self, child, label)
- VALUE self, child, label;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_notebook_prepend_page(GTK_NOTEBOOK(widget),
- get_widget(child),
- get_widget(label));
- return self;
-}
-
-static VALUE
-note_insert_page(self, child, label, pos)
- VALUE self, child, label, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_notebook_insert_page(GTK_NOTEBOOK(widget),
- get_widget(child),
- get_widget(label),
- NUM2INT(pos));
- return self;
-}
-
-static VALUE
-note_remove_page(self, pos)
- VALUE self, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_notebook_remove_page(GTK_NOTEBOOK(widget), NUM2INT(pos));
- return self;
-}
-
-static VALUE
-note_set_page(self, pos)
- VALUE self, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_notebook_set_page(GTK_NOTEBOOK(widget), NUM2INT(pos));
- return self;
-}
-
-static VALUE
-note_cur_page(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- return INT2FIX(GTK_NOTEBOOK(widget)->cur_page);
-}
-
-static VALUE
-note_next_page(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_notebook_next_page(GTK_NOTEBOOK(widget));
- return self;
-}
-
-static VALUE
-note_prev_page(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_notebook_prev_page(GTK_NOTEBOOK(widget));
- return self;
-}
-
-static VALUE
-note_set_tab_pos(self, pos)
- VALUE self, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_notebook_set_tab_pos(GTK_NOTEBOOK(widget), NUM2INT(pos));
- return self;
-}
-
-static VALUE
-note_tab_pos(self, pos)
- VALUE self, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- return INT2FIX(GTK_NOTEBOOK(widget)->tab_pos);
-}
-
-static VALUE
-note_set_show_tabs(self, show_tabs)
- VALUE self, show_tabs;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_notebook_set_tab_pos(GTK_NOTEBOOK(widget), RTEST(show_tabs));
- return self;
-}
-
-static VALUE
-note_show_tabs(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- return GTK_NOTEBOOK(widget)->show_tabs?TRUE:FALSE;
-}
-
-static VALUE
-note_set_show_border(self, show_border)
- VALUE self, show_border;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_notebook_set_tab_pos(GTK_NOTEBOOK(widget), RTEST(show_border));
- return self;
-}
-
-static VALUE
-note_show_border(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- return GTK_NOTEBOOK(widget)->show_border?TRUE:FALSE;
-}
-
-static VALUE
-omenu_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_option_menu_new());
-}
-
-static VALUE
-omenu_set_menu(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- rb_iv_set(self, "option_menu", child);
- gtk_option_menu_set_menu(GTK_OPTION_MENU(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-omenu_get_menu(self)
- VALUE self;
-{
- return rb_iv_get(self, "option_menu");
-}
-
-static VALUE
-omenu_remove_menu(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_option_menu_remove_menu(GTK_OPTION_MENU(widget));
- return self;
-}
-
-static VALUE
-omenu_set_history(self, index)
- VALUE self, index;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_option_menu_set_history(GTK_OPTION_MENU(widget), NUM2INT(index));
- return self;
-}
-
-static VALUE
-image_s_new(self, val, mask)
- VALUE self, val, mask;
-{
- return make_widget(self, gtk_image_new(get_gdkimage(val),
- (GdkBitmap*)get_gdkpixmap(mask)));
-}
-
-static VALUE
-image_set(self, val, mask)
- VALUE self, val, mask;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_image_set(GTK_IMAGE(widget), get_gdkimage(val), get_gdkpixmap(mask));
- return self;
-}
-
-static VALUE
-image_get(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- GdkImage *val;
- GdkBitmap *mask;
-
- gtk_image_get(GTK_IMAGE(widget), &val, &mask);
-
- return assoc_new(make_gdkimage(self, val),
- make_gdkpixmap(self, mask));
-}
-
-static VALUE
-preview_s_new(self, type)
- VALUE self, type;
-{
- return make_widget(self, gtk_preview_new((GtkPreviewType)NUM2INT(type)));
-}
-
-
-static VALUE
-preview_size(self, w, h)
- VALUE self, w, h;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_preview_size(GTK_PREVIEW(widget), NUM2INT(w), NUM2INT(h));
- return self;
-}
-
-#if 0
- rb_define_method(gPixmap, "put", preview_size, 8);
- rb_define_method(gPixmap, "put_row", preview_size, 5);
- rb_define_method(gPixmap, "draw_row", preview_size, 4);
-#endif
-
-static VALUE
-preview_set_expand(self, expand)
- VALUE self, expand;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_preview_set_expand(GTK_PREVIEW(widget), NUM2INT(expand));
- return self;
-}
-
-static VALUE
-preview_set_gamma(self, gamma)
- VALUE self, gamma;
-{
- gtk_preview_set_gamma(NUM2DBL(gamma));
- return Qnil;
-}
-
-static VALUE
-preview_set_color_cube(self, nred, ngreen, nblue, ngray)
- VALUE self, nred, ngreen, nblue, ngray;
-{
- gtk_preview_set_color_cube(NUM2INT(nred),
- NUM2INT(ngreen),
- NUM2INT(nblue),
- NUM2INT(ngray));
- return Qnil;
-}
-
-static VALUE
-preview_set_install_cmap(self, cmap)
- VALUE self, cmap;
-{
- gtk_preview_set_install_cmap(NUM2INT(cmap));
- return Qnil;
-}
-
-static VALUE
-preview_set_reserved(self, nreserved)
- VALUE self, nreserved;
-{
- gtk_preview_set_reserved(NUM2INT(nreserved));
- return Qnil;
-}
-
-static VALUE
-preview_get_visual(self)
- VALUE self;
-{
- GdkVisual *v = gtk_preview_get_visual();
- return make_gdkvisual(v);
-}
-
-static VALUE
-preview_get_cmap(self)
- VALUE self;
-{
- GdkColormap *c = gtk_preview_get_cmap();
- return make_gdkcmap(c);
-}
-
-static VALUE
-preview_get_info(self)
- VALUE self;
-{
- GtkPreviewInfo *i = gtk_preview_get_info();
- return make_gtkprevinfo(i);
-}
-
-static VALUE
-pbar_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_progress_bar_new());
-}
-
-static VALUE
-pbar_update(self, percentage)
- VALUE self, percentage;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_progress_bar_update(GTK_PROGRESS_BAR(widget),
- NUM2DBL(percentage));
- return self;
-}
-
-static VALUE
-scwin_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE arg1, arg2;
- GtkAdjustment *h_adj = NULL;
- GtkAdjustment *v_adj = NULL;
-
- rb_scan_args(argc, argv, "02", &arg1, &arg2);
- if (!NIL_P(arg1)) h_adj = (GtkAdjustment*)get_gobject(arg1);
- if (!NIL_P(arg2)) v_adj = (GtkAdjustment*)get_gobject(arg2);
-
- return make_widget(self, gtk_scrolled_window_new(h_adj, v_adj));
-}
-
-static VALUE
-scwin_set_policy(self, hpolicy, vpolicy)
- VALUE self, hpolicy, vpolicy;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
- (GtkPolicyType)NUM2INT(hpolicy),
- (GtkPolicyType)NUM2INT(vpolicy));
- return self;
-}
-
-
-static VALUE
-tbl_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
-{
- VALUE row, col, homogeneous;
-
- rb_scan_args(argc, argv, "21", &row, &col, &homogeneous);
- return make_widget(self, gtk_table_new(NUM2INT(row),
- NUM2INT(col),
- RTEST(homogeneous)));
-}
-
-static VALUE
-tbl_attach(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- VALUE child, left, right, top, bottom;
- VALUE arg0, arg1, arg2, arg3;
- int xopt, yopt, xspc, yspc;
-
- xopt = yopt = GTK_EXPAND | GTK_FILL;
- xspc = yspc = 0;
- rb_scan_args(argc, argv, "54",
- &child, &left, &right, &top, &bottom,
- &arg0, &arg1, &arg2, &arg3);
- if (!NIL_P(arg0)) xopt = NUM2INT(arg0);
- if (!NIL_P(arg1)) yopt = NUM2INT(arg1);
- if (!NIL_P(arg2)) xspc = NUM2INT(arg2);
- if (!NIL_P(arg3)) yspc = NUM2INT(arg3);
-
- gtk_table_attach(GTK_TABLE(widget),
- get_widget(child),
- NUM2INT(left),NUM2INT(right),
- NUM2INT(top),NUM2INT(bottom),
- xopt, yopt, xspc, yspc);
-
- return self;
-}
-
-static VALUE
-tbl_set_row_spacing(self, row, spc)
- VALUE self, row, spc;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_table_set_row_spacing(GTK_TABLE(widget), NUM2INT(row), NUM2INT(spc));
- return self;
-}
-
-static VALUE
-tbl_set_col_spacing(self, col, spc)
- VALUE self, col, spc;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_table_set_col_spacing(GTK_TABLE(widget), NUM2INT(col), NUM2INT(spc));
- return self;
-}
-
-static VALUE
-tbl_set_row_spacings(self, spc)
- VALUE self, spc;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_table_set_row_spacings(GTK_TABLE(widget), NUM2INT(spc));
- return self;
-}
-
-static VALUE
-tbl_set_col_spacings(self, spc)
- VALUE self, spc;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_table_set_col_spacings(GTK_TABLE(widget), NUM2INT(spc));
- return self;
-}
-
-static VALUE
-txt_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE arg1, arg2;
- GtkAdjustment *h_adj = NULL;
- GtkAdjustment *v_adj = NULL;
-
- rb_scan_args(argc, argv, "02", &arg1, &arg2);
- if (!NIL_P(arg1)) h_adj = (GtkAdjustment*)get_gobject(arg1);
- if (!NIL_P(arg2)) v_adj = (GtkAdjustment*)get_gobject(arg2);
-
- return make_widget(self, gtk_text_new(h_adj, v_adj));
-}
-
-static VALUE
-txt_set_editable(self, editable)
- VALUE self, editable;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_text_set_editable(GTK_TEXT(widget), RTEST(editable));
- return self;
-}
-
-static VALUE
-txt_set_adjustment(self, h_adj, v_adj)
- VALUE self, h_adj, v_adj;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_text_set_adjustments(GTK_TEXT(widget),
- (GtkAdjustment*)get_gobject(h_adj),
- (GtkAdjustment*)get_gobject(v_adj));
-
- return self;
-}
-
-static VALUE
-txt_set_point(self, index)
- VALUE self, index;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_text_set_point(GTK_TEXT(widget), NUM2INT(index));
- return self;
-}
-
-static VALUE
-txt_get_point(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- int index = gtk_text_get_point(GTK_TEXT(widget));
-
- return INT2FIX(index);
-}
-
-static VALUE
-txt_get_length(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- int len = gtk_text_get_length(GTK_TEXT(widget));
-
- return INT2FIX(len);
-}
-
-static VALUE
-txt_freeze(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_text_freeze(GTK_TEXT(widget));
- return self;
-}
-
-static VALUE
-txt_thaw(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_text_thaw(GTK_TEXT(widget));
- return self;
-}
-
-static VALUE
-txt_insert(self, font, fore, back, str)
- VALUE self, font, fore, back, str;
-{
- GtkWidget *widget = get_widget(self);
-
- Check_Type(str, T_STRING);
- gtk_text_insert(GTK_TEXT(widget),
- get_gdkfont(font),
- get_gdkcolor(fore),
- get_gdkcolor(back),
- RSTRING(str)->ptr,
- RSTRING(str)->len);
-
- return self;
-}
-
-static VALUE
-txt_backward_delete(self, nchars)
- VALUE self, nchars;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_text_backward_delete(GTK_TEXT(widget), NUM2INT(nchars));
- return self;
-}
-
-static VALUE
-txt_forward_delete(self, nchars)
- VALUE self, nchars;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_text_forward_delete(GTK_TEXT(widget), NUM2INT(nchars));
- return self;
-}
-
-static VALUE
-tbar_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE arg1, arg2;
- GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL;
- GtkToolbarStyle style = GTK_TOOLBAR_BOTH;
-
- rb_scan_args(argc, argv, "02", &arg1, &arg2);
- if (!NIL_P(arg1)) orientation = (GtkOrientation)NUM2INT(arg1);
- if (!NIL_P(arg2)) style = (GtkToolbarStyle)NUM2INT(arg2);
-
- return make_widget(self, gtk_toolbar_new(orientation, style));
-}
-
-static VALUE
-tbar_append_item(self, text, ttext, icon, func)
- VALUE self, text, ttext, icon, func;
-{
- GtkWidget *widget = get_widget(self);
- GtkObject *pixmap = get_gobject(icon);
-
- if (NIL_P(func)) {
- func = f_lambda();
- }
- gtk_toolbar_append_item(GTK_TOOLBAR(widget),
- get_cstring(text),
- get_cstring(ttext),
- GTK_PIXMAP(pixmap),
- exec_callback,
- (gpointer)ary_new3(1, func));
- return self;
-}
-
-static VALUE
-tbar_prepend_item(self, text, ttext, icon, func)
- VALUE self, text, ttext, icon, func;
-{
- GtkWidget *widget = get_widget(self);
- GtkObject *pixmap = get_gobject(icon);
-
- if (NIL_P(func)) {
- func = f_lambda();
- }
- gtk_toolbar_prepend_item(GTK_TOOLBAR(widget),
- get_cstring(text),
- get_cstring(ttext),
- GTK_PIXMAP(pixmap),
- exec_callback,
- (gpointer)ary_new3(1, func));
- return self;
-}
-
-static VALUE
-tbar_insert_item(self, text, ttext, icon, func, pos)
- VALUE self, text, ttext, icon, func, pos;
-{
- GtkWidget *widget = get_widget(self);
- GtkObject *pixmap = get_gobject(icon);
-
- if (NIL_P(func)) {
- func = f_lambda();
- }
- gtk_toolbar_insert_item(GTK_TOOLBAR(widget),
- get_cstring(text),
- get_cstring(ttext),
- GTK_PIXMAP(pixmap),
- exec_callback,
- (gpointer)ary_new3(1, func),
- NUM2INT(pos));
- return self;
-}
-
-static VALUE
-tbar_append_space(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_toolbar_append_space(GTK_TOOLBAR(widget));
- return self;
-}
-
-static VALUE
-tbar_prepend_space(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_toolbar_prepend_space(GTK_TOOLBAR(widget));
- return self;
-}
-
-static VALUE
-tbar_insert_space(self, pos)
- VALUE self, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_toolbar_insert_space(GTK_TOOLBAR(widget), NUM2INT(pos));
- return self;
-}
-
-static VALUE
-tbar_set_orientation(self, orientation)
- VALUE self, orientation;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_toolbar_set_orientation(GTK_TOOLBAR(widget),
- (GtkOrientation)NUM2INT(orientation));
- return self;
-}
-
-static VALUE
-tbar_set_style(self, style)
- VALUE self, style;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_toolbar_set_style(GTK_TOOLBAR(widget),
- (GtkToolbarStyle)NUM2INT(style));
- return self;
-}
-
-static VALUE
-tbar_set_space_size(self, size)
- VALUE self, size;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_toolbar_set_space_size(GTK_TOOLBAR(widget), NUM2INT(size));
- return self;
-}
-
-static VALUE
-tbar_set_tooltips(self, enable)
- VALUE self, enable;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_toolbar_set_tooltips(GTK_TOOLBAR(widget), RTEST(enable));
- return self;
-}
-
-static VALUE
-ttips_s_new(self)
- VALUE self;
-{
- return make_ttips(self, gtk_tooltips_new());
-}
-
-static VALUE
-ttips_set_tips(self, win, text)
- VALUE self, win, text;
-{
- Check_Type(text, T_STRING);
- gtk_tooltips_set_tips(get_ttips(self),
- get_widget(win),
- RSTRING(text)->ptr);
-
- return self;
-}
-
-static VALUE
-ttips_set_delay(self, delay)
- VALUE self, delay;
-{
- gtk_tooltips_set_delay(get_ttips(self), NUM2INT(delay));
-
- return self;
-}
-
-static VALUE
-ttips_enable(self)
- VALUE self;
-{
- gtk_tooltips_enable(get_ttips(self));
- return self;
-}
-
-static VALUE
-ttips_disable(self)
- VALUE self;
-{
- gtk_tooltips_enable(get_ttips(self));
- return self;
-}
-
-static VALUE
-tree_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_tree_new());
-}
-
-static VALUE
-tree_append(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_tree_append(GTK_TREE(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-tree_prepend(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_tree_prepend(GTK_TREE(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-tree_insert(self, child, pos)
- VALUE self, child, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_tree_insert(GTK_TREE(widget), get_widget(child), NUM2INT(pos));
- return self;
-}
-
-static VALUE
-titem_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
-{
- VALUE label;
- GtkWidget *widget;
-
- if (rb_scan_args(argc, argv, "01", &label) == 1) {
- Check_Type(label, T_STRING);
- widget = gtk_tree_item_new_with_label(RSTRING(label)->ptr);
- }
- else {
- widget = gtk_tree_item_new();
- }
-
- return make_widget(self, widget);
-}
-
-static VALUE
-titem_set_subtree(self, subtree)
- VALUE self, subtree;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_tree_item_set_subtree(GTK_TREE_ITEM(widget), get_widget(subtree));
- return self;
-}
-
-static VALUE
-titem_select(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_tree_item_select(GTK_TREE_ITEM(widget));
- return self;
-}
-
-static VALUE
-titem_deselect(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_tree_item_deselect(GTK_TREE_ITEM(widget));
- return self;
-}
-
-static VALUE
-titem_expand(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_tree_item_expand(GTK_TREE_ITEM(widget));
- return self;
-}
-
-static VALUE
-titem_collapse(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_tree_item_collapse(GTK_TREE_ITEM(widget));
- return self;
-}
-
-static VALUE
-vport_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE arg1, arg2;
- GtkAdjustment *h_adj = NULL;
- GtkAdjustment *v_adj = NULL;
-
- rb_scan_args(argc, argv, "02", &arg1, &arg2);
- if (!NIL_P(arg1)) h_adj = (GtkAdjustment*)get_gobject(arg1);
- if (!NIL_P(arg2)) v_adj = (GtkAdjustment*)get_gobject(arg2);
-
- return make_widget(self, gtk_viewport_new(h_adj, v_adj));
-}
-
-static VALUE
-vport_get_hadj(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- GtkAdjustment *adj = gtk_viewport_get_hadjustment(GTK_VIEWPORT(widget));
-
- return make_gobject(gAdjustment, GTK_OBJECT(adj));
-}
-
-static VALUE
-vport_get_vadj(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- GtkAdjustment *adj = gtk_viewport_get_vadjustment(GTK_VIEWPORT(widget));
-
- return make_gobject(gAdjustment, GTK_OBJECT(adj));
-}
-
-static VALUE
-vport_set_vadj(self, adj)
- VALUE self, adj;
-{
- GtkWidget *widget = get_widget(self);
- GtkObject *adjustment = get_gobject(adj);
-
- gtk_viewport_set_vadjustment(GTK_VIEWPORT(widget),
- GTK_ADJUSTMENT(adj));
-
- return self;
-}
-
-static VALUE
-vport_set_hadj(self, adj)
- VALUE self, adj;
-{
- GtkWidget *widget = get_widget(self);
- GtkObject *adjustment = get_gobject(adj);
-
- gtk_viewport_set_hadjustment(GTK_VIEWPORT(widget),
- GTK_ADJUSTMENT(adj));
-
- return self;
-}
-
-static VALUE
-vport_set_shadow(self, type)
- VALUE self, type;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_viewport_set_shadow_type(GTK_VIEWPORT(widget),
- (GtkShadowType)NUM2INT(type));
-
- return self;
-}
-
-static VALUE
-button_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
-{
- VALUE label;
- GtkWidget *widget;
-
- if (rb_scan_args(argc, argv, "01", &label) == 1) {
- Check_Type(label, T_STRING);
- widget = gtk_button_new_with_label(RSTRING(label)->ptr);
- }
- else {
- widget = gtk_button_new();
- }
-
- return make_widget(self, widget);
-}
-
-static VALUE
-button_pressed(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_button_pressed(GTK_BUTTON(widget));
- return self;
-}
-
-static VALUE
-button_released(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_button_released(GTK_BUTTON(widget));
- return self;
-}
-
-static VALUE
-button_clicked(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_button_clicked(GTK_BUTTON(widget));
- return self;
-}
-
-static VALUE
-button_enter(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_button_enter(GTK_BUTTON(widget));
- return self;
-}
-
-static VALUE
-button_leave(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_button_leave(GTK_BUTTON(widget));
- return self;
-}
-
-static VALUE
-tbtn_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
-{
- VALUE label;
- GtkWidget *widget;
-
- if (rb_scan_args(argc, argv, "01", &label) == 1) {
- Check_Type(label, T_STRING);
- widget = gtk_toggle_button_new_with_label(RSTRING(label)->ptr);
- }
- else {
- widget = gtk_toggle_button_new();
- }
-
- return make_widget(self, widget);
-}
-
-static VALUE
-tbtn_set_mode(self, mode)
- VALUE self, mode;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(widget), NUM2INT(mode));
- return self;
-}
-
-static VALUE
-tbtn_set_state(self, state)
- VALUE self, state;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(widget), NUM2INT(state));
- return self;
-}
-
-static VALUE
-tbtn_toggled(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_toggle_button_toggled(GTK_TOGGLE_BUTTON(widget));
- return self;
-}
-
-static VALUE
-cbtn_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
-{
- VALUE label;
- GtkWidget *widget;
-
- if (rb_scan_args(argc, argv, "01", &label) == 1) {
- Check_Type(label, T_STRING);
- widget = gtk_check_button_new_with_label(RSTRING(label)->ptr);
- }
- else {
- widget = gtk_check_button_new();
- }
-
- return make_widget(self, widget);
-}
-
-static VALUE
-rbtn_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
-{
- VALUE arg1, arg2;
- GtkWidget *widget;
- GSList *list = NULL;
- char *label = NULL;
-
- if (rb_scan_args(argc, argv, "02", &arg1, &arg2) == 1 &&
- TYPE(arg1) == T_STRING) {
- label = RSTRING(arg1)->ptr;
- }
- else {
- if (!NIL_P(arg2)) {
- Check_Type(arg2, T_STRING);
- label = RSTRING(arg2)->ptr;
- }
- if (obj_is_kind_of(arg1, gRButton)) {
- GtkWidget *b = get_widget(arg1);
- list = GTK_RADIO_BUTTON(b)->group;
- }
- else {
- list = ary2gslist(arg1);
- }
- }
- if (label) {
- widget = gtk_radio_button_new_with_label(list, label);
- }
- else {
- widget = gtk_radio_button_new(list);
- }
- return make_widget(self, widget);
-}
-
-static VALUE
-rbtn_group(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- return gslist2ary(gtk_radio_button_group(GTK_RADIO_BUTTON(widget)));
-}
-
-static void
-box_pack_start_or_end(argc, argv, self, start)
- int argc;
- VALUE *argv;
- VALUE self;
- int start;
-{
- VALUE arg0, arg1, arg2, arg3;
- gint expand, fill, padding;
- GtkWidget *widget, *child;
-
- expand = fill = TRUE; padding = 0;
- switch (rb_scan_args(argc, argv, "13", &arg0, &arg1, &arg2, &arg3)) {
- case 4:
- padding = NUM2INT(arg3);
- case 3:
- fill = RTEST(arg2);
- case 2:
- expand = RTEST(arg1);
- default:
- child = get_widget(arg0);
- break;
- }
- widget = get_widget(self);
-
- if (start)
- gtk_box_pack_start(GTK_BOX(widget), child, expand, fill, padding);
- else
- gtk_box_pack_end(GTK_BOX(widget), child, expand, fill, padding);
-}
-
-static VALUE
-box_pack_start(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- box_pack_start_or_end(argc, argv, self, 1);
- return self;
-}
-
-static VALUE
-box_pack_end(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- box_pack_start_or_end(argc, argv, self, 0);
- return self;
-}
-
-static VALUE
-vbox_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE homogeneous, spacing;
- GtkWidget *widget;
-
- rb_scan_args(argc, argv, "02", &homogeneous, &spacing);
- widget = gtk_vbox_new(RTEST(homogeneous), NUM2INT(spacing));
-
- return make_widget(self, widget);
-}
-
-static VALUE
-colorsel_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_color_selection_new());
-}
-
-static VALUE
-colorsel_set_update_policy(self, policy)
- VALUE self, policy;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_color_selection_set_update_policy(GTK_COLOR_SELECTION(widget),
- (GtkUpdateType)NUM2INT(policy));
- return self;
-}
-
-static VALUE
-colorsel_set_opacity(self, opacity)
- VALUE self, opacity;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_color_selection_set_opacity(GTK_COLOR_SELECTION(widget),
- RTEST(opacity));
- return self;
-}
-
-static VALUE
-colorsel_set_color(self, color)
- VALUE self, color;
-{
- GtkWidget *widget = get_widget(self);
- double buf[3];
-
- Check_Type(color, T_ARRAY);
- if (RARRAY(color)->len < 3) {
- ArgError("color array too small");
- }
- buf[0] = NUM2DBL(RARRAY(color)->ptr[0]);
- buf[1] = NUM2DBL(RARRAY(color)->ptr[1]);
- buf[2] = NUM2DBL(RARRAY(color)->ptr[2]);
-
- gtk_color_selection_set_color(GTK_COLOR_SELECTION(widget), buf);
- return self;
-}
-
-static VALUE
-colorsel_get_color(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- double buf[3];
- VALUE ary;
-
- gtk_color_selection_get_color(GTK_COLOR_SELECTION(widget), buf);
- ary = ary_new2(3);
- ary_push(ary, NUM2DBL(buf[0]));
- ary_push(ary, NUM2DBL(buf[1]));
- ary_push(ary, NUM2DBL(buf[2]));
- return ary;
-}
-
-static VALUE
-cdialog_s_new(self, title)
- VALUE self;
-{
- char *t;
-
- Check_Type(title, T_STRING);
- t = RSTRING(title)->ptr;
- return make_widget(self, gtk_color_selection_dialog_new(t));
-}
-
-static VALUE
-pixmap_s_new(self, val, mask)
- VALUE self, val, mask;
-{
- return make_widget(self, gtk_pixmap_new(get_gdkpixmap(val),
- get_gdkpixmap(mask)));
-}
-
-static VALUE
-pixmap_set(self, val, mask)
- VALUE self, val, mask;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_pixmap_set(GTK_PIXMAP(widget),
- get_gdkpixmap(val), get_gdkpixmap(mask));
- return self;
-}
-
-static VALUE
-pixmap_get(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- GdkPixmap *val;
- GdkBitmap *mask;
-
- gtk_pixmap_get(GTK_PIXMAP(widget), &val, &mask);
-
- return assoc_new(make_gdkpixmap(self, val),
- make_gdkpixmap(self, mask));
-}
-
-static VALUE
-darea_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_drawing_area_new());
-}
-
-static VALUE
-darea_size(self, w, h)
- VALUE self, w, h;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_drawing_area_size(GTK_DRAWING_AREA(widget), NUM2INT(w), NUM2INT(h));
- return self;
-}
-
-static VALUE
-entry_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_entry_new());
-}
-
-static VALUE
-entry_set_text(self, text)
- VALUE self, text;
-{
- GtkWidget *widget = get_widget(self);
-
- Check_Type(text, T_STRING);
- gtk_entry_set_text(GTK_ENTRY(widget), RSTRING(text)->ptr);
-
- return self;
-}
-
-static VALUE
-eventbox_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_event_box_new());
-}
-
-static VALUE
-fixed_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_fixed_new());
-}
-
-static VALUE
-fixed_put(self, win, x, y)
- VALUE self, win, x, y;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_fixed_put(GTK_FIXED(widget), get_widget(win), NUM2INT(x), NUM2INT(y));
- return self;
-}
-
-static VALUE
-fixed_move(self, win, x, y)
- VALUE self, win, x, y;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_fixed_move(GTK_FIXED(widget), get_widget(win), NUM2INT(x), NUM2INT(y));
- return self;
-}
-
-static VALUE
-gamma_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_gamma_curve_new());
-}
-
-static VALUE
-gamma_gamma(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- return float_new(GTK_GAMMA_CURVE(widget)->gamma);
-}
-
-static VALUE
-hbbox_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_hbutton_box_new());
-}
-
-static VALUE
-hbbox_get_spacing_default(self)
- VALUE self;
-{
- int n = gtk_hbutton_box_get_spacing_default();
-
- return INT2FIX(n);
-}
-
-static VALUE
-hbbox_get_layout_default(self)
- VALUE self;
-{
- int n = gtk_hbutton_box_get_layout_default();
-
- return INT2FIX(n);
-}
-
-static VALUE
-hbbox_set_spacing_default(self, spacing)
- VALUE self, spacing;
-{
- gtk_hbutton_box_set_spacing_default(NUM2INT(spacing));
- return Qnil;
-}
-
-static VALUE
-hbbox_set_layout_default(self, layout)
- VALUE self, layout;
-{
- gtk_hbutton_box_set_layout_default(NUM2INT(layout));
- return Qnil;
-}
-
-static VALUE
-vbbox_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_vbutton_box_new());
-}
-
-static VALUE
-vbbox_get_spacing_default(self)
- VALUE self;
-{
- int n = gtk_vbutton_box_get_spacing_default();
-
- return INT2FIX(n);
-}
-
-static VALUE
-vbbox_get_layout_default(self)
- VALUE self;
-{
- int n = gtk_vbutton_box_get_layout_default();
-
- return INT2FIX(n);
-}
-
-static VALUE
-vbbox_set_spacing_default(self, spacing)
- VALUE self, spacing;
-{
- gtk_vbutton_box_set_spacing_default(NUM2INT(spacing));
- return Qnil;
-}
-
-static VALUE
-vbbox_set_layout_default(self, layout)
- VALUE self, layout;
-{
- gtk_vbutton_box_set_layout_default(NUM2INT(layout));
- return Qnil;
-}
-
-static VALUE
-hbox_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE homogeneous, spacing;
- GtkWidget *widget;
-
- rb_scan_args(argc, argv, "02", &homogeneous, &spacing);
- widget = gtk_hbox_new(RTEST(homogeneous), NUM2INT(spacing));
-
- return make_widget(self, widget);
-}
-
-static VALUE
-paned_add1(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_paned_add1(GTK_PANED(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-paned_add2(self, child)
- VALUE self, child;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_paned_add2(GTK_PANED(widget), get_widget(child));
- return self;
-}
-
-static VALUE
-paned_handle_size(self, size)
- VALUE self, size;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_paned_handle_size(GTK_PANED(widget), NUM2INT(size));
- return self;
-}
-
-static VALUE
-paned_gutter_size(self, size)
- VALUE self, size;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_paned_gutter_size(GTK_PANED(widget), NUM2INT(size));
- return self;
-}
-
-static VALUE
-hpaned_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_hpaned_new());
-}
-
-static VALUE
-vpaned_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_vpaned_new());
-}
-
-static VALUE
-ruler_set_metric(self, metric)
- VALUE self, metric;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_ruler_set_metric(GTK_RULER(widget),
- (GtkMetricType)NUM2INT(metric));
-
- return self;
-}
-
-static VALUE
-ruler_set_range(self, lower, upper, position, max_size)
- VALUE self, lower, upper, position, max_size;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_ruler_set_range(GTK_RULER(widget),
- NUM2DBL(lower), NUM2DBL(upper),
- NUM2DBL(position), NUM2DBL(max_size));
-
- return self;
-}
-
-static VALUE
-ruler_draw_ticks(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_ruler_draw_ticks(GTK_RULER(widget));
- return self;
-}
-
-static VALUE
-ruler_draw_pos(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_ruler_draw_pos(GTK_RULER(widget));
- return self;
-}
-
-static VALUE
-hruler_s_new(self)
-{
- return make_widget(self, gtk_hruler_new());
-}
-
-static VALUE
-vruler_s_new(self)
-{
- return make_widget(self, gtk_vruler_new());
-}
-
-static VALUE
-range_get_adj(self)
-{
- GtkWidget *widget = get_widget(self);
- GtkAdjustment *adj = gtk_range_get_adjustment(GTK_RANGE(widget));
-
- return make_gobject(gAdjustment, GTK_OBJECT(adj));
-}
-
-static VALUE
-range_set_update_policy(self, policy)
- VALUE self, policy;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_set_update_policy(GTK_RANGE(widget),
- (GtkUpdateType)NUM2INT(policy));
- return self;
-}
-
-static VALUE
-range_set_adj(self, adj)
- VALUE self, adj;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_set_adjustment(GTK_RANGE(widget),
- (GtkAdjustment*)get_gobject(adj));
-
- return self;
-}
-
-static VALUE
-range_draw_bg(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_draw_background(GTK_RANGE(widget));
- return self;
-}
-
-static VALUE
-range_draw_trough(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_draw_trough(GTK_RANGE(widget));
- return self;
-}
-
-static VALUE
-range_draw_slider(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_draw_slider(GTK_RANGE(widget));
- return self;
-}
-
-static VALUE
-range_draw_step_forw(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_draw_step_forw(GTK_RANGE(widget));
- return self;
-}
-
-static VALUE
-range_draw_step_back(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_draw_step_back(GTK_RANGE(widget));
- return self;
-}
-
-static VALUE
-range_slider_update(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_slider_update(GTK_RANGE(widget));
- return self;
-}
-
-static VALUE
-range_trough_click(self, x, y)
- VALUE self, x, y;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_trough_click(GTK_RANGE(widget), NUM2INT(x), NUM2INT(y));
- return self;
-}
-
-static VALUE
-range_default_hslider_update(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_default_hslider_update(GTK_RANGE(widget));
- return self;
-}
-
-static VALUE
-range_default_vslider_update(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_default_vslider_update(GTK_RANGE(widget));
- return self;
-}
-
-static VALUE
-range_default_htrough_click(self, x, y)
- VALUE self, x, y;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_default_htrough_click(GTK_RANGE(widget),
- NUM2INT(x), NUM2INT(y));
- return self;
-}
-
-static VALUE
-range_default_vtrough_click(self, x, y)
- VALUE self, x, y;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_default_vtrough_click(GTK_RANGE(widget),
- NUM2INT(x), NUM2INT(y));
- return self;
-}
-
-static VALUE
-range_default_hmotion(self, xdelta, ydelta)
- VALUE self, xdelta, ydelta;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_default_hmotion(GTK_RANGE(widget),
- NUM2INT(xdelta), NUM2INT(ydelta));
- return self;
-}
-
-static VALUE
-range_default_vmotion(self, xdelta, ydelta)
- VALUE self, xdelta, ydelta;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_default_vmotion(GTK_RANGE(widget),
- NUM2INT(xdelta), NUM2INT(ydelta));
- return self;
-}
-
-static VALUE
-range_calc_value(self, pos)
- VALUE self, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_range_calc_value(GTK_RANGE(widget), NUM2INT(pos));
- return self;
-}
-
-static VALUE
-scale_set_digits(self, digits)
- VALUE self, digits;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_scale_set_digits(GTK_SCALE(widget), NUM2INT(digits));
- return self;
-}
-
-static VALUE
-scale_set_draw_value(self, draw_value)
- VALUE self, draw_value;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_scale_set_draw_value(GTK_SCALE(widget), NUM2INT(draw_value));
- return self;
-}
-
-static VALUE
-scale_set_value_pos(self, pos)
- VALUE self, pos;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_scale_set_value_pos(GTK_SCALE(widget),
- (GtkPositionType)NUM2INT(pos));
- return self;
-}
-
-static VALUE
-scale_value_width(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
- int i = gtk_scale_value_width(GTK_SCALE(widget));
-
- return INT2FIX(i);
-}
-
-static VALUE
-scale_draw_value(self)
- VALUE self;
-{
- GtkWidget *widget = get_widget(self);
-
- gtk_scale_draw_value(GTK_SCALE(widget));
- return self;
-}
-
-static VALUE
-hscale_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE arg1;
- GtkAdjustment *adj = NULL;
-
- rb_scan_args(argc, argv, "01", &arg1);
- if (!NIL_P(arg1)) adj = (GtkAdjustment*)get_gobject(arg1);
-
- return make_widget(self, gtk_hscale_new(adj));
-}
-
-static VALUE
-vscale_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE arg1;
- GtkAdjustment *adj = NULL;
-
- rb_scan_args(argc, argv, "01", &arg1);
- if (!NIL_P(arg1)) adj = (GtkAdjustment*)get_gobject(arg1);
-
- return make_widget(self, gtk_vscale_new(adj));
-}
-
-static VALUE
-hscrollbar_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE arg1;
- GtkAdjustment *adj = NULL;
-
- rb_scan_args(argc, argv, "01", &arg1);
- if (!NIL_P(arg1)) adj = (GtkAdjustment*)get_gobject(arg1);
-
- return make_widget(self, gtk_hscrollbar_new(adj));
-}
-
-static VALUE
-vscrollbar_s_new(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE arg1;
- GtkAdjustment *adj = NULL;
-
- rb_scan_args(argc, argv, "01", &arg1);
- if (!NIL_P(arg1)) adj = (GtkAdjustment*)get_gobject(arg1);
-
- return make_widget(self, gtk_vscrollbar_new(adj));
-}
-
-static VALUE
-hsep_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_hseparator_new());
-}
-
-static VALUE
-vsep_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_vseparator_new());
-}
-
-static VALUE
-idiag_s_new(self)
- VALUE self;
-{
- return make_widget(self, gtk_input_dialog_new());
-}
-
-static VALUE
-gtk_m_main(self)
- VALUE self;
-{
- gtk_main();
- return Qnil;
-}
-
-static gint
-idle()
-{
- CHECK_INTS;
- return TRUE;
-}
-
-static void
-exec_interval(proc)
- VALUE proc;
-{
- rb_funcall(proc, id_call, 0);
-}
-
-static VALUE
-timeout_add(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE interval, func;
- int id;
-
- rb_scan_args(argc, argv, "11", &interval, &func);
- if (NIL_P(func)) {
- func = f_lambda();
- }
- id = gtk_timeout_add_interp(NUM2INT(interval), exec_interval,
- (gpointer)func, 0);
- return INT2FIX(id);
-}
-
-static VALUE
-timeout_remove(self, id)
- VALUE self, id;
-{
- gtk_timeout_remove(NUM2INT(id));
- return Qnil;
-}
-
-static VALUE
-idle_add(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE func;
- int id;
-
- rb_scan_args(argc, argv, "01", &func);
- if (NIL_P(func)) {
- func = f_lambda();
- }
- id = gtk_idle_add_interp(exec_interval, (gpointer)func, 0);
- return INT2FIX(id);
-}
-
-static VALUE
-idle_remove(self, id)
- VALUE self, id;
-{
- gtk_idle_remove(NUM2INT(id));
- return Qnil;
-}
-
-static VALUE warn_handler;
-static VALUE mesg_handler;
-static VALUE print_handler;
-
-static void
-gtkwarn(mesg)
- char *mesg;
-{
- rb_funcall(warn_handler, id_call, 1, str_new2(mesg));
-}
-
-static void
-gtkmesg(mesg)
- char *mesg;
-{
- rb_funcall(mesg_handler, id_call, 1, str_new2(mesg));
-}
-
-static void
-gtkprint(mesg)
- char *mesg;
-{
- rb_funcall(print_handler, id_call, 1, str_new2(mesg));
-}
-
-static VALUE
-set_warning_handler(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE handler;
-
- rb_scan_args(argc, argv, "01", &handler);
- if (NIL_P(handler)) {
- handler = f_lambda();
- }
- g_set_warning_handler(gtkwarn);
-}
-
-static VALUE
-set_message_handler(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE handler;
-
- rb_scan_args(argc, argv, "01", &handler);
- if (NIL_P(handler)) {
- handler = f_lambda();
- }
- g_set_message_handler(gtkmesg);
-}
-
-static VALUE
-set_print_handler(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
-{
- VALUE handler;
-
- rb_scan_args(argc, argv, "01", &handler);
- if (NIL_P(handler)) {
- handler = f_lambda();
- }
- g_set_print_handler(gtkprint);
-}
-
-static void
-gtkerr(mesg)
- char *mesg;
-{
- Fail("%s", mesg);
-}
-
-void
-Init_gtk()
-{
- int argc, i;
- char **argv;
-
- gtk_object_list = ary_new();
- rb_global_variable(&gtk_object_list);
-
- mGtk = rb_define_module("Gtk");
-
- gObject = rb_define_class_under(mGtk, "GtkObject", cObject);
- gWidget = rb_define_class_under(mGtk, "Widget", gObject);
- gContainer = rb_define_class_under(mGtk, "Container", gWidget);
- gBin = rb_define_class_under(mGtk, "Bin", gContainer);
- gAlignment = rb_define_class_under(mGtk, "Alignment", gBin);
- gMisc = rb_define_class_under(mGtk, "Misc", gWidget);
- gArrow = rb_define_class_under(mGtk, "Arrow", gMisc);
- gFrame = rb_define_class_under(mGtk, "Frame", gBin);
- gAspectFrame = rb_define_class_under(mGtk, "AspectFrame", gFrame);
- gData = rb_define_class_under(mGtk, "Data", gObject);
- gAdjustment = rb_define_class_under(mGtk, "Adjustment", gData);
- gBox = rb_define_class_under(mGtk, "Box", gContainer);
- gButton = rb_define_class_under(mGtk, "Button", gContainer);
- gTButton = rb_define_class_under(mGtk, "ToggleButton", gButton);
- gCButton = rb_define_class_under(mGtk, "CheckButton", gTButton);
- gRButton = rb_define_class_under(mGtk, "RadioButton", gCButton);
- gBBox = rb_define_class_under(mGtk, "ButtonBox", gBox);
- gCList = rb_define_class_under(mGtk, "CList", gContainer);
- gWindow = rb_define_class_under(mGtk, "Window", gBin);
- gDialog = rb_define_class_under(mGtk, "Dialog", gWindow);
- gFileSel = rb_define_class_under(mGtk, "FileSelection", gWindow);
- gVBox = rb_define_class_under(mGtk, "VBox", gBox);
- gColorSel = rb_define_class_under(mGtk, "ColorSelection", gVBox);
- gColorSelDialog = rb_define_class_under(mGtk, "ColorSelectionDialog", gWindow);
- gImage = rb_define_class_under(mGtk, "Image", gMisc);
- gDrawArea = rb_define_class_under(mGtk, "DrawingArea", gWidget);
- gEntry = rb_define_class_under(mGtk, "Entry", gWidget);
- gEventBox = rb_define_class_under(mGtk, "EventBox", gBin);
- gFixed = rb_define_class_under(mGtk, "Fixed", gContainer);
- gGamma = rb_define_class_under(mGtk, "GammaCurve", gVBox);
- gHBBox = rb_define_class_under(mGtk, "HButtonBox", gBBox);
- gVBBox = rb_define_class_under(mGtk, "VButtonBox", gBBox);
- gHBox = rb_define_class_under(mGtk, "HBox", gBox);
- gPaned = rb_define_class_under(mGtk, "Paned", gContainer);
- gHPaned = rb_define_class_under(mGtk, "HPaned", gPaned);
- gVPaned = rb_define_class_under(mGtk, "VPaned", gPaned);
- gRuler = rb_define_class_under(mGtk, "Ruler", gWidget);
- gHRuler = rb_define_class_under(mGtk, "HRuler", gRuler);
- gVRuler = rb_define_class_under(mGtk, "VRuler", gRuler);
- gRange = rb_define_class_under(mGtk, "Range", gWidget);
- gScale = rb_define_class_under(mGtk, "Scale", gRange);
- gHScale = rb_define_class_under(mGtk, "HScale", gScale);
- gVScale = rb_define_class_under(mGtk, "VScale", gScale);
- gScrollbar = rb_define_class_under(mGtk, "Scrollbar", gRange);
- gHScrollbar = rb_define_class_under(mGtk, "HScrollbar", gScrollbar);
- gVScrollbar = rb_define_class_under(mGtk, "VScrollbar", gScrollbar);
- gSeparator = rb_define_class_under(mGtk, "Separator", gWidget);
- gHSeparator = rb_define_class_under(mGtk, "HSeparator", gSeparator);
- gVSeparator = rb_define_class_under(mGtk, "VSeparator", gSeparator);
- gInputDialog = rb_define_class_under(mGtk, "InputDialog", gDialog);
- gLabel = rb_define_class_under(mGtk, "Label", gMisc);
- gList = rb_define_class_under(mGtk, "List", gContainer);
- gItem = rb_define_class_under(mGtk, "Item", gBin);
- gListItem = rb_define_class_under(mGtk, "ListItem", gItem);
- gMenuShell = rb_define_class_under(mGtk, "MenuShell", gContainer);
- gMenu = rb_define_class_under(mGtk, "Menu", gMenuShell);
- gMenuBar = rb_define_class_under(mGtk, "MenuBar", gMenuShell);
- gMenuItem = rb_define_class_under(mGtk, "MenuItem", gItem);
- gCMenuItem = rb_define_class_under(mGtk, "CheckMenuItem", gMenuItem);
- gRMenuItem = rb_define_class_under(mGtk, "RadioMenuItem", gCMenuItem);
- gNotebook = rb_define_class_under(mGtk, "Notebook", gContainer);
- gOptionMenu = rb_define_class_under(mGtk, "OptionMenu", gButton);
- gPixmap = rb_define_class_under(mGtk, "Pixmap", gMisc);
- gPreview = rb_define_class_under(mGtk, "Preview", gWidget);
- gProgressBar = rb_define_class_under(mGtk, "ProgressBar", gWidget);
- gScrolledWin = rb_define_class_under(mGtk, "ScrolledWindow", gContainer);
- gTable = rb_define_class_under(mGtk, "Table", gContainer);
- gText = rb_define_class_under(mGtk, "Text", gWidget);
- gToolbar = rb_define_class_under(mGtk, "Toolbar", gContainer);
- gTooltips = rb_define_class_under(mGtk, "Tooltips", cObject);
- gTree = rb_define_class_under(mGtk, "Tree", gContainer);
- gTreeItem = rb_define_class_under(mGtk, "TreeItem", gItem);
- gViewPort = rb_define_class_under(mGtk, "ViewPort", gBin);
-
- gAcceleratorTable = rb_define_class_under(mGtk, "AcceleratorTable", cObject);
- gStyle = rb_define_class_under(mGtk, "Style", cObject);
- gPreviewInfo = rb_define_class_under(mGtk, "PreviewInfo", cObject);
- gRequisiton = rb_define_class_under(mGtk, "Requisiton", cObject);
- gAllocation = rb_define_class_under(mGtk, "Allocation", cObject);
-
- mGdk = rb_define_module("Gdk");
-
- gdkFont = rb_define_class_under(mGdk, "Font", cObject);
- gdkColor = rb_define_class_under(mGdk, "Color", cObject);
- gdkPixmap = rb_define_class_under(mGdk, "Pixmap", cObject);
- gdkBitmap = rb_define_class_under(mGdk, "Bitmap", gdkPixmap);
- gdkWindow = rb_define_class_under(mGdk, "Window", cObject);
- gdkImage = rb_define_class_under(mGdk, "Image", cObject);
- gdkVisual = rb_define_class_under(mGdk, "Visual", cObject);
- gdkGC = rb_define_class_under(mGdk, "GC", cObject);
- gdkGCValues = rb_define_class_under(mGdk, "GCValues", cObject);
- gdkRectangle = rb_define_class_under(mGdk, "Rectangle", cObject);
- gdkSegment = rb_define_class_under(mGdk, "Segment", cObject);
- gdkWindowAttr = rb_define_class_under(mGdk, "WindowAttr", cObject);
- gdkCursor = rb_define_class_under(mGdk, "Cursor", cObject);
- gdkAtom = rb_define_class_under(mGdk, "Atom", cObject);
- gdkColorContext = rb_define_class_under(mGdk, "ColotContext", cObject);
- gdkEvent = rb_define_class_under(mGdk, "gdkEvent", cObject);
-
- /* GtkObject */
- rb_define_singleton_method(gObject, "new", gobj_s_new, -1);
- rb_define_method(gObject, "set_flags", gobj_set_flags, 1);
- rb_define_method(gObject, "unset_flags", gobj_unset_flags, 1);
- rb_define_method(gObject, "destroy", gobj_destroy, 0);
- rb_define_method(gObject, "signal_connect", gobj_sig_connect, -1);
- rb_define_method(gObject, "signal_connect_after", gobj_sig_connect_after, -1);
- rb_define_method(gObject, "singleton_method_added", gobj_smethod_added, 1);
-
- /* Widget */
- rb_define_method(gWidget, "destroy", widget_destroy, 0);
- rb_define_method(gWidget, "show", widget_show, 0);
- rb_define_method(gWidget, "show_all", widget_show_all, 0);
- rb_define_method(gWidget, "hide", widget_hide, 0);
- rb_define_method(gWidget, "hide_all", widget_hide_all, 0);
- rb_define_method(gWidget, "map", widget_map, 0);
- rb_define_method(gWidget, "unmap", widget_unmap, 0);
- rb_define_method(gWidget, "realize", widget_realize, 0);
- rb_define_method(gWidget, "unrealize", widget_unrealize, 0);
- rb_define_method(gWidget, "queue_draw", widget_queue_draw, 0);
- rb_define_method(gWidget, "queue_resize", widget_queue_resize, 0);
- rb_define_method(gWidget, "draw", widget_draw, 1);
- rb_define_method(gWidget, "draw_focus", widget_draw_focus, 0);
- rb_define_method(gWidget, "draw_default", widget_draw_default, 0);
- rb_define_method(gWidget, "draw_children", widget_draw_children, 0);
- rb_define_method(gWidget, "size_request", widget_size_request, 1);
- rb_define_method(gWidget, "size_alocate", widget_size_allocate, 1);
- rb_define_method(gWidget, "install_accelerator", widget_inst_accel, 4);
- rb_define_method(gWidget, "remove_accelerator", widget_rm_accel, 4);
- rb_define_method(gWidget, "event", widget_event, 1);
- rb_define_method(gWidget, "activate", widget_activate, 0);
- rb_define_method(gWidget, "grab_focus", widget_grab_focus, 0);
- rb_define_method(gWidget, "grab_default", widget_grab_default, 0);
- rb_define_method(gWidget, "restore_state", widget_restore_state, 0);
- rb_define_method(gWidget, "visible?", widget_visible, 0);
- rb_define_method(gWidget, "reparent", widget_reparent, 1);
- rb_define_method(gWidget, "popup", widget_popup, 2);
- rb_define_method(gWidget, "intersect", widget_intersect, 2);
- rb_define_method(gWidget, "basic", widget_basic, 0);
- rb_define_method(gWidget, "get_name", widget_set_name, 0);
- rb_define_method(gWidget, "set_name", widget_set_name, 1);
- rb_define_method(gWidget, "set_parent", widget_set_parent, 1);
- rb_define_method(gWidget, "set_sensitive", widget_set_sensitive, 1);
- rb_define_method(gWidget, "set_usize", widget_set_usize, 2);
- rb_define_method(gWidget, "set_uposition", widget_set_uposition, 2);
- rb_define_method(gWidget, "set_style", widget_set_style, 1);
- rb_define_method(gWidget, "set_events", widget_set_events, 1);
- rb_define_method(gWidget, "set_extension_events", widget_set_eevents, 1);
- rb_define_method(gWidget, "unparent", widget_unparent, 0);
- rb_define_method(gWidget, "get_toplevel", widget_get_toplevel, 0);
- rb_define_method(gWidget, "get_ancestor", widget_get_ancestor, 1);
- rb_define_method(gWidget, "get_colormap", widget_get_colormap, 0);
- rb_define_method(gWidget, "get_visual", widget_get_visual, 0);
- rb_define_method(gWidget, "get_style", widget_get_style, 0);
- rb_define_method(gWidget, "style", widget_get_style, 0);
- rb_define_method(gWidget, "get_events", widget_get_events, 0);
- rb_define_method(gWidget, "get_extension_events", widget_get_eevents, 0);
- rb_define_method(gWidget, "get_pointer", widget_get_eevents, 0);
- rb_define_method(gWidget, "ancestor?", widget_is_ancestor, 1);
- rb_define_method(gWidget, "child?", widget_is_child, 1);
- rb_define_method(gWidget, "window", widget_window, 0);
-
- rb_define_singleton_method(gWidget, "push_colomap", widget_push_cmap, 1);
- rb_define_singleton_method(gWidget, "push_visual", widget_push_visual, 1);
- rb_define_singleton_method(gWidget, "push_style", widget_push_style, 1);
- rb_define_singleton_method(gWidget, "pop_colomap", widget_pop_cmap, 0);
- rb_define_singleton_method(gWidget, "pop_visual", widget_pop_visual, 0);
- rb_define_singleton_method(gWidget, "pop_style", widget_pop_style, 0);
-
- rb_define_singleton_method(gWidget, "set_default_colomap",
- widget_set_default_cmap, 1);
- rb_define_singleton_method(gWidget, "set_default_visual",
- widget_set_default_visual, 1);
- rb_define_singleton_method(gWidget, "set_default_style",
- widget_set_default_style, 1);
- rb_define_singleton_method(gWidget, "get_default_colomap",
- widget_get_default_cmap, 0);
- rb_define_singleton_method(gWidget, "get_default_visual",
- widget_get_default_visual, 0);
- rb_define_singleton_method(gWidget, "get_default_style",
- widget_get_default_style, 0);
- rb_define_singleton_method(gWidget, "set_default_colomap",
- widget_set_default_cmap, 1);
- rb_define_singleton_method(gWidget, "set_default_visual",
- widget_set_default_visual, 1);
- rb_define_singleton_method(gWidget, "set_default_style",
- widget_set_default_style, 1);
- rb_define_singleton_method(gWidget, "set_default_colomap",
- widget_set_default_cmap, 1);
- rb_define_singleton_method(gWidget, "set_default_visual",
- widget_set_default_visual, 1);
- rb_define_singleton_method(gWidget, "propagage_default_style",
- widget_propagate_default_style, 0);
-
- /* Container */
- rb_define_method(gContainer, "border_width", cont_bwidth, 1);
- rb_define_method(gContainer, "add", cont_add, 1);
- rb_define_method(gContainer, "disable_resize", cont_disable_resize, 0);
- rb_define_method(gContainer, "enable_resize", cont_enable_resize, 0);
- rb_define_method(gContainer, "block_resize", cont_block_resize, 0);
- rb_define_method(gContainer, "unblock_resize", cont_unblock_resize, 0);
- rb_define_method(gContainer, "need_resize", cont_need_resize, 0);
- rb_define_method(gContainer, "foreach", cont_foreach, -1);
- rb_define_method(gContainer, "each", cont_each, 0);
- rb_define_method(gContainer, "focus", cont_focus, 1);
- rb_define_method(gContainer, "children", cont_children, 0);
-
- /* Bin */
- /* -- */
-
- /* Alignment */
- rb_define_singleton_method(gAlignment, "new", align_s_new, 4);
- rb_define_method(gAlignment, "set", align_set, 4);
-
- /* Misc */
- rb_define_method(gMisc, "set_alignment", misc_set_align, 2);
- rb_define_method(gMisc, "set_padding", misc_set_padding, 2);
-
- /* Arrow */
- rb_define_singleton_method(gArrow, "new", arrow_s_new, 2);
- rb_define_method(gArrow, "set", arrow_s_new, 2);
-
- /* Frame */
- rb_define_singleton_method(gFrame, "new", frame_s_new, 1);
- rb_define_method(gFrame, "set_label", frame_set_label, 1);
- rb_define_method(gFrame, "set_label_align", frame_set_label_align, 2);
- rb_define_method(gFrame, "set_shadow_type", frame_set_shadow_type, 1);
-
- /* AspectFrame */
- rb_define_singleton_method(gAspectFrame, "new", aframe_s_new, 5);
- rb_define_method(gAspectFrame, "set", aframe_set, 4);
-
- /* Data */
- /* -- */
-
- /* Adjustment */
- rb_define_singleton_method(gAdjustment, "new", adj_s_new, 6);
-
- /* Box */
- rb_define_method(gBox, "pack_start", box_pack_start, -1);
- rb_define_method(gBox, "pack_end", box_pack_end, -1);
-
- /* Button */
- rb_define_singleton_method(gButton, "new", button_s_new, -1);
- rb_define_method(gButton, "pressed", button_pressed, 0);
- rb_define_method(gButton, "released", button_released, 0);
- rb_define_method(gButton, "clicked", button_clicked, 0);
- rb_define_method(gButton, "enter", button_enter, 0);
- rb_define_method(gButton, "leave", button_leave, 0);
-
- /* ToggleButton */
- rb_define_singleton_method(gTButton, "new", tbtn_s_new, -1);
- rb_define_method(gTButton, "set_mode", tbtn_set_mode, 1);
- rb_define_method(gTButton, "set_state", tbtn_set_state, 1);
- rb_define_method(gTButton, "toggled", tbtn_toggled, 0);
-
- /* CheckButton */
- rb_define_singleton_method(gCButton, "new", cbtn_s_new, -1);
-
- /* RadioButton */
- rb_define_singleton_method(gCButton, "new", rbtn_s_new, -1);
- rb_define_method(gCButton, "group", rbtn_group, 0);
-
- /* ButtonBox */
- rb_define_singleton_method(gBBox, "get_child_size_default",
- bbox_get_child_size_default, 0);
- rb_define_singleton_method(gBBox, "get_child_ipadding_default",
- bbox_get_child_ipadding_default, 0);
- rb_define_singleton_method(gBBox, "set_child_size_default",
- bbox_set_child_size_default, 2);
- rb_define_singleton_method(gBBox, "set_child_ipadding_default",
- bbox_set_child_ipadding_default, 2);
- rb_define_method(gBBox, "get_spacing", bbox_get_spacing, 0);
- rb_define_method(gBBox, "get_layout", bbox_get_layout, 0);
- rb_define_method(gBBox, "get_child_size", bbox_get_child_size, 0);
- rb_define_method(gBBox, "get_child_ipadding", bbox_get_child_ipadding, 0);
- rb_define_method(gBBox, "set_spacing", bbox_set_spacing, 1);
- rb_define_method(gBBox, "set_layout", bbox_set_layout, 1);
- rb_define_method(gBBox, "set_child_size", bbox_set_child_size, 2);
- rb_define_method(gBBox, "set_child_ipadding", bbox_set_child_ipadding, 2);
-
- /* CList */
- rb_define_singleton_method(gCList, "new", clist_s_new, 1);
- rb_define_method(gCList, "set_border", clist_set_border, 1);
- rb_define_method(gCList, "set_selection_mode", clist_set_sel_mode, 1);
- rb_define_method(gCList, "set_policy", clist_set_policy, 2);
- rb_define_method(gCList, "freeze", clist_freeze, 0);
- rb_define_method(gCList, "thaw", clist_thaw, 0);
- rb_define_method(gCList, "set_column_title", clist_set_col_title, 2);
- rb_define_method(gCList, "set_column_widget", clist_set_col_wigdet, 2);
- rb_define_method(gCList, "set_column_justification", clist_set_col_just, 2);
- rb_define_method(gCList, "set_column_width", clist_set_col_width, 2);
- rb_define_method(gCList, "set_row_height", clist_set_row_height, 1);
- rb_define_method(gCList, "moveto", clist_moveto, 4);
- rb_define_method(gCList, "set_text", clist_set_text, 3);
- rb_define_method(gCList, "set_pixmap", clist_set_text, 4);
- rb_define_method(gCList, "set_pixtext", clist_set_pixtext, 6);
- rb_define_method(gCList, "set_foreground", clist_set_foreground, 2);
- rb_define_method(gCList, "set_background", clist_set_background, 2);
- rb_define_method(gCList, "set_shift", clist_set_shift, 4);
- rb_define_method(gCList, "append", clist_append, 1);
- rb_define_method(gCList, "insert", clist_insert, 2);
- rb_define_method(gCList, "remove", clist_remove, 1);
- rb_define_method(gCList, "set_row_data", clist_set_row_data, 2);
- rb_define_method(gCList, "get_row_data", clist_set_row_data, 1);
- rb_define_method(gCList, "select_row", clist_select_row, 2);
- rb_define_method(gCList, "unselect_row", clist_unselect_row, 2);
- rb_define_method(gCList, "clear", clist_clear, 0);
-
- /* Window */
- rb_define_singleton_method(gWindow, "new", gwin_s_new, 1);
- rb_define_method(gWindow, "set_title", gwin_set_title, 1);
- rb_define_method(gWindow, "set_policy", gwin_set_policy, 3);
- rb_define_method(gWindow, "set_wmclass", gwin_set_wmclass, 1);
- rb_define_method(gWindow, "set_focus", gwin_set_focus, 1);
- rb_define_method(gWindow, "set_default", gwin_set_focus, 1);
- rb_define_method(gWindow, "add_accelerator_table", gwin_add_accel, 1);
- rb_define_method(gWindow, "remove_accelerator_table", gwin_rm_accel, 1);
- rb_define_method(gWindow, "position", gwin_position, 1);
-
- /* Dialog */
- rb_define_singleton_method(gDialog, "new", dialog_s_new, 0);
-
- /* FileSelection */
- rb_define_singleton_method(gFileSel, "new", fsel_s_new, 1);
- rb_define_method(gFileSel, "set_filename", fsel_set_fname, 1);
- rb_define_method(gFileSel, "get_filename", fsel_get_fname, 0);
- rb_define_method(gFileSel, "ok_button", fsel_ok_button, 0);
- rb_define_method(gFileSel, "cancel_button", fsel_cancel_button, 0);
- rb_define_method(gFileSel, "help_button", fsel_help_button, 0);
-
- /* VBox */
- rb_define_singleton_method(gVBox, "new", vbox_s_new, -1);
-
- /* ColorSelection */
- rb_define_singleton_method(gColorSel, "new", colorsel_s_new, 0);
- rb_define_method(gColorSel, "set_update_policy", colorsel_set_update_policy, 1);
- rb_define_method(gColorSel, "set_opacity", colorsel_set_opacity, 1);
- rb_define_method(gColorSel, "set_color", colorsel_set_color, 1);
- rb_define_method(gColorSel, "get_color", colorsel_get_color, 0);
-
- /* ColorSelectionDialog */
- rb_define_singleton_method(gColorSelDialog, "new", cdialog_s_new, 1);
-
- /* Image */
- rb_define_singleton_method(gImage, "new", image_s_new, 2);
- rb_define_method(gImage, "set", image_set, 2);
- rb_define_method(gImage, "get", image_get, 0);
-
- /* DrawingArea */
- rb_define_singleton_method(gDrawArea, "new", darea_s_new, 0);
- rb_define_method(gDrawArea, "size", darea_size, 2);
-
- /* Entry */
- rb_define_singleton_method(gEntry, "new", entry_s_new, 0);
- rb_define_method(gEntry, "set_text", entry_set_text, 1);
-
- /* EventBox */
- rb_define_singleton_method(gEventBox, "new", eventbox_s_new, 0);
-
- /* Fixed */
- rb_define_singleton_method(gFixed, "new", fixed_s_new, 0);
- rb_define_method(gFixed, "put", fixed_put, 3);
- rb_define_method(gFixed, "move", fixed_move, 3);
-
- /* GammaCurve */
- rb_define_singleton_method(gGamma, "new", gamma_s_new, 0);
- rb_define_method(gGamma, "gamma", gamma_gamma, 0);
-
- /* HButtonBox */
- rb_define_singleton_method(gHBBox, "new", hbbox_s_new, 0);
- rb_define_singleton_method(gHBBox, "get_spacing_default",
- hbbox_get_spacing_default, 0);
- rb_define_singleton_method(gHBBox, "get_layout_default",
- hbbox_get_spacing_default, 0);
- rb_define_singleton_method(gHBBox, "set_spacing_default",
- hbbox_set_spacing_default, 1);
- rb_define_singleton_method(gHBBox, "set_layout_default",
- hbbox_set_layout_default, 1);
-
- /* VButtonBox */
- rb_define_singleton_method(gVBBox, "new", vbbox_s_new, 0);
- rb_define_singleton_method(gVBBox, "get_spacing_default",
- vbbox_get_spacing_default, 0);
- rb_define_singleton_method(gVBBox, "get_layout_default",
- vbbox_get_spacing_default, 0);
- rb_define_singleton_method(gVBBox, "set_spacing_default",
- vbbox_set_spacing_default, 1);
- rb_define_singleton_method(gVBBox, "set_layout_default",
- vbbox_set_layout_default, 1);
-
- /* HBox */
- rb_define_singleton_method(gHBox, "new", hbox_s_new, -1);
-
- /* Paned */
- rb_define_method(gPaned, "add1", paned_add1, 1);
- rb_define_method(gPaned, "add2", paned_add1, 1);
- rb_define_method(gPaned, "handle_size", paned_handle_size, 1);
- rb_define_method(gPaned, "gutter_size", paned_gutter_size, 1);
-
- /* HPaned */
- rb_define_singleton_method(gHPaned, "new", hpaned_s_new, 0);
-
- /* VPaned */
- rb_define_singleton_method(gVPaned, "new", vpaned_s_new, 0);
-
- /* Ruler */
- rb_define_method(gRuler, "set_metric", ruler_set_metric, 1);
- rb_define_method(gRuler, "set_range", ruler_set_range, 4);
- rb_define_method(gRuler, "draw_ticks", ruler_draw_ticks, 0);
- rb_define_method(gRuler, "draw_pos", ruler_draw_pos, 0);
-
- /* HRuler */
- rb_define_singleton_method(gHRuler, "new", hruler_s_new, 0);
-
- /* VRuler */
- rb_define_singleton_method(gVRuler, "new", vruler_s_new, 0);
-
- /* Range */
- rb_define_method(gRange, "get_adjustment", range_get_adj, 0);
- rb_define_method(gRange, "set_update_policy", range_set_update_policy, 1);
- rb_define_method(gRange, "set_adjustment", range_set_adj, 1);
- rb_define_method(gRange, "draw_background", range_draw_bg, 0);
- rb_define_method(gRange, "draw_trough", range_draw_trough, 0);
- rb_define_method(gRange, "draw_slider", range_draw_slider, 0);
- rb_define_method(gRange, "draw_step_forw", range_draw_step_forw, 0);
- rb_define_method(gRange, "draw_step_back", range_draw_step_back, 0);
- rb_define_method(gRange, "slider_update", range_slider_update, 0);
- rb_define_method(gRange, "trough_click", range_trough_click, 2);
- rb_define_method(gRange, "draw_background", range_draw_bg, 2);
- rb_define_method(gRange, "default_hslider_update", range_default_hslider_update, 0);
- rb_define_method(gRange, "default_vslider_update", range_default_vslider_update, 0);
- rb_define_method(gRange, "default_htrough_click", range_default_htrough_click, 2);
- rb_define_method(gRange, "default_vtrough_click", range_default_vtrough_click, 2);
- rb_define_method(gRange, "default_hmotion", range_default_hmotion, 2);
- rb_define_method(gRange, "default_vmotion", range_default_vmotion, 2);
- rb_define_method(gRange, "calc_value", range_calc_value, 1);
-
- /* Scale */
- rb_define_method(gScale, "set_digits", scale_set_digits, 1);
- rb_define_method(gScale, "set_draw_value", scale_set_draw_value, 1);
- rb_define_method(gScale, "set_value_pos", scale_set_value_pos, 1);
- rb_define_method(gScale, "value_width", scale_value_width, 0);
- rb_define_method(gScale, "draw_value", scale_draw_value, 0);
-
- /* HScale */
- rb_define_singleton_method(gHScale, "new", hscale_s_new, -1);
-
- /* VScale */
- rb_define_singleton_method(gVScale, "new", vscale_s_new, -1);
-
- /* Scrollbar */
- /* -- */
-
- /* HScrollbar */
- rb_define_singleton_method(gHScrollbar, "new", hscrollbar_s_new, -1);
-
- /* VScrollbar */
- rb_define_singleton_method(gVScrollbar, "new", vscrollbar_s_new, -1);
-
- /* Separator */
- /* -- */
-
- /* HSeparator */
- rb_define_singleton_method(gHSeparator, "new", hsep_s_new, 0);
-
- /* VSeparator */
- rb_define_singleton_method(gVSeparator, "new", vsep_s_new, 0);
-
- /* InputDialog */
- rb_define_singleton_method(gInputDialog, "new", idiag_s_new, 0);
-
- /* Label */
- rb_define_singleton_method(gLabel, "new", label_s_new, 1);
-
- /* List */
- rb_define_singleton_method(gList, "new", list_s_new, 0);
- rb_define_method(gList, "set_selection_mode", list_set_sel_mode, 1);
- rb_define_method(gList, "selection_mode", list_sel_mode, 1);
- rb_define_method(gList, "selection", list_selection, 0);
- rb_define_method(gList, "insert_items", list_insert_items, 2);
- rb_define_method(gList, "append_items", list_append_items, 1);
- rb_define_method(gList, "prepend_items", list_prepend_items, 1);
- rb_define_method(gList, "remove_items", list_remove_items, 1);
- rb_define_method(gList, "clear_items", list_clear_items, 2);
- rb_define_method(gList, "select_item", list_select_item, 1);
- rb_define_method(gList, "unselect_item", list_unselect_item, 1);
- rb_define_method(gList, "select_child", list_select_child, 1);
- rb_define_method(gList, "unselect_child", list_unselect_child, 1);
- rb_define_method(gList, "child_position", list_child_position, 1);
-
- /* Item */
- rb_define_method(gItem, "select", item_select, 0);
- rb_define_method(gItem, "deselect", item_deselect, 0);
- rb_define_method(gItem, "toggle", item_toggle, 0);
-
- /* ListItem */
- rb_define_singleton_method(gListItem, "new", litem_s_new, -1);
-
- /* MenuShell */
- rb_define_method(gMenuShell, "append", mshell_append, 1);
- rb_define_method(gMenuShell, "prepend", mshell_prepend, 1);
- rb_define_method(gMenuShell, "insert", mshell_insert, 2);
- rb_define_method(gMenuShell, "deactivate", mshell_deactivate, 0);
-
- /* Menu */
- rb_define_singleton_method(gMenu, "new", menu_s_new, 0);
- rb_define_method(gMenu, "append", menu_append, 1);
- rb_define_method(gMenu, "prepend", menu_prepend, 1);
- rb_define_method(gMenu, "insert", menu_insert, 2);
- rb_define_method(gMenu, "popup", menu_popup, 6);
- rb_define_method(gMenu, "popdown", menu_popup, 0);
- rb_define_method(gMenu, "get_active", menu_get_active, 0);
- rb_define_method(gMenu, "set_active", menu_set_active, 1);
- rb_define_method(gMenu, "set_accelerator_table", menu_set_acceltbl, 1);
-
- /* MenuBar */
- rb_define_singleton_method(gMenuBar, "new", mbar_s_new, 0);
- rb_define_method(gMenuBar, "append", mbar_append, 1);
- rb_define_method(gMenuBar, "prepend", mbar_prepend, 1);
- rb_define_method(gMenuBar, "insert", mbar_insert, 2);
-
- /* MenuItem */
- rb_define_singleton_method(gMenuItem, "new", mitem_s_new, -1);
- rb_define_method(gMenuItem, "set_submenu", mitem_set_submenu, 1);
- rb_define_method(gMenuItem, "set_placement", mitem_set_placement, 1);
- rb_define_method(gMenuItem, "accelerator_size", mitem_accelerator_size, 0);
- rb_define_method(gMenuItem, "accelerator_text", mitem_accelerator_text, 0);
- rb_define_method(gMenuItem, "configure", mitem_configure, 2);
- rb_define_method(gMenuItem, "select", mitem_select, 0);
- rb_define_method(gMenuItem, "deselect", mitem_deselect, 0);
- rb_define_method(gMenuItem, "activate", mitem_activate, 0);
- rb_define_method(gMenuItem, "right_justify", mitem_right_justify, 0);
-
- /* CheckMenuItem */
- rb_define_singleton_method(gCMenuItem, "new", cmitem_s_new, -1);
- rb_define_method(gCMenuItem, "set_state", cmitem_set_state, 1);
- rb_define_method(gCMenuItem, "set_show_toggle", cmitem_set_show_toggle, 1);
- rb_define_method(gCMenuItem, "toggled", cmitem_toggled, 0);
-
- /* RadioMenuItem */
- rb_define_singleton_method(gRMenuItem, "new", rmitem_s_new, -1);
- rb_define_method(gRMenuItem, "group", rmitem_group, 0);
-
- /* NoteBook */
- rb_define_singleton_method(gNotebook, "new", note_s_new, 0);
- rb_define_method(gNotebook, "append_page", note_append_page, 2);
- rb_define_method(gNotebook, "prepend_page", note_prepend_page, 2);
- rb_define_method(gNotebook, "insert_page", note_insert_page, 3);
- rb_define_method(gNotebook, "remove_page", note_remove_page, 1);
- rb_define_method(gNotebook, "set_page", note_set_page, 1);
- rb_define_method(gNotebook, "cur_page", note_cur_page, 0);
- rb_define_method(gNotebook, "page", note_cur_page, 0);
- rb_define_method(gNotebook, "next_page", note_next_page, 0);
- rb_define_method(gNotebook, "prev_page", note_prev_page, 0);
- rb_define_method(gNotebook, "set_tab_pos", note_set_tab_pos, 1);
- rb_define_method(gNotebook, "tab_pos", note_tab_pos, 0);
- rb_define_method(gNotebook, "set_show_tabs", note_set_show_tabs, 1);
- rb_define_method(gNotebook, "show_tabs", note_show_tabs, 0);
- rb_define_method(gNotebook, "set_show_border", note_set_show_border, 1);
- rb_define_method(gNotebook, "show_border", note_show_border, 0);
-
- /* OptionMenu */
- rb_define_singleton_method(gOptionMenu, "new", omenu_s_new, 0);
- rb_define_method(gOptionMenu, "get_menu", omenu_get_menu, 0);
- rb_define_method(gOptionMenu, "set_menu", omenu_set_menu, 1);
- rb_define_method(gOptionMenu, "remove_menu", omenu_set_menu, 0);
- rb_define_method(gOptionMenu, "set_history", omenu_set_history, 1);
-
- /* Pixmap */
- rb_define_singleton_method(gPixmap, "new", pixmap_s_new, 2);
- rb_define_method(gPixmap, "set", pixmap_set, 2);
- rb_define_method(gPixmap, "get", pixmap_get, 0);
-
- /* Preview */
- rb_define_singleton_method(gPreview, "new", preview_s_new, 1);
- rb_define_method(gPreview, "size", preview_size, 2);
- rb_define_method(gPreview, "put", preview_size, 8);
- rb_define_method(gPreview, "put_row", preview_size, 5);
- rb_define_method(gPreview, "draw_row", preview_size, 4);
- rb_define_method(gPreview, "set_expand", preview_set_expand, 1);
- rb_define_singleton_method(gPreview, "set_gamma", preview_set_gamma, 1);
- rb_define_singleton_method(gPreview, "set_color_cube",
- preview_set_color_cube, 4);
- rb_define_singleton_method(gPreview, "set_install_cmap",
- preview_set_install_cmap, 1);
- rb_define_singleton_method(gPreview, "set_reserved",
- preview_set_reserved, 1);
- rb_define_singleton_method(gPreview, "get_visual", preview_get_visual, 0);
- rb_define_singleton_method(gPreview, "get_cmap", preview_get_cmap, 0);
- rb_define_singleton_method(gPreview, "get_info", preview_get_info, 0);
-
- /* ProgressBar */
- rb_define_singleton_method(gProgressBar, "new", pbar_s_new, 0);
- rb_define_method(gProgressBar, "update", pbar_update, 1);
-
- /* ScrolledWindow */
- rb_define_singleton_method(gScrolledWin, "new", scwin_s_new, -1);
- rb_define_method(gScrolledWin, "set_policy", scwin_set_policy, 2);
-
- /* Table */
- rb_define_singleton_method(gTable, "new", tbl_s_new, -1);
- rb_define_method(gTable, "attach", tbl_attach, -1);
- rb_define_method(gTable, "set_row_spacing", tbl_set_row_spacing, 2);
- rb_define_method(gTable, "set_col_spacing", tbl_set_col_spacing, 2);
- rb_define_method(gTable, "set_row_spacings", tbl_set_row_spacings, 1);
- rb_define_method(gTable, "set_col_spacings", tbl_set_col_spacings, 1);
-
- /* Text */
- rb_define_singleton_method(gText, "new", txt_s_new, -1);
- rb_define_method(gText, "set_editable", txt_set_editable, 1);
- rb_define_method(gText, "set_adjustment", txt_set_adjustment, 2);
- rb_define_method(gText, "set_point", txt_set_point, 1);
- rb_define_method(gText, "get_point", txt_get_point, 0);
- rb_define_method(gText, "get_length", txt_get_length, 0);
- rb_define_method(gText, "freeze", txt_freeze, 0);
- rb_define_method(gText, "thaw", txt_thaw, 0);
- rb_define_method(gText, "insert", txt_insert, 4);
- rb_define_method(gText, "backward_delete", txt_backward_delete, 1);
- rb_define_method(gText, "forward_delete", txt_forward_delete, 1);
-
- /* Toolbar */
- rb_define_singleton_method(gToolbar, "new", tbar_s_new, -1);
- rb_define_method(gToolbar, "append_item", tbar_append_item, 4);
- rb_define_method(gToolbar, "prepend_item", tbar_prepend_item, 4);
- rb_define_method(gToolbar, "insert_item", tbar_append_item, 5);
- rb_define_method(gToolbar, "append_space", tbar_append_space, 0);
- rb_define_method(gToolbar, "prepend_space", tbar_prepend_space, 0);
- rb_define_method(gToolbar, "insert_space", tbar_append_space, 1);
- rb_define_method(gToolbar, "set_orientation", tbar_set_orientation, 1);
- rb_define_method(gToolbar, "set_style", tbar_set_style, 1);
- rb_define_method(gToolbar, "set_space_size", tbar_set_space_size, 1);
- rb_define_method(gToolbar, "set_tooltips", tbar_set_tooltips, 1);
-
- /* Tooltips */
- rb_define_singleton_method(gTooltips, "new", ttips_s_new, 0);
- rb_define_method(gTooltips, "set_tips", ttips_set_tips, 2);
- rb_define_method(gTooltips, "set_delay", ttips_set_delay, 1);
- rb_define_method(gTooltips, "enable", ttips_enable, 0);
- rb_define_method(gTooltips, "disable", ttips_disable, 0);
-
- /* Tree */
- rb_define_singleton_method(gTree, "new", tree_s_new, 0);
- rb_define_method(gTree, "append", tree_append, 1);
- rb_define_method(gTree, "prepend", tree_prepend, 1);
- rb_define_method(gTree, "insert", tree_insert, 2);
-
- /* TreeItem */
- rb_define_singleton_method(gTreeItem, "new", titem_s_new, -1);
- rb_define_method(gTreeItem, "set_subtree", titem_set_subtree, 1);
- rb_define_method(gTreeItem, "select", titem_select, 0);
- rb_define_method(gTreeItem, "deselect", titem_deselect, 0);
- rb_define_method(gTreeItem, "expand", titem_expand, 0);
- rb_define_method(gTreeItem, "collapse", titem_collapse, 0);
-
- /* ViewPort */
- rb_define_singleton_method(gViewPort, "new", vport_s_new, -1);
- rb_define_method(gViewPort, "get_hadjustment", vport_get_hadj, 0);
- rb_define_method(gViewPort, "get_vadjustment", vport_get_vadj, 0);
- rb_define_method(gViewPort, "set_hadjustment", vport_set_hadj, 1);
- rb_define_method(gViewPort, "set_vadjustment", vport_set_vadj, 1);
- rb_define_method(gViewPort, "set_shadow_type", vport_set_shadow, 1);
-
- /* AcceleratorTable */
- /* Style */
-
- /* Gtk module */
- rb_define_module_function(mGtk, "main", gtk_m_main, 0);
- rb_define_module_function(mGtk, "timeout_add", timeout_add, -1);
- rb_define_module_function(mGtk, "timeout_remove", timeout_remove, 1);
- rb_define_module_function(mGtk, "idle_add", idle_add, -1);
- rb_define_module_function(mGtk, "idle_remove", idle_remove, 1);
-
- rb_define_module_function(mGtk, "set_warning_handler",
- set_warning_handler, -1);
- rb_define_module_function(mGtk, "set_message_handler",
- set_message_handler, -1);
- rb_define_module_function(mGtk, "set_print_handler",
- set_print_handler, -1);
-
- /* Gdk module */
- /* GdkFont */
- rb_define_method(gdkFont, "==", gdkfnt_equal, 1);
-
- /* GdkBitmap */
- rb_define_singleton_method(gdkBitmap, "new", gdkbmap_s_new, 3);
- rb_define_singleton_method(gdkBitmap, "create_from_data",
- gdkbmap_create_from_data, 4);
-
- /* GdkPixmap */
- rb_define_singleton_method(gdkPixmap, "new", gdkpmap_s_new, 4);
- rb_define_singleton_method(gdkPixmap, "create_from_xpm",
- gdkpmap_create_from_xpm, 3);
- rb_define_singleton_method(gdkPixmap, "create_from_xpm_d",
- gdkpmap_create_from_xpm, 3);
-
- /* GdkWindow */
-
- /* GdkImage */
-
- rb_define_const(mGtk, "VISIBLE", INT2FIX(GTK_VISIBLE));
- rb_define_const(mGtk, "MAPPED", INT2FIX(GTK_MAPPED));
- rb_define_const(mGtk, "UNMAPPED", INT2FIX(GTK_UNMAPPED));
- rb_define_const(mGtk, "REALIZED", INT2FIX(GTK_REALIZED));
- rb_define_const(mGtk, "SENSITIVE", INT2FIX(GTK_SENSITIVE));
- rb_define_const(mGtk, "PARENT_SENSITIVE", INT2FIX(GTK_PARENT_SENSITIVE));
- rb_define_const(mGtk, "NO_WINDOW", INT2FIX(GTK_NO_WINDOW));
- rb_define_const(mGtk, "HAS_FOCUS", INT2FIX(GTK_HAS_FOCUS));
- rb_define_const(mGtk, "CAN_FOCUS", INT2FIX(GTK_CAN_FOCUS));
- rb_define_const(mGtk, "HAS_DEFAULT", INT2FIX(GTK_HAS_DEFAULT));
- rb_define_const(mGtk, "CAN_DEFAULT", INT2FIX(GTK_CAN_DEFAULT));
- rb_define_const(mGtk, "PROPAGATE_STATE", INT2FIX(GTK_PROPAGATE_STATE));
- rb_define_const(mGtk, "ANCHORED", INT2FIX(GTK_ANCHORED));
- rb_define_const(mGtk, "BASIC", INT2FIX(GTK_BASIC));
- rb_define_const(mGtk, "USER_STYLE", INT2FIX(GTK_USER_STYLE));
- rb_define_const(mGtk, "GRAB_ALL", INT2FIX(GTK_GRAB_ALL));
- rb_define_const(mGtk, "REDRAW_PENDING", INT2FIX(GTK_REDRAW_PENDING));
- rb_define_const(mGtk, "RESIZE_PENDING", INT2FIX(GTK_RESIZE_PENDING));
- rb_define_const(mGtk, "RESIZE_NEEDED", INT2FIX(GTK_RESIZE_NEEDED));
- rb_define_const(mGtk, "HAS_SHAPE_MASK", INT2FIX(GTK_HAS_SHAPE_MASK));
-
- /* GtkWindowType */
- rb_define_const(mGtk, "WINDOW_TOPLEVEL", INT2FIX(GTK_WINDOW_TOPLEVEL));
- rb_define_const(mGtk, "WINDOW_DIALOG", INT2FIX(GTK_WINDOW_DIALOG));
- rb_define_const(mGtk, "WIN_POS_NONE", INT2FIX(GTK_WIN_POS_NONE));
- rb_define_const(mGtk, "WIN_POS_CENTER", INT2FIX(GTK_WIN_POS_CENTER));
- rb_define_const(mGtk, "WIN_POS_MOUSE", INT2FIX(GTK_WIN_POS_MOUSE));
-
- /* GtkDirectionType */
- rb_define_const(mGtk, "DIR_TAB_FORWARD", INT2FIX(GTK_DIR_TAB_FORWARD));
- rb_define_const(mGtk, "DIR_TAB_BACKWARD", INT2FIX(GTK_DIR_TAB_BACKWARD));
- rb_define_const(mGtk, "DIR_UP", INT2FIX(GTK_DIR_UP));
- rb_define_const(mGtk, "DIR_DOWN", INT2FIX(GTK_DIR_DOWN));
- rb_define_const(mGtk, "DIR_LEFT", INT2FIX(GTK_DIR_LEFT));
- rb_define_const(mGtk, "DIR_RIGHT", INT2FIX(GTK_DIR_RIGHT));
-
- /* GtkPolicyType */
- rb_define_const(mGtk, "POLICY_ALWAYS", INT2FIX(GTK_POLICY_ALWAYS));
- rb_define_const(mGtk, "POLICY_AUTOMATIC", INT2FIX(GTK_POLICY_AUTOMATIC));
-
- /* GtkSelectionMode */
- rb_define_const(mGtk, "SELECTION_SINGLE", INT2FIX(GTK_SELECTION_SINGLE));
- rb_define_const(mGtk, "SELECTION_BROWSE", INT2FIX(GTK_SELECTION_BROWSE));
- rb_define_const(mGtk, "SELECTION_MULTIPLE", INT2FIX(GTK_SELECTION_MULTIPLE));
- rb_define_const(mGtk, "SELECTION_EXTENDED", INT2FIX(GTK_SELECTION_EXTENDED));
- /* GtkPositionType */
- rb_define_const(mGtk, "POS_LEFT", INT2FIX(GTK_POS_LEFT));
- rb_define_const(mGtk, "POS_RIGHT", INT2FIX(GTK_POS_RIGHT));
- rb_define_const(mGtk, "POS_TOP", INT2FIX(GTK_POS_TOP));
- rb_define_const(mGtk, "POS_BOTTOM", INT2FIX(GTK_POS_BOTTOM));
-
- /* GtkShadowType */
- rb_define_const(mGtk, "SHADOW_NONE", INT2FIX(GTK_SHADOW_NONE));
- rb_define_const(mGtk, "SHADOW_IN", INT2FIX(GTK_SHADOW_IN));
- rb_define_const(mGtk, "SHADOW_OUT", INT2FIX(GTK_SHADOW_OUT));
- rb_define_const(mGtk, "SHADOW_ETCHED_IN", INT2FIX(GTK_SHADOW_ETCHED_IN));
- rb_define_const(mGtk, "SHADOW_ETCHED_OUT", INT2FIX(GTK_SHADOW_ETCHED_OUT));
- /* GtkStateType */
- rb_define_const(mGtk, "STATE_NORMAL", INT2FIX(GTK_STATE_NORMAL));
- rb_define_const(mGtk, "STATE_ACTIVE", INT2FIX(GTK_STATE_ACTIVE));
- rb_define_const(mGtk, "STATE_PRELIGHT", INT2FIX(GTK_STATE_PRELIGHT));
- rb_define_const(mGtk, "STATE_SELECTED", INT2FIX(GTK_STATE_SELECTED));
- rb_define_const(mGtk, "STATE_INSENSITIVE", INT2FIX(GTK_STATE_INSENSITIVE));
- /* GtkAttachOptions */
- rb_define_const(mGtk, "EXPAND", INT2FIX(GTK_EXPAND));
- rb_define_const(mGtk, "SHRINK", INT2FIX(GTK_SHRINK));
- rb_define_const(mGtk, "FILL", INT2FIX(GTK_FILL));
- /* GtkSubmenuDirection */
- rb_define_const(mGtk, "DIRECTION_LEFT", INT2FIX(GTK_DIRECTION_LEFT));
- rb_define_const(mGtk, "DIRECTION_RIGHT", INT2FIX(GTK_DIRECTION_RIGHT));
- /* GtkSubmenuPlacement */
- rb_define_const(mGtk, "TOP_BOTTOM", INT2FIX(GTK_TOP_BOTTOM));
- rb_define_const(mGtk, "LEFT_RIGHT", INT2FIX(GTK_LEFT_RIGHT));
- /* GtkMetricType */
- rb_define_const(mGtk, "PIXELS", INT2FIX(GTK_PIXELS));
- rb_define_const(mGtk, "INCHES", INT2FIX(GTK_INCHES));
- rb_define_const(mGtk, "CENTIMETERS", INT2FIX(GTK_CENTIMETERS));
-
- /* GtkArrowType */
- rb_define_const(mGtk, "ARROW_UP", INT2FIX(GTK_ARROW_UP));
- rb_define_const(mGtk, "ARROW_DOWN", INT2FIX(GTK_ARROW_DOWN));
- rb_define_const(mGtk, "ARROW_LEFT", INT2FIX(GTK_ARROW_LEFT));
- rb_define_const(mGtk, "ARROW_RIGHT", INT2FIX(GTK_ARROW_RIGHT));
-
- /* GtkPreviewType */
- rb_define_const(mGtk, "PREVIEW_COLOR", INT2FIX(GTK_PREVIEW_COLOR));
- rb_define_const(mGtk, "PREVIEW_GRAYSCALE", INT2FIX(GTK_PREVIEW_GRAYSCALE));
-
- rb_define_const(mGtk, "BUTTONBOX_DEFAULT", INT2FIX(GTK_BUTTONBOX_DEFAULT));
- rb_define_const(mGtk, "BUTTONBOX_SPREAD", INT2FIX(GTK_BUTTONBOX_SPREAD));
- rb_define_const(mGtk, "BUTTONBOX_EDGE", INT2FIX(GTK_BUTTONBOX_EDGE));
- rb_define_const(mGtk, "BUTTONBOX_START", INT2FIX(GTK_BUTTONBOX_START));
- rb_define_const(mGtk, "BUTTONBOX_END", INT2FIX(GTK_BUTTONBOX_END));
-
- /* GtkToolbarStyle */
- rb_define_const(mGtk, "TOOLBAR_ICONS", INT2FIX(GTK_TOOLBAR_ICONS));
- rb_define_const(mGtk, "TOOLBAR_TEXT", INT2FIX(GTK_TOOLBAR_TEXT));
- rb_define_const(mGtk, "TOOLBAR_BOTH", INT2FIX(GTK_TOOLBAR_BOTH));
-
- /* GtkOrientation */
- rb_define_const(mGtk, "ORIENTATION_HORIZONTAL", INT2FIX(GTK_ORIENTATION_HORIZONTAL));
- rb_define_const(mGtk, "ORIENTATION_VERTICAL", INT2FIX(GTK_ORIENTATION_VERTICAL));
-
- /* GdkExtensionMode */
- rb_define_const(mGdk, "EXTENSION_EVENTS_NONE", INT2FIX(GDK_EXTENSION_EVENTS_NONE));
- rb_define_const(mGdk, "EXTENSION_EVENTS_ALL", INT2FIX(GDK_EXTENSION_EVENTS_ALL));
- rb_define_const(mGdk, "EXTENSION_EVENTS_CURSOR", INT2FIX(GDK_EXTENSION_EVENTS_CURSOR));
-
- argc = RARRAY(rb_argv)->len;
- argv = ALLOCA_N(char*,argc+1);
- argv[0] = RSTRING(rb_argv0)->ptr;
- for (i=0;i<argc;i++) {
- if (TYPE(RARRAY(rb_argv)->ptr[i]) == T_STRING) {
- argv[i+1] = RSTRING(RARRAY(rb_argv)->ptr[i])->ptr;
- }
- else {
- argv[i+1] = "";
- }
- }
- argc++;
- {
- /* Gdk modifies sighandlers, sigh */
- RETSIGTYPE (*sigfunc[7])();
-
- sigfunc[0] = signal(SIGHUP, SIG_IGN);
- sigfunc[1] = signal(SIGINT, SIG_IGN);
- sigfunc[2] = signal(SIGQUIT, SIG_IGN);
- sigfunc[3] = signal(SIGBUS, SIG_IGN);
- sigfunc[4] = signal(SIGSEGV, SIG_IGN);
- sigfunc[5] = signal(SIGPIPE, SIG_IGN);
- sigfunc[6] = signal(SIGTERM, SIG_IGN);
-
- gdk_init(&argc, &argv);
-
- signal(SIGHUP, sigfunc[0]);
- signal(SIGINT, sigfunc[1]);
- signal(SIGQUIT, sigfunc[2]);
- signal(SIGBUS, sigfunc[3]);
- signal(SIGSEGV, sigfunc[4]);
- signal(SIGPIPE, sigfunc[5]);
- signal(SIGTERM, sigfunc[6]);
- }
-
- for (i=1;i<argc;i++) {
- RARRAY(rb_argv)->ptr[i] = str_taint(str_new2(argv[i]));
- }
- RARRAY(rb_argv)->len = argc-1;
-
- id_gtkdata = rb_intern("gtkdata");
- id_relatives = rb_intern("relatives");
- id_call = rb_intern("call");
- gtk_idle_add((GtkFunction)idle, 0);
-
- g_set_error_handler(gtkerr);
- g_set_warning_handler(gtkerr);
- rb_global_variable(&warn_handler);
- rb_global_variable(&mesg_handler);
- rb_global_variable(&print_handler);
-}
diff --git a/ext/gtk/test.rb b/ext/gtk/test.rb
deleted file mode 100644
index 52ce5db..0000000
--- a/ext/gtk/test.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-require 'gtk'
-
-def create_menu(depth)
- return nil if depth < 1
-
- menu = Gtk::Menu::new()
- group = nil
- submenu = nil
-
- for i in 0..4
- buf = sprintf("item %2d - %d", depth, i+1)
-# menuitem = Gtk::MenuItem::new(buf)
- menuitem = Gtk::RadioMenuItem.new(group, buf)
- group = menuitem.group
- if depth % 2
- menuitem.set_show_toggle TRUE
- end
- menu.append menuitem
- menuitem.show
- if depth > 0
- unless submenu
- submenu = create_menu(depth - 1)
- end
- menuitem.set_submenu submenu
- end
- end
- return menu
-end
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.signal_connect("destroy") do
- exit
-end
-window.signal_connect("delete_event") do
- exit
-end
-window.set_title("menus")
-window.border_width(0)
-
-box1 = Gtk::VBox::new(FALSE, 0)
-window.add box1
-box1.show
-
-menubar = Gtk::MenuBar::new()
-box1.pack_start menubar, FALSE, TRUE, 0
-menubar.show
-
-menu = create_menu(2)
-menuitem = Gtk::MenuItem::new("test\nline2")
-menuitem.set_submenu menu
-menubar.append menuitem
-menuitem.show
-
-menuitem = Gtk::MenuItem::new("foo")
-menuitem.set_submenu menu
-menubar.append menuitem
-menuitem.show
-
-menuitem = Gtk::MenuItem::new("bar")
-menuitem.set_submenu menu
-menubar.append menuitem
-menuitem.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width 10
-box1.pack_start box2, TRUE, TRUE, 0
-box2.show
-
-optionmenu = Gtk::OptionMenu::new()
-optionmenu.set_menu create_menu(1)
-optionmenu.set_history 4
-box2.pack_start optionmenu, TRUE, TRUE, 0
-optionmenu.show
-
-separator = Gtk::HSeparator::new()
-box1.pack_start(separator, FALSE, TRUE, 0)
-separator.show
-
-box2 = Gtk::HBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, FALSE, TRUE, 0)
-box2.show
-
-button = Gtk::Button::new("close")
-button.signal_connect("clicked") do
- window.destroy
- exit
-end
-box2.pack_start(button, TRUE, TRUE, 0)
-button.set_flags(Gtk::CAN_DEFAULT);
-button.grab_default
-button.show
-
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/test.xpm b/ext/gtk/test.xpm
deleted file mode 100644
index 9b0d2ef..0000000
--- a/ext/gtk/test.xpm
+++ /dev/null
@@ -1,92 +0,0 @@
-/* XPM */
-static char *openfile[] = {
-/* width height num_colors chars_per_pixel */
-" 20 19 66 2",
-/* colors */
-".. c None",
-".# c #000000",
-".a c #dfdfdf",
-".b c #7f7f7f",
-".c c #006f6f",
-".d c #00efef",
-".e c #009f9f",
-".f c #004040",
-".g c #00bfbf",
-".h c #ff0000",
-".i c #ffffff",
-".j c #7f0000",
-".k c #007070",
-".l c #00ffff",
-".m c #00a0a0",
-".n c #004f4f",
-".o c #00cfcf",
-".p c #8f8f8f",
-".q c #6f6f6f",
-".r c #a0a0a0",
-".s c #7f7f00",
-".t c #007f7f",
-".u c #5f5f5f",
-".v c #707070",
-".w c #00f0f0",
-".x c #009090",
-".y c #ffff00",
-".z c #0000ff",
-".A c #00afaf",
-".B c #00d0d0",
-".C c #00dfdf",
-".D c #005f5f",
-".E c #00b0b0",
-".F c #001010",
-".G c #00c0c0",
-".H c #000f0f",
-".I c #00007f",
-".J c #005050",
-".K c #002f2f",
-".L c #dfcfcf",
-".M c #dfd0d0",
-".N c #006060",
-".O c #00e0e0",
-".P c #00ff00",
-".Q c #002020",
-".R c #dfc0c0",
-".S c #008080",
-".T c #001f1f",
-".U c #003f3f",
-".V c #007f00",
-".W c #00000f",
-".X c #000010",
-".Y c #00001f",
-".Z c #000020",
-".0 c #00002f",
-".1 c #000030",
-".2 c #00003f",
-".3 c #000040",
-".4 c #00004f",
-".5 c #000050",
-".6 c #00005f",
-".7 c #000060",
-".8 c #00006f",
-".9 c #000070",
-"#. c #7f7f80",
-"## c #9f9f9f",
-/* pixels */
-"........................................",
-"........................................",
-"........................................",
-".......................#.#.#............",
-".....................#.......#...#......",
-"...............................#.#......",
-".......#.#.#.................#.#.#......",
-".....#.y.i.y.#.#.#.#.#.#.#..............",
-".....#.i.y.i.y.i.y.i.y.i.#..............",
-".....#.y.i.y.i.y.i.y.i.y.#..............",
-".....#.i.y.i.y.#.#.#.#.#.#.#.#.#.#.#....",
-".....#.y.i.y.#.s.s.s.s.s.s.s.s.s.#......",
-".....#.i.y.#.s.s.s.s.s.s.s.s.s.#........",
-".....#.y.#.s.s.s.s.s.s.s.s.s.#..........",
-".....#.#.s.s.s.s.s.s.s.s.s.#............",
-".....#.#.#.#.#.#.#.#.#.#.#..............",
-"........................................",
-"........................................",
-"........................................"
-};
diff --git a/ext/gtk/test0.rb b/ext/gtk/test0.rb
deleted file mode 100644
index 4ff802d..0000000
--- a/ext/gtk/test0.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.border_width(10)
-button = Gtk::Button::new("Hello World")
-button.signal_connect("clicked") do
- print "hello world\n"
- exit
-end
-window.add(button)
-button.show
-window.show
-Gtk::main()
diff --git a/ext/gtk/test1.rb b/ext/gtk/test1.rb
deleted file mode 100644
index 7d24199..0000000
--- a/ext/gtk/test1.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.set_title("entry")
-window.border_width(0)
-
-box1 = Gtk::VBox::new(FALSE, 0)
-window.add(box1)
-box1.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, TRUE, TRUE, 0)
-box2.show
-
-entry = Gtk::Entry::new()
-entry.set_text("hello world")
-box2.pack_start(entry, TRUE, TRUE, 0)
-entry.show
-
-separator = Gtk::HSeparator::new()
-box1.pack_start(separator, FALSE, TRUE, 0)
-separator.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, FALSE, TRUE, 0)
-box2.show
-
-button = Gtk::Button::new("close")
-button.signal_connect("clicked") do
- window.destroy
- exit
-end
-box2.pack_start(button, TRUE, TRUE, 0)
-button.set_flags(Gtk::CAN_DEFAULT);
-button.grab_default
-button.show
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/test2.rb b/ext/gtk/test2.rb
deleted file mode 100644
index 170de96..0000000
--- a/ext/gtk/test2.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.set_title("list")
-window.border_width(0)
-
-box1 = Gtk::VBox::new(FALSE, 0)
-window.add(box1)
-box1.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, TRUE, TRUE, 0)
-box2.show
-
-scrolled_win = Gtk::ScrolledWindow::new()
-scrolled_win.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
-box2.pack_start(scrolled_win, TRUE, TRUE, 0)
-scrolled_win.show
-
-list = Gtk::List::new()
-list.set_selection_mode(Gtk::SELECTION_MULTIPLE)
-list.set_selection_mode(Gtk::SELECTION_BROWSE)
-scrolled_win.add(list)
-list.show
-
-for i in [
- "hello",
- "world",
- "blah",
- "foo",
- "bar",
- "argh",
- "spencer",
- "is a",
- "wussy",
- "programmer",
- ]
- list_item = Gtk::ListItem::new(i)
- list.add(list_item)
- list_item.show
-end
-
-button = Gtk::Button::new("add")
-button.set_flags(Gtk::CAN_FOCUS);
-i = 1
-button.signal_connect("clicked") do
- list_item = Gtk::ListItem::new(format("added item %d", i))
- list.add(list_item)
- list_item.show
- i += 1
-end
-box2.pack_start(button, FALSE, TRUE, 0)
-button.show
-
-button = Gtk::Button::new("remove")
-button.set_flags(Gtk::CAN_FOCUS);
-button.signal_connect("clicked") do
- tmp_list = list.selection
- list.remove_items(tmp_list)
- for i in tmp_list
- i.destroy
- end
-end
-box2.pack_start(button, FALSE, TRUE, 0)
-button.show
-
-separator = Gtk::HSeparator::new()
-box1.pack_start(separator, FALSE, TRUE, 0)
-separator.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, FALSE, TRUE, 0)
-box2.show
-
-button = Gtk::Button::new("close")
-button.signal_connect("clicked") do
- window.destroy
- exit
-end
-box2.pack_start(button, TRUE, TRUE, 0)
-button.set_flags(Gtk::CAN_DEFAULT);
-button.grab_default
-button.show
-
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/test3.rb b/ext/gtk/test3.rb
deleted file mode 100644
index d73f72f..0000000
--- a/ext/gtk/test3.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'gtk'
-
-window = Gtk::FileSelection::new("file selection dialog")
-window.position(Gtk::WIN_POS_MOUSE)
-window.border_width(0)
-
-window.ok_button.signal_connect("clicked") do
- print window.get_filename, "\n"
-end
-window.cancel_button.signal_connect("clicked") do
- window.destroy
- exit
-end
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/test4.rb b/ext/gtk/test4.rb
deleted file mode 100644
index da0000c..0000000
--- a/ext/gtk/test4.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.set_title("notebook")
-window.border_width(0)
-
-box1 = Gtk::VBox::new(FALSE, 0)
-window.add(box1)
-box1.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, TRUE, TRUE, 0)
-box2.show
-
-notebook = Gtk::Notebook::new()
-notebook.set_tab_pos(Gtk::POS_TOP)
-box2.pack_start(notebook, TRUE, TRUE, 0)
-notebook.show
-
-for i in 1..5
- frame = Gtk::Frame::new(format("Page %d", i))
- frame.border_width(10)
- frame.set_usize(200, 150)
- frame.show
-
- label = Gtk::Label::new(format("Box %d", i))
- frame.add label
- label.show
-
- label = Gtk::Label::new(format("Tab %d", i))
- notebook.append_page frame, label
-end
-
-separator = Gtk::HSeparator::new()
-box1.pack_start(separator, FALSE, TRUE, 0)
-separator.show
-
-box2 = Gtk::HBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, FALSE, TRUE, 0)
-box2.show
-
-button = Gtk::Button::new("close")
-button.signal_connect("clicked") do
- window.destroy
- exit
-end
-box2.pack_start(button, TRUE, TRUE, 0)
-button.set_flags(Gtk::CAN_DEFAULT);
-button.grab_default
-button.show
-
-button = Gtk::Button::new("next")
-button.signal_connect("clicked") do
- notebook.next_page
-end
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-button = Gtk::Button::new("prev")
-button.signal_connect("clicked") do
- notebook.prev_page
-end
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-button = Gtk::Button::new("rotate")
-button.signal_connect("clicked") do
- notebook.set_tab_pos((notebook.tab_pos+1)%4)
-end
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/test5.rb b/ext/gtk/test5.rb
deleted file mode 100644
index 7142320..0000000
--- a/ext/gtk/test5.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.set_title("buttons")
-window.border_width(0)
-
-box1 = Gtk::VBox::new(FALSE, 0)
-window.add(box1)
-box1.show
-
-table = Gtk::Table::new(3, 3, FALSE)
-table.set_row_spacings(5)
-table.set_col_spacings(5)
-table.border_width(10)
-box1.pack_start(table, TRUE, TRUE, 0)
-table.show
-
-button = []
-0.upto(8) do |i|
- button.push Gtk::Button::new("button"+(i+1))
-end
-0.upto(8) do |i|
- button[i].signal_connect("clicked") do |w|
- if button[i+1].visible?
- button[i+1].hide
- else
- button[i+1].show
- end
- end
- button[i].show
-end
-table.attach(button[0], 0, 1, 0, 1, nil, nil, 0, 0)
-table.attach(button[1], 1, 2, 1, 2, nil, nil, 0, 0)
-table.attach(button[2], 2, 3, 2, 3, nil, nil, 0, 0)
-table.attach(button[3], 0, 1, 2, 3, nil, nil, 0, 0)
-table.attach(button[4], 2, 3, 0, 1, nil, nil, 0, 0)
-table.attach(button[5], 1, 2, 2, 3, nil, nil, 0, 0)
-table.attach(button[6], 1, 2, 0, 1, nil, nil, 0, 0)
-table.attach(button[7], 2, 3, 1, 2, nil, nil, 0, 0)
-table.attach(button[8], 0, 1, 1, 2, nil, nil, 0, 0)
-
-separator = Gtk::HSeparator::new()
-box1.pack_start(separator, FALSE, TRUE, 0)
-separator.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, FALSE, TRUE, 0)
-box2.show
-
-close = Gtk::Button::new("close")
-close.signal_connect("clicked") do
- window.destroy
- exit
-end
-box2.pack_start(close, TRUE, TRUE, 0)
-close.set_flags(Gtk::CAN_DEFAULT);
-close.grab_default
-close.show
-
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/test6.rb b/ext/gtk/test6.rb
deleted file mode 100644
index a589530..0000000
--- a/ext/gtk/test6.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.set_title("toggle buttons")
-window.border_width(0)
-
-box1 = Gtk::VBox::new(FALSE, 0)
-window.add(box1)
-box1.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, TRUE, TRUE, 0)
-box2.show
-
-button = Gtk::ToggleButton::new("button1")
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-button = Gtk::ToggleButton::new("button2")
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-button = Gtk::ToggleButton::new("button3")
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-separator = Gtk::HSeparator::new()
-box1.pack_start(separator, FALSE, TRUE, 0)
-separator.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, FALSE, TRUE, 0)
-box2.show
-
-close = Gtk::Button::new("close")
-close.signal_connect("clicked") do
- window.destroy
- exit
-end
-box2.pack_start(close, TRUE, TRUE, 0)
-close.set_flags(Gtk::CAN_DEFAULT);
-close.grab_default
-close.show
-
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/test7.rb b/ext/gtk/test7.rb
deleted file mode 100644
index 4d78648..0000000
--- a/ext/gtk/test7.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.set_title("check buttons")
-window.border_width(0)
-
-box1 = Gtk::VBox::new(FALSE, 0)
-window.add(box1)
-box1.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, TRUE, TRUE, 0)
-box2.show
-
-button = Gtk::CheckButton::new("button1")
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-button = Gtk::CheckButton::new("button2")
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-button = Gtk::CheckButton::new("button3")
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-separator = Gtk::HSeparator::new()
-box1.pack_start(separator, FALSE, TRUE, 0)
-separator.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, FALSE, TRUE, 0)
-box2.show
-
-close = Gtk::Button::new("close")
-close.signal_connect("clicked") do
- window.destroy
- exit
-end
-box2.pack_start(close, TRUE, TRUE, 0)
-close.set_flags(Gtk::CAN_DEFAULT);
-close.grab_default
-close.show
-
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/test8.rb b/ext/gtk/test8.rb
deleted file mode 100644
index 4ac4b0b..0000000
--- a/ext/gtk/test8.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.set_title("radio buttons")
-window.border_width(0)
-
-box1 = Gtk::VBox::new(FALSE, 0)
-window.add(box1)
-box1.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width 10
-box1.pack_start(box2, TRUE, TRUE, 0)
-box2.show
-
-button = Gtk::RadioButton::new("button1")
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-button = Gtk::RadioButton::new(button, "button2")
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-button = Gtk::RadioButton::new(button, "button3")
-box2.pack_start(button, TRUE, TRUE, 0)
-button.show
-
-separator = Gtk::HSeparator::new()
-box1.pack_start(separator, FALSE, TRUE, 0)
-separator.show
-
-box2 = Gtk::VBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, FALSE, TRUE, 0)
-box2.show
-
-close = Gtk::Button::new("close")
-close.signal_connect("clicked") do
- window.destroy
- exit
-end
-box2.pack_start(close, TRUE, TRUE, 0)
-close.set_flags(Gtk::CAN_DEFAULT);
-close.grab_default
-close.show
-
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/test9.rb b/ext/gtk/test9.rb
deleted file mode 100644
index 7bb3bf3..0000000
--- a/ext/gtk/test9.rb
+++ /dev/null
@@ -1,98 +0,0 @@
-require 'gtk'
-
-def create_bbox_window(horizontal, title, pos, spacing, cw, ch, layout)
- window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
- window.set_title(title)
- window.signal_connect("destroy") do
- window.destroy
- end
- window.signal_connect("delete_event") do
- window.hide
- window.destroy
- end
- if horizontal
- window.set_usize(550, 60)
- window.set_uposition(150, pos)
- else
- window.set_usize(150, 400)
- window.set_uposition(pos, 200)
- end
- box1 = Gtk::VBox::new(FALSE, 0)
- window.add box1
- box1.show
- if horizontal
- bbox = Gtk::HButtonBox::new()
- else
- bbox = Gtk::VButtonBox::new()
- end
- bbox.set_layout layout
- bbox.set_spacing spacing
- bbox.set_child_size cw, ch
- bbox.show
- box1.border_width 25
- box1.pack_start(bbox, TRUE, TRUE, 0)
- button = Gtk::Button::new("OK")
- bbox.add button
- button.signal_connect("clicked") do
- window.hide
- window.destroy
- end
- button.show
-
- button = Gtk::Button::new("Cancel")
- bbox.add button
- button.signal_connect("clicked") do
- window.hide
- window.destroy
- end
- button.show
-
- button = Gtk::Button::new("Help")
- bbox.add button
- button.show
-
- window.show
-end
-
-def test_hbbox
- create_bbox_window(TRUE, "Spread", 50, 40, 85, 25, Gtk::BUTTONBOX_SPREAD);
- create_bbox_window(TRUE, "Edge", 250, 40, 85, 28, Gtk::BUTTONBOX_EDGE);
- create_bbox_window(TRUE, "Start", 450, 40, 85, 25, Gtk::BUTTONBOX_START);
- create_bbox_window(TRUE, "End", 650, 15, 30, 25, Gtk::BUTTONBOX_END);
-end
-
-def test_vbbox
- create_bbox_window(FALSE, "Spread", 50, 40, 85, 25, Gtk::BUTTONBOX_SPREAD);
- create_bbox_window(FALSE, "Edge", 250, 40, 85, 28, Gtk::BUTTONBOX_EDGE);
- create_bbox_window(FALSE, "Start", 450, 40, 85, 25, Gtk::BUTTONBOX_START);
- create_bbox_window(FALSE, "End", 650, 15, 30, 25, Gtk::BUTTONBOX_END);
-end
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.signal_connect("delete_event") do
- window.destroy
- exit
-end
-window.set_title("button box")
-window.border_width(20)
-
-bbox = Gtk::HButtonBox::new()
-window.add(bbox)
-bbox.show
-
-button = Gtk::Button::new("Horizontal")
-def button.clicked(*args)
- test_hbbox
-end
-bbox.add button
-button.show
-
-button = Gtk::Button::new("Vertical")
-def button.clicked(*args)
- test_vbbox
-end
-bbox.add button
-button.show
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/testa.rb b/ext/gtk/testa.rb
deleted file mode 100644
index 00a6603..0000000
--- a/ext/gtk/testa.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.set_title("toolbar test")
-window.set_policy(TRUE, TRUE, TRUE)
-window.signal_connect("destroy") do
- exit
-end
-window.signal_connect("delete_event") do
- exit
-end
-window.border_width(0)
-window.realize
-
-toolbar = Gtk::Toolbar::new(Gtk::ORIENTATION_HORIZONTAL, Gtk::TOOLBAR_BOTH)
-toolbar.append_item "Horizontal", "Horizontal toolbar layout",
- Gtk::Pixmap::new(*Gdk::Pixmap::create_from_xpm(window.window,
- nil,
- #window.style.bg[Gtk::STATE_NORMAL],
- "test.xpm")), nil do
- toolbar.set_orientation Gtk::ORIENTATION_HORIZONTAL
-end
-toolbar.append_item "Vertival", "Vertical toolbar layout",
- Gtk::Pixmap::new(*Gdk::Pixmap::create_from_xpm(window.window,
- nil, #window.style.bg[Gtk::STATE_NORMAL],
- "test.xpm")), nil do
- toolbar.set_orientation Gtk::ORIENTATION_VERTICAL
-end
-toolbar.append_space
-toolbar.append_item "Icons", "Only show toolbar icons",
- Gtk::Pixmap::new(*Gdk::Pixmap::create_from_xpm(window.window,
- nil, #window.style.bg[Gtk::STATE_NORMAL],
- "test.xpm")), nil do
- toolbar.set_style Gtk::TOOLBAR_ICONS
-end
-toolbar.append_item "Text", "Only show toolbar text",
- Gtk::Pixmap::new(*Gdk::Pixmap::create_from_xpm(window.window,
- nil,#window.style.bg[Gtk::STATE_NORMAL],
- "test.xpm")), nil do
- toolbar.set_style Gtk::TOOLBAR_TEXT
-end
-toolbar.append_item "Both", "Show toolbar icons and text",
- Gtk::Pixmap::new(*Gdk::Pixmap::create_from_xpm(window.window,
- nil, #window.style.bg[Gtk::STATE_NORMAL],
- "test.xpm")), nil do
- toolbar.set_style Gtk::TOOLBAR_BOTH
-end
-toolbar.append_space
-toolbar.append_item "Small", "User small spaces",
- Gtk::Pixmap::new(*Gdk::Pixmap::create_from_xpm(window.window,
- nil,#window.style.bg[Gtk::STATE_NORMAL],
- "test.xpm")), nil do
- toolbar.set_space_size 5
-end
-toolbar.append_item "Big", "User big spaces",
- Gtk::Pixmap::new(*Gdk::Pixmap::create_from_xpm(window.window,
- nil,#window.style.bg[Gtk::STATE_NORMAL],
- "test.xpm")), nil do
- toolbar.set_space_size 10
-end
-toolbar.append_space
-toolbar.append_item "Enable", "Enable tooltips",
- Gtk::Pixmap::new(*Gdk::Pixmap::create_from_xpm(window.window,
- nil,#window.style.bg[Gtk::STATE_NORMAL],
- "test.xpm")), nil do
- toolbar.set_tooltips TRUE
-end
-toolbar.append_item "Disable", "Disable tooltips",
- Gtk::Pixmap::new(*Gdk::Pixmap::create_from_xpm(window.window,
- nil,#window.style.bg[Gtk::STATE_NORMAL],
- "test.xpm")), nil do
- toolbar.set_tooltips FALSE
-end
-window.add toolbar
-toolbar.show
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/testb.rb b/ext/gtk/testb.rb
deleted file mode 100644
index 4e707bc..0000000
--- a/ext/gtk/testb.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.signal_connect("destroy") do
- exit
-end
-window.signal_connect("delete_event") do
- exit
-end
-window.set_title("buttons")
-window.border_width(0)
-
-box1 = Gtk::VBox::new(FALSE, 0)
-window.add box1
-box1.show
-
-box2 = Gtk::HBox::new(FALSE, 5)
-box2.border_width 10
-box1.pack_start box2, TRUE, TRUE, 0
-box2.show
-
-label = Gtk::Label::new("Hello World")
-frame = Gtk::Frame::new("Frame 1")
-box2.pack_start frame, TRUE, TRUE, 0
-frame.show
-
-box3 = Gtk::VBox::new(FALSE, 5)
-box3.border_width 5
-frame.add box3
-box3.show
-
-button = Gtk::Button::new("switch")
-button.signal_connect("clicked") do
- label.reparent box3
-end
-box3.pack_start button, FALSE, TRUE, 0
-button.show
-box3.pack_start label, FALSE, TRUE, 0
-label.show
-
-frame = Gtk::Frame::new("Frame 2")
-box2.pack_start frame, TRUE, TRUE, 0
-frame.show
-
-box4 = Gtk::VBox::new(FALSE, 5)
-box4.border_width 5
-frame.add box4
-box4.show
-
-button = Gtk::Button::new("switch")
-button.signal_connect("clicked") do
- label.reparent box4
-end
-box4.pack_start button, FALSE, TRUE, 0
-button.show
-
-separator = Gtk::HSeparator::new()
-box1.pack_start(separator, FALSE, TRUE, 0)
-separator.show
-
-box2 = Gtk::HBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, FALSE, TRUE, 0)
-box2.show
-
-button = Gtk::Button::new("close")
-button.signal_connect("clicked") do
- window.destroy
- exit
-end
-box2.pack_start(button, TRUE, TRUE, 0)
-button.set_flags(Gtk::CAN_DEFAULT);
-button.grab_default
-button.show
-
-window.show
-
-Gtk::main()
diff --git a/ext/gtk/testc.rb b/ext/gtk/testc.rb
deleted file mode 100644
index 98c6466..0000000
--- a/ext/gtk/testc.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require 'gtk'
-
-window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
-window.signal_connect("destroy") do
- exit
-end
-window.signal_connect("delete_event") do
- exit
-end
-window.set_title("pixmap")
-window.border_width(0)
-window.realize
-
-box1 = Gtk::VBox::new(FALSE, 0)
-window.add box1
-box1.show
-
-box2 = Gtk::HBox::new(FALSE, 10)
-box2.border_width 10
-box1.pack_start box2, TRUE, TRUE, 0
-box2.show
-
-button = Gtk::Button::new()
-box2.pack_start button, FALSE, FALSE, 0
-button.show
-
-style = button.style
-pixmap, mask = Gdk::Pixmap::create_from_xpm(window.window,
- nil,
- #style.bg[Gtk::STATE_NORMAL],
- "test.xpm")
-pixmapwid = Gtk::Pixmap::new(pixmap, mask)
-label = Gtk::Label::new("Pixmap\ntest")
-box3 = Gtk::HBox::new(FALSE, 0)
-box3.border_width 2
-box3.add pixmapwid
-box3.add label
-button.add box3
-pixmapwid.show
-label.show
-box3.show
-
-separator = Gtk::HSeparator::new()
-box1.pack_start(separator, FALSE, TRUE, 0)
-separator.show
-
-box2 = Gtk::HBox::new(FALSE, 10)
-box2.border_width(10)
-box1.pack_start(box2, FALSE, TRUE, 0)
-box2.show
-
-button = Gtk::Button::new("close")
-button.signal_connect("clicked") do
- window.destroy
- exit
-end
-box2.pack_start(button, TRUE, TRUE, 0)
-button.set_flags(Gtk::CAN_DEFAULT);
-button.grab_default
-button.show
-
-window.show
-
-Gtk::main()
diff --git a/ext/marshal/MANIFEST b/ext/marshal/MANIFEST
deleted file mode 100644
index 54870ec7..0000000
--- a/ext/marshal/MANIFEST
+++ /dev/null
@@ -1,5 +0,0 @@
-MANIFEST
-depend
-extconf.rb
-marshal.c
-marshal.doc
diff --git a/ext/marshal/depend b/ext/marshal/depend
deleted file mode 100644
index c955eb2..0000000
--- a/ext/marshal/depend
+++ /dev/null
@@ -1,2 +0,0 @@
-marshal.o: marshal.c ../../ruby.h ../../config.h ../../defines.h ../../io.h \
- ../../st.h
diff --git a/ext/marshal/extconf.rb b/ext/marshal/extconf.rb
deleted file mode 100644
index ab30bd1..0000000
--- a/ext/marshal/extconf.rb
+++ /dev/null
@@ -1 +0,0 @@
-create_makefile("marshal")
diff --git a/ext/marshal/marshal.c b/ext/marshal/marshal.c
deleted file mode 100644
index 99e87d0..0000000
--- a/ext/marshal/marshal.c
+++ /dev/null
@@ -1,850 +0,0 @@
-/************************************************
-
- marshal.c -
-
- $Author$
- $Revision$
- $Date$
- created at: Thu Apr 27 16:30:01 JST 1995
-
-************************************************/
-
-#include "ruby.h"
-#include "io.h"
-#include "st.h"
-
-#define MARSHAL_MAJOR 4
-#define MARSHAL_MINOR 0
-
-#define TYPE_NIL '0'
-#define TYPE_TRUE 'T'
-#define TYPE_FALSE 'F'
-#define TYPE_FIXNUM 'i'
-
-#define TYPE_UCLASS 'C'
-#define TYPE_OBJECT 'o'
-#define TYPE_USERDEF 'u'
-#define TYPE_FLOAT 'f'
-#define TYPE_BIGNUM 'l'
-#define TYPE_STRING '"'
-#define TYPE_REGEXP '/'
-#define TYPE_ARRAY '['
-#define TYPE_HASH '{'
-#define TYPE_STRUCT 'S'
-#define TYPE_MODULE 'M'
-
-#define TYPE_SYMBOL ':'
-#define TYPE_SYMLINK ';'
-
-#define TYPE_LINK '@'
-
-extern VALUE cString;
-extern VALUE cRegexp;
-extern VALUE cArray;
-extern VALUE cHash;
-
-VALUE rb_path2class();
-
-static ID s_dump, s_load;
-
-struct dump_arg {
- VALUE obj;
- FILE *fp;
- VALUE str;
- st_table *symbol;
- st_table *data;
-};
-
-struct dump_call_arg {
- VALUE obj;
- struct dump_arg *arg;
- int limit;
-};
-
-static void w_long _((long, struct dump_arg*));
-
-static void
-w_byte(c, arg)
- char c;
- struct dump_arg *arg;
-{
- if (arg->fp) putc(c, arg->fp);
- else str_cat(arg->str, (UCHAR*)&c, 1);
-}
-
-static void
-w_bytes(s, n, arg)
- char *s;
- int n;
- struct dump_arg *arg;
-{
- w_long(n, arg);
- if (arg->fp) {
- fwrite(s, 1, n, arg->fp);
- }
- else {
- str_cat(arg->str, s, n);
- }
-}
-
-static void
-w_short(x, arg)
- int x;
- struct dump_arg *arg;
-{
- int i;
-
- for (i=0; i<sizeof(USHORT); i++) {
- w_byte((x >> (i*8)) & 0xff, arg);
- }
-}
-
-static void
-w_long(x, arg)
- long x;
- struct dump_arg *arg;
-{
- char buf[sizeof(long)+1];
- int i, len = 0;
-
- if (x == 0) {
- w_byte(0, arg);
- return;
- }
- for (i=1;i<sizeof(long)+1;i++) {
- buf[i] = x & 0xff;
- x = RSHIFT(x,8);
- if (x == 0) {
- buf[0] = i;
- break;
- }
- if (x == -1) {
- buf[0] = -i;
- break;
- }
- }
- len = i;
- for (i=0;i<=len;i++) {
- w_byte(buf[i], arg);
- }
-}
-
-static void
-w_float(d, arg)
- double d;
- struct dump_arg *arg;
-{
- char buf[100];
-
- sprintf(buf, "%.12g", d);
- w_bytes(buf, strlen(buf), arg);
-}
-
-static void
-w_symbol(id, arg)
- ID id;
- struct dump_arg *arg;
-{
- char *sym = rb_id2name(id);
- int num;
-
- if (st_lookup(arg->symbol, id, &num)) {
- w_byte(TYPE_SYMLINK, arg);
- w_long(num, arg);
- }
- else {
- w_byte(TYPE_SYMBOL, arg);
- w_bytes(sym, strlen(sym), arg);
- st_insert(arg->symbol, id, arg->symbol->num_entries);
- }
-}
-
-static void
-w_unique(s, arg)
- char *s;
- struct dump_arg *arg;
-{
- w_symbol(rb_intern(s), arg);
-}
-
-static void w_object _((VALUE,struct dump_arg*,int));
-extern VALUE cIO, cBignum, cStruct;
-
-static int
-hash_each(key, value, arg)
- VALUE key, value;
- struct dump_call_arg *arg;
-{
- w_object(key, arg->arg, arg->limit);
- w_object(value, arg->arg, arg->limit);
- return ST_CONTINUE;
-}
-
-static int
-obj_each(id, value, arg)
- ID id;
- VALUE value;
- struct dump_call_arg *arg;
-{
- w_symbol(id, arg->arg);
- w_object(value, arg->arg, arg->limit);
- return ST_CONTINUE;
-}
-
-static void
-w_uclass(obj, class, arg)
- VALUE obj, class;
- struct dump_arg *arg;
-{
- if (CLASS_OF(obj) != class) {
- w_byte(TYPE_UCLASS, arg);
- w_unique(rb_class2name(CLASS_OF(obj)), arg);
- }
-}
-
-static void
-w_object(obj, arg, limit)
- VALUE obj;
- struct dump_arg *arg;
- int limit;
-{
- int n;
- struct dump_call_arg c_arg;
-
- if (limit == 0) {
- Fail("exceed depth limit");
- }
- limit--;
- c_arg.limit = limit;
- c_arg.arg = arg;
-
- if (obj == Qnil) {
- w_byte(TYPE_NIL, arg);
- }
- else if (obj == TRUE) {
- w_byte(TYPE_TRUE, arg);
- }
- else if (obj == FALSE) {
- w_byte(TYPE_FALSE, arg);
- }
- else if (FIXNUM_P(obj)) {
-#if SIZEOF_LONG <= 4
- w_byte(TYPE_FIXNUM, arg);
- w_long(FIX2INT(obj), arg);
-#else
- if (RSHIFT(obj, 32) == 0 || RSHIFT(obj, 32) == -1) {
- w_byte(TYPE_FIXNUM, arg);
- w_long(FIX2INT(obj), arg);
- }
- else {
- obj = int2big(FIX2INT(obj));
- goto write_bignum;
- }
-#endif
- }
- else {
- int num;
-
- if (st_lookup(arg->data, obj, &num)) {
- w_byte(TYPE_LINK, arg);
- w_long(num, arg);
- return;
- }
- st_insert(arg->data, obj, arg->data->num_entries);
- if (rb_respond_to(obj, s_dump)) {
- VALUE v;
-
- w_byte(TYPE_USERDEF, arg);
- w_unique(rb_class2name(CLASS_OF(obj)), arg);
- v = rb_funcall(obj, s_dump, 1, limit);
- if (TYPE(v) != T_STRING) {
- TypeError("_dump_to must return String");
- }
- w_bytes(RSTRING(v)->ptr, RSTRING(v)->len, arg);
- return;
- }
-
- switch (BUILTIN_TYPE(obj)) {
- case T_MODULE:
- case T_CLASS:
- w_byte(TYPE_MODULE, arg);
- {
- VALUE path = rb_class_path(obj);
- w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg);
- }
- return;
-
- case T_FLOAT:
- w_byte(TYPE_FLOAT, arg);
- w_float(RFLOAT(obj)->value, arg);
- return;
-
- case T_BIGNUM:
- write_bignum:
- w_byte(TYPE_BIGNUM, arg);
- {
- char sign = RBIGNUM(obj)->sign?'+':'-';
- int len = RBIGNUM(obj)->len;
- USHORT *d = RBIGNUM(obj)->digits;
-
- w_byte(sign, arg);
- w_long(len, arg);
- while (len--) {
- w_short(*d, arg);
- d++;
- }
- }
- return;
-
- case T_STRING:
- w_uclass(obj, cString, arg);
- w_byte(TYPE_STRING, arg);
- w_bytes(RSTRING(obj)->ptr, RSTRING(obj)->len, arg);
- return;
-
- case T_REGEXP:
- w_uclass(obj, cRegexp, arg);
- w_byte(TYPE_REGEXP, arg);
- w_bytes(RREGEXP(obj)->str, RREGEXP(obj)->len, arg);
- w_byte(FL_TEST(obj, FL_USER1), arg);
- return;
-
- case T_ARRAY:
- w_uclass(obj, cArray, arg);
- w_byte(TYPE_ARRAY, arg);
- {
- int len = RARRAY(obj)->len;
- VALUE *ptr = RARRAY(obj)->ptr;
-
- w_long(len, arg);
- while (len--) {
- w_object(*ptr, arg, limit);
- ptr++;
- }
- }
- break;
-
- case T_HASH:
- w_uclass(obj, cHash, arg);
- w_byte(TYPE_HASH, arg);
- w_long(RHASH(obj)->tbl->num_entries, arg);
- st_foreach(RHASH(obj)->tbl, hash_each, &c_arg);
- break;
-
- case T_STRUCT:
- w_byte(TYPE_STRUCT, arg);
- {
- int len = RSTRUCT(obj)->len;
- char *path = rb_class2name(CLASS_OF(obj));
- VALUE mem;
- int i;
-
- w_unique(path, arg);
- w_long(len, arg);
- mem = rb_ivar_get(CLASS_OF(obj), rb_intern("__member__"));
- if (mem == Qnil) {
- Fatal("non-initialized struct");
- }
- for (i=0; i<len; i++) {
- w_symbol(FIX2INT(RARRAY(mem)->ptr[i]), arg);
- w_object(RSTRUCT(obj)->ptr[i], arg, limit);
- }
- }
- break;
-
- case T_OBJECT:
- w_byte(TYPE_OBJECT, arg);
- {
- VALUE class = CLASS_OF(obj);
- char *path;
-
- if (FL_TEST(class, FL_SINGLETON)) {
- TypeError("singleton can't be dumped");
- }
- path = rb_class2name(class);
- w_unique(path, arg);
- if (ROBJECT(obj)->iv_tbl) {
- w_long(ROBJECT(obj)->iv_tbl->num_entries, arg);
- st_foreach(ROBJECT(obj)->iv_tbl, obj_each, &c_arg);
- }
- else {
- w_long(0, arg);
- }
- }
- break;
-
- default:
- TypeError("can't dump %s", rb_class2name(CLASS_OF(obj)));
- break;
- }
- }
-}
-
-static VALUE
-dump(arg)
- struct dump_call_arg *arg;
-{
- w_object(arg->obj, arg->arg, arg->limit);
-}
-
-static VALUE
-dump_ensure(arg)
- struct dump_arg *arg;
-{
- st_free_table(arg->symbol);
- st_free_table(arg->data);
-}
-
-static VALUE
-marshal_dump(argc, argv)
- int argc;
- VALUE argv;
-{
- VALUE obj, port, a1, a2;
- int limit = -1;
- extern VALUE cIO;
- struct dump_arg arg;
- struct dump_call_arg c_arg;
-
- port = 0;
- rb_scan_args(argc, argv, "12", &obj, &a1, &a2);
- if (argc == 3) {
- limit = NUM2INT(a2);
- port = a1;
- }
- else if (argc == 2) {
- if (FIXNUM_P(a1)) limit = FIX2INT(a1);
- else port = a1;
- }
- if (port) {
- if (obj_is_kind_of(port, cIO)) {
- OpenFile *fptr;
-
- io_binmode(port);
- GetOpenFile(port, fptr);
- io_writable(fptr);
- arg.fp = (fptr->f2) ? fptr->f2 : fptr->f;
- }
- else {
- TypeError("instance of IO needed");
- }
- }
- else {
- arg.fp = 0;
- port = str_new(0, 0);
- arg.str = port;
- }
-
- arg.symbol = st_init_numtable();
- arg.data = st_init_numtable();
- c_arg.obj = obj;
- c_arg.arg = &arg;
- c_arg.limit = limit;
-
- w_byte(MARSHAL_MAJOR, &arg);
- w_byte(MARSHAL_MINOR, &arg);
-
- rb_ensure(dump, &c_arg, dump_ensure, &arg);
-
- return port;
-}
-
-struct load_arg {
- FILE *fp;
- UCHAR *ptr, *end;
- st_table *symbol;
- st_table *data;
-};
-
-static int
-r_byte(arg)
- struct load_arg *arg;
-{
- if (arg->fp) return getc(arg->fp);
- if (arg->ptr < arg->end) return *arg->ptr++;
- return EOF;
-}
-
-static USHORT
-r_short(arg)
- struct load_arg *arg;
-{
- USHORT x;
- int i;
-
- x = 0;
- for (i=0; i<sizeof(USHORT); i++) {
- x |= r_byte(arg)<<(i*8);
- }
-
- return x;
-}
-
-static void
-long_toobig(size)
- int size;
-{
- TypeError("long too big for this architecture (size %d, given %d)",
- sizeof(long), size);
-}
-
-static long
-r_long(arg)
- struct load_arg *arg;
-{
- int c = r_byte(arg), i;
- register long x;
-
- if (c == 0) return 0;
- if (c > 0) {
- if (c > sizeof(long)) long_toobig((int)c);
- x = 0;
- for (i=0;i<c;i++) {
- x |= (long)r_byte(arg) << (8*i);
- }
- }
- else if (c < 0) {
- c = -c;
- if (c > sizeof(long)) long_toobig((int)c);
- x = -1;
- for (i=0;i<c;i++) {
- x &= ~(0xff << (8*i));
- x |= (long)r_byte(arg) << (8*i);
- }
- }
- return x;
-}
-
-#define r_bytes(s, arg) \
- (s = (char*)r_long(arg), r_bytes0(&s,ALLOCA_N(char,(long)s),(long)s,arg))
-
-static int
-r_bytes0(sp, s, len, arg)
- char **sp, *s;
- int len;
- struct load_arg *arg;
-{
- if (arg->fp) {
- len = fread(s, 1, len, arg->fp);
- }
- else {
- if (arg->ptr + len > arg->end) {
- len = arg->end - arg->ptr;
- }
- memcpy(s, arg->ptr, len);
- arg->ptr += len;
- }
-
- (s)[len] = '\0';
- *sp = s;
-
- return len;
-}
-
-static ID
-r_symbol(arg)
- struct load_arg *arg;
-{
- char *buf;
- ID id;
- char type;
-
- if (r_byte(arg) == TYPE_SYMLINK) {
- int num = r_long(arg);
-
- if (st_lookup(arg->symbol, num, &id)) {
- return id;
- }
- TypeError("bad symbol");
- }
- r_bytes(buf, arg);
- id = rb_intern(buf);
- st_insert(arg->symbol, arg->symbol->num_entries, id);
-
- return id;
-}
-
-static char*
-r_unique(arg)
- struct load_arg *arg;
-{
- return rb_id2name(r_symbol(arg));
-}
-
-static VALUE
-r_string(arg)
- struct load_arg *arg;
-{
- char *buf;
- int len = r_bytes(buf, arg);
-
- return str_taint(str_new(buf, len));
-}
-
-static VALUE
-r_regist(v, arg)
- VALUE v;
- struct load_arg *arg;
-{
- st_insert(arg->data, arg->data->num_entries, v);
- return v;
-}
-
-static VALUE
-r_object(arg)
- struct load_arg *arg;
-{
- VALUE v;
- int type = r_byte(arg);
-
- switch (type) {
- case EOF:
- eof_error();
- return Qnil;
-
- case TYPE_LINK:
- if (st_lookup(arg->data, r_long(arg), &v)) {
- return v;
- }
- ArgError("dump format error (unlinked)");
- break;
-
- case TYPE_UCLASS:
- {
- VALUE c = rb_path2class(r_unique(arg));
- v = r_object(arg);
- if (rb_special_const_p(v)) {
- ArgError("dump format error (user class)");
- }
- RBASIC(v)->class = c;
- return v;
- }
-
- case TYPE_NIL:
- return Qnil;
-
- case TYPE_TRUE:
- return TRUE;
-
- case TYPE_FALSE:
- return FALSE;
-
- case TYPE_FIXNUM:
- {
- int i = r_long(arg);
- return INT2FIX(i);
- }
-
- case TYPE_FLOAT:
- {
-#ifndef atof
- double atof();
-#endif
- char *buf;
-
- r_bytes(buf, arg);
- v = float_new(atof(buf));
- return r_regist(v, arg);
- }
-
- case TYPE_BIGNUM:
- {
- int len;
- USHORT *digits;
-
- NEWOBJ(big, struct RBignum);
- OBJSETUP(big, cBignum, T_BIGNUM);
- big->sign = (r_byte(arg) == '+');
- big->len = len = r_long(arg);
- big->digits = digits = ALLOC_N(USHORT, len);
- while (len--) {
- *digits++ = r_short(arg);
- }
- big = RBIGNUM(big_norm((VALUE)big));
- if (TYPE(big) == T_BIGNUM) {
- r_regist(big, arg);
- }
- return (VALUE)big;
- }
-
- case TYPE_STRING:
- return r_regist(r_string(arg), arg);
-
- case TYPE_REGEXP:
- {
- char *buf;
- int len = r_bytes(buf, arg);
- int ci = r_byte(arg);
- return r_regist(reg_new(buf, len, ci), arg);
- }
-
- case TYPE_ARRAY:
- {
- volatile int len = r_long(arg);
- v = ary_new2(len);
- r_regist(v, arg);
- while (len--) {
- ary_push(v, r_object(arg));
- }
- return v;
- }
-
- case TYPE_HASH:
- {
- int len = r_long(arg);
-
- v = hash_new();
- r_regist(v, arg);
- while (len--) {
- VALUE key = r_object(arg);
- VALUE value = r_object(arg);
- hash_aset(v, key, value);
- }
- return v;
- }
-
- case TYPE_STRUCT:
- {
- VALUE class, mem, values;
- int i, len;
- int num = arg->data->num_entries;
-
- class = rb_path2class(r_unique(arg));
- mem = rb_ivar_get(class, rb_intern("__member__"));
- if (mem == Qnil) {
- Fatal("non-initialized struct");
- }
- len = r_long(arg);
-
- values = ary_new2(len);
- for (i=0; i<len; i++) {
- ary_push(values, Qnil);
- }
- v = struct_alloc(class, values);
- r_regist(v, arg);
- for (i=0; i<len; i++) {
- ID slot = r_symbol(arg);
- if (RARRAY(mem)->ptr[i] != INT2FIX(slot))
- TypeError("struct not compatible");
- struct_aset(v, INT2FIX(i), r_object(arg));
- }
- return v;
- }
- break;
-
- case TYPE_USERDEF:
- {
- VALUE class;
- int len;
-
- class = rb_path2class(r_unique(arg));
- if (rb_respond_to(class, s_load)) {
- v = rb_funcall(class, s_load, 1, r_string(arg));
- return r_regist(v, arg);
- }
- TypeError("class %s needs to have method `_load_from'",
- rb_class2name(class));
- }
- break;
-
- case TYPE_OBJECT:
- {
- VALUE class;
- int len;
-
- class = rb_path2class(r_unique(arg));
- len = r_long(arg);
- v = obj_alloc(class);
- r_regist(v, arg);
- if (len > 0) {
- while (len--) {
- ID id = r_symbol(arg);
- VALUE val = r_object(arg);
- rb_ivar_set(v, id, val);
- }
- }
- return v;
- }
- break;
-
- case TYPE_MODULE:
- {
- char *buf;
- r_bytes(buf, arg);
- return rb_path2class(buf);
- }
-
- default:
- ArgError("dump format error(0x%x)", type);
- break;
- }
-}
-
-static VALUE
-load(arg)
- struct load_arg *arg;
-{
- return r_object(arg);
-}
-
-static VALUE
-load_ensure(arg)
- struct load_arg *arg;
-{
- st_free_table(arg->symbol);
- st_free_table(arg->data);
-}
-
-static VALUE
-marshal_load(self, port)
- VALUE self, port;
-{
- FILE *fp;
- int major;
- VALUE v;
- OpenFile *fptr;
- struct load_arg arg;
-
- if (TYPE(port) == T_STRING) {
- arg.fp = 0;
- arg.ptr = RSTRING(port)->ptr;
- arg.end = arg.ptr + RSTRING(port)->len;
- }
- else {
- if (obj_is_kind_of(port, cIO)) {
- io_binmode(port);
- GetOpenFile(port, fptr);
- io_readable(fptr);
- arg.fp = fptr->f;
- }
- else {
- TypeError("instance of IO needed");
- }
- }
-
- major = r_byte(&arg);
- if (major == MARSHAL_MAJOR) {
- if (r_byte(&arg) != MARSHAL_MINOR) {
- Warning("Old marshal file format (can be read)");
- }
- arg.symbol = st_init_numtable();
- arg.data = st_init_numtable();
- v = rb_ensure(load, &arg, load_ensure, &arg);
- }
- else {
- TypeError("Old marshal file format (can't read)");
- }
-
- return v;
-}
-
-Init_marshal()
-{
- VALUE mMarshal = rb_define_module("Marshal");
-
- s_dump = rb_intern("_dump_to");
- s_load = rb_intern("_load_from");
- rb_define_module_function(mMarshal, "dump", marshal_dump, -1);
- rb_define_module_function(mMarshal, "load", marshal_load, 1);
- rb_define_module_function(mMarshal, "restore", marshal_load, 1);
-}
diff --git a/ext/marshal/marshal.doc b/ext/marshal/marshal.doc
deleted file mode 100644
index 7529e79..0000000
--- a/ext/marshal/marshal.doc
+++ /dev/null
@@ -1,48 +0,0 @@
-.\" marshal.doc - -*- Indented-Text -*- created at: Tue May 16 12:18:08 JST 1995
-
-** Marshal(モジュール)
-
-rubyオブジェクトをファイルに書き出したり,読みも度したりする機能を提供
-するモジュール.大部分のクラスのインスタンスを書き出す事ができるが,ファ
-イルへの不可能なクラスも存在し(例:IO),そのようなクラスを書き出そうと
-すると例外を発生させる.
-
-Methods:
-Single Methods:
-
- dump(obj, port[, limit])
-
- objを再帰的にファイルに書き出す.ファイルに書き出せないクラスのイ
- ンスタンスをファイルに書き出そうとすると例外を発生させる.ファイル
- に書き出せないクラスは以下の通り.
-
- Class, Module, Data
-
- また,これらのクラスを間接的に指すクラス(例えばIOのサブクラス)など
- も書き出せない.portはIO(またはそのサブクラス)のインスタンスを指定
- する.
-
- 出力するオブジェクトがメソッド`_dump_to'を定義している場合には,ファ
- イル出力はそのメソッドを使って行われる.メソッド`_dump_to'は引数と
- して出力先のファイルオブジェクトを受け取る.インスタンスがメソッド
- `_dump_to'を持つクラスは必ず同じフォーマットを読み戻す特異メソッド
- `_load_from'を定義する必要がある.
-
- limitを指定した場合,limit段以上深くリンクしたオブジェクトをダンプ
- できない(デフォルトは100レベル)。負のlimitを指定すると深さチェック
- を行わない。
-
- dumps(obj)
-
- dump()がファイルに書き出すのと同じ内容を含む文字列を返す.
-
- load(port)
-
- portからオブジェクトを読み込んで来て,元のオブジェクトと同じ状態を
- もつオブジェクトを生成する.portは文字列かIO(またはそのサブクラス)
- のインスタンスである.
-
--------------------------------------------------------
-Local variables:
-fill-column: 70
-end:
diff --git a/ext/md5/MANIFEST b/ext/md5/MANIFEST
index e4f0004..8057ebb 100644
--- a/ext/md5/MANIFEST
+++ b/ext/md5/MANIFEST
@@ -1,6 +1,7 @@
MANIFEST
depend
-md5.doc
+md5.txt
+md5.txt.jp
md5.h
md5c.c
md5init.c
diff --git a/ext/nkf/MANIFEST b/ext/nkf/MANIFEST
new file mode 100644
index 0000000..7e3345a
--- /dev/null
+++ b/ext/nkf/MANIFEST
@@ -0,0 +1,7 @@
+MANIFEST
+depend
+extconf.rb
+lib/kconv.rb
+nkf.c
+orig/nkf.c
+test.rb
diff --git a/ext/nkf/extconf.rb b/ext/nkf/extconf.rb
new file mode 100644
index 0000000..710662f
--- /dev/null
+++ b/ext/nkf/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('nkf')
diff --git a/ext/nkf/lib/kconv.rb b/ext/nkf/lib/kconv.rb
new file mode 100644
index 0000000..bfd2763
--- /dev/null
+++ b/ext/nkf/lib/kconv.rb
@@ -0,0 +1,58 @@
+require 'nkf'
+
+module Kconv
+ AUTO = NKF::AUTO
+ JIS = NKF::JIS
+ EUC = NKF::EUC
+ SJIS = NKF::SJIS
+ BINARY = NKF::BINARY
+ NOCONV = NKF::NOCONV
+ UNKNOWN = NKF::UNKNOWN
+ def kconv(str, out_code, in_code = AUTO)
+ opt = '-'
+ case in_code
+ when NKF::JIS
+ opt << 'J'
+ when NKF::EUC
+ opt << 'E'
+ when NKF::SJIS
+ opt << 'S'
+ end
+
+ case out_code
+ when NKF::JIS
+ opt << 'j'
+ when NKF::EUC
+ opt << 'e'
+ when NKF::SJIS
+ opt << 's'
+ when NKF::NOCONV
+ return str
+ end
+
+ opt = '' if opt == '-'
+
+ NKF::nkf(opt, str)
+ end
+ module_function :kconv
+
+ def tojis(str)
+ NKF::nkf('-j', str)
+ end
+ module_function :tojis
+
+ def toeuc(str)
+ NKF::nkf('-e', str)
+ end
+ module_function :toeuc
+
+ def tosjis(str)
+ NKF::nkf('-s', str)
+ end
+ module_function :tosjis
+
+ def guess(str)
+ NKF::guess(str)
+ end
+ module_function :guess
+end
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
new file mode 100644
index 0000000..6b5db0f
--- /dev/null
+++ b/ext/nkf/nkf.c
@@ -0,0 +1,207 @@
+#include "ruby.h"
+
+#define _AUTO 0
+#define _JIS 1
+#define _EUC 2
+#define _SJIS 3
+#define _BINARY 4
+#define _NOCONV 4
+#define _UNKNOWN _AUTO
+
+#undef getc
+#undef ungetc
+#define getc(f) (input_ctr>i_len?-1:input[input_ctr++])
+#define ungetc(c,f) input_ctr--
+
+#undef putchar
+#define putchar(c) rb_nkf_putchar(c)
+
+#define INCSIZE 32
+static int incsize;
+
+static unsigned char *input, *output;
+static int input_ctr, i_len;
+static int output_ctr, o_len;
+
+static VALUE dst;
+
+static int
+rb_nkf_putchar(c)
+ unsigned int c;
+{
+ if (output_ctr >= o_len) {
+ o_len += incsize;
+ rb_str_cat(dst, "", incsize);
+ incsize *= 2;
+ }
+
+ output[output_ctr++] = c;
+/*
+printf("[[%c][%c][%d]]\n", c, output[output_ctr - 1], output_ctr);
+*/
+ return c;
+}
+
+#define PERL_XS 1
+#include "orig/nkf.c"
+
+static VALUE
+rb_nkf_kconv(obj, opt, src)
+ VALUE obj, opt, src;
+{
+ int i;
+ char *opt_ptr, *opt_end;
+
+ reinit();
+ opt_ptr = str2cstr(opt, &i);
+ opt_end = opt_ptr + i;
+ for (; opt_ptr < opt_end; opt_ptr++) {
+ if (*opt_ptr != '-') {
+ continue;
+ }
+ arguments(opt_ptr);
+ }
+ dst = rb_str_new(0, RSTRING(src)->len*3 + 10); /* large enough? */
+
+ incsize = INCSIZE;
+
+ input_ctr = 0;
+ input = str2cstr(src, &i_len);
+
+ output_ctr = 0;
+ output = RSTRING(dst)->ptr;
+ o_len = RSTRING(dst)->len;
+ *output = '\0';
+
+ if(iso8859_f && (oconv != j_oconv || !x0201_f )) {
+ iso8859_f = FALSE;
+ }
+
+ kanji_convert(NULL);
+ output_ctr--;
+ if (output[output_ctr] == '\0') {
+/*
+printf("([%c][%d])\n", output[output_ctr], output_ctr);
+*/
+ RSTRING(dst)->len = output_ctr;
+ } else {
+/*
+printf("<[%c][%d]>\n", output[output_ctr], output_ctr);
+*/
+ RSTRING(dst)->len = output_ctr + 1;
+ }
+
+ return dst;
+}
+
+/*
+ * Character code detection - Algorithm described in:
+ * Ken Lunde. `Understanding Japanese Information Processing'
+ * Sebastopol, CA: O'Reilly & Associates.
+ */
+
+static VALUE
+rb_nkf_guess(obj, src)
+ VALUE obj, src;
+{
+ unsigned char *p;
+ unsigned char *pend;
+ int sequence_counter = 0;
+
+ Check_Type(src, T_STRING);
+
+ p = RSTRING(src)->ptr;
+ pend = p + RSTRING(src)->len;
+
+#define INCR do {\
+ p++;\
+ if (p==pend) return INT2FIX(_UNKNOWN);\
+ sequence_counter++;\
+ if (sequence_counter % 2 == 1 && *p != 0xa4)\
+ sequence_counter = 0;\
+ if (6 <= sequence_counter) {\
+ sequence_counter = 0;\
+ return INT2FIX(_EUC);\
+ }\
+} while (0)
+
+ if (*p == 0xa4)
+ sequence_counter = 1;
+
+ while (p<pend) {
+ if (*p == '\033') {
+ return INT2FIX(_JIS);
+ }
+ if ('\000' < *p && *p < '\006'
+ || *p == 0x7f
+ || *p == 0xdf) {
+ return INT2FIX(_BINARY);
+ }
+ if (0x81 <= *p && *p <= 0x8d) {
+ return INT2FIX(_SJIS);
+ }
+ if (0x8f <= *p && *p <= 0x9f) {
+ return INT2FIX(_SJIS);
+ }
+ if (*p == 0x8e) { /* SS2 */
+ INCR;
+ if ((0x40 <= *p && *p <= 0x7e) ||
+ (0x80 <= *p && *p <= 0xa0) ||
+ (0xe0 <= *p && *p <= 0xfc))
+ return INT2FIX(_SJIS);
+ }
+ else if (0xa1 <= *p && *p <= 0xdf) {
+ INCR;
+ if (0xf0 <= *p && *p <= 0xfe)
+ return INT2FIX(_EUC);
+ if (0xe0 <= *p && *p <= 0xef) {
+ while (p < pend && *p >= 0x40) {
+ if (*p >= 0x81) {
+ if (*p <= 0x8d || (0x8f <= *p && *p <= 0x9f)) {
+ return INT2FIX(_SJIS);
+ }
+ else if (0xfd <= *p && *p <= 0xfe) {
+ return INT2FIX(_EUC);
+ }
+ }
+ INCR;
+ }
+ }
+ else if (*p <= 0x9f) {
+ return INT2FIX(_SJIS);
+ }
+ }
+ else if (0xf0 <= *p && *p <= 0xfe) {
+ return INT2FIX(_EUC);
+ }
+ else if (0xe0 <= *p && *p <= 0xef) {
+ INCR;
+ if ((0x40 <= *p && *p <= 0x7e) ||
+ (0x80 <= *p && *p <= 0xa0)) {
+ return INT2FIX(_SJIS);
+ }
+ if (0xfd <= *p && *p <= 0xfe) {
+ return INT2FIX(_EUC);
+ }
+ }
+ INCR;
+ }
+ return INT2FIX(_UNKNOWN);
+}
+
+void
+Init_nkf()
+{
+ VALUE mKconv = rb_define_module("NKF");
+
+ rb_define_module_function(mKconv, "nkf", rb_nkf_kconv, 2);
+ rb_define_module_function(mKconv, "guess", rb_nkf_guess, 1);
+
+ rb_define_const(mKconv, "AUTO", INT2FIX(_AUTO));
+ rb_define_const(mKconv, "JIS", INT2FIX(_JIS));
+ rb_define_const(mKconv, "EUC", INT2FIX(_EUC));
+ rb_define_const(mKconv, "SJIS", INT2FIX(_SJIS));
+ rb_define_const(mKconv, "BINARY", INT2FIX(_BINARY));
+ rb_define_const(mKconv, "NOCONV", INT2FIX(_NOCONV));
+ rb_define_const(mKconv, "UNKNOWN", INT2FIX(_UNKNOWN));
+}
diff --git a/ext/nkf/orig/nkf.c b/ext/nkf/orig/nkf.c
new file mode 100644
index 0000000..8de08a8
--- /dev/null
+++ b/ext/nkf/orig/nkf.c
@@ -0,0 +1,1897 @@
+/** Network Kanji Filter. (PDS Version)
+************************************************************************
+** Copyright (C) 1987, Fujitsu LTD. (Itaru ICHIKAWA)
+** $BO"Mm@h!'(B $B!J3t!KIY;NDL8&5f=j!!%=%U%H#38&!!;T@n!!;j(B
+** $B!J(BE-Mail Address: ichikawa@flab.fujitsu.co.jp$B!K(B
+** Copyright (C) 1996,1998
+** $BO"Mm@h!'(B $BN05eBg3X>pJs9)3X2J(B $B2OLn(B $B??<#(B mine/X0208 support
+** $B!J(BE-Mail Address: kono@ie.u-ryukyu.ac.jp$B!K(B
+** $BO"Mm@h!'(B COW for DOS & Win16 & Win32 & OS/2
+** $B!J(BE-Mail Address: GHG00637@niftyserve.or.p$B!K(B
+** $B$3$N%=!<%9$N$$$+$J$kJ#<L!$2~JQ!$=$@5$b5vBz$7$^$9!#$?$@$7!"(B
+** $B$=$N:]$K$O!"C/$,9W8%$7$?$r<($9$3$NItJ,$r;D$9$3$H!#(B
+** $B:FG[I[$d;(;o$NIUO?$J$I$NLd$$9g$o$;$bI,MW$"$j$^$;$s!#(B
+** $B$3$N%W%m%0%i%`$K$D$$$F$OFC$K2?$NJ]>Z$b$7$J$$!"0-$7$+$i$:!#(B
+** Everyone is permitted to do anything on this program
+** including copying, modifying, improving.
+** as long as you don't try to pretend that you wrote it.
+** i.e., the above copyright notice has to appear in all copies.
+** You don't have to ask before copying or publishing.
+** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+***********************************************************************/
+
+static char *CopyRight =
+ "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),1998 S. Kono, COW";
+static char *Version =
+ "1.7";
+static char *Patchlevel =
+ "0/9711/Shinji Kono";
+
+/*
+**
+**
+**
+** USAGE: nkf [flags] [file]
+**
+** Flags:
+** b Output is bufferred (DEFAULT)
+** u Output is unbufferred
+**
+** t no operation
+**
+** j Outout code is JIS 7 bit (DEFAULT SELECT)
+** s Output code is MS Kanji (DEFAULT SELECT)
+** e Output code is AT&T JIS (DEFAULT SELECT)
+** l Output code is JIS 7bit and ISO8859-1 Latin-1
+**
+** m MIME conversion for ISO-2022-JP
+** i_ Output sequence to designate JIS-kanji (DEFAULT_J)
+** o_ Output sequence to designate single-byte roman characters (DEFAULT_R)
+**
+** r {de/en}crypt ROT13/47
+**
+** v display Version
+**
+** T Text mode output (for MS-DOS)
+**
+** x Do not convert X0201 kana into X0208
+** Z Convert X0208 alphabet to ASCII
+**
+** f60 fold option
+**
+** m MIME decode
+** B try to fix broken JIS, missing Escape
+** B[1-9] broken level
+**
+** O Output to 'nkf.out' file
+** d Delete \r in line feed
+** c Add \r in line feed
+**/
+/******************************/
+/* $B%G%U%)%k%H$N=PNO%3!<%IA*Br(B */
+/* Select DEFAULT_CODE */
+#define DEFAULT_CODE_JIS
+/* #define DEFAULT_CODE_SJIS */
+/* #define DEFAULT_CODE_EUC */
+/******************************/
+
+#if (defined(__TURBOC__) || defined(LSI_C)) && !defined(MSDOS)
+#define MSDOS
+#endif
+
+#ifndef PERL_XS
+#include <stdio.h>
+#endif
+
+#if defined(MSDOS) || defined(__OS2__)
+#include <stdlib.h>
+#include <fcntl.h>
+#include <io.h>
+#endif
+
+#ifdef MSDOS
+#ifdef LSI_C
+#define setbinmode(fp) fsetbin(fp)
+#else /* Microsoft C, Turbo C */
+#define setbinmode(fp) setmode(fileno(fp), O_BINARY)
+#endif
+#else /* UNIX,OS/2 */
+#define setbinmode(fp)
+#endif
+
+#ifdef _IOFBF /* SysV and MSDOS */
+#define setvbuffer(fp, buf, size) setvbuf(fp, buf, _IOFBF, size)
+#else /* BSD */
+#define setvbuffer(fp, buf, size) setbuffer(fp, buf, size)
+#endif
+
+/*Borland C++ 4.5 EasyWin*/
+#if defined(__TURBOC__) && defined(_Windows) && !defined(__WIN32__) /*Easy Win */
+#define EASYWIN
+#include <windows.h>
+#endif
+
+#define FALSE 0
+#define TRUE 1
+
+/* state of output_mode and input_mode */
+
+#define ASCII 0
+#define X0208 1
+#define X0201 2
+#define NO_X0201 3
+#define JIS_INPUT 4
+#define SJIS_INPUT 5
+#define LATIN1_INPUT 6
+#define FIXED_MIME 7
+#define DOUBLE_SPACE -2
+
+#define NL 0x0a
+#define ESC 0x1b
+#define SPACE 0x20
+#define AT 0x40
+#define SSP 0xa0
+#define DEL 0x7f
+#define SI 0x0f
+#define SO 0x0e
+#define SSO 0x8e
+
+#define HOLD_SIZE 32
+#define IOBUF_SIZE 16384
+
+#define DEFAULT_J 'B'
+#define DEFAULT_R 'B'
+
+#define SJ0162 0x00e1 /* 01 - 62 ku offset */
+#define SJ6394 0x0161 /* 63 - 94 ku offset */
+
+
+/* MIME preprocessor */
+
+#undef STRICT_MIME /* do stupid strict mime integrity check */
+#define GETC(p) ((!mime_mode)?getc(p):mime_getc(p))
+#define UNGETC(c,p) ((!mime_mode)?ungetc(c,p):mime_ungetc(c))
+
+
+#ifdef EASYWIN /*Easy Win */
+extern POINT _BufferSize;
+#endif
+
+/* function prototype */
+
+#ifndef _
+# ifdef __STDC__
+# define _(args) args
+# else
+# define _(args) ()
+# endif
+#endif
+
+#ifndef PERL_XS
+static void noconvert _((FILE *f));
+static int mime_integrity _((FILE *f,unsigned char *p));
+static int usage _((void));
+static char stdibuf[IOBUF_SIZE];
+static char stdobuf[IOBUF_SIZE];
+static unsigned int mime_input = 0; /* undecoded */
+static int end_check;
+#endif
+
+static void kanji_convert _((FILE *f));
+static void h_conv _((FILE *f,int c2,int c1));
+static int push_hold_buf _((int c2,int c1));
+static void s_iconv _((int c2,int c1));
+static void e_oconv _((int c2,int c1));
+static void s_oconv _((int c2,int c1));
+static void j_oconv _((int c2,int c1));
+static int line_fold _((int c2,int c1));
+static int pre_convert _((int c1,int c2));
+static int mime_begin _((FILE *f));
+static int mime_getc _((FILE *f));
+static int mime_ungetc _((unsigned int c));
+static int base64decode _((int c));
+static void arguments _((char *c));
+static void reinit _((void));
+
+/* buffers */
+
+static unsigned char hold_buf[HOLD_SIZE*2];
+static int hold_count;
+
+/* MIME preprocessor fifo */
+
+#define MIME_BUF_SIZE (1024) /* 2^n ring buffer */
+#define MIME_BUF_MASK (MIME_BUF_SIZE-1)
+#define Fifo(n) mime_buf[(n)&MIME_BUF_MASK]
+static unsigned char mime_buf[MIME_BUF_SIZE];
+static unsigned int mime_top = 0;
+static unsigned int mime_last = 0; /* decoded */
+
+/* flags */
+static int unbuf_f = FALSE;
+static int estab_f = FALSE;
+static int nop_f = FALSE;
+static int binmode_f = TRUE; /* binary mode */
+static int rot_f = FALSE; /* rot14/43 mode */
+static int input_f = FALSE; /* non fixed input code */
+static int alpha_f = FALSE; /* convert JIx0208 alphbet to ASCII */
+static int mime_f = TRUE; /* convert MIME B base64 or Q */
+static int mimebuf_f = FALSE; /* MIME buffered input */
+static int broken_f = FALSE; /* convert ESC-less broken JIS */
+static int iso8859_f = FALSE; /* ISO8859 through */
+#if defined(MSDOS) || defined(__OS2__)
+static int x0201_f = TRUE; /* Assume JISX0201 kana */
+#else
+static int x0201_f = NO_X0201; /* Assume NO JISX0201 */
+#endif
+
+/* X0208 -> ASCII converter */
+
+static int c1_return;
+
+/* fold parameter */
+static int line = 0; /* chars in line */
+static int prev = 0;
+static int fold_f = FALSE;
+static int fold_len = 0;
+
+/* options */
+static char kanji_intro = DEFAULT_J,
+ ascii_intro = DEFAULT_R;
+
+/* Folding */
+
+int line_fold();
+#define FOLD_MARGIN 10
+#define DEFAULT_FOLD 60
+
+/* converters */
+
+#ifdef DEFAULT_CODE_JIS
+# define DEFAULT_CONV j_oconv
+#endif
+#ifdef DEFAULT_CODE_SJIS
+# define DEFAULT_CONV s_oconv
+#endif
+#ifdef DEFAULT_CODE_EUC
+# define DEFAULT_CONV e_oconv
+#endif
+
+static void (*iconv)(int c2,int c1);
+ /* s_iconv or oconv */
+static void (*oconv)(int c2,int c1) = DEFAULT_CONV;
+ /* [ejs]_oconv */
+
+/* Global states */
+static int output_mode = ASCII, /* output kanji mode */
+ input_mode = ASCII, /* input kanji mode */
+ shift_mode = FALSE; /* TRUE shift out, or X0201 */
+static int mime_mode = FALSE; /* MIME mode B base64, Q hex */
+
+/* X0201 / X0208 conversion tables */
+
+/* X0201 kana conversion table */
+/* 90-9F A0-DF */
+unsigned char cv[]= {
+0x21,0x21,0x21,0x23,0x21,0x56,0x21,0x57,
+0x21,0x22,0x21,0x26,0x25,0x72,0x25,0x21,
+0x25,0x23,0x25,0x25,0x25,0x27,0x25,0x29,
+0x25,0x63,0x25,0x65,0x25,0x67,0x25,0x43,
+0x21,0x3c,0x25,0x22,0x25,0x24,0x25,0x26,
+0x25,0x28,0x25,0x2a,0x25,0x2b,0x25,0x2d,
+0x25,0x2f,0x25,0x31,0x25,0x33,0x25,0x35,
+0x25,0x37,0x25,0x39,0x25,0x3b,0x25,0x3d,
+0x25,0x3f,0x25,0x41,0x25,0x44,0x25,0x46,
+0x25,0x48,0x25,0x4a,0x25,0x4b,0x25,0x4c,
+0x25,0x4d,0x25,0x4e,0x25,0x4f,0x25,0x52,
+0x25,0x55,0x25,0x58,0x25,0x5b,0x25,0x5e,
+0x25,0x5f,0x25,0x60,0x25,0x61,0x25,0x62,
+0x25,0x64,0x25,0x66,0x25,0x68,0x25,0x69,
+0x25,0x6a,0x25,0x6b,0x25,0x6c,0x25,0x6d,
+0x25,0x6f,0x25,0x73,0x21,0x2b,0x21,0x2c,
+0x00,0x00};
+
+
+/* X0201 kana conversion table for daguten */
+/* 90-9F A0-DF */
+unsigned char dv[]= {
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x25,0x2c,0x25,0x2e,
+0x25,0x30,0x25,0x32,0x25,0x34,0x25,0x36,
+0x25,0x38,0x25,0x3a,0x25,0x3c,0x25,0x3e,
+0x25,0x40,0x25,0x42,0x25,0x45,0x25,0x47,
+0x25,0x49,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x25,0x50,0x25,0x53,
+0x25,0x56,0x25,0x59,0x25,0x5c,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00};
+
+/* X0201 kana conversion table for han-daguten */
+/* 90-9F A0-DF */
+unsigned char ev[]= {
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x25,0x51,0x25,0x54,
+0x25,0x57,0x25,0x5a,0x25,0x5d,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00};
+
+
+/* X0208 kigou conversion table */
+/* 0x8140 - 0x819e */
+unsigned char fv[] = {
+
+0x00,0x00,0x00,0x00,0x2c,0x2e,0x00,0x3a,
+0x3b,0x3f,0x21,0x00,0x00,0x27,0x60,0x00,
+0x5e,0x00,0x5f,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x2f,
+0x5c,0x00,0x00,0x7c,0x00,0x00,0x60,0x27,
+0x22,0x22,0x28,0x29,0x00,0x00,0x5b,0x5d,
+0x7b,0x7d,0x3c,0x3e,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x2b,0x2d,0x00,0x00,
+0x00,0x3d,0x00,0x3c,0x3e,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x24,0x00,0x00,0x25,0x23,0x26,0x2a,0x40,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+} ;
+
+
+static int file_out = FALSE;
+static int add_cr = FALSE;
+static int del_cr = FALSE;
+
+#ifndef PERL_XS
+int
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ FILE *fin;
+ char *cp;
+
+#ifdef EASYWIN /*Easy Win */
+ _BufferSize.y = 400;/*Set Scroll Buffer Size*/
+#endif
+
+ for (argc--,argv++; (argc > 0) && **argv == '-'; argc--, argv++) {
+ cp = *argv;
+ arguments(cp);
+ }
+
+ if(iso8859_f && (oconv != j_oconv || !x0201_f )) {
+ fprintf(stderr,"Mixed ISO8859/JISX0201/SJIS/EUC output is not allowed.\n");
+ exit(1);
+ }
+
+ if(binmode_f == TRUE)
+#ifdef __OS2__
+ if(freopen("","wb",stdout) == NULL)
+ return (-1);
+#else
+ setbinmode(stdout);
+#endif
+
+ if(unbuf_f)
+ setbuf(stdout, (char *) NULL);
+ else
+ setvbuffer(stdout, stdobuf, IOBUF_SIZE);
+
+ if(argc == 0) {
+ if(binmode_f == TRUE)
+#ifdef __OS2__
+ if(freopen("","rb",stdin) == NULL) return (-1);
+#else
+ setbinmode(stdin);
+#endif
+ setvbuffer(stdin, stdibuf, IOBUF_SIZE);
+ if(nop_f)
+ noconvert(stdin);
+ else
+ kanji_convert(stdin);
+ } else {
+ while (argc--) {
+ if((fin = fopen(*argv++, "r")) == NULL) {
+ perror(*--argv);
+ return(-1);
+ } else {
+/* reopen file for stdout */
+ if(file_out == TRUE){
+ if(argc == 1 ) {
+ if(freopen(*argv++, "w", stdout) == NULL) {
+ perror(*--argv);
+ return (-1);
+ }
+ argc--;
+ } else {
+ if(freopen("nkf.out", "w", stdout) == NULL) {
+ perror(*--argv);
+ return (-1);
+ }
+ }
+ if(binmode_f == TRUE) {
+#ifdef __OS2__
+ if(freopen("","wb",stdout) == NULL)
+ return (-1);
+#else
+ setbinmode(stdout);
+#endif
+ }
+ }
+ if(binmode_f == TRUE)
+#ifdef __OS2__
+ if(freopen("","rb",fin) == NULL)
+ return (-1);
+#else
+ setbinmode(fin);
+#endif
+ setvbuffer(fin, stdibuf, IOBUF_SIZE);
+ if(nop_f)
+ noconvert(fin);
+ else
+ kanji_convert(fin);
+ fclose(fin);
+ }
+ }
+ }
+#ifdef EASYWIN /*Easy Win */
+ if(file_out == FALSE)
+ scanf("%d",&end_check);
+ else
+ fclose(stdout);
+#else /* for Other OS */
+ if(file_out == TRUE)
+ fclose(stdout);
+#endif
+ return (0);
+}
+#endif
+
+void
+arguments(cp)
+ char *cp;
+{
+ while (*cp) {
+ switch (*cp++) {
+ case 'b': /* buffered mode */
+ unbuf_f = FALSE;
+ continue;
+ case 'u': /* non bufferd mode */
+ unbuf_f = TRUE;
+ continue;
+ case 't': /* transparent mode */
+ nop_f = TRUE;
+ continue;
+ case 'j': /* JIS output */
+ case 'n':
+ oconv = j_oconv;
+ continue;
+ case 'e': /* AT&T EUC output */
+ oconv = e_oconv;
+ continue;
+ case 's': /* SJIS output */
+ oconv = s_oconv;
+ continue;
+ case 'l': /* ISO8859 Latin-1 support, no conversion */
+ iso8859_f = TRUE; /* Only compatible with ISO-2022-JP */
+ input_f = LATIN1_INPUT;
+ continue;
+ case 'i': /* Kanji IN ESC-$-@/B */
+ if(*cp=='@'||*cp=='B')
+ kanji_intro = *cp++;
+ continue;
+ case 'o': /* ASCII IN ESC-(-J/B */
+ if(*cp=='J'||*cp=='B'||*cp=='H')
+ ascii_intro = *cp++;
+ continue;
+ case 'r':
+ rot_f = TRUE;
+ continue;
+#if defined(MSDOS) || defined(__OS2__)
+ case 'T':
+ binmode_f = FALSE;
+ continue;
+#endif
+#ifndef PERL_XS
+ case 'v':
+ usage();
+ exit(1);
+ break;
+#endif
+ /* Input code assumption */
+ case 'J': /* JIS input */
+ case 'E': /* AT&T EUC input */
+ input_f = JIS_INPUT;
+ continue;
+ case 'S': /* MS Kanji input */
+ input_f = SJIS_INPUT;
+ if(x0201_f==NO_X0201) x0201_f=TRUE;
+ continue;
+ case 'Z': /* Convert X0208 alphabet to asii */
+ /* bit:0 Convert X0208
+ bit:1 Convert Kankaku to one space
+ bit:2 Convert Kankaku to two spaces
+ */
+ if('9'>= *cp && *cp>='0')
+ alpha_f |= 1<<(*cp++ -'0');
+ else
+ alpha_f |= TRUE;
+ continue;
+ case 'x': /* Convert X0201 kana to X0208 or X0201 Conversion */
+ x0201_f = FALSE; /* No X0201->X0208 conversion */
+ /* accept X0201
+ ESC-(-I in JIS, EUC, MS Kanji
+ SI/SO in JIS, EUC, MS Kanji
+ SSO in EUC, JIS, not in MS Kanji
+ MS Kanji (0xa0-0xdf)
+ output X0201
+ ESC-(-I in JIS (0x20-0x5f)
+ SSO in EUC (0xa0-0xdf)
+ 0xa0-0xd in MS Kanji (0xa0-0xdf)
+ */
+ continue;
+ case 'X': /* Assume X0201 kana */
+ /* Default value is NO_X0201 for EUC/MS-Kanji mix */
+ x0201_f = TRUE;
+ continue;
+ case 'f': /* folding -f60 or -f */
+ fold_f = TRUE;
+ fold_len = atoi(cp);
+ if(!(0<fold_len && fold_len<BUFSIZ))
+ fold_len = DEFAULT_FOLD;
+ while('0'<= *cp && *cp <='9') cp++;
+ continue;
+ case 'm': /* MIME support */
+ mime_f = TRUE;
+ if(*cp=='B'||*cp=='Q') {
+ mime_mode = *cp++;
+ mimebuf_f = FIXED_MIME;
+ } else if (*cp=='0') {
+ mime_f = FALSE;
+ }
+ continue;
+ case 'M': /* MIME output */
+ oconv = j_oconv; /* sorry... not yet done.. */
+ continue;
+ case 'B': /* Broken JIS support */
+ /* bit:0 no ESC JIS
+ bit:1 allow any x on ESC-(-x or ESC-$-x
+ bit:2 reset to ascii on NL
+ */
+ if('9'>= *cp && *cp>='0')
+ broken_f |= 1<<(*cp++ -'0');
+ else
+ broken_f |= TRUE;
+ continue;
+#ifndef PERL_XS
+ case 'O':/* for Output file */
+ file_out = TRUE;
+ continue;
+#endif
+ case 'c':/* add cr code */
+ add_cr = TRUE;
+ continue;
+ case 'd':/* delete cr code */
+ del_cr = TRUE;
+ continue;
+ default:
+ /* bogus option but ignored */
+ continue;
+ }
+ }
+}
+
+#ifndef PERL_XS
+static void
+noconvert(f)
+ FILE *f;
+{
+ int c;
+
+ while ((c = getc(f)) != EOF)
+ putchar(c);
+}
+#endif
+
+
+static void
+kanji_convert(f)
+ FILE *f;
+{
+ int c1, c2;
+
+ c2 = 0;
+
+ if(input_f == JIS_INPUT || input_f == LATIN1_INPUT) {
+ estab_f = TRUE; iconv = oconv;
+ } else if(input_f == SJIS_INPUT) {
+ estab_f = TRUE; iconv = s_iconv;
+ } else {
+ estab_f = FALSE; iconv = oconv;
+ }
+ input_mode = ASCII;
+ output_mode = ASCII;
+ shift_mode = FALSE;
+
+#define NEXT continue /* no output, get next */
+#define SEND ; /* output c1 and c2, get next */
+#define LAST break /* end of loop, go closing */
+
+ while ((c1 = GETC(f)) != EOF) {
+ if(c2) {
+ /* second byte */
+ if(c2 > DEL) {
+ /* in case of 8th bit is on */
+ if(!estab_f) {
+ /* in case of not established yet */
+ if(c1 > SSP) {
+ /* It is still ambiguious */
+ h_conv(f, c2, c1);
+ c2 = 0;
+ NEXT;
+ } else if(c1 < AT) {
+ /* ignore bogus code */
+ c2 = 0;
+ NEXT;
+ } else {
+ /* established */
+ /* it seems to be MS Kanji */
+ estab_f = TRUE;
+ iconv = s_iconv;
+ SEND;
+ }
+ } else
+ /* in case of already established */
+ if(c1 < AT) {
+ /* ignore bogus code */
+ c2 = 0;
+ NEXT;
+ } else
+ SEND;
+ } else
+ /* 7 bit code */
+ /* it might be kanji shitfted */
+ if((c1 == DEL) || (c1 <= SPACE)) {
+ /* ignore bogus first code */
+ c2 = 0;
+ NEXT;
+ } else
+ SEND;
+ } else {
+ /* first byte */
+ if(c1 > DEL) {
+ /* 8 bit code */
+ if(!estab_f && !iso8859_f) {
+ /* not established yet */
+ if(c1 < SSP) {
+ /* it seems to be MS Kanji */
+ estab_f = TRUE;
+ iconv = s_iconv;
+ } else if(c1 < 0xe0) {
+ /* it seems to be EUC */
+ estab_f = TRUE;
+ iconv = oconv;
+ } else {
+ /* still ambiguious */
+ }
+ c2 = c1;
+ NEXT;
+ } else { /* estab_f==TRUE */
+ if(iso8859_f) {
+ SEND;
+ } else if(SSP<=c1 && c1<0xe0 && iconv == s_iconv) {
+ /* SJIS X0201 Case... */
+ /* This is too arrogant, but ... */
+ if(x0201_f==NO_X0201) {
+ iconv = oconv;
+ c2 = c1;
+ NEXT;
+ } else
+ if(x0201_f) {
+ if(dv[(c1-SSP)*2]||ev[(c1-SSP)*2]) {
+ /* look ahead for X0201/X0208conversion */
+ if((c2 = GETC(f)) == EOF) {
+ (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]);
+ LAST;
+ } else if(c2==(0xde)) { /* $BByE@(B */
+ (*oconv)(dv[(c1-SSP)*2],dv[(c1-SSP)*2+1]);
+ c2=0;
+ NEXT;
+ } else if(c2==(0xdf)&&ev[(c1-SSP)*2]) {
+ /* $BH>ByE@(B */
+ (*oconv)(ev[(c1-SSP)*2],ev[(c1-SSP)*2+1]);
+ c2=0;
+ NEXT;
+ }
+ UNGETC(c2,f); c2 = 0;
+ }
+ (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]);
+ NEXT;
+ } else
+ SEND;
+ } else if(c1==SSO && iconv != s_iconv) {
+ /* EUC X0201 Case */
+ /* This is too arrogant
+ if(x0201_f == NO_X0201) {
+ estab_f = FALSE;
+ c2 = 0;
+ NEXT;
+ } */
+ c1 = GETC(f); /* skip SSO */
+ euc_1byte_check:
+ if(x0201_f && SSP<=c1 && c1<0xe0) {
+ if(dv[(c1-SSP)*2]||ev[(c1-SSP)*2]) {
+ if((c2 = GETC(f)) == EOF) {
+ (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]);
+ LAST;
+ }
+ /* forward lookup $BByE@(B/$BH>ByE@(B */
+ if(c2 != SSO) {
+ UNGETC(c2,f); c2 = 0;
+ (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]);
+ NEXT;
+ } else if((c2 = GETC(f)) == EOF) {
+ (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]);
+ (*oconv)(0,SSO);
+ LAST;
+ } else if(c2==(0xde)) { /* $BByE@(B */
+ (*oconv)(dv[(c1-SSP)*2],dv[(c1-SSP)*2+1]);
+ c2=0;
+ NEXT;
+ } else if(c2==(0xdf)&&ev[(c1-SSP)*2]) {
+ /* $BH>ByE@(B */
+ (*oconv)(ev[(c1-SSP)*2],ev[(c1-SSP)*2+1]);
+ c2=0;
+ NEXT;
+ } else {
+ (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]);
+ /* we have to check this c2 */
+ /* and no way to push back SSO */
+ c1 = c2; c2 = 0;
+ goto euc_1byte_check;
+ }
+ }
+ (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]);
+ NEXT;
+ } else
+ SEND;
+ } else if(c1 < SSP && iconv != s_iconv) {
+ /* strange code in EUC */
+ iconv = s_iconv; /* try SJIS */
+ c2 = c1;
+ NEXT;
+ } else {
+ /* already established */
+ c2 = c1;
+ NEXT;
+ }
+ }
+ } else if((c1 > SPACE) && (c1 != DEL)) {
+ /* in case of Roman characters */
+ if(shift_mode) {
+ c1 |= 0x80;
+ /* output 1 shifted byte */
+ if(x0201_f && (!iso8859_f||input_mode==X0201) &&
+ SSP<=c1 && c1<0xe0 ) {
+ if(dv[(c1-SSP)*2]||ev[(c1-SSP)*2]) {
+ if((c2 = GETC(f)) == EOF) {
+ (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]);
+ LAST;
+ } else if(c2==(0xde&0x7f)) { /* $BByE@(B */
+ (*oconv)(dv[(c1-SSP)*2],dv[(c1-SSP)*2+1]);
+ c2=0;
+ NEXT;
+ } else if(c2==(0xdf&0x7f)&&ev[(c1-SSP)*2]) {
+ /* $BH>ByE@(B */
+ (*oconv)(ev[(c1-SSP)*2],ev[(c1-SSP)*2+1]);
+ c2=0;
+ NEXT;
+ }
+ UNGETC(c2,f); c2 = 0;
+ }
+ (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]);
+ NEXT;
+ } else
+ SEND;
+ } else if(c1 == '(' && broken_f && input_mode == X0208
+ && !mime_mode ) {
+ /* Try to recover missing escape */
+ if((c1 = GETC(f)) == EOF) {
+ (*oconv)(0, '(');
+ LAST;
+ } else {
+ if(c1 == 'B' || c1 == 'J' || c1 == 'H') {
+ input_mode = ASCII; shift_mode = FALSE;
+ NEXT;
+ } else {
+ (*oconv)(0, '(');
+ /* do not modify various input_mode */
+ /* It can be vt100 sequence */
+ SEND;
+ }
+ }
+ } else if(input_mode == X0208) {
+ /* in case of Kanji shifted */
+ c2 = c1;
+ NEXT;
+ /* goto next_byte */
+ } else if(c1 == '=' && mime_f && !mime_mode ) {
+ if((c1 = getc(f)) == EOF) {
+ (*oconv)(0, '=');
+ LAST;
+ } else if(c1 == '?') {
+ /* =? is mime conversiooon start sequence */
+ if(mime_begin(f) == EOF) /* check in detail */
+ LAST;
+ else
+ NEXT;
+ } else {
+ (*oconv)(0, '=');
+ ungetc(c1,f);
+ NEXT;
+ }
+ } else if(c1 == '$' && broken_f && !mime_mode) {
+ /* try to recover missing escape */
+ if((c1 = GETC(f)) == EOF) {
+ (*oconv)(0, '$');
+ LAST;
+ } else if(c1 == '@'|| c1 == 'B') {
+ /* in case of Kanji in ESC sequence */
+ input_mode = X0208;
+ shift_mode = FALSE;
+ NEXT;
+ } else {
+ /* sorry */
+ (*oconv)(0, '$');
+ (*oconv)(0, c1);
+ NEXT;
+ }
+ } else
+ SEND;
+ } else if(c1 == SI) {
+ shift_mode = FALSE;
+ NEXT;
+ } else if(c1 == SO) {
+ shift_mode = TRUE;
+ NEXT;
+ } else if(c1 == ESC ) {
+ if((c1 = GETC(f)) == EOF) {
+ (*oconv)(0, ESC);
+ LAST;
+ } else if(c1 == '$') {
+ if((c1 = GETC(f)) == EOF) {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$');
+ LAST;
+ } else if(c1 == '@'|| c1 == 'B') {
+ /* This is kanji introduction */
+ input_mode = X0208;
+ shift_mode = FALSE;
+ NEXT;
+ } else if(c1 == '(') {
+ if((c1 = GETC(f)) == EOF) {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$');
+ (*oconv)(0, '(');
+ LAST;
+ } else if(c1 == '@'|| c1 == 'B') {
+ /* This is kanji introduction */
+ input_mode = X0208;
+ shift_mode = FALSE;
+ NEXT;
+ } else {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$');
+ (*oconv)(0, '(');
+ (*oconv)(0, c1);
+ NEXT;
+ }
+ } else if(broken_f&0x2) {
+ input_mode = X0208;
+ shift_mode = FALSE;
+ NEXT;
+ } else {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$');
+ (*oconv)(0, c1);
+ NEXT;
+ }
+ } else if(c1 == '(') {
+ if((c1 = GETC(f)) == EOF) {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '(');
+ LAST;
+ } else {
+ if(c1 == 'I') {
+ /* This is X0201 kana introduction */
+ input_mode = X0201; shift_mode = X0201;
+ NEXT;
+ } else if(c1 == 'B' || c1 == 'J' || c1 == 'H') {
+ /* This is X0208 kanji introduction */
+ input_mode = ASCII; shift_mode = FALSE;
+ NEXT;
+ } else if(broken_f&0x2) {
+ input_mode = ASCII; shift_mode = FALSE;
+ NEXT;
+ } else {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '(');
+ /* maintain various input_mode here */
+ SEND;
+ }
+ }
+ } else {
+ /* lonely ESC */
+ (*oconv)(0, ESC);
+ SEND;
+ }
+ } else if(c1 == NL && broken_f&4) {
+ input_mode = ASCII;
+ SEND;
+ } else
+ SEND;
+ }
+ /* send: */
+ if(input_mode == X0208)
+ (*oconv)(c2, c1); /* this is JIS, not SJIS/EUC case */
+ else
+ (*iconv)(c2, c1); /* can be EUC/SJIS */
+ c2 = 0;
+ continue;
+ /* goto next_word */
+ }
+
+ /* epilogue */
+ (*iconv)(EOF, 0);
+}
+
+
+
+
+static void
+h_conv(f, c2, c1)
+ FILE *f;
+ int c1, c2;
+{
+ int wc;
+
+
+ /** it must NOT be in the kanji shifte sequence */
+ /** it must NOT be written in JIS7 */
+ /** and it must be after 2 byte 8bit code */
+
+ hold_count = 0;
+ push_hold_buf(c2, c1);
+ c2 = 0;
+
+ while ((c1 = GETC(f)) != EOF) {
+ if(c2) {
+ /* second byte */
+ if(!estab_f) {
+ /* not established */
+ if(c1 > SSP) {
+ /* it is still ambiguious yet */
+ SEND;
+ } else if(c1 < AT) {
+ /* ignore bogus first byte */
+ c2 = 0;
+ SEND;
+ } else {
+ /* now established */
+ /* it seems to be MS Kanji */
+ estab_f = TRUE;
+ iconv = s_iconv;
+ SEND;
+ }
+ } else
+ SEND;
+ } else {
+ /* First byte */
+ if(c1 > DEL) {
+ /* 8th bit is on */
+ if(c1 < SSP) {
+ /* it seems to be MS Kanji */
+ estab_f = TRUE;
+ iconv = s_iconv;
+ } else if(c1 < 0xe0) {
+ /* it seems to be EUC */
+ estab_f = TRUE;
+ iconv = oconv;
+ } else {
+ /* still ambiguious */
+ }
+ c2 = c1;
+ NEXT;
+ } else
+ /* 7 bit code , then send without any process */
+ SEND;
+ }
+ /* send: */
+ if((push_hold_buf(c2, c1) == EOF) || estab_f)
+ break;
+ c2 = 0;
+ continue;
+ }
+
+ /** now,
+ ** 1) EOF is detected, or
+ ** 2) Code is established, or
+ ** 3) Buffer is FULL (but last word is pushed)
+ **
+ ** in 1) and 3) cases, we continue to use
+ ** Kanji codes by oconv and leave estab_f unchanged.
+ **/
+
+ for (wc = 0; wc < hold_count; wc += 2) {
+ c2 = hold_buf[wc];
+ c1 = hold_buf[wc+1];
+ (*iconv)(c2, c1);
+ }
+ return;
+}
+
+
+
+int
+push_hold_buf(c2, c1)
+ int c2, c1;
+{
+ if(hold_count >= HOLD_SIZE*2)
+ return (EOF);
+ hold_buf[hold_count++] = c2;
+ hold_buf[hold_count++] = c1;
+ return ((hold_count >= HOLD_SIZE*2) ? EOF : hold_count);
+}
+
+
+static void
+s_iconv(c2, c1)
+ int c2,
+ c1;
+{
+ if((c2 == EOF) || (c2 == 0)) {
+ /* NOP */
+ } else {
+ c2 = c2 + c2 - ((c2 <= 0x9f) ? SJ0162 : SJ6394);
+ if(c1 < 0x9f)
+ c1 = c1 - ((c1 > DEL) ? SPACE : 0x1f);
+ else {
+ c1 = c1 - 0x7e;
+ c2++;
+ }
+ }
+ (*oconv)(c2, c1);
+}
+
+
+static void
+e_oconv(c2, c1)
+ int c2, c1;
+{
+ c2 = pre_convert(c1,c2); c1 = c1_return;
+ if(fold_f) {
+ switch(line_fold(c2,c1)) {
+ case '\n':
+ if(add_cr == TRUE) {
+ putchar('\r');
+ c1 = '\n';
+ }
+ putchar('\n');
+ break;
+ case 0: return;
+ case '\r':
+ c1 = '\n'; c2 = 0;
+ break;
+ case '\t':
+ case ' ':
+ c1 = ' '; c2 = 0;
+ break;
+ }
+ }
+ if(c2==DOUBLE_SPACE) {
+ putchar(' '); putchar(' ');
+ return;
+ }
+ if(c2 == EOF)
+ return;
+ else if(c2 == 0 && (c1&0x80)) {
+ putchar(SSO); putchar(c1);
+ } else if(c2 == 0) {
+ if(c1 == '\n' && add_cr == TRUE)
+ putchar('\r');
+ if(c1 != '\r')
+ putchar(c1);
+ else if(del_cr == FALSE)
+ putchar(c1);
+ } else {
+ if((c1<0x20 || 0x7e<c1) ||
+ (c2<0x20 || 0x7e<c2)) {
+ estab_f = FALSE;
+ return; /* too late to rescue this char */
+ }
+ putchar(c2 | 0x080);
+ putchar(c1 | 0x080);
+ }
+ return;
+}
+
+
+static void
+s_oconv(c2, c1)
+ int c2, c1;
+{
+ c2 = pre_convert(c1,c2); c1 = c1_return;
+ if(fold_f) {
+ switch(line_fold(c2,c1)) {
+ case '\n':
+ if(add_cr == TRUE) {
+ putchar('\r');
+ c1 = '\n';
+ }
+ putchar('\n');
+ break;
+ case '\r':
+ c1 = '\n'; c2 = 0;
+ break;
+ case 0: return;
+ case '\t':
+ case ' ':
+ c1 = ' '; c2 = 0;
+ break;
+ }
+ }
+ if(c2==DOUBLE_SPACE) {
+ putchar(' '); putchar(' ');
+ return;
+ }
+ if(c2 == EOF)
+ return;
+ else if(c2 == 0) {
+ if(c1 == '\n' && add_cr == TRUE)
+ putchar('\r');
+ if(c1 != '\r')
+ putchar(c1);
+ else if(del_cr == FALSE)
+ putchar(c1);
+ } else {
+ if((c1<0x20 || 0x7e<c1) ||
+ (c2<0x20 || 0x7e<c2)) {
+ estab_f = FALSE;
+ return; /* too late to rescue this char */
+ }
+ putchar((((c2 - 1) >> 1) + ((c2 <= 0x5e) ? 0x71 : 0xb1)));
+ putchar((c1 + ((c2 & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e)));
+ }
+ return;
+}
+
+
+static void
+j_oconv(c2, c1)
+ int c2, c1;
+{
+ c2 = pre_convert(c1,c2); c1 = c1_return;
+ if(fold_f) {
+ switch(line_fold(c2,c1)) {
+ case '\n':
+ if(output_mode) {
+ putchar(ESC);
+ putchar('(');
+ putchar(ascii_intro);
+ }
+ if(add_cr == TRUE) {
+ putchar('\r');
+ c1 = '\n';
+ }
+ putchar('\n');
+ output_mode = ASCII;
+ break;
+ case '\r':
+ c1 = '\n'; c2 = 0;
+ break;
+ case '\t':
+ case ' ':
+ c1 = ' '; c2 = 0;
+ break;
+ case 0: return;
+ }
+ }
+ if(c2 == EOF) {
+ if(output_mode) {
+ putchar(ESC);
+ putchar('(');
+ putchar(ascii_intro);
+ }
+ } else if(c2 == 0 && (c1 & 0x80)) {
+ if(input_mode==X0201 || !iso8859_f) {
+ if(output_mode!=X0201) {
+ putchar(ESC);
+ putchar('(');
+ putchar('I');
+ output_mode = X0201;
+ }
+ c1 &= 0x7f;
+ } else {
+ /* iso8859 introduction, or 8th bit on */
+ /* Can we convert in 7bit form using ESC-'-'-A ?
+ Is this popular? */
+ }
+ putchar(c1);
+ } else if(c2 == 0) {
+ if(output_mode) {
+ putchar(ESC);
+ putchar('(');
+ putchar(ascii_intro);
+ output_mode = ASCII;
+ }
+ if(c1 == '\n' && add_cr == TRUE)
+ putchar('\r');
+ if(c1 != '\r')
+ putchar(c1);
+ else if(del_cr == FALSE)
+ putchar(c1);
+ } else if(c2 == DOUBLE_SPACE) {
+ if(output_mode) {
+ putchar(ESC);
+ putchar('(');
+ putchar(ascii_intro);
+ output_mode = ASCII;
+ }
+ putchar(' ');
+ if(c1 == '\n' && add_cr == TRUE)
+ putchar('\r');
+ if(c1 != '\r')
+ putchar(c1);
+ else if(del_cr == FALSE)
+ putchar(c1);
+ } else {
+ if(output_mode != X0208) {
+ putchar(ESC);
+ putchar('$');
+ putchar(kanji_intro);
+ output_mode = X0208;
+ }
+ if(c1<0x20 || 0x7e<c1)
+ return;
+ if(c2<0x20 || 0x7e<c2)
+ return;
+ putchar(c2);
+ if(c1 == '\n' && add_cr == TRUE)
+ putchar('\r');
+ if(c1 != '\r')
+ putchar(c1);
+ else if(del_cr == FALSE)
+ putchar(c1);
+ }
+ return;
+}
+
+
+
+#define rot13(c) ( \
+ ( c < 'A' ) ? c: \
+ (c <= 'M') ? (c + 13): \
+ (c <= 'Z') ? (c - 13): \
+ (c < 'a') ? (c): \
+ (c <= 'm') ? (c + 13): \
+ (c <= 'z') ? (c - 13): \
+ (c) \
+)
+
+#define rot47(c) ( \
+ ( c < '!' ) ? c: \
+ ( c <= 'O' ) ? (c + 47) : \
+ ( c <= '~' ) ? (c - 47) : \
+ c \
+)
+
+
+/*
+ Return value of line_fold()
+
+ \n add newline and output char
+ \r add newline and output nothing
+ ' ' space
+ 0 skip
+ 1 (or else) normal output
+
+ fold state in prev (previous character)
+
+ >0x80 Japanese (X0208/X0201)
+ <0x80 ASCII
+ \n new line
+ ' ' space
+
+ This fold algorthm does not preserve heading space in a line.
+ This is the main difference from fmt.
+*/
+
+int
+line_fold(c2,c1)
+int c2,c1;
+{
+ int prev0;
+ if(c1=='\r')
+ return 0; /* ignore cr */
+ if(c1== 8) {
+ if(line>0) line--;
+ return 1;
+ }
+ if(c2==EOF && line != 0) /* close open last line */
+ return '\n';
+ /* new line */
+ if(c1=='\n') {
+ if(prev == c1) { /* duplicate newline */
+ if(line) {
+ line = 0;
+ return '\n'; /* output two newline */
+ } else {
+ line = 0;
+ return 1;
+ }
+ } else {
+ if(prev&0x80) { /* Japanese? */
+ prev = c1;
+ return 0; /* ignore given single newline */
+ } else if(prev==' ') {
+ return 0;
+ } else {
+ prev = c1;
+ if(++line<=fold_len)
+ return ' ';
+ else {
+ line = 0;
+ return '\r'; /* fold and output nothing */
+ }
+ }
+ }
+ }
+ if(c1=='\f') {
+ prev = '\n';
+ if(line==0)
+ return 1;
+ line = 0;
+ return '\n'; /* output newline and clear */
+ }
+ /* X0208 kankaku or ascii space */
+ if( (c2==0&&c1==' ')||
+ (c2==0&&c1=='\t')||
+ (c2==DOUBLE_SPACE)||
+ (c2=='!'&& c1=='!')) {
+ if(prev == ' ') {
+ return 0; /* remove duplicate spaces */
+ }
+ prev = ' ';
+ if(++line<=fold_len)
+ return ' '; /* output ASCII space only */
+ else {
+ prev = ' '; line = 0;
+ return '\r'; /* fold and output nothing */
+ }
+ }
+ prev0 = prev; /* we still need this one... , but almost done */
+ prev = c1;
+ if(c2 || (SSP<=c1 && c1<=0xdf))
+ prev |= 0x80; /* this is Japanese */
+ line += (c2==0)?1:2;
+ if(line<=fold_len) { /* normal case */
+ return 1;
+ }
+ if(line>=fold_len+FOLD_MARGIN) { /* too many kinsou suspension */
+ line = (c2==0)?1:2;
+ return '\n'; /* We can't wait, do fold now */
+ }
+ /* simple kinsoku rules return 1 means no folding */
+ if(c2==0) {
+ if(c1==0xde) return 1; /* $B!+(B*/
+ if(c1==0xdf) return 1; /* $B!,(B*/
+ if(c1==0xa4) return 1; /* $B!#(B*/
+ if(c1==0xa3) return 1; /* $B!$(B*/
+ if(c1==0xa1) return 1; /* $B!W(B*/
+ if(c1==0xb0) return 1; /* - */
+ if(SSP<=c1 && c1<=0xdf) { /* X0201 */
+ line = 1;
+ return '\n';/* add one new line before this character */
+ }
+ /* fold point in ASCII { [ ( */
+ if(( c1!=')'&&
+ c1!=']'&&
+ c1!='}'&&
+ c1!='.'&&
+ c1!=','&&
+ c1!='!'&&
+ c1!='?'&&
+ c1!='/'&&
+ c1!=':'&&
+ c1!=';')&&
+ ((prev0=='\n')|| (prev0==' ')|| /* ignored new line */
+ (prev0&0x80)) /* X0208 - ASCII */
+ ) {
+ line = 1;
+ return '\n';/* add one new line before this character */
+ }
+ return 1; /* default no fold in ASCII */
+ } else {
+ if(c2=='!') {
+ if(c1=='"') return 1; /* $B!"(B */
+ if(c1=='#') return 1; /* $B!#(B */
+ if(c1=='$') return 1; /* $B!$(B */
+ if(c1=='%') return 1; /* $B!%(B */
+ if(c1=='\'') return 1; /* $B!\(B */
+ if(c1=='(') return 1; /* $B!((B */
+ if(c1==')') return 1; /* $B!)(B */
+ if(c1=='*') return 1; /* $B!*(B */
+ if(c1=='+') return 1; /* $B!+(B */
+ if(c1==',') return 1; /* $B!,(B */
+ }
+ line = 2;
+ return '\n'; /* add one new line before this character */
+ }
+}
+
+int
+pre_convert(c1,c2)
+ int c1,c2;
+{
+ if(c2) c1 &= 0x7f;
+ c1_return = c1;
+ if(c2==EOF) return c2;
+ c2 &= 0x7f;
+ if(rot_f) {
+ if(c2) {
+ c1 = rot47(c1);
+ c2 = rot47(c2);
+ } else {
+ if(!(c1 & 0x80))
+ c1 = rot13(c1);
+ }
+ c1_return = c1;
+ }
+ /* JISX0208 Alphabet */
+ if(alpha_f && c2 == 0x23 ) return 0;
+ /* JISX0208 Kigou */
+ if(alpha_f && c2 == 0x21 ) {
+ if(0x21==c1) {
+ if(alpha_f&0x2) {
+ c1_return = ' ';
+ return 0;
+ } else if(alpha_f&0x4) {
+ c1_return = ' ';
+ return DOUBLE_SPACE;
+ } else {
+ return c2;
+ }
+ } else if(0x20<c1 && c1<0x7f && fv[c1-0x20]) {
+ c1_return = fv[c1-0x20];
+ return 0;
+ }
+ }
+ return c2;
+}
+
+
+#ifdef STRICT_MIME
+/* This converts */
+
+unsigned char *mime_pattern[] = {
+ (unsigned char *)"\075?ISO-8859-1?Q?",
+ (unsigned char *)"\075?ISO-2022-JP?B?",
+ (unsigned char *)"\075?ISO-2022-JP?Q?",
+ (unsigned char *)"\075?JAPANESE_EUC?B?",
+ (unsigned char *)"\075?SHIFT_JIS?B?",
+ NULL
+};
+
+int mime_encode[] = {
+ 'Q', 'B', 'Q',
+ 0
+};
+#endif
+
+#define MAXRECOVER 20
+int iso8859_f_save;
+
+#ifdef STRICT_MIME
+
+#define nkf_toupper(c) (('a'<=c && c<='z')?(c-('a'-'A')):c)
+/* I don't trust portablity of toupper */
+
+int
+mime_begin(f)
+ FILE *f;
+{
+ int c1;
+ int i,j,k;
+ unsigned char *p,*q;
+ int r[MAXRECOVER]; /* recovery buffer, max mime pattern lenght */
+
+ mime_mode = FALSE;
+ /* =? has been checked */
+ j = 0;
+ p = mime_pattern[j];
+ r[0]='='; r[1]='?';
+
+ for(i=2;p[i]>' ';i++) { /* start at =? */
+ if( ((((r[i] = c1 = getc(f))==EOF) || nkf_toupper(c1) != p[i] ) {
+ /* pattern fails, try next one */
+ q = p;
+ while (p = mime_pattern[++j]) {
+ for(k=2;k<i;k++) /* assume length(p) > i */
+ if(p[k]!=q[k]) break;
+ if(k==i && nkf_toupper(c1)==p[k]) break;
+ }
+ if(p) continue; /* found next one, continue */
+ /* all fails, output from recovery buffer */
+ ungetc(c1,f);
+ for(j=0;j<i;j++) {
+ (*oconv)(0,r[j]);
+ }
+ return c1;
+ }
+ }
+ mime_mode = mime_encode[j];
+ iso8859_f_save = iso8859_f;
+ if(j==0) {
+ iso8859_f = TRUE;
+ }
+ if(mime_mode=='B') {
+ mimebuf_f = unbuf_f;
+ if(!unbuf_f) {
+ /* do MIME integrity check */
+ return mime_integrity(f,mime_pattern[j]);
+ }
+ }
+ mimebuf_f = TRUE;
+ return c1;
+}
+
+#define mime_getc0(f) (mimebuf_f?getc(f):Fifo(mime_input++))
+#define mime_ungetc0(c,f) (mimebuf_f?ungetc(c,f):mime_input--)
+
+#else
+int
+mime_begin(f)
+FILE *f;
+{
+ int c1;
+ int i,j,k;
+ int r[MAXRECOVER]; /* recovery buffer, max mime pattern lenght */
+
+ mime_mode = FALSE;
+ /* =? has been checked */
+ j = 0;
+ r[0]='='; r[1]='?';
+ for(i=2;i<MAXRECOVER;i++) { /* start at =? */
+ /* We accept any charcter type even if it is breaked by new lines */
+ if( (r[i] = c1 = getc(f))==EOF) break;
+ if(c1=='=') break;
+ if(c1<' '&& c1!='\r' && c1!='\n') break;
+ if(c1=='?') {
+ i++;
+ if(!(i<MAXRECOVER) || (r[i] = c1 = getc(f))==EOF) break;
+ if(c1=='b'||c1=='B') {
+ mime_mode = 'B';
+ } else if(c1=='q'||c1=='Q') {
+ mime_mode = 'Q';
+ } else {
+ break;
+ }
+ i++;
+ if(!(i<MAXRECOVER) || (r[i] = c1 = getc(f))==EOF) break;
+ if(c1=='?') {
+ break;
+ } else {
+ mime_mode = FALSE;
+ }
+ break;
+ }
+ }
+ if(!mime_mode || c1==EOF || i==MAXRECOVER) {
+ ungetc(c1,f);
+ for(j=0;j<i;j++) {
+ (*oconv)(0,r[j]);
+ }
+ return c1;
+ }
+ iso8859_f_save = iso8859_f;
+ /* do no MIME integrity check */
+ return c1; /* used only for checking EOF */
+}
+
+#define mime_getc0(f) getc(f)
+#define mime_ungetc0(c,f) ungetc(c,f)
+
+#endif
+
+int
+mime_getc(f)
+ FILE *f;
+{
+ int c1, c2, c3, c4, cc;
+ int t1, t2, t3, t4, mode, exit_mode;
+
+ if(mime_top != mime_last) { /* Something is in FIFO */
+ return Fifo(mime_top++);
+ }
+
+ if(mimebuf_f == FIXED_MIME)
+ exit_mode = mime_mode;
+ else
+ exit_mode = FALSE;
+ if(mime_mode == 'Q') {
+ if((c1 = mime_getc0(f)) == EOF) return (EOF);
+ if(c1=='_') return ' ';
+ if(c1!='=' && c1!='?')
+ return c1;
+ mime_mode = exit_mode; /* prepare for quit */
+ if(c1<=' ') return c1;
+ if((c2 = mime_getc0(f)) == EOF) return (EOF);
+ if(c2<=' ') return c2;
+ if(c1=='?'&&c2=='=') {
+ /* end Q encoding */
+ input_mode = exit_mode;
+ iso8859_f = iso8859_f_save;
+ return getc(f);
+ }
+ if(c1=='?') {
+ mime_mode = 'Q'; /* still in MIME */
+ mime_ungetc0(c2,f);
+ return c1;
+ }
+ if((c3 = mime_getc0(f)) == EOF) return (EOF);
+ if(c2<=' ') return c2;
+ mime_mode = 'Q'; /* still in MIME */
+#define hex(c) (('0'<=c&&c<='9')?(c-'0'):\
+ ('A'<=c&&c<='F')?(c-'A'+10):('a'<=c&&c<='f')?(c-'a'+10):0)
+ return ((hex(c2)<<4) + hex(c3));
+ }
+
+ if(mime_mode != 'B') {
+ mime_mode = FALSE;
+ return getc(f);
+ }
+
+
+ /* Base64 encoding */
+ /*
+ MIME allows line break in the middle of
+ Base64, but we are very pessimistic in decoding
+ in unbuf mode because MIME encoded code may broken by
+ less or editor's control sequence (such as ESC-[-K in unbuffered
+ mode. ignore incomplete MIME.
+ */
+ mode = mime_mode;
+ mime_mode = exit_mode; /* prepare for quit */
+
+ while ((c1 = mime_getc0(f))<=' ') {
+ if(c1==EOF)
+ return (EOF);
+ }
+ if((c2 = mime_getc0(f))<=' ') {
+ if(c2==EOF)
+ return (EOF);
+ if(mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ return c2;
+ }
+ if((c1 == '?') && (c2 == '=')) {
+ input_mode = ASCII;
+ while((c1 = getc(f))==' ' /* || c1=='\n' || c1=='\r' */);
+ return c1;
+ }
+ if((c3 = mime_getc0(f))<=' ') {
+ if(c3==EOF)
+ return (EOF);
+ if(mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ return c3;
+ }
+ if((c4 = mime_getc0(f))<=' ') {
+ if(c4==EOF)
+ return (EOF);
+ if(mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ return c4;
+ }
+
+ mime_mode = mode; /* still in MIME sigh... */
+
+ /* BASE 64 decoding */
+
+ t1 = 0x3f & base64decode(c1);
+ t2 = 0x3f & base64decode(c2);
+ t3 = 0x3f & base64decode(c3);
+ t4 = 0x3f & base64decode(c4);
+ cc = ((t1 << 2) & 0x0fc) | ((t2 >> 4) & 0x03);
+ if(c2 != '=') {
+ Fifo(mime_last++) = cc;
+ cc = ((t2 << 4) & 0x0f0) | ((t3 >> 2) & 0x0f);
+ if(c3 != '=') {
+ Fifo(mime_last++) = cc;
+ cc = ((t3 << 6) & 0x0c0) | (t4 & 0x3f);
+ if(c4 != '=')
+ Fifo(mime_last++) = cc;
+ }
+ } else {
+ return c1;
+ }
+ return Fifo(mime_top++);
+}
+
+int
+mime_ungetc(c)
+ unsigned int c;
+{
+ Fifo(mime_last++) = c;
+ return c;
+}
+
+#ifdef STRICT_MIME
+int
+mime_integrity(f,p)
+ FILE *f;
+ unsigned char *p;
+{
+ int c,d;
+ unsigned int q;
+ /* In buffered mode, read until =? or NL or buffer fffull
+ */
+ mime_input = mime_top;
+ mime_last = mime_top;
+ while(*p) Fifo(mime_input++) = *p++;
+ d = 0;
+ q = mime_input;
+ while((c=getc(f))!=EOF) {
+ if(((mime_input-mime_top)&MIME_BUF_MASK)==0) break;
+ if(c=='=' && d=='?') {
+ /* checked. skip header, start decode */
+ Fifo(mime_input++) = c;
+ mime_input = q;
+ return 1;
+ }
+ if(!( (c=='+'||c=='/'|| c=='=' || c=='?' ||
+ ('a'<=c && c<='z')||('A'<= c && c<='Z')||('0'<=c && c<='9'))))
+ break;
+ /* Should we check length mod 4? */
+ Fifo(mime_input++) = c;
+ d=c;
+ }
+ /* In case of Incomplete MIME, no MIME decode */
+ Fifo(mime_input++) = c;
+ mime_last = mime_input; /* point undecoded buffer */
+ mime_mode = 1; /* no decode on Fifo last in mime_getc */
+ return 1;
+}
+#endif
+
+int
+base64decode(c)
+ int c;
+{
+ int i;
+ if(c > '@')
+ if(c < '[')
+ i = c - 'A'; /* A..Z 0-25 */
+ else
+ i = c - 'G' /* - 'a' + 26 */ ; /* a..z 26-51 */
+ else if(c > '/')
+ i = c - '0' + '4' /* - '0' + 52 */ ; /* 0..9 52-61 */
+ else if(c == '+')
+ i = '>' /* 62 */ ; /* + 62 */
+ else
+ i = '?' /* 63 */ ; /* / 63 */
+ return (i);
+}
+
+void
+reinit()
+{
+ unbuf_f = FALSE;
+ estab_f = FALSE;
+ nop_f = FALSE;
+ binmode_f = TRUE;
+ rot_f = FALSE;
+ input_f = FALSE;
+ alpha_f = FALSE;
+ mime_f = TRUE;
+ mimebuf_f = FALSE;
+ broken_f = FALSE;
+ iso8859_f = FALSE;
+ x0201_f = TRUE;
+ x0201_f = NO_X0201;
+ fold_f = FALSE;
+ kanji_intro = DEFAULT_J;
+ ascii_intro = DEFAULT_R;
+ oconv = DEFAULT_CONV;
+ output_mode = ASCII;
+ input_mode = ASCII;
+ shift_mode = FALSE;
+ mime_mode = FALSE;
+ file_out = FALSE;
+ add_cr = FALSE;
+ del_cr = FALSE;
+}
+
+#ifndef PERL_XS
+int
+usage()
+{
+ fprintf(stderr,"USAGE: nkf(nkf32,wnkf,nkf2) -[flags] [in file] .. [out file for -O flag]\n");
+ fprintf(stderr,"Flags:\n");
+ fprintf(stderr,"b,u Output is bufferred (DEFAULT),Output is unbufferred\n");
+#ifdef DEFAULT_CODE_SJIS
+ fprintf(stderr,"j,s,e Outout code is JIS 7 bit, Shift JIS (DEFAULT), AT&T JIS (EUC)\n");
+#endif
+#ifdef DEFAULT_CODE_JIS
+ fprintf(stderr,"j,s,e Outout code is JIS 7 bit (DEFAULT), Shift JIS, AT&T JIS (EUC)\n");
+#endif
+#ifdef DEFAULT_CODE_EUC
+ fprintf(stderr,"j,s,e Outout code is JIS 7 bit, Shift JIS, AT&T JIS (EUC) (DEFAULT)\n");
+#endif
+ fprintf(stderr,"J,S,E Input assumption is JIS 7 bit , Shift JIS, AT&T JIS (EUC)\n");
+ fprintf(stderr,"t no conversion\n");
+ fprintf(stderr,"i_ Output sequence to designate JIS-kanji (DEFAULT B)\n");
+ fprintf(stderr,"o_ Output sequence to designate ASCII (DEFAULT B)\n");
+ fprintf(stderr,"r {de/en}crypt ROT13/47\n");
+ fprintf(stderr,"v Show this usage\n");
+ fprintf(stderr,"m[BQ0] MIME decode [B:base64,Q:quoted,0:no decode]\n");
+ fprintf(stderr,"l ISO8859-1 (Latin-1) support\n");
+ fprintf(stderr,"f Folding: -f60 or -f\n");
+ fprintf(stderr,"Z[0-2] Convert X0208 alphabet to ASCII 1: Kankaku to space,2: 2 spaces\n");
+ fprintf(stderr,"X,x Assume X0201 kana in MS-Kanji, -x preserves X0201\n");
+ fprintf(stderr,"B[0-2] Broken input 0: missing ESC,1: any X on ESC-[($]-X,2: ASCII on NL\n");
+#ifdef MSDOS
+ fprintf(stderr,"T Text mode output\n");
+#endif
+ fprintf(stderr,"O Output to File (DEFAULT 'nkf.out')\n");
+ fprintf(stderr,"d,c Delete \\r in line feed, Add \\r in line feed\n");
+ fprintf(stderr,"Network Kanji Filter Version %s (%s) "
+#if defined(MSDOS) && !defined(_Windows)
+ "for DOS"
+#endif
+#if !defined(__WIN32__) && defined(_Windows)
+ "for Win16"
+#endif
+#if defined(__WIN32__) && defined(_Windows)
+ "for Win32"
+#endif
+#ifdef __OS2__
+ "for OS/2"
+#endif
+ ,Version,Patchlevel);
+ fprintf(stderr,"\n%s\n",CopyRight);
+ return 0;
+}
+#endif
+
+/**
+ ** $B%Q%C%A@):n<T(B
+ ** void@merope.pleiades.or.jp (Kusakabe Youichi)
+ ** NIDE Naoyuki <nide@ics.nara-wu.ac.jp>
+ ** ohta@src.ricoh.co.jp (Junn Ohta)
+ ** inouet@strl.nhk.or.jp (Tomoyuki Inoue)
+ ** kiri@pulser.win.or.jp (Tetsuaki Kiriyama)
+ ** Kimihiko Sato <sato@sail.t.u-tokyo.ac.jp>
+ ** a_kuroe@kuroe.aoba.yokohama.jp (Akihiko Kuroe)
+ ** kono@ie.u-ryukyu.ac.jp (Shinji Kono)
+ ** GHG00637@nifty-serve.or.jp (COW)
+ **
+ ** $B:G=*99?7F|(B
+ ** 1998.11.7
+ **/
+
+/* end */
diff --git a/ext/nkf/test.rb b/ext/nkf/test.rb
new file mode 100644
index 0000000..4519f8b
--- /dev/null
+++ b/ext/nkf/test.rb
@@ -0,0 +1,318 @@
+$counter = 0
+def result(result, message = nil)
+ $counter += 1
+ printf("%s %d%s\n",
+ result ? 'ok' : 'no',
+ $counter,
+ message ? ' ... ' + message : '')
+end
+
+begin
+ require 'nkf'
+ include NKF
+rescue LoadError
+ result(false)
+end
+result(true)
+
+if nkf('-me', '1')
+ result(true);
+else
+ result(false);
+end
+
+output = nkf('-e', "\033\$@#1#3#2%B")
+if output
+ # print output, "\n"
+ result(true, output)
+else
+ result(false)
+end
+
+output = nkf('-Zj', "\033\$@#1#3#2%B")
+if output
+ # print output, "\n"
+ result(true, output)
+else
+ result(false)
+end
+
+output = "\244\306 " * 1024
+old = output.length
+output = nkf("-j", output)
+if output
+ # print output, "\n"
+ result(true, "#{old} #{output.length}")
+else
+ result(false)
+end
+
+
+$detail = false
+def test(opt, input, expect)
+ print "\nINPUT:\n", input if $detail
+ print "\nEXPECT:\n", expect if $detail
+ result = nkf(opt, input)
+ print "\nGOT:\n", result if $detail
+
+ print result == expect ? "Ok\n" : "Fail\n"
+ return result
+end
+
+# Basic Conversion
+print "\nBasic Conversion test\n\n"
+
+example = {}
+example['jis'] = <<'eofeof'.unpack('u')[0]
+M1FER<W0@4W1A9V4@&R1"(3DQ(3%^2R%+?D]3&RA"(%-E8V]N9"!3=&%G92`;
+M)$)0)TU:&RA"($AI<F%G86YA(!LD0B0B)"0D)B0H)"HD;R1R)',;*$(*2V%T
+M86MA;F$@&R1")2(E)"4F)2@E*B5O)7(E<QLH0B!+:6=O=2`;)$(A)B%G(S`C
+/029!)E@G(B=!*$`;*$(*
+eofeof
+#'
+
+example['sjis'] = <<'eofeof'.unpack('u')[0]
+M1FER<W0@4W1A9V4@@5B)0(F>ED"6GIAR(%-E8V]N9"!3=&%G92"8I9=Y($AI
+M<F%G86YA((*@@J*"I(*F@JB"[8+P@O$*2V%T86MA;F$@@T&#0X-%@T>#28./
+>@Y*#DR!+:6=O=2"!18&'@D^"8(._@]:$081@A+X*
+eofeof
+#'
+
+example['euc'] = <<'eofeof'.unpack('u')[0]
+M1FER<W0@4W1A9V4@H;FQH;'^RZ'+_L_3(%-E8V]N9"!3=&%G92#0I\W:($AI
+M<F%G86YA(*2BI*2DIJ2HI*JD[Z3RI/,*2V%T86MA;F$@I:*EI*6FI:BEJJ7O
+>I?*E\R!+:6=O=2"AIJ'GH["CP:;!IMBGHJ?!J,`*
+eofeof
+#'
+
+example['amb'] = <<'eofeof'.unpack('u')[0]
+MI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&E
+MPK"QI<*PL:7"L+&EPK"QI<(*I<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*P
+ML:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<(*I<*PL:7"L+&E
+MPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"
+ML+&EPK"QI<(*I<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"Q
+MI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<(*I<*PL:7"L+&EPK"QI<*PL:7"
+ML+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<(*
+eofeof
+
+example['amb.euc'] = <<'eofeof'.unpack('u')[0]
+M&R1")4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25"
+M,#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*&R1")4(P,25",#$E0C`Q)4(P,25"
+M,#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;
+M*$(*&R1")4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P
+M,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*&R1")4(P,25",#$E0C`Q)4(P
+M,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q
+M)4(;*$(*&R1")4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q
+>)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*
+eofeof
+
+example['amb.sjis'] = <<'eofeof'.unpack('u')[0]
+M&RA))4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25"
+M,#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*&RA))4(P,25",#$E0C`Q)4(P,25"
+M,#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;
+M*$(*&RA))4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P
+M,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*&RA))4(P,25",#$E0C`Q)4(P
+M,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q
+M)4(;*$(*&RA))4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q
+>)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*
+eofeof
+
+example['x0201.sjis'] = <<'eofeof'.unpack('u')[0]
+MD5.*<(-*@TR#3H-0@U*#2X--@T^#48-3"I%3B7""8()A@F*"8X)D@F6"9H*!
+M@H*"@X*$@H6"AH*'"I%3BTR-AH%)@9>!E(&0@9.!3X&5@9:!:8%J@7R!>X&!
+M@6V!;H%O@7"!CPJ4O(IPMK>X/;FZMMZWWKC>N=ZZWH+&"I2\BG#*W\O?S-_-
+MW\[?M]^QW@K*W\O?S`IH86YK86MU(,K?R]_,I`K*W\O?S-VA"I2\BG""S(SC
+!"@!"
+eofeof
+#'
+
+example['x0201.euc'] = <<'eofeof'.unpack('u')[0]
+MP;2ST:6KI:VEKZ6QI;.EK*6NI;"ELJ6T"L&TL=&CP:/"H\.CQ*/%H\:CQZ/A
+MH^*CXZ/DH^6CYJ/G"L&TM:VYYJ&JH?>A]*'PH?.AL*'UH?:ARJ'+H=VAW*'A
+MH<ZASZ'0H=&A[PK(OK/1CK:.MXZX/8ZYCKJ.MH[>CK>.WHZXCMZ.N8[>CKJ.
+MWJ3("LB^L]&.RH[?CLN.WX[,CM^.S8[?CLZ.WXZWCM^.L8[>"H[*CM^.RX[?
+MCLP*:&%N:V%K=2".RH[?CLN.WX[,CJ0*CLJ.WX[+CM^.S([=CJ$*R+ZST:3.
+#N.4*
+eofeof
+#'
+
+example['x0201.jis'] = <<'eofeof'.unpack('u')[0]
+M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA""ALD0D$T,5$C02-"(T,C
+M1"-%(T8C1R-A(V(C8R-D(V4C9B-G&RA""ALD0D$T-2TY9B$J(7<A="%P(7,A
+M,"%U(78A2B%+(5TA7"%A(4XA3R%0(5$A;QLH0@H;)$)(/C-1&RA)-C<X&RA"
+M/1LH23DZ-EXW7CA>.5XZ7ALD0B1(&RA""ALD0D@^,U$;*$E*7TM?3%]-7TY?
+M-U\Q7ALH0@H;*$E*7TM?3!LH0@IH86YK86MU(!LH24I?2U],)!LH0@H;*$E*
+97TM?3%TA&RA""ALD0D@^,U$D3CAE&RA""@``
+eofeof
+#`
+
+example['x0201.sosi'] = <<'eofeof'.unpack('u')[0]
+M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA*"ALD0D$T,5$C02-"(T,C
+M1"-%(T8C1R-A(V(C8R-D(V4C9B-G&RA*"ALD0D$T-2TY9B$J(7<A="%P(7,A
+M,"%U(78A2B%+(5TA7"%A(4XA3R%0(5$A;QLH2@H;)$)(/C-1&RA*#C8W.`\;
+M*$H]#CDZ-EXW7CA>.5XZ7@\;)$(D2!LH2@H;)$)(/C-1&RA*#DI?2U],7TU?
+M3E\W7S%>#PH.2E]+7TP/&RA*"FAA;FMA:W4@#DI?2U],)`\;*$H*#DI?2U],
+672$/&RA*"ALD0D@^,U$D3CAE&RA""@``
+eofeof
+#"
+
+example['x0201.x0208'] = <<'eofeof'.unpack('u')[0]
+M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA""ALD0D$T,5$;*$)!0D-$
+M149'86)C9&5F9PH;)$)!-#4M.68;*$(A0",D)5XF*B@I+2L]6UU[?1LD0B%O
+M&RA""ALD0D@^,U$E*R4M)2\;*$(]&R1")3$E,R4L)2XE,"4R)30D2!LH0@H;
+M)$)(/C-1)5$E5"57)5HE724M(2PE(B$K&RA""ALD0B51)50E51LH0@IH86YK
+M86MU(!LD0B51)50E52$B&RA""ALD0B51)50E525S(2,;*$(*&R1"2#XS421.
+&.&4;*$(*
+eofeof
+#`
+
+example['mime.iso2022'] = <<'eofeof'.unpack('u')[0]
+M/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23TI566Q/4U9)1WEH2S\]"CT_
+M:7-O+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]*55EL3U-624=Y:$L_/0H]/VES
+M;RTR,#(R+4I0/U$_/3%")$(D1B11/3%"*$)?96YD/ST*&R1`)#TD)B0K)$H;
+M*$H@/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23U!Y:S=D:'-O4V<]/3\]
+M(&5N9"!O9B!L:6YE"CT_25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]0>6LW
+M9&AS;U-G/3T_/2`]/TE33RTR,#(R+4I0/T(_1WE204Y%13=E:5)/4'EK-V1H
+M<V]39ST]/ST*0G)O:V5N(&-A<V4*/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W
+M96E23U!Y:S=D"FAS;U-G/3T_/2`]/TE33RTR,`HR,BU*4#]"/T=Y4D%.144W
+M96E23U!Y:S=D:'-O4V<]/3\]"CT_25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I
+44D]*55EL3QM;2U-624=Y:$L_/0H_
+eofeof
+#'
+
+example['mime.ans.strict'] = <<'eofeof'.unpack('u')[0]
+M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
+M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
+M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
+M/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23U!Y:S=D"FAS;U-G/3T_/2`]
+M/TE33RTR,`HR,BU*4#]"/T=Y4D%.144W96E23U!Y:S=D:'-O4V<]/3\]"CT_
+L25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]*55EL3QM;2U-624=Y:$L_/0H_
+eofeof
+#'
+
+example['mime.unbuf.strict'] = <<'eofeof'.unpack('u')[0]
+M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
+M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
+M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
+M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@/3])4T\M,C`*,C(M2E`_0C]'>5)!
+M3D5%-V5I4D]0>6LW9&AS;U-G/3T_/0H;)$(T03MZ)$XE1ALH0EM+4U9)1WEH
+$2S\]"F5I
+eofeof
+
+example['mime.ans'] = <<'eofeof'.unpack('u')[0]
+M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
+M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
+M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
+M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@&R1"-$$[>B1./RD[=ALH0@H;)$(T
+603MZ)$XE1ALH0EM+4U9)1WEH2S\]"@`*
+eofeof
+#"
+
+example['mime.unbuf'] = <<'eofeof'.unpack('u')[0]
+M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
+M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
+M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
+M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@&R1"-$$[>B1./RD[=ALH0@H;)$(T
+603MZ)$XE1ALH0EM+4U9)1WEH2S\]"@`*
+eofeof
+#"
+
+example['mime.base64'] = <<'eofeof'.unpack('u')[0]
+M9W-M5"])3&YG<FU#>$I+-&=Q=4,S24LS9W%Q0E%:3TUI-39,,S0Q-&=S5T)1
+M43!+9VUA1%9O3T@*9S)+1%1O3'=K8C)1;$E+;V=Q2T-X24MG9W5M0W%*3EEG
+<<T=#>$E+9V=U;4,X64Q&9W)70S592VMG<6U""F=Q
+eofeof
+#"
+
+example['mime.base64.ans'] = <<'eofeof'.unpack('u')[0]
+M&R1")$M&?B1I)#LD1D0Z)"TD7B0Y)"PA(D5L-7XV83E9)$<A(ALH0@T*&R1"
+M(T<E-R5G)4,E+R1R0C\_="0J)"0D1B0B)&LD*D4Y)$,D1B0B)&LD<R1')#<D
+(9R0F)"L;*$(E
+eofeof
+#'
+
+example['mime.is8859'] = <<'eofeof'.unpack('u')[0]
+M/3])4T\M.#@U.2TQ/U$_*CU#-V%V83\_/2`*4&5E<B!4]G)N9W)E;@I,87-S
+M92!(:6QL97+X92!0971E<G-E;B`@7"`B36EN(&MA97!H97-T(&AA<B!F86%E
+M="!E="!F;V5L(2(*06%R:'5S(%5N:79E<G-I='DL($1%3DU!4DL@(%P@(DUI
+<;B!KYG!H97-T(&AA<B!FY65T(&5T(&;X;"$B"@!K
+eofeof
+
+example['mime.is8859.ans'] = <<'eofeof'.unpack('u')[0]
+M*L=A=F$_(`I0965R(%3V<FYG<F5N"DQA<W-E($AI;&QE<OAE(%!E=&5R<V5N
+M("!<(")-:6X@:V%E<&AE<W0@:&%R(&9A865T(&5T(&9O96PA(@I!87)H=7,@
+M56YI=F5R<VET>2P@1$5.34%22R`@7"`B36EN(&OF<&AE<W0@:&%R(&;E970@
+)970@9OAL(2(*
+eofeof
+#"
+
+print 'JIS to JIS ... '; test(' ', example['jis'], example['jis'])
+print 'JIS to SJIS... '; test('-s', example['jis'], example['sjis'])
+print 'JIS to EUC ... '; test('-e', example['jis'], example['euc'])
+
+print 'SJIS to JIS ... '; test('-j', example['sjis'], example['jis'])
+print 'SJIS to SJIS... '; test('-s', example['sjis'], example['sjis'])
+print 'SJIS to EUC ... '; test('-e', example['sjis'], example['euc'])
+
+print 'EUC to JIS ... '; test(' ', example['euc'], example['jis'])
+print 'EUC to SJIS... '; test('-s', example['euc'], example['sjis'])
+print 'EUC to EUC ... '; test('-e', example['euc'], example['euc'])
+
+
+# Ambigous Case
+print 'Ambiguous Case. '; test('' , example['amb'], example['amb.euc'])
+
+# Input assumption
+print 'SJIS Input assumption '
+test('-Sx', example['amb'], example['amb.sjis'])
+
+# X0201 仮名
+# X0201->X0208 conversion
+# X0208 aphabet -> ASCII
+# X0201 相互変換
+
+print "\nX0201 test\n\n"
+
+# -X is necessary to allow X0201 in SJIS
+# -Z convert X0208 alphabet to ASCII
+print 'X0201 conversion: SJIS '
+test('-XZ', example['x0201.sjis'], example['x0201.x0208'])
+print 'X0201 conversion: JIS '
+test('-Z', example['x0201.jis'], example['x0201.x0208'])
+print 'X0201 conversion:SI/SO '
+test('-Z', example['x0201.sosi'], example['x0201.x0208'])
+print 'X0201 conversion: EUC '
+test('-Z', example['x0201.euc'], example['x0201.x0208'])
+# -x means X0201 output
+print 'X0201 output: SJIS '
+test('-xs', example['x0201.euc'], example['x0201.sjis'])
+print 'X0201 output: JIS '
+test('-xj', example['x0201.sjis'], example['x0201.jis'])
+print 'X0201 output: EUC '
+test('-xe', example['x0201.jis'], example['x0201.euc'])
+
+# MIME decode
+
+print "\nMIME test\n\n"
+
+# MIME ISO-2022-JP
+
+print "Next test is expeced to Fail.\n"
+
+print 'MIME decode (strict) '
+tmp = test('-m', example['mime.iso2022'], example['mime.ans.strict'])
+print 'MIME decode (nonstrict)'
+tmp = test('-m', example['mime.iso2022'], example['mime.ans'])
+# open(OUT,'>tmp1');print OUT pack('u',$tmp);close(OUT);
+# unbuf mode implies more pessimistic decode
+print 'MIME decode (unbuf) '
+test('-mu', example['mime.iso2022'], example['mime.unbuf'])
+print 'MIME decode (base64) '
+t = test('-mB', example['mime.base64'], example['mime.base64.ans'])
+
+# MIME ISO-8859-1
+
+# Without -l, ISO-8859-1 was handled as X0201.
+
+print 'MIME ISO-8859-1 (Q) '
+test('-ml', example['mime.is8859'], example['mime.is8859.ans'])
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index e9bdbc9..875c8aa 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -96,6 +96,8 @@ sock_new(class, fd)
fp->f = rb_fdopen(fd, "r");
#ifdef NT
fp->finalize = sock_finalize;
+#else
+ fd = dup(fd);
#endif
fp->f2 = rb_fdopen(fd, "w");
fp->mode = FMODE_READWRITE;
@@ -140,11 +142,13 @@ bsock_close_read(sock)
rb_secure(4);
GetOpenFile(sock, fptr);
+ shutdown(fileno(fptr->f), 0);
if (fptr->f2 == 0) {
return rb_io_close(sock);
}
- if (shutdown(fileno(fptr->f), 0) == -1)
- rb_sys_fail(0);
+#ifdef USE_THREAD
+ rb_thread_fd_close(fileno(fptr->f));
+#endif
fptr->mode &= ~FMODE_READABLE;
#ifdef NT
free(fptr->f);
@@ -168,8 +172,7 @@ bsock_close_write(sock)
if (fptr->f2 == 0) {
return rb_io_close(sock);
}
- if (shutdown(fileno(fptr->f), 1) == -1)
- rb_sys_fail(0);
+ shutdown(fileno(fptr->f2), 1);
fptr->mode &= ~FMODE_WRITABLE;
#ifdef NT
free(fptr->f2);
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index 625fe61..11eb977 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -16,10 +16,10 @@
# include <Quickdraw.h>
#endif
-/* for rb_debug */
+/* for ruby_debug */
-#define DUMP1(ARG1) if (rb_debug) { fprintf(stderr, "tcltklib: %s\n", ARG1);}
-#define DUMP2(ARG1, ARG2) if (rb_debug) { fprintf(stderr, "tcltklib: ");\
+#define DUMP1(ARG1) if (ruby_debug) { fprintf(stderr, "tcltklib: %s\n", ARG1);}
+#define DUMP2(ARG1, ARG2) if (ruby_debug) { fprintf(stderr, "tcltklib: ");\
fprintf(stderr, ARG1, ARG2); fprintf(stderr, "\n"); }
/*
#define DUMP1(ARG1)
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index e32723b..8fc57f3 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -579,6 +579,7 @@ module Tk
end
module Wm
+ include TkComm
def aspect(*args)
w = window(tk_call('wm', 'grid', path, *args))
w.split.collect{|s|s.to_i} if args.length == 0
@@ -2412,6 +2413,9 @@ class TkMenubutton<TkLabel
end
module TkComposite
+ include Tk
+ extend Tk
+
def initialize(parent=nil, *args)
@frame = TkFrame.new(parent)
@path = @epath = @frame.path
diff --git a/ext/tk/lib/tkscrollbox.rb b/ext/tk/lib/tkscrollbox.rb
index 8d129b2..6236430 100644
--- a/ext/tk/lib/tkscrollbox.rb
+++ b/ext/tk/lib/tkscrollbox.rb
@@ -2,13 +2,13 @@
# tkscrollbox.rb - Tk Listbox with Scrollbar
# as an example of Composite Widget
# $Date$
-# by Yukihiro Matsumoto <matz@caelum.co.jp>
+# by Yukihiro Matsumoto <matz@netlab.co.jp>
require 'tk.rb'
class TkScrollbox<TkListbox
include TkComposite
- def initialize_composite
+ def initialize_composite(keys=nil)
list = TkListbox.new(@frame)
scroll = TkScrollbar.new(@frame)
@path = list.path
@@ -23,5 +23,7 @@ class TkScrollbox<TkListbox
delegate('background', list, scroll)
delegate('borderwidth', @frame)
delegate('relief', @frame)
+
+ configure keys if keys
end
end
diff --git a/ext/tkutil/MANIFEST b/ext/tkutil/MANIFEST
deleted file mode 100644
index 870e04b..0000000
--- a/ext/tkutil/MANIFEST
+++ /dev/null
@@ -1,3 +0,0 @@
-MANIFEST
-tkutil.c
-depend
diff --git a/ext/tkutil/depend b/ext/tkutil/depend
deleted file mode 100644
index e325a82..0000000
--- a/ext/tkutil/depend
+++ /dev/null
@@ -1 +0,0 @@
-tkutil.o: tkutil.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h
diff --git a/ext/tkutil/tkutil.c b/ext/tkutil/tkutil.c
deleted file mode 100644
index 540995e..0000000
--- a/ext/tkutil/tkutil.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/************************************************
-
- tk.c -
-
- $Author$
- $Date$
- created at: Fri Nov 3 00:47:54 JST 1995
-
-************************************************/
-
-#include "ruby.h"
-
-static VALUE
-tk_eval_cmd(argc, argv)
- int argc;
- VALUE argv[];
-{
- VALUE cmd, rest;
-
- rb_scan_args(argc, argv, "1*", &cmd, &rest);
- rb_eval_cmd(cmd, rest);
- return Qnil;
-}
-
-static VALUE
-tk_s_new(argc, argv, class)
- int argc;
- VALUE *argv;
- VALUE class;
-{
- VALUE obj = obj_alloc(class);
-
- rb_funcall2(obj, rb_intern("initialize"), argc, argv);
- if (iterator_p()) rb_yield_0(obj, obj);
- return obj;
-}
-
-Init_tkutil()
-{
- VALUE mTK = rb_define_module("TkUtil");
- VALUE cTK = rb_define_class("TkKernel", cObject);
-
- rb_define_singleton_method(mTK, "eval_cmd", tk_eval_cmd, -1);
-
- rb_define_singleton_method(cTK, "new", tk_s_new, -1);
-}
diff --git a/file.c b/file.c
index 11a8ded..8591023 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
@@ -58,107 +61,13 @@ char *strrchr _((char*,char));
#include "macruby_missing.h"
extern int fileno(FILE *stream);
extern int utimes();
+ char* strdup(char*);
#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)();
@@ -1396,8 +1305,9 @@ rb_file_truncate(obj, len)
#if defined(USE_THREAD) && 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 +1318,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 +1326,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
@@ -1600,11 +1511,20 @@ rb_f_test(argc, argv)
return Qnil; /* not reached */
}
+static VALUE rb_mConst;
+
+void
+rb_file_const(name, value)
+ char *name;
+ VALUE value;
+{
+ rb_define_const(rb_cFile, name, value);
+ rb_define_const(rb_mConst, name, value);
+}
+
void
Init_File()
{
- VALUE rb_mConst;
-
rb_mFileTest = rb_define_module("FileTest");
rb_define_module_function(rb_mFileTest, "directory?", test_d, 1);
@@ -1637,9 +1557,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);
@@ -1671,8 +1588,6 @@ Init_File()
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);
-
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 +1602,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 f031749..0000000
--- 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 62c8c8f..0000000
--- 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 31ed111..215479e 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,10 +42,10 @@ 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;
@@ -389,10 +389,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;
@@ -598,7 +598,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];
@@ -769,10 +770,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 +808,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);
diff --git a/hash.c b/hash.c
index 9141406..66bf6e7 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");
}
@@ -127,7 +132,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");
@@ -428,7 +433,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 +459,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;
}
@@ -500,7 +505,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 +549,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 +566,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 +583,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 +600,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 +630,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 +692,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 +713,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 +745,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 +778,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 +812,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 +832,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 +846,6 @@ rb_hash_update(hash1, hash2)
return hash1;
}
-#ifndef __MACOS__ /* no environment variables on MacOS. */
static int path_tainted = -1;
#ifndef NT
@@ -849,6 +853,24 @@ extern char **environ;
#endif
static char **origenviron;
+void
+ruby_unsetenv(name)
+ char *name;
+{
+ int i, len;
+
+ len = strlen(name);
+ for(i=0; environ[i]; i++) {
+ if (strncmp(environ[i], name, len) == 0 && environ[i][len] == '=') {
+ break;
+ }
+ }
+ while (environ[i]) {
+ environ[i] = environ[i+1];
+ i++;
+ }
+}
+
static VALUE
env_delete(obj, name)
VALUE obj, name;
@@ -858,7 +880,9 @@ env_delete(obj, name)
rb_secure(4);
nam = STR2CSTR(name);
- if (strcmp(nam, "PATH") == 0) path_tainted = 0;
+ if (strcmp(nam, "PATH") == 0 && !OBJ_TAINTED(name)) {
+ path_tainted = 0;
+ }
len = strlen(nam);
for(i=0; environ[i]; i++) {
if (strncmp(environ[i], nam, len) == 0 && environ[i][len] == '=') {
@@ -988,8 +1012,8 @@ char *nam;
return i;
}
-static void
-my_setenv(name, value)
+void
+ruby_setenv(name, value)
char *name;
char *value;
{
@@ -1095,6 +1119,17 @@ my_setenv(name, value)
#endif /* WIN32 */
}
+void
+ruby_setenv2(name, value)
+ char *name;
+ char *value;
+{
+ if (value == NULL) {
+ ruby_unsetenv(name);
+ }
+ ruby_setenv(name, value);
+}
+
static VALUE
rb_f_setenv(obj, nm, val)
VALUE obj, nm, val;
@@ -1112,13 +1147,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");
if (strlen(value) != vlen)
rb_raise(rb_eArgError, "Bad environment value");
- my_setenv(name, value);
+ ruby_setenv(name, value);
if (strcmp(name, "PATH") == 0) {
if (OBJ_TAINTED(val)) {
/* already tainted, no check */
@@ -1363,8 +1398,6 @@ env_to_hash(obj)
return hash;
}
-#endif /* ifndef __MACOS__ no environment variables on MacOS. */
-
void
Init_Hash()
{
@@ -1414,6 +1447,7 @@ 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);
@@ -1438,6 +1472,7 @@ 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);
diff --git a/inits.c b/inits.c
index 3708edc..170912d 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,6 +52,7 @@ rb_call_inits()
Init_Object();
Init_Comparable();
Init_Enumerable();
+ Init_Precision();
Init_eval();
Init_String();
Init_Exception();
diff --git a/instruby.rb b/instruby.rb
index d489e0f..6f46f86 100644
--- a/instruby.rb
+++ b/instruby.rb
@@ -15,43 +15,54 @@ 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+binsuffix,
+ "#{bindir}/#{ruby_install_name}#{binsuffix}", 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, 0644, 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
Dir.chdir "ext"
system "../miniruby#{binsuffix} extmk.rb install #{destdir}"
Dir.chdir CONFIG["srcdir"]
for f in Dir["lib/*.rb"]
- File.install f, "#{destdir}#{pkglibdir}", 0644, true
+ File.install f, pkglibdir, 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
-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 8b88751..3a524c1 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 _((int));
+VALUE rb_ary_new3 __((int,...));
+VALUE rb_ary_new4 _((int, 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, int, 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, int));
VALUE rb_ary_each _((VALUE));
VALUE rb_ary_join _((VALUE, VALUE));
VALUE rb_ary_print_on _((VALUE, VALUE));
@@ -118,6 +118,7 @@ void rb_jump_tag _((int)) NORETURN;
void rb_provide _((char*));
VALUE rb_f_require _((VALUE, VALUE));
void rb_obj_call_init _((VALUE));
+void rb_obj_call_init2 _((VALUE, int, VALUE*));
VALUE rb_class_new_instance _((int, VALUE*, VALUE));
VALUE rb_f_lambda _((void));
VALUE rb_protect _((VALUE (*)(), VALUE, int*));
@@ -127,7 +128,7 @@ 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));
int rb_thread_alone _((void));
void rb_thread_sleep _((int));
void rb_thread_sleep_forever _((void));
@@ -142,9 +143,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));
VALUE rb_file_s_expand_path _((int, VALUE *));
+void rb_file_const _((char*, VALUE));
/* gc.c */
void rb_global_variable _((VALUE*));
void rb_gc_mark_locations _((VALUE*, VALUE*));
@@ -176,8 +177,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 _((char*, char*));
VALUE rb_gets _((void));
void rb_str_setter _((VALUE, ID, VALUE*));
/* numeric.c */
@@ -230,7 +230,7 @@ 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 _((char*, int, int));
VALUE rb_reg_match _((VALUE, VALUE));
VALUE rb_reg_match2 _((VALUE));
int rb_reg_options _((VALUE));
@@ -238,6 +238,7 @@ char*rb_get_kcode _((void));
void rb_set_kcode _((char*));
int rb_ignorecase_p _((void));
/* ruby.c */
+extern VALUE rb_argv0;
void rb_load_file _((char*));
void ruby_script _((char*));
void ruby_prog_init _((void));
@@ -257,23 +258,22 @@ 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_new _((char*, int));
VALUE rb_str_new2 _((char*));
VALUE rb_str_new3 _((VALUE));
VALUE rb_str_new4 _((VALUE));
-VALUE rb_tainted_str_new _((char*, size_t));
+VALUE rb_tainted_str_new _((char*, int));
VALUE rb_tainted_str_new2 _((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, int, int));
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, int));
+VALUE rb_str_cat _((VALUE, char*, int));
VALUE rb_str_concat _((VALUE, VALUE));
int rb_str_hash _((VALUE));
int rb_str_cmp _((VALUE, VALUE));
@@ -287,8 +287,6 @@ 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));
/* variable.c */
VALUE rb_mod_name _((VALUE));
VALUE rb_class_path _((VALUE));
diff --git a/io.c b/io.c
index 5573e76..9eba04a 100644
--- a/io.c
+++ b/io.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Oct 15 18:08:59 JST 1993
- Copyright (C) 1993-1998 Yukihiro Matsumoto
+ Copyright (C) 1993-1999 Yukihiro Matsumoto
************************************************/
@@ -20,7 +20,7 @@
#if !defined(DJGPP) && !defined(NT) && !defined(__human68k__)
#include <sys/ioctl.h>
#endif
-#if defined(HAVE_FCNTL)
+#if defined(HAVE_FCNTL) || defined(NT)
#include <fcntl.h>
#endif
@@ -54,10 +54,14 @@ struct timeval {
#include <sys/errno.h>
#include <unix.mac.h>
#include <compat.h>
+ extern char* strdup(const char*);
#endif
extern void Init_File _((void));
#ifdef __BEOS__
+# ifdef _X86_
+# define NOFILE (OPEN_MAX)
+# endif
#include <net/socket.h>
#endif
@@ -99,7 +103,7 @@ 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();
@@ -110,7 +114,10 @@ extern int ReadDataPending();
# define READ_CHECK(fp) 0
#else
# define READ_CHECK(fp) do {\
- if (!READ_DATA_PENDING(fp)) rb_thread_wait_fd(fileno(fp));\
+ if (!READ_DATA_PENDING(fp)) {\
+ rb_thread_wait_fd(fileno(fp));\
+ rb_io_check_closed(fptr);\
+ }\
} while(0)
#endif
@@ -840,8 +847,14 @@ static void
rb_io_fptr_close(fptr)
OpenFile *fptr;
{
+ int fd;
+
if (fptr->f == NULL && fptr->f2 == NULL) return;
+#ifdef USE_THREAD
+ rb_thread_fd_close(fileno(fptr->f));
+#endif
+
if (fptr->finalize) {
(*fptr->finalize)(fptr);
}
@@ -953,7 +966,9 @@ rb_io_syswrite(io, str)
f = GetWriteFile(fptr);
#ifdef USE_THREAD
- rb_thread_fd_writable(fileno(f));
+ if (!rb_thread_fd_writable(fileno(f))) {
+ rb_io_check_closed(fptr);
+ }
#endif
n = write(fileno(f), RSTRING(str)->ptr, RSTRING(str)->len);
@@ -1014,9 +1029,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
@@ -1025,7 +1040,7 @@ rb_io_binmode(io)
return io;
}
-int
+static int
rb_io_mode_flags(mode)
char *mode;
{
@@ -1042,7 +1057,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,29 +1068,112 @@ 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;
{
- 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 *
@@ -1082,18 +1181,65 @@ rb_fdopen(fd, mode)
int fd;
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;
+}
+
+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;
+}
+
+VALUE
+rb_file_sysopen(fname, flags, mode)
+ 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(fname, rb_io_flags_mode(flags));
+#else
+ OpenFile *fptr;
+ int fd;
+ char *m;
+ NEWOBJ(port, struct RFile);
+ OBJSETUP(port, rb_cFile, 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);
+ rb_obj_call_init((VALUE)port);
+
+ return (VALUE)port;
+#endif
}
#if defined (NT) || defined(DJGPP) || defined(__CYGWIN32__) || defined(__human68k__)
@@ -1329,15 +1475,41 @@ rb_io_s_popen(argc, argv, self)
}
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(path, flags, fmode);
}
else {
- return rb_file_open(fname, mode);
+ 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
@@ -1346,24 +1518,31 @@ 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 (rb_iterator_p()) {
return rb_ensure(rb_yield, port, rb_io_close, port);
}
@@ -1372,6 +1551,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 +1584,7 @@ rb_io_mode_string(fptr)
}
}
-VALUE
+static VALUE
rb_io_reopen(io, nfile)
VALUE io, nfile;
{
@@ -1412,6 +1603,9 @@ rb_io_reopen(io, nfile)
else if (orig->mode & FMODE_WRITABLE) {
fflush(orig->f);
}
+#ifdef USE_THREAD
+ rb_thread_fd_close(fileno(fptr->f));
+#endif
/* copy OpenFile structure */
fptr->mode = orig->mode;
@@ -1458,6 +1652,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;
{
@@ -1870,8 +2114,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__)
fstat(fileno(fw), &st2);
fchmod(fileno(fw), st.st_mode);
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
@@ -1900,7 +2143,12 @@ rb_f_gets_internal(argc, argv)
retry:
if (!next_argv()) return Qnil;
- line = rb_io_gets_internal(argc, argv, file);
+ if (rb_rs == rb_default_rs) {
+ line = rb_io_gets(file);
+ }
+ else {
+ line = rb_io_gets_internal(argc, argv, file);
+ }
if (NIL_P(line) && next_p != -1) {
rb_io_close(file);
next_p = 1;
@@ -1928,6 +2176,10 @@ 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);
@@ -1960,76 +2212,13 @@ rb_f_readline(argc, argv)
}
static VALUE
-rb_f_tell()
-{
- return rb_io_tell(file);
-}
-
-static VALUE
-rb_f_seek(self, offset, ptrname)
- VALUE self, offset, ptrname;
-{
- if (!next_argv()) {
- rb_raise(rb_eArgError, "no stream to seek");
- }
-
- return rb_io_seek(file, offset, ptrname);
-}
-
-static VALUE
-rb_f_set_pos(self, offset)
- VALUE self, offset;
-{
- if (!next_argv()) {
- rb_raise(rb_eArgError, "no stream to pos");
- }
-
- return rb_io_set_pos(file, offset);
-}
-
-static VALUE
-rb_f_rewind()
-{
- return rb_io_rewind(file);
-}
-
-static VALUE
-rb_f_eof()
-{
- if (init_p == 0 && !next_argv())
- return Qtrue;
- if (rb_io_eof(file)) {
- next_p = 1;
- return Qtrue;
- }
- return Qfalse;
-}
-
-static VALUE
rb_f_getc()
{
+ rb_warn("getc is obsolete; use STDIN.getc instead");
return rb_io_getc(rb_stdin);
}
static VALUE
-rb_f_ungetc(self, c)
- VALUE self, c;
-{
- return rb_io_ungetc(rb_stdin, c);
-}
-
-static VALUE
-rb_f_readchar()
-{
- VALUE c = rb_f_getc();
-
- if (NIL_P(c)) {
- rb_eof_error();
- }
- return c;
-}
-
-static VALUE
rb_f_readlines(argc, argv)
int argc;
VALUE *argv;
@@ -2452,8 +2641,8 @@ rb_io_s_pipe()
#endif
rb_sys_fail(0);
- r = prep_stdio(fdopen(pipes[0], "r"), FMODE_READABLE, rb_cIO);
- w = prep_stdio(fdopen(pipes[1], "w"), FMODE_WRITABLE, rb_cIO);
+ r = prep_stdio(rb_fdopen(pipes[0], "r"), FMODE_READABLE, rb_cIO);
+ w = prep_stdio(rb_fdopen(pipes[1], "w"), FMODE_WRITABLE, rb_cIO);
ary = rb_ary_new2(2);
rb_ary_push(ary, r);
@@ -2533,6 +2722,40 @@ rb_io_s_readlines(argc, argv, io)
}
static VALUE
+arg_tell()
+{
+ return rb_io_tell(file);
+}
+
+static VALUE
+arg_seek(self, offset, ptrname)
+ VALUE self, offset, ptrname;
+{
+ if (!next_argv()) {
+ rb_raise(rb_eArgError, "no stream to seek");
+ }
+
+ return rb_io_seek(file, offset, ptrname);
+}
+
+static VALUE
+arg_set_pos(self, offset)
+ VALUE self, offset;
+{
+ if (!next_argv()) {
+ rb_raise(rb_eArgError, "no stream to pos");
+ }
+
+ return rb_io_set_pos(file, offset);
+}
+
+static VALUE
+arg_rewind()
+{
+ return rb_io_rewind(file);
+}